From ebfdea6c82046131e1b24b22009cd119edf63f57 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Thu, 23 Feb 2012 19:23:10 +0000 Subject: [PATCH] SOLR-2667: use require.js to load UI dynamically git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1292908 13f79535-47bb-0310-9956-ffa450edef68 --- solr/webapp/web/css/main.css | 15 + solr/webapp/web/css/styles/analysis.css | 263 + solr/webapp/web/css/styles/cloud.css | 128 + solr/webapp/web/css/styles/common.css | 464 ++ solr/webapp/web/css/styles/cores.css | 272 + solr/webapp/web/css/styles/dashboard.css | 114 + solr/webapp/web/css/styles/dataimport.css | 232 + solr/webapp/web/css/styles/index.css | 158 + .../webapp/web/css/styles/java-properties.css | 33 + solr/webapp/web/css/styles/logging.css | 150 + solr/webapp/web/css/styles/menu.css | 242 + solr/webapp/web/css/styles/plugins.css | 128 + solr/webapp/web/css/styles/query.css | 132 + solr/webapp/web/css/styles/replication.css | 463 ++ solr/webapp/web/css/styles/schema-browser.css | 345 + solr/webapp/web/css/styles/threads.css | 167 + solr/webapp/web/index.jsp | 14 +- .../web/js/{0_console.js => lib/console.js} | 0 solr/webapp/web/js/{ => lib}/highlight.js | 0 solr/webapp/web/js/{ => lib}/jquery.form.js | 0 solr/webapp/web/js/{ => lib}/jquery.jstree.js | 0 solr/webapp/web/js/{ => lib}/jquery.sammy.js | 0 .../web/js/{ => lib}/jquery.sparkline.js | 0 .../webapp/web/js/{ => lib}/jquery.timeago.js | 0 solr/webapp/web/js/lib/order.js | 189 + solr/webapp/web/js/main.js | 36 + .../webapp/web/js/{1_jquery.js => require.js} | 5774 ++++++++++++----- solr/webapp/web/js/script.js | 4681 ------------- solr/webapp/web/js/scripts/analysis.js | 420 ++ solr/webapp/web/js/scripts/app.js | 263 + solr/webapp/web/js/scripts/cloud.js | 174 + solr/webapp/web/js/scripts/cores.js | 495 ++ solr/webapp/web/js/scripts/dashboard.js | 400 ++ solr/webapp/web/js/scripts/dataimport.js | 452 ++ solr/webapp/web/js/scripts/file.js | 37 + solr/webapp/web/js/scripts/index.js | 184 + solr/webapp/web/js/scripts/java-properties.js | 84 + solr/webapp/web/js/scripts/logging.js | 164 + solr/webapp/web/js/scripts/ping.js | 58 + solr/webapp/web/js/scripts/plugins.js | 259 + solr/webapp/web/js/scripts/query.js | 142 + solr/webapp/web/js/scripts/replication.js | 443 ++ solr/webapp/web/js/scripts/schema-browser.js | 1052 +++ solr/webapp/web/js/scripts/threads.js | 144 + solr/webapp/web/tpl/analysis.html | 12 +- solr/webapp/web/tpl/cloud.html | 18 +- solr/webapp/web/tpl/query.html | 23 +- solr/webapp/web/tpl/schema-browser.html | 48 +- .../web/tpl/schema-browser_dynamic-field.html | 16 - solr/webapp/web/tpl/schema-browser_type.html | 16 - solr/webapp/web/tpl/threads.html | 7 +- 51 files changed, 12453 insertions(+), 6458 deletions(-) create mode 100644 solr/webapp/web/css/main.css create mode 100644 solr/webapp/web/css/styles/analysis.css create mode 100644 solr/webapp/web/css/styles/cloud.css create mode 100644 solr/webapp/web/css/styles/common.css create mode 100644 solr/webapp/web/css/styles/cores.css create mode 100644 solr/webapp/web/css/styles/dashboard.css create mode 100644 solr/webapp/web/css/styles/dataimport.css create mode 100644 solr/webapp/web/css/styles/index.css create mode 100644 solr/webapp/web/css/styles/java-properties.css create mode 100644 solr/webapp/web/css/styles/logging.css create mode 100644 solr/webapp/web/css/styles/menu.css create mode 100644 solr/webapp/web/css/styles/plugins.css create mode 100644 solr/webapp/web/css/styles/query.css create mode 100644 solr/webapp/web/css/styles/replication.css create mode 100644 solr/webapp/web/css/styles/schema-browser.css create mode 100644 solr/webapp/web/css/styles/threads.css rename solr/webapp/web/js/{0_console.js => lib/console.js} (100%) rename solr/webapp/web/js/{ => lib}/highlight.js (100%) rename solr/webapp/web/js/{ => lib}/jquery.form.js (100%) rename solr/webapp/web/js/{ => lib}/jquery.jstree.js (100%) rename solr/webapp/web/js/{ => lib}/jquery.sammy.js (100%) rename solr/webapp/web/js/{ => lib}/jquery.sparkline.js (100%) rename solr/webapp/web/js/{ => lib}/jquery.timeago.js (100%) create mode 100644 solr/webapp/web/js/lib/order.js create mode 100644 solr/webapp/web/js/main.js rename solr/webapp/web/js/{1_jquery.js => require.js} (54%) delete mode 100644 solr/webapp/web/js/script.js create mode 100644 solr/webapp/web/js/scripts/analysis.js create mode 100644 solr/webapp/web/js/scripts/app.js create mode 100644 solr/webapp/web/js/scripts/cloud.js create mode 100644 solr/webapp/web/js/scripts/cores.js create mode 100644 solr/webapp/web/js/scripts/dashboard.js create mode 100644 solr/webapp/web/js/scripts/dataimport.js create mode 100644 solr/webapp/web/js/scripts/file.js create mode 100644 solr/webapp/web/js/scripts/index.js create mode 100644 solr/webapp/web/js/scripts/java-properties.js create mode 100644 solr/webapp/web/js/scripts/logging.js create mode 100644 solr/webapp/web/js/scripts/ping.js create mode 100644 solr/webapp/web/js/scripts/plugins.js create mode 100644 solr/webapp/web/js/scripts/query.js create mode 100644 solr/webapp/web/js/scripts/replication.js create mode 100644 solr/webapp/web/js/scripts/schema-browser.js create mode 100644 solr/webapp/web/js/scripts/threads.js delete mode 100644 solr/webapp/web/tpl/schema-browser_dynamic-field.html delete mode 100644 solr/webapp/web/tpl/schema-browser_type.html diff --git a/solr/webapp/web/css/main.css b/solr/webapp/web/css/main.css new file mode 100644 index 00000000000..00e90403f6f --- /dev/null +++ b/solr/webapp/web/css/main.css @@ -0,0 +1,15 @@ +@import url( styles/common.css ); +@import url( styles/analysis.css ); +@import url( styles/cloud.css ); +@import url( styles/cores.css ); +@import url( styles/dashboard.css ); +@import url( styles/dataimport.css ); +@import url( styles/index.css ); +@import url( styles/java-properties.css ); +@import url( styles/logging.css ); +@import url( styles/menu.css ); +@import url( styles/plugins.css ); +@import url( styles/query.css ); +@import url( styles/replication.css ); +@import url( styles/schema-browser.css ); +@import url( styles/threads.css ); \ No newline at end of file diff --git a/solr/webapp/web/css/styles/analysis.css b/solr/webapp/web/css/styles/analysis.css new file mode 100644 index 00000000000..c820b0e02f1 --- /dev/null +++ b/solr/webapp/web/css/styles/analysis.css @@ -0,0 +1,263 @@ +#content #analysis-holder +{ + background-image: url( ../../img/div.gif ); + background-position: 50% 0; + background-repeat: repeat-y; +} + +#content #analysis #field-analysis +{ + margin-bottom: 0; +} + +#content #analysis #field-analysis .content +{ + padding-bottom: 0; +} + +#content #analysis .settings-holder +{ + clear: both; + padding-top: 15px; +} + +#content #analysis .settings +{ + background-color: #fff; + border-top: 1px solid #fafafa; + border-bottom: 1px solid #fafafa; + padding-top: 10px; + padding-bottom: 10px; +} + +#content #analysis .settings select.loader +{ + background-position: 3px 50%; + padding-left: 21px; +} + +#content #analysis .settings select optgroup +{ + font-style: normal; + padding: 5px; +} + +#content #analysis .settings select option +{ + padding-left: 10px; +} + +#content #analysis .settings div +{ + float: right; + width: 47%; +} + +#content #analysis .settings button +{ + float: right; +} + +#content #analysis .settings button.loader +{ + background-position: 2px 50%; + padding-left: 21px; +} + +#content #analysis .settings .verbose_output +{ + float: left; + width: auto; +} + +#content #analysis .settings .verbose_output a +{ + background-image: url( ../../img/ico/ui-check-box-uncheck.png ); + background-position: 0 50%; + color: #999; + display: block; + padding-left: 21px; +} + +#content #analysis .settings .verbose_output.active a +{ + background-image: url( ../../img/ico/ui-check-box.png ); +} + +#content #analysis .index label, +#content #analysis .query label +{ + display: block; +} + +#content #analysis .index textarea, +#content #analysis .query textarea +{ + display: block; + width: 100%; +} + +#content #analysis .index +{ + float: left; + margin-right: 0.5%; + min-width: 47%; + max-width: 99%; +} + +#content #analysis .query +{ + float: right; + margin-left: 0.5%; + min-width: 47%; + max-width: 99%; +} + +#content #analysis .analysis-error +{ + background-color: #f00; + background-image: url( ../../img/ico/construction.png ); + background-position: 10px 50%; + color: #fff; + display: none; + font-weight: bold; + margin-bottom: 20px; + padding: 10px; + padding-left: 35px; +} + +#content #analysis #analysis-result +{ + overflow: auto; +} + +#content #analysis #analysis-result .index, +#content #analysis #analysis-result .query +{ + background-color: #fff; + padding-top: 20px; +} + +#content #analysis #analysis-result table +{ + border-collapse: collapse; +} + +#content #analysis #analysis-result td +{ + vertical-align: top; + white-space: nowrap; +} + +#content #analysis #analysis-result td.part.analyzer div, +#content #analysis #analysis-result td.part.spacer .holder, +#content #analysis #analysis-result td td td +{ + padding-top: 1px; + padding-bottom: 1px; +} + +#content #analysis #analysis-result td.legend, +#content #analysis #analysis-result td.data tr.verbose_output +{ + display: none; +} + +#content #analysis #analysis-result.verbose_output td.legend +{ + display: table-cell; +} + +#content #analysis #analysis-result.verbose_output td.data tr.verbose_output +{ + display: table-row; +} + +#content #analysis #analysis-result .match +{ + background-color: #e9eff7; + background-color: #f2f2ff; +} + +#content #analysis #analysis-result td.part +{ + padding-bottom: 10px; +} + +#content #analysis #analysis-result td.part.analyzer div +{ + border-right: 1px solid #f0f0f0; + padding-right: 10px; +} + +#content #analysis #analysis-result td.part.analyzer abbr +{ + color: #c0c0c0; +} + +#content #analysis #analysis-result td.part.legend .holder, +#content #analysis #analysis-result td.part.data .holder +{ + padding-left: 10px; + padding-right: 10px; + border-right: 1px solid #c0c0c0; +} + +#content #analysis #analysis-result td.part.legend td +{ + color: #c0c0c0; +} + +#content #analysis #analysis-result td.part.legend .holder +{ + border-right-color: #f0f0f0; +} + +#content #analysis #analysis-result td.part.data:last-child .holder +{ + padding-right: 0; + border-right: 0; +} + +#content #analysis #analysis-result td.details +{ + padding-left: 10px; + padding-right: 10px; + border-left: 1px solid #f0f0f0; + border-right: 1px solid #f0f0f0; +} + +#content #analysis #analysis-result td.details:first-child +{ + padding-left: 0; + border-left: 0; +} + +#content #analysis #analysis-result td.details:last-child +{ + padding-right: 0; + border-right: 0; +} + +#content #analysis #analysis-result td.details tr.empty td +{ + color: #f0f0f0; +} + +#content #analysis #analysis-result td.details tr.raw_bytes td +{ + letter-spacing: -1px; +} + +#content #analysis #analysis-result .part table table td +{ + border-top: 1px solid #f0f0f0; +} + +#content #analysis #analysis-result .part table table tr:first-child td +{ + border-top: 0; +} + +#content #analysis #field-analysis h2 { background-image: url( ../../img/ico/receipt.png ); } +#content #analysis .analysis-result h2 { background-image: url( ../../img/ico/receipt-invoice.png ); } \ No newline at end of file diff --git a/solr/webapp/web/css/styles/cloud.css b/solr/webapp/web/css/styles/cloud.css new file mode 100644 index 00000000000..7eb6c554ded --- /dev/null +++ b/solr/webapp/web/css/styles/cloud.css @@ -0,0 +1,128 @@ +#content #cloud .loader +{ + background-position: 0 50%; + padding-left: 21px; +} + +#content #cloud #error +{ + background-color: #f00; + background-image: url( ../../img/ico/construction.png ); + background-position: 10px 50%; + color: #fff; + font-weight: bold; + margin-bottom: 20px; + padding: 10px; + padding-left: 35px; +} + +#content #cloud h2 { background-image: url( ../../img/ico/sitemap.png ); } + +#content #cloud .content +{ + padding-left: 0; + padding-right: 0; +} + +#content #cloud .content.show +{ + background-image: url( ../../img/div.gif ); + background-repeat: repeat-y; + background-position: 31% 0; +} + +#content #cloud #tree +{ + float: left; + width: 30%; +} + +#content #cloud #file-content +{ + display: none; + float: right; + position: relative; + width: 68%; + min-height: 100px +} + +#content #cloud .show #file-content +{ + display: block; +} + +#content #cloud #file-content .close +{ + background-image: url( ../../img/ico/cross-0.png ); + background-position: 50% 50%; + display: block; + height: 20px; + position: absolute; + right: 0; + top: 0; + width: 20px; +} + +#content #cloud #file-content .close:hover +{ + background-image: url( ../../img/ico/cross-1.png ); +} + +#content #cloud #file-content .close span +{ + display: none; +} + +#content #cloud #file-content #data +{ + border-top: 1px solid #c0c0c0; + margin-top: 10px; + padding-top: 10px; +} + +#content #cloud #file-content #data pre +{ + display: block; + max-height: 600px; + overflow: auto; +} + +#content #cloud #file-content #data em +{ + color: #c0c0c0; +} + +#content #cloud #file-content #prop +{ +} + +#content #cloud #file-content li +{ + padding-top: 3px; + padding-bottom: 3px; +} + +#content #cloud #file-content li.odd +{ + background-color: #F8F8F8; +} + +#content #cloud #file-content li dt +{ + float: left; + width: 19%; +} + +#content #cloud #file-content li dd +{ + float: right; + width: 80%; +} + +/* tree */ + +#content #cloud .tree a.active +{ + background-color: #f0f0f0; + color: #00f; +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/common.css b/solr/webapp/web/css/styles/common.css new file mode 100644 index 00000000000..5452ead56a2 --- /dev/null +++ b/solr/webapp/web/css/styles/common.css @@ -0,0 +1,464 @@ +* +{ + background-repeat: no-repeat; + margin: 0; + padding: 0; +} + +body, h1, h2, h3, h4, h5, h6, a, button, input, select, option, textarea, th, td +{ + color: #333; + font: 12px/1.6em "Lucida Grande", "DejaVu Sans", "Bitstream Vera Sans", Verdana, Arial, sans-serif; +} + +body +{ + padding: 30px; + text-align: center; +} + +a, button +{ + cursor: pointer; +} + +button, input, select, textarea +{ + border: 1px solid #c0c0c0; + padding: 2px; +} + +a +{ + text-decoration: none; +} + +pre +{ + color: #333; + text-align: left; +} + +abbr +{ + cursor: help; +} + +ul +{ + list-style: none; +} + +.clearfix:after { clear: both; content: "."; display: block; font-size: 0; height: 0; visibility: hidden; } +.clearfix { display: block; } + +.loader +{ + background-image: url( ../../img/loader.gif ) !important; +} + +.loader-light +{ + background-image: url( ../../img/loader-light.gif ) !important; +} + +#wrapper +{ + margin: 0 auto; + margin-bottom: 30px; + text-align: left; +} + +#header +{ + padding-bottom: 10px; + position: relative; +} + +#header #solr +{ + background-image: url( ../../img/solr.png ); + display: block; + height: 78px; + width: 200px; +} + +#header #solr span +{ + display: none; +} + +#header #wip-notice +{ + background-color: #eceffa; + background-image: url( ../../img/ico/information-button.png ); + background-position: 8px 7px; + border: 1px solid #4465cb; + padding: 5px 10px; + padding-left: 31px; + left: 212px; + position: absolute; + top: 0; +} + +#header #wip-notice a +{ + display: block; +} + +#header #wip-notice span +{ + border-bottom: 1px solid #c0c0c0; +} + +#main +{ + border: 1px solid #c0c0c0; + min-height: 600px; + min-width: 750px; + position: relative; +} + +#meta +{ + position: absolute; + bottom: -26px; + right: 0; +} + +#meta li +{ + float: left; +} + +#meta li a +{ + background-position: 10px 50%; + display: block; + height: 25px; + line-height: 25px; + padding-left: 31px; + padding-right: 10px; +} + +#meta li a:hover +{ + background-color: #f0f0f0; +} + +#meta .documentation a { background-image: url( ../../img/ico/document-text.png ); } +#meta .issues a { background-image: url( ../../img/ico/bug.png ); } +#meta .irc a { background-image: url( ../../img/ico/users.png ); } +#meta .mailinglist a { background-image: url( ../../img/ico/mail.png ); } +#meta .wiki-query-syntax a { background-image: url( ../../img/ico/script-code.png ); } + +#environment +{ + background-image: url( ../../img/ico/box.png ); + background-position: 10px 50%; + border: 1px solid #c0c0c0; + display: none; + font-weight: bold; + padding: 5px 10px; + padding-left: 31px; + position: absolute; + top: 0; + right: 0; +} + +#environment.prod +{ + background-color: #c37f7f; + border-color: #b15757; + color: #fff; +} + +#environment.test +{ + background-color: #f5f5b2; + border-color: #e4e433; +} + +#environment.dev +{ + background-color: #cce7cc; + border-color: #66b866; +} + + +#content-wrapper +{ + float: right; + width: 80%; +} + +#content +{ + padding: 10px; +} + +#content > .loader +{ + background-position: 0 50%; + padding-left: 21px; +} + +#content iframe +{ + border: 0; + display: block; + min-height: 400px; + width: 100%; +} + +#content > pre +{ + max-height: 600px; + overflow: auto; +} + +#content .block +{ + margin-bottom: 10px; +} + +#content .block h2 +{ + background-color: #fafafa; + background-position: 5px 50%; + border-bottom: 1px solid #f0f0f0; + font-weight: bold; + padding: 5px; + padding-left: 26px; +} + +#content .block.disabled, +#content .block.disabled h2 +{ + color: #c0c0c0; +} + +#content .block .message, +#content .block .content +{ + padding: 5px; +} + +#content .block .message +{ + display: none; +} + +/* syntax */ + +pre.syntax +{ + overflow: auto; +} + +pre.syntax code +{ + display: block; + color: #000; +} + +pre.syntax .comment, +pre.syntax .template_comment, +pre.syntax .diff .header, +pre.syntax .javadoc +{ + color: #998; + font-style: italic; +} + +pre.syntax .keyword, +pre.syntax .css .rule .keyword, +pre.syntax .winutils, +pre.syntax .javascript .title, +pre.syntax .lisp .title, +pre.syntax .subst +{ + color: #000; + font-weight: bold; +} + +pre.syntax .number, +pre.syntax .hexcolor +{ + color: #40a070; +} + +pre.syntax .string, +pre.syntax .tag .value, +pre.syntax .phpdoc, +pre.syntax .tex .formula +{ + color: #d14; +} + +pre.syntax .title, +pre.syntax .id +{ + color: #900; + font-weight: bold; +} + +pre.syntax .javascript .title, +pre.syntax .lisp .title, +pre.syntax .subst +{ + font-weight: normal; +} + +pre.syntax .class .title, +pre.syntax .tex .command +{ + color: #458; + font-weight: bold; +} + +pre.syntax .tag, +pre.syntax .css .keyword, +pre.syntax .html .keyword, +pre.syntax .tag .title, +pre.syntax .django .tag .keyword +{ + color: #000080; + font-weight: normal; +} + +pre.syntax .attribute, +pre.syntax .variable, +pre.syntax .instancevar, +pre.syntax .lisp .body +{ + color: #008080; +} + +pre.syntax .regexp +{ + color: #009926; +} + +pre.syntax .class +{ + color: #458; + font-weight: bold; +} + +pre.syntax .symbol, +pre.syntax .ruby .symbol .string, +pre.syntax .ruby .symbol .keyword, +pre.syntax .ruby .symbol .keymethods, +pre.syntax .lisp .keyword, +pre.syntax .tex .special +{ + color: #990073; +} + +pre.syntax .builtin, +pre.syntax .built_in, +pre.syntax .lisp .title +{ + color: #0086b3; +} + +pre.syntax .preprocessor, +pre.syntax .pi, +pre.syntax .doctype, +pre.syntax .shebang, +pre.syntax .cdata +{ + color: #999; + font-weight: bold; +} + +pre.syntax .deletion +{ + background: #fdd; +} + +pre.syntax .addition +{ + background: #dfd; +} + +pre.syntax .diff .change +{ + background: #0086b3; +} + +pre.syntax .chunk +{ + color: #aaa; +} + +pre.syntax .tex .formula +{ + opacity: 0.5; +} + +#content .tree li, +#content .tree ins +{ + background-color: transparent; + background-image: url( ../../img/tree.png ); + background-repeat: no-repeat; +} + +#content .tree li +{ + background-position: -54px 0; + background-repeat: repeat-y; + line-height: 22px; +} + +#content .tree li.jstree-last +{ + background:transparent; +} + +#content .tree .jstree-open > ins +{ + background-position: -36px 0; +} + +#content .tree .jstree-closed > ins +{ + background-position: -18px 0; +} + +#content .tree .jstree-leaf > ins +{ + background-position: 0 0; +} + +#content .tree .jstree-hovered +{ + background:#e7f4f9; border:1px solid #d8f0fa; padding:0 2px 0 1px; +} + +#content .tree .jstree-clicked +{ + background:#beebff; border:1px solid #99defd; padding:0 2px 0 1px; +} + +#content .tree a .jstree-icon +{ + background-image: url( ../../img/ico/folder.png ); +} + +#content .tree .jstree-leaf a .jstree-icon +{ + background-image: url( ../../img/ico/document-text.png ); +} + +#content .tree .jstree-search +{ + font-style:italic; +} + +#content .tree a.jstree-search +{ + color:aqua; +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/cores.css b/solr/webapp/web/css/styles/cores.css new file mode 100644 index 00000000000..7eb6653836f --- /dev/null +++ b/solr/webapp/web/css/styles/cores.css @@ -0,0 +1,272 @@ +#content #cores +{ +} + +#content #cores #frame +{ + float: right; + width: 78%; +} + +#content #cores #navigation +{ + background-image: url( ../../img/div.gif ); + background-position: 100% 0; + background-repeat: repeat-y; + width: 20%; +} + +#content #cores #list +{ + float: left; + padding-top: 15px; + width: 100%; +} + +#content #cores #list a +{ + border-right: 1px solid #f0f0f0; + display: block; + margin-left: 1px; + padding: 3px 0; +} + +#content #cores #list a:hover +{ + background-color: #fafafa; +} + +#content #cores #list .current a +{ + background-color: #fff; + border-right-color: #fff; + border-top: 1px solid #f0f0f0; + border-bottom: 1px solid #f0f0f0; + font-weight: bold; +} + +#content #cores #frame .actions +{ + margin-bottom: 20px; +} + +#content #cores .actions form .buttons +{ + padding-left: 40px; +} + +#content #cores .actions form a +{ + display: block; + float: left; + height: 20px; + margin-right: 5px; + padding-left: 21px; +} + +#content #cores .actions form a span +{ + display: none; +} + +#content #cores .actions form a.submit +{ + background-image: url( ../../img/ico/tick.png ); + background-position: 50% 50%; +} + +#content #cores .actions form a.submit:hover +{ + background-color: #e6f3e6; +} + +#content #cores .actions form a.reset +{ + background-image: url( ../../img/ico/cross.png ); + background-position: 50% 50%; +} + +#content #cores .actions form a.reset:hover +{ + background-color: #f3e6e6; +} + +#content #cores .actions form p +{ + padding-bottom: 3px; +} + +#content #cores .actions form label +{ + float: left; + width: 40px; +} + +#content #cores .actions form input, +#content #cores .actions form select +{ + width: 100px; +} + +#content #cores .actions form select option.disabled +{ + color: #c0c0c0; +} + +#content #cores .actions .button-holder +{ + float: left; + margin-right: 10px; + margin-bottom: 5px; +} + +#content #cores .actions .button-holder.active +{ + margin-bottom: 0; +} + +#content #cores .actions .button-holder .button +{ + background-color: #f5f5f5; + border: 1px solid #c0c0c0; + position: relative; + z-index: 100; +} + +#content #cores .actions .button-holder.active .button +{ + background-color: #fff; + border-bottom-color: #fff; + padding-bottom: 5px; +} + +#content #cores .actions .button-holder .button a +{ + background-position: 5px 50%; + display: block; + padding: 1px 5px; + padding-left: 24px; +} + +#content #cores .actions .button-holder .button a.success +{ + background-image: url( ../../img/ico/tick.png ); +} + +#content #cores .actions .button-holder.active .button a +{ + cursor: auto; +} + +#content #cores .actions .button-holder .button-content +{ + background-color: #fff; + border: 1px solid #c0c0c0; + box-shadow: 5px 5px 10px #c0c0c0; + -moz-box-shadow: 5px 5px 10px #c0c0c0; + -webkit-box-shadow: 5px 5px 10px #c0c0c0; + display: none; + margin-top: -1px; + padding: 5px; + padding-top: 15px; + position: absolute; + z-index: 99; +} + +#content #cores .actions .button-holder.active .button-content +{ + display: block; +} + +#content #cores .actions .button .reload +{ + background-image: url( ../../img/ico/arrow-circle.png ); +} + +#content #cores .actions .button .rename +{ + background-image: url( ../../img/ico/ui-text-field-select.png ); +} + +#content #cores .actions .button .swap +{ + background-image: url( ../../img/ico/arrow-switch.png ); +} + +#content #cores .actions .button .unload +{ + background-image: url( ../../img/ico/cross.png ); +} + +#content #cores .actions .button .optimize +{ + background-image: url( ../../img/ico/hammer-screwdriver.png ); + display: none; +} + +#content #cores #navigation .add +{ + background-image: url( ../../img/ico/plus-button.png ); +} + +#content #cores #navigation .add label +{ + width: 85px; +} + +#content #cores #navigation .add input +{ + width: 155px; +} + +#content #cores #navigation .add .buttons +{ + padding-left: 85px; +} + +#content #cores #data #core-data h2 { background-image: url( ../../img/ico/database.png ); } +#content #cores #data #index-data h2 { background-image: url( ../../img/ico/chart.png ); } + +#content #cores #data #index-data +{ + margin-top: 10px; +} + +#content #cores #data li +{ + padding-bottom: 3px; + padding-top: 3px; +} + +#content #cores #data li.odd +{ + background-color: #f8f8f8; +} + +#content #cores #data li dt +{ + float: left; + width: 17%; +} + +#content #cores #data li dd +{ + float: right; + width: 82%; +} + +#content #cores #data li dd.ico +{ + background-image: url( ../../img/ico/slash.png ); + height: 20px; +} + +#content #cores #data li dd.ico.ico-1 +{ + background-image: url( ../../img/ico/tick.png ); +} + +#content #cores #data li dd.ico span +{ + display: none; +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/dashboard.css b/solr/webapp/web/css/styles/dashboard.css new file mode 100644 index 00000000000..1cac25cb3f9 --- /dev/null +++ b/solr/webapp/web/css/styles/dashboard.css @@ -0,0 +1,114 @@ +#content #dashboard .block +{ + background-image: none; + width: 49%; +} + +#content #dashboard #statistics +{ + float: left; +} + +#content #dashboard #statistics dt, +#content #dashboard #statistics dd +{ + display: block; + float: left; +} + +#content #dashboard #statistics dt +{ + clear: left; + margin-right: 2%; + text-align: right; + width: 23%; +} + +#content #dashboard #statistics dd +{ + width: 74%; +} + +#content #dashboard #statistics .index_optimized +{ + margin-top: 10px; +} + +#content #dashboard #statistics .ico +{ + background-image: url( ../../img/ico/slash.png ); + height: 20px; +} + +#content #dashboard #statistics .ico.ico-1 +{ + background-image: url( ../../img/ico/tick.png ); +} + +#content #dashboard #statistics .ico span +{ + display: none; +} + +#content #dashboard #statistics .index_optimized.value a +{ + display: none; +} + +#content #dashboard #statistics .index_optimized.value.ico-0 a +{ + background-color: #f0f0f0; + background-image: url( ../../img/ico/hammer-screwdriver.png ); + background-position: 5px 50%; + border: 1px solid #c0c0c0; + display: block; + float: left; + margin-left: 50px; + padding: 1px 5px; + padding-left: 26px; +} + +#content #dashboard #statistics .index_has-deletions +{ + display: none; +} + +#content #dashboard #statistics .index_has-deletions.value.ico-0 +{ + background-image: url( ../../img/ico/tick-red.png ); +} + +#content #dashboard #replication +{ + float: left; +} + +#content #dashboard #replication .is-replicating +{ + background-position: 99% 50%; + display: block; +} + +#content #dashboard #replication #details table thead td span +{ + display: none; +} + +#content #dashboard #dataimport +{ + float: right; +} + + +#content #dashboard #admin-extra +{ + float: right; +} + +#content #dashboard #system h2 { background-image: url( ../../img/ico/server.png ); } +#content #dashboard #statistics h2 { background-image: url( ../../img/ico/chart.png ); } +#content #dashboard #replication h2 { background-image: url( ../../img/ico/node.png ); } +#content #dashboard #replication.is-master h2 { background-image: url( ../../img/ico/node-master.png ); } +#content #dashboard #replication.is-slave h2 { background-image: url( ../../img/ico/node-slave.png ); } +#content #dashboard #dataimport h2 { background-image: url( ../../img/ico/document-import.png ); } +#content #dashboard #admin-extra h2 { background-image: url( ../../img/ico/plus-button.png ); } \ No newline at end of file diff --git a/solr/webapp/web/css/styles/dataimport.css b/solr/webapp/web/css/styles/dataimport.css new file mode 100644 index 00000000000..b7b1156ca1a --- /dev/null +++ b/solr/webapp/web/css/styles/dataimport.css @@ -0,0 +1,232 @@ +#content #dataimport +{ + background-image: url( ../../img/div.gif ); + background-position: 21% 0; + background-repeat: repeat-y; +} + +#content #dataimport #frame +{ + float: right; + width: 78%; +} + +#content #dataimport #form +{ + float: left; + width: 20%; +} + +#content #dataimport.error #form form +{ + display: none !important; +} + +#content #dataimport #form label +{ + cursor: pointer; + display: block; + margin-top: 5px; +} + +#content #dataimport #form input, +#content #dataimport #form select, +#content #dataimport #form textarea +{ + margin-bottom: 2px; + width: 100%; +} + +#content #dataimport #form #start +{ + float: left; + margin-right: 2%; + width: 49%; +} + +#content #dataimport #form #rows +{ + width: 49%; +} + +#content #dataimport #form .checkbox input +{ + margin-bottom: 0; + width: auto; +} + +#content #dataimport #form fieldset, +#content #dataimport #form .optional.expanded +{ + border: 1px solid #fff; + border-top: 1px solid #c0c0c0; + margin-bottom: 10px; +} + +#content #dataimport #form fieldset legend, +#content #dataimport #form .optional.expanded legend +{ + display: block; + margin-left: 10px; + padding: 0px 5px; +} + +#content #dataimport #form fieldset legend label +{ + margin-top: 0; +} + +#content #dataimport #form .handler +{ + display: none; +} + +#content #dataimport #form .handler ul +{ + list-style: disc; + margin-left: 0.7em; + padding-left: 0.7em; +} + +#content #dataimport #form .handler ul li a +{ + color: #c0c0c0; + display: block; +} + +#content #dataimport #form .handler ul li.active a +{ + color: #333; +} + +#content #dataimport #current_state +{ + display: none; + padding: 10px; + margin-bottom: 20px; +} + +#content #dataimport.error #current_state +{ + display: none !important; +} + +#content #dataimport #current_state .time, +#content #dataimport #current_state .info +{ + display: block; + padding-left: 21px; +} + +#content #dataimport #current_state .time +{ + color: #c0c0c0; + font-size: 11px; +} + +#content #dataimport #current_state .info +{ + background-position: 0 1px; +} + +#content #dataimport #current_state.indexing +{ + background-color: #f9f9f9; +} + +#content #dataimport #current_state.success +{ + background-color: #e6f3e6; +} + +#content #dataimport #current_state.success .info +{ + background-image: url( ../../img/ico/tick-circle.png ); +} + +#content #dataimport #current_state.success .info strong +{ + color: #080; +} + +#content #dataimport #current_state.failure +{ + background-color: #f3e6e6; +} + +#content #dataimport #current_state.failure .info +{ + background-image: url( ../../img/ico/slash.png ); +} + +#content #dataimport #current_state.failure .info strong +{ + color: #800; +} + +#content #dataimport #config-error +{ + background-color: #f00; + background-image: url( ../../img/ico/construction.png ); + background-position: 10px 50%; + color: #fff; + display: none; + font-weight: bold; + margin-bottom: 20px; + padding: 10px; + padding-left: 35px; +} + +#content #dataimport #config h2 +{ + border-color: #c0c0c0; + padding-left: 5px; + position: relative; +} + +#content #dataimport #config.hidden h2 +{ + border-color: #fafafa; +} + +#content #dataimport #config h2 a.toggle +{ + background-image: url( ../../img/ico/toggle-small.png ); + background-position: 0 50%; + padding-left: 21px; +} + +#content #dataimport #config.hidden h2 a.toggle +{ + background-image: url( ../../img/ico/toggle-small-expand.png ); +} + +#content #dataimport #config h2 a.reload_config +{ + background-image: url( ../../img/ico/arrow-circle.png ); + padding-left: 21px; + position: absolute; + right: 5px; + top: 5px; +} + +#content #dataimport #config h2 a.reload_config.success +{ + background-image: url( ../../img/ico/tick.png ); +} + +#content #dataimport #config h2 a.reload_config.error +{ + background-image: url( ../../img/ico/slash.png ); +} + +#content #dataimport #config.hidden .content +{ + display: none; +} + +#content #dataimport #dataimport_config .loader +{ + background-position: 0 50%; + padding-left: 21px; +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/index.css b/solr/webapp/web/css/styles/index.css new file mode 100644 index 00000000000..2cf82a6cb63 --- /dev/null +++ b/solr/webapp/web/css/styles/index.css @@ -0,0 +1,158 @@ +#content #index .loader +{ + background-position: 0 50%; + padding-left: 21px; +} + +#content #index #data +{ + float: left; + width: 74%; +} + +#content #index #memory +{ + float: right; + width: 24%; +} + +#content #index #data h2 { background-image: url( ../../img/ico/server.png ); } +#content #index #memory h2 { background-image: url( ../../img/ico/battery.png ); } + +#content #index #data li +{ + display: none; + padding-top: 3px; + padding-bottom: 3px; +} + +#content #index #data li.odd +{ + background-color: #f8f8f8; +} + +#content #index #data li dt +{ + float: left; + width: 27%; +} + +#content #index #data li dd +{ + float: right; + width: 72% +} + +#content #index #data li dd.odd +{ + color: #999; +} + +#content #index #data dt span +{ + background-position: 0 50%; + display: block; + padding-left: 21px; +} + +#content #index #data .start_time dt span +{ + background-image: url( ../../img/ico/clock-select.png ); +} + +#content #index #data .host dt span +{ + background-image: url( ../../img/ico/globe.png ); +} + +#content #index #data .cwd dt span +{ + background-image: url( ../../img/ico/folder-export.png ); +} + +#content #index #data .jvm dt span +{ + background-image: url( ../../img/ico/jar.png ); +} + +#content #index #data .command_line_args dt span +{ + background-image: url( ../../img/ico/terminal.png ); +} + +#content #index #data .lucene dt span +{ + background-image: url( ../../img/lucene-ico.png ); +} + +#content #index #memory #memory-bar +{ + background-color: #00f; + box-shadow: 5px 5px 10px #c0c0c0; + -moz-box-shadow: 5px 5px 10px #c0c0c0; + -webkit-box-shadow: 5px 5px 10px #c0c0c0; + margin-top: 20px; + width: 100px; +} + +#content #index #memory .bar +{ + bottom: 0; + position: absolute; + width: 100%; +} + +#content #index #memory div .value +{ + border-top: 1px solid #f00; + display: block; + font-size: 10px; + line-height: 12px; + padding-left: 10px; + padding-right: 2px; + position: absolute; + margin-left: 100px; + white-space: nowrap; +} + +#content #index #memory div .value.upper +{ + border-top-width: 0; + border-bottom-width: 1px; + border-bottom-style: solid; +} + +#content #index #memory #memory-bar-max +{ + background-color: #f0f0f0; + height: 200px; + position: relative; +} + +#content #index #memory #memory-bar-max .value +{ + border-color: #f0f0f0; + color: #d6d6d6; +} + +#content #index #memory #memory-bar-total +{ + background-color: #c0c0c0; +} + +#content #index #memory #memory-bar-total .value +{ + border-color: #c0c0c0; + color: #c0c0c0; +} + +#content #index #memory #memory-bar-used +{ + background-color: #969696; +} + +#content #index #memory #memory-bar-used .value +{ + border-color: #969696; + color: #969696; +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/java-properties.css b/solr/webapp/web/css/styles/java-properties.css new file mode 100644 index 00000000000..be0e98881c4 --- /dev/null +++ b/solr/webapp/web/css/styles/java-properties.css @@ -0,0 +1,33 @@ +#content #java-properties .loader +{ + background-position: 0 50%; + padding-left: 21px; +} + +#content #java-properties li +{ + padding-top: 3px; + padding-bottom: 3px; +} + +#content #java-properties li.odd +{ + background-color: #f8f8f8; +} + +#content #java-properties li dt +{ + float: left; + width: 29%; +} + +#content #java-properties li dd +{ + float: right; + width: 70% +} + +#content #java-properties li dd.odd +{ + color: #999; +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/logging.css b/solr/webapp/web/css/styles/logging.css new file mode 100644 index 00000000000..36965cd628d --- /dev/null +++ b/solr/webapp/web/css/styles/logging.css @@ -0,0 +1,150 @@ +#content #logging .loader +{ + background-position: 0 50%; + padding-left: 21px; +} + +#content #logging .jstree +{ + position: relative; +} + +#content #logging .jstree a +{ + cursor: auto; +} + +#content #logging .jstree .trigger span +{ + background-position: 100% 50%; + cursor: pointer; + padding-right: 21px; +} + +#content #logging .jstree a.trigger:hover span +{ + background-image: url( ../../img/ico/pencil-small.png ); +} + +#content #logging .jstree .inactive, +#content #logging .jstree .inactive .effective_level +{ + color: #c0c0c0; +} + +#content #logging .jstree li +{ + position: relative; +} + +#content #logging .jstree .odd +{ + background-color: #f8f8f8; +} + +#content #logging .jstree .loglevel +{ + position: absolute; + margin-top: 3px; + top: 0; +} + +#content #logging .jstree li .loglevel { left: 340px; } +#content #logging .jstree li li .loglevel { left: 322px; } +#content #logging .jstree li li li .loglevel { left: 304px; } +#content #logging .jstree li li li li .loglevel { left: 286px; } +#content #logging .jstree li li li li li .loglevel { left: 268px; } +#content #logging .jstree li li li li li li .loglevel { left: 250px; } + +#content #logging .jstree .loglevel a +{ + display: block; +} + +#content #logging .jstree .loglevel .effective_level +{ + height: 22px; + line-height: 22px; + padding-left: 5px; + width: 150px; +} + +#content #logging .jstree .loglevel.open .effective_level +{ + background-color: #f0f0f0; +} + +#content #logging .jstree .loglevel.open .effective_level +{ + background-image: url( ../../img/ico/arrow-000-small.png ); + background-position: 75px 50%; +} + +#content #logging .jstree .loglevel.open .effective_level span +{ + background-image: none; +} + +#content #logging .jstree .loglevel ul +{ + background-color: #fff; + border: 1px solid #f0f0f0; + display: none; + position: absolute; + left: 100px; + top: 0; +} + +#content #logging .jstree .loglevel.open ul +{ + display: block; +} + +#content #logging .jstree .loglevel ul li +{ + background-image: none; + line-height: auto; + margin-left: 0; +} + +#content #logging .jstree .loglevel ul li a +{ + background-image: url( ../../img/ico/ui-radio-button-uncheck.png ); + background-position: 2px 50%; + cursor: pointer; + display: block; + height: 22px; + line-height: 22px; + padding-left: 21px; + padding-right: 5px; +} + +#content #logging .jstree .loglevel ul li.selected a +{ + background-image: url( ../../img/ico/ui-radio-button.png ); +} + +#content #logging .jstree .loglevel ul li a:hover +{ + background-color: #f8f8f8; + color: #008; +} + +#content #logging .jstree .loglevel ul li.unset +{ + border-top: 1px solid #f0f0f0; +} + +#content #logging .jstree .loglevel ul li.unset a +{ + background-image: url( ../../img/ico/cross-0.png ); + background-position: 4px 50%; + padding-top: 3px; + padding-bottom: 3px; +} + +#content #logging .jstree .loglevel ul li.unset a:hover +{ + background-image: url( ../../img/ico/cross-1.png ); + color: #800; +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/menu.css b/solr/webapp/web/css/styles/menu.css new file mode 100644 index 00000000000..e53dee44bd1 --- /dev/null +++ b/solr/webapp/web/css/styles/menu.css @@ -0,0 +1,242 @@ +#menu-wrapper +{ + float: left; + width: 20%; +} + +#menu p.loader +{ + background-position: 5px 50%; + color: #c0c0c0; + margin-top: 5px; + padding-left: 26px; +} + +#menu a +{ + display: block; + padding: 4px 2px; +} + +#menu .active +{ + background-color: #fafafa; +} + +#menu p a +{ + background-position: 97% 50%; + background-image: url( ../../img/ico/status-offline.png ); + padding-left: 5px; + padding-top: 5px; + padding-bottom: 5px; +} + +#menu p a:hover +{ + background-color: #f0f0f0; +} + +#menu .active p a +{ + background-color: #c0c0c0; /* #a5a5a6 */ + font-weight: bold; +} + +#menu p a small +{ + color: #b5b5b5; + font-weight: normal; +} + +#menu p a small span.txt +{ + display: none; +} + +#menu p a small:hover span.txt +{ + display: inline; +} + +#menu .busy +{ + border-right-color: #f6f5d9; +} + +#menu .busy p a +{ + background-color: #f6f5d9; + background-image: url( ../../img/ico/status-away.png ); +} + +#menu .offline +{ + border-right-color: #eccfcf; +} + +#menu .offline p a +{ + background-color: #eccfcf; + background-image: url( ../../img/ico/status-busy.png ); +} + +#menu .online +{ + border-right-color: #cfecd3; +} + +#menu .online p a +{ + background-color: #cfecd3; + background-image: url( ../../img/ico/status.png ); +} + +#menu .ping small +{ + color: #000 +} + +#menu li +{ + border-bottom: 1px solid #c0c0c0; +} + +#menu li p +{ + border-right: 1px solid #c0c0c0; +} + +#menu li.optional +{ + display: none; +} + +#menu li.active:last-child +{ + border-bottom: 0; +} + +#menu ul ul +{ + background-image: url( ../../img/div.gif ); + background-position: 100% 0; + background-repeat: repeat-y; + display: none; + padding-top: 5px; + padding-bottom: 10px; +} + +#menu ul .active ul +{ + display: block; +} + +#menu ul li.active:last-child ul +{ + border-bottom: 1px solid #f0f0f0; +} + +#menu ul ul li +{ + border-bottom: 0; + /*border-right: 0;*/ + border-right: 1px solid #f0f0f0; +} + +#menu ul ul li a +{ + background-position: 7px 50%; + border-bottom: 1px solid #f0f0f0; + color: #bbb; + margin-left: 15px; + padding-left: 26px; +} + +#menu ul ul li:last-child a +{ + border-bottom: 0; +} + +#menu ul ul li a:hover +{ + background-color: #f0f0f0; + color: #333; +} + +#menu ul ul li.active +{ + background-color: #fff; + border-right-color: #fff; +} + +#menu ul ul li.active a +{ + color: #333; +} + +#menu ul ul li.active a:hover +{ + background-color: transparent; +} + +#menu .global p a +{ + background-position: 5px 50%; + padding-left: 26px; +} + +#menu #index p a +{ + background-image: url( ../../img/ico/dashboard.png ); +} + +#menu #logging p a +{ + background-image: url( ../../img/ico/inbox-document-text.png ); +} + +#menu #java-properties p a +{ + background-image: url( ../../img/ico/jar.png ); +} + +#menu #threads p a +{ + background-image: url( ../../img/ico/ui-accordion.png ); +} + +#menu #cores p a +{ + background-image: url( ../../img/ico/databases.png ); +} + +#menu #cloud p a +{ + background-image: url( ../../img/ico/network-cloud.png ); +} + +#menu .query a { background-image: url( ../../img/ico/magnifier.png ); } +#menu .schema a { background-image: url( ../../img/ico/table.png ); } +#menu .config a { background-image: url( ../../img/ico/gear.png ); } +#menu .analysis a { background-image: url( ../../img/ico/funnel.png ); } +#menu .schema-browser a { background-image: url( ../../img/ico/book-open-text.png ); } +#menu .replication a { background-image: url( ../../img/ico/node.png ); } +#menu .distribution a { background-image: url( ../../img/ico/node-select.png ); } +#menu .ping a { background-image: url( ../../img/ico/system-monitor.png ); } +#menu .logging a { background-image: url( ../../img/ico/inbox-document-text.png ); } +#menu .plugins a { background-image: url( ../../img/ico/block.png ); } +#menu .dataimport a { background-image: url( ../../img/ico/document-import.png ); } + +#menu .ping.error +{ + background-color: #f7f7e9; + background-color: #ffcccc; +} + +#menu .ping.error a +{ + background-color: transparent; + background-image: url( ../../img/ico/system-monitor--exclamation.png ); + cursor: help; +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/plugins.css b/solr/webapp/web/css/styles/plugins.css new file mode 100644 index 00000000000..b99748fb4de --- /dev/null +++ b/solr/webapp/web/css/styles/plugins.css @@ -0,0 +1,128 @@ +#content #plugins #navigation +{ + background-image: url( ../../img/div.gif ); + background-position: 100% 0; + background-repeat: repeat-y; + width: 20%; +} + +#content #plugins #navigation a +{ + background-position: 0 50%; + border-right: 1px solid #f0f0f0; + display: block; + margin-left: 1px; + padding: 3px 0; + padding-left: 21px; +} + +#content #plugins #navigation .cache a { background-image: url( ../../img/ico/disk-black.png ); } +#content #plugins #navigation .core a { background-image: url( ../../img/ico/toolbox.png ); } +#content #plugins #navigation .other a { background-image: url( ../../img/ico/zone.png ); } +#content #plugins #navigation .highlighting a { background-image: url( ../../img/ico/highlighter-text.png ); } +#content #plugins #navigation .updatehandler a{ background-image: url( ../../img/ico/arrow-circle.png ); } +#content #plugins #navigation .queryhandler a { background-image: url( ../../img/ico/magnifier.png ); } + +#content #plugins #navigation a:hover +{ + background-color: #fafafa; +} + +#content #plugins #navigation .current a +{ + background-color: #fff; + border-right-color: #fff; + border-top: 1px solid #f0f0f0; + border-bottom: 1px solid #f0f0f0; + font-weight: bold; +} + +#content #plugins #frame +{ + float: right; + width: 78%; +} + +#content #plugins #frame .entry +{ + margin-bottom: 10px; +} + +#content #plugins #frame .entry:last-child +{ + margin-bottom: 0; +} + +#content #plugins #frame .entry a +{ + background-image: url( ../../img/ico/chevron-small-expand.png ); + background-position: 0 50%; + display: block; + font-weight: bold; + padding-left: 21px; +} + +#content #plugins #frame .entry.expanded a +{ + background-image: url( ../../img/ico/chevron-small.png ); +} + +#content #plugins #frame .entry.expanded ul +{ + display: block; +} + +#content #plugins #frame .entry ul +{ + display: none; + padding-top: 5px; + margin-left: 21px; +} + +#content #plugins #frame .entry li +{ + padding-top: 2px; + padding-bottom: 2px; +} + +#content #plugins #frame .entry li.stats +{ + border-top: 1px solid #c0c0c0; + margin-top: 5px; + padding-top: 5px; +} + +#content #plugins #frame .entry li.odd +{ + background-color: #f8f8f8; +} + +#content #plugins #frame .entry dt, +#content #plugins #frame .entry .stats span +{ + float: left; + width: 11%; +} + +#content #plugins #frame .entry dd, +#content #plugins #frame .entry .stats ul +{ + float: right; + width: 88%; +} + +#content #plugins #frame .entry .stats ul +{ + margin: 0; + padding: 0; +} + +#content #plugins #frame .entry .stats dt +{ + width: 27%; +} + +#content #plugins #frame .entry .stats dd +{ + width: 72%; +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/query.css b/solr/webapp/web/css/styles/query.css new file mode 100644 index 00000000000..f6dd28a26df --- /dev/null +++ b/solr/webapp/web/css/styles/query.css @@ -0,0 +1,132 @@ +#content #query +{ + background-image: url( ../../img/div.gif ); + background-position: 22% 0; + background-repeat: repeat-y; +} + +#content #query #form +{ + float: left; + width: 21%; +} + +#content #query #form label +{ + cursor: pointer; + display: block; + margin-top: 5px; +} + +#content #query #form input, +#content #query #form select, +#content #query #form textarea +{ + margin-bottom: 2px; + width: 100%; +} + +#content #query #form #start +{ + float: left; + margin-right: 2%; + width: 49%; +} + +#content #query #form #rows +{ + width: 49%; +} + +#content #query #form .checkbox input +{ + margin-bottom: 0; + width: auto; +} + +#content #query #form fieldset, +#content #query #form .optional.expanded +{ + border: 1px solid #fff; + border-top: 1px solid #c0c0c0; + margin-bottom: 10px; +} + +#content #query #form fieldset legend, +#content #query #form .optional.expanded legend +{ + display: block; + margin-left: 10px; + padding: 0px 5px; +} + +#content #query #form fieldset legend label +{ + margin-top: 0; +} + +#content #query #form fieldset .fieldset +{ + border-bottom: 1px solid #f0f0f0; + margin-bottom: 5px; + padding-bottom: 5px; +} + +#content #query #form .optional +{ + border: 0; +} + +#content #query #form .optional .fieldset +{ + display: none; +} + +#content #query #form .optional legend +{ + margin-left: 0; + padding-left: 0; +} + +#content #query #form .optional.expanded .fieldset +{ + display: block; +} + +#content #query #result +{ + display: none; + float: right; + width: 77%; +} + +#content #query #result #url +{ + margin-bottom: 10px; + background-image: url( ../../img/ico/ui-address-bar.png ); + background-position: 5px 50%; + border: 1px solid #f0f0f0; + box-shadow: 1px 1px 0 #f0f0f0; + -moz-box-shadow: 1px 1px 0 #f0f0f0; + -webkit-box-shadow: 1px 1px 0 #f0f0f0; + color: #c0c0c0; + display: block; + overflow: hidden; + padding: 5px; + padding-left: 26px; + white-space: nowrap; +} + +#content #query #result #url:focus, +#content #query #result #url:hover +{ + border-color: #c0c0c0; + box-shadow: 1px 1px 0 #d8d8d8; + -moz-box-shadow: 1px 1px 0 #d8d8d8; + -webkit-box-shadow: 1px 1px 0 #d8d8d8; + color: #333; +} + +#content #query #result #response +{ +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/replication.css b/solr/webapp/web/css/styles/replication.css new file mode 100644 index 00000000000..3b33ad7ab94 --- /dev/null +++ b/solr/webapp/web/css/styles/replication.css @@ -0,0 +1,463 @@ +#content #replication +{ + background-image: url( ../../img/div.gif ); + background-position: 21% 0; + background-repeat: repeat-y; +} + +#content #replication #frame +{ + float: right; + width: 78%; +} + +#content #replication #navigation +{ + float: left; + width: 20%; +} + +#content #replication #error +{ + background-color: #f00; + background-image: url( ../../img/ico/construction.png ); + background-position: 10px 50%; + color: #fff; + display: none; + font-weight: bold; + margin-bottom: 20px; + padding: 10px; + padding-left: 35px; +} + +#content #replication .block +{ + border-bottom: 1px solid #c0c0c0; + margin-bottom: 20px; + padding-bottom: 20px; +} + +#content #replication .block.last +{ + border-bottom: 0; +} + +#content #replication .masterOnly, +#content #replication .slaveOnly +{ + display: none; +} + +#content #replication.master .masterOnly +{ + display: block; +} + +#content #replication.slave .slaveOnly +{ + display: block; +} + +#content #replication .replicating +{ + display: none; +} + +#content #replication.replicating .replicating +{ + display: block; +} + +#content #replication #progress +{ + padding-bottom: 80px; + position: relative; +} + +#content #replication #progress .info +{ + padding: 5px; +} + +#content #replication #progress #start +{ + margin-left: 100px; + border-left: 1px solid #c0c0c0; +} + +#content #replication #progress #bar +{ + background-color: #f0f0f0; + margin-left: 100px; + margin-right: 100px; + position: relative; +} + +#content #replication #progress #bar #bar-info, +#content #replication #progress #bar #eta +{ + position: absolute; + right: -100px; + width: 100px; +} + +#content #replication #progress #bar #bar-info +{ + border-left: 1px solid #f0f0f0; + margin-top: 30px; +} + +#content #replication #progress #eta .info +{ + color: #c0c0c0; + height: 30px; + line-height: 30px; + padding-top: 0; + padding-bottom: 0; +} + +#content #replication #progress #speed +{ + color: #c0c0c0; + position: absolute; + right: 100px; + top: 0; +} + +#content #replication #progress #bar #done +{ + background-color: #c0c0c0; + box-shadow: 5px 5px 10px #c0c0c0; + -moz-box-shadow: 5px 5px 10px #c0c0c0; + -webkit-box-shadow: 5px 5px 10px #c0c0c0; + height: 30px; + position: relative; +} + +#content #replication #progress #bar #done .percent +{ + font-weight: bold; + height: 30px; + line-height: 30px; + padding-left: 5px; + padding-right: 5px; + position: absolute; + right: 0; + text-align: right; +} + +#content #replication #progress #bar #done #done-info +{ + border-right: 1px solid #c0c0c0; + position: absolute; + right: 0; + margin-top: 30px; + text-align: right; + width: 100px; +} + +#content #replication #progress #bar #done #done-info .percent +{ + font-weight: bold; +} + +#content #replication .block .label, +#content #replication #current-file .file, +#content #replication #current-file .progress, +#content #replication #iterations .iterations +{ + float: left; +} + +#content #replication .block .label +{ + width: 100px; +} + +#content #replication .block .label span +{ + display: block; + padding-left: 21px; +} + +#content #replication #current-file +{ + border-top: 1px solid #f0f0f0; + margin-top: 10px; + padding-top: 10px; +} + +#content #replication #current-file .progress +{ + color: #c0c0c0; + margin-left: 20px; +} + +#content #replication #iterations +{ + display: none; +} + +#content #replication #iterations .label span +{ + background-image: url( ../../img/ico/node-design.png ); +} + +#content #replication #iterations .iterations li +{ + background-position: 100% 50%; + display: none; + padding-right: 21px; +} + +#content #replication #iterations .iterations.expanded li +{ + display: block; +} + +#content #replication #iterations .iterations .latest +{ + display: block; +} + +#content #replication #iterations .iterations .replicated +{ + color: #80c480; +} + +#content #replication #iterations .iterations ul:hover .replicated, +#content #replication #iterations .iterations .replicated.latest +{ + color: #080; +} + +#content #replication #iterations .iterations .replicated.latest +{ + background-image: url( ../../img/ico/tick.png ); +} + +#content #replication #iterations .iterations .failed +{ + color: #c48080; +} + +#content #replication #iterations .iterations ul:hover .failed, +#content #replication #iterations .iterations .failed.latest +{ + color: #800; +} + +#content #replication #iterations .iterations .failed.latest +{ + background-image: url( ../../img/ico/cross.png ); +} + +#content #replication #iterations .iterations a +{ + border-top: 1px solid #f0f0f0; + display: none; + margin-top: 2px; + padding-top: 2px; +} + +#content #replication #iterations .iterations a span +{ + background-position: 0 50%; + color: #c0c0c0; + display: none; + padding-left: 21px; +} + +#content #replication #iterations .iterations a span.expand +{ + background-image: url( ../../img/ico/chevron-small-expand.png ); + display: block; +} + +#content #replication #iterations .iterations.expanded a span.expand +{ + display: none; +} + +#content #replication #iterations .iterations.expanded a span.collapse +{ + background-image: url( ../../img/ico/chevron-small.png ); + display: block; +} + +#content #replication #details table +{ + border-collapse: collapse; +} + +#content #replication #details table th +{ + text-align: left; +} + +#content #replication.slave #details table .slaveOnly +{ + display: table-row; +} + +#content #replication #details table thead th +{ + color: #c0c0c0; +} + +#content #replication #details table thead th, +#content #replication #details table tbody td +{ + padding-right: 20px; +} + +#content #replication #details table thead td, +#content #replication #details table thead th, +#content #replication #details table tbody th, +#content #replication #details table tbody td div +{ + padding-top: 3px; + padding-bottom: 3px; +} + +#content #replication #details table tbody td, +#content #replication #details table tbody th +{ + border-top: 1px solid #f0f0f0; +} + +#content #replication #details table thead td +{ + width: 100px; +} + +#content #replication #details table thead td span +{ + background-image: url( ../../img/ico/clipboard-list.png ); + background-position: 0 50%; + display: block; + padding-left: 21px; +} + +#content #replication #details table tbody th +{ + padding-right: 10px; + text-align: right; +} + +#content #replication #details table tbody .size +{ + text-align: right; + white-space: nowrap; +} + +#content #replication #details table tbody .generation div +{ + text-align: center; +} + +#content #replication #details table tbody .diff div +{ + background-color: #fcfcc9; + padding-left: 1px; + padding-right: 1px; +} + +#content #replication .settings .label span +{ + background-image: url( ../../img/ico/hammer-screwdriver.png ); +} + +#content #replication .settings ul, +#content #replication .settings dl dt, +#content #replication .settings dl dd +{ + float: left; +} + +#content #replication .settings ul li +{ + border-top: 1px solid #f0f0f0; + display: none; + padding-top: 3px; + padding-top: 3px; +} + +#content #replication .settings ul li:first-child +{ + border-top: 0; + padding-top: 0; +} + +#content #replication .settings dl dt +{ + clear: left; + margin-right: 5px; + width: 120px; +} + +#content #replication .settings dl .ico +{ + background-position: 0 50%; + padding-left: 21px; +} + +#content #replication .settings dl .ico.ico-0 +{ + background-image: url( ../../img/ico/slash.png ); +} + +#content #replication .settings dl .ico.ico-1 +{ + background-image: url( ../../img/ico/tick.png ); +} + +#content #replication #navigation button +{ + background-position: 2px 50%; + margin-bottom: 10px; + padding-left: 21px; +} + +#content #replication #navigation button.optional +{ + display: none; +} + +#content #replication #navigation .replicate-now +{ + background-image: url( ../../img/ico/document-convert.png ); +} + +#content #replication #navigation .abort-replication +{ + background-color: #800; + background-image: url( ../../img/ico/hand.png ); + border-color: #800; + color: #fff; +} + +#content #replication #navigation .disable-polling +{ + background-image: url( ../../img/ico/cross.png ); +} + +#content #replication #navigation .enable-polling +{ + background-image: url( ../../img/ico/tick.png ); +} + +#content #replication #navigation .disable-replication +{ + background-image: url( ../../img/ico/cross.png ); +} + +#content #replication #navigation .enable-replication +{ + background-image: url( ../../img/ico/tick.png ); +} + +#content #replication #navigation .refresh-status +{ + background-image: url( ../../img/ico/arrow-circle.png ); +} \ No newline at end of file diff --git a/solr/webapp/web/css/styles/schema-browser.css b/solr/webapp/web/css/styles/schema-browser.css new file mode 100644 index 00000000000..2a0ff3ba5f0 --- /dev/null +++ b/solr/webapp/web/css/styles/schema-browser.css @@ -0,0 +1,345 @@ +#content #schema-browser .loader +{ + background-position: 0 50%; + padding-left: 21px; +} + +#content #schema-browser.loaded +{ + background-image: url( ../../img/div.gif ); + background-position: 21% 0; + background-repeat: repeat-y; +} + +#content #schema-browser #data +{ + float: right; + width: 78%; +} + +#content #schema-browser #related +{ + float: left; + width: 20%; +} + +#content #schema-browser #related select +{ + width: 100%; +} + +#content #schema-browser #related select optgroup +{ + font-style: normal; + padding: 5px; +} + +#content #schema-browser #related select option +{ + padding-left: 10px; +} + +#content #schema-browser #related #f-df-t +{ + border-bottom: 1px solid #f0f0f0; + padding-bottom: 15px; +} + +#content #schema-browser #related dl +{ + margin-top: 15px; +} + +#content #schema-browser #related dl dt, +#content #schema-browser #related dl dd a +{ + color: #c0c0c0; +} + +#content #schema-browser #related dl dt +{ + font-weight: bold; + margin-top: 5px; +} + +#content #schema-browser #related dl dd a +{ + display: block; + padding-left: 10px; +} + +#content #schema-browser #related dl dd a:hover +{ + background-color: #f8f8f8; +} + +#content #schema-browser #related .field .field, +#content #schema-browser #related .field .field a, +#content #schema-browser #related .dynamic-field .dynamic-field, +#content #schema-browser #related .dynamic-field .dynamic-field a, +#content #schema-browser #related .type .type, +#content #schema-browser #related .type .type a, +#content #schema-browser #related .active, +#content #schema-browser #related .active a +{ + color: #333; +} + +#content #schema-browser #related .copyfield, +#content #schema-browser #related .copyfield a +{ + color: #666; +} + +#content #schema-browser #data +{ + display: none; +} + +#content #schema-browser #data #index dt +{ + display: none; + float: left; + margin-right: 5px; + width: 150px; +} + +#content #schema-browser #data #field .field-options +{ + margin-bottom: 20px; +} + +#content #schema-browser #data #field .field-options .options dt, +#content #schema-browser #data #field .field-options .options dd +{ + float: left; +} + +#content #schema-browser #data #field .field-options .options dt +{ + clear: left; + display: none; + margin-right: 5px; + width: 100px; +} + +#content #schema-browser #data #field .field-options .options dd +{ + margin-right: 5px; +} + +#content #schema-browser #data #field .field-options .analyzer, +#content #schema-browser #data #field .field-options .analyzer li, +#content #schema-browser #data #field .field-options .analyzer ul, +#content #schema-browser #data #field .field-options .analyzer ul li +{ + display: none; +} + +#content #schema-browser #data #field .field-options .analyzer p, +#content #schema-browser #data #field .field-options .analyzer dl +{ + float: left; +} + +#content #schema-browser #data #field .field-options .analyzer p +{ + margin-right: 5px; + text-align: right; + width: 100px; +} + +#content #schema-browser #data #field .field-options .analyzer li +{ + border-top: 1px solid #f0f0f0; + margin-top: 10px; + padding-top: 10px; +} + +#content #schema-browser #data #field .field-options .analyzer ul +{ + clear: left; + display: block; + margin-left: 30px; + padding-top: 5px; +} + +#content #schema-browser #data #field .field-options .analyzer ul li +{ + border-top: 1px solid #f8f8f8; + margin-top: 5px; + padding-top: 5px; +} + +#content #schema-browser #data #field .field-options .analyzer ul p +{ + color: #999; + margin-right: 5px; + text-align: right; + width: 70px; +} + +#content #schema-browser #data #field .field-options .analyzer ul dd +{ + margin-left: 20px; +} + +#content #schema-browser #data #field .field-options .analyzer ul dd +{ + background-image: url( ../../img/ico/document-list.png ); + background-position: 0 50%; + color: #c0c0c0; + padding-left: 21px; +} + +#content #schema-browser #data #field .field-options .analyzer ul dd.ico-0 +{ + background-image: url( ../../img/ico/slash.png ); +} + +#content #schema-browser #data #field .field-options .analyzer ul dd.ico-1 +{ + background-image: url( ../../img/ico/tick.png ); +} + +#content #schema-browser #data #field .head +{ + margin-bottom: 5px; +} + +#content #schema-browser #data #field .topterms-holder +{ + display: none; + float: left; +} + +#content #schema-browser #data #field .topterms-holder .head .max-holder +{ + color: #c0c0c0; +} + +#content #schema-browser #data #field .topterms-holder table +{ + border-collapse: collapse; + width: 100%; +} + +#content #schema-browser #data #field .topterms-holder th, +#content #schema-browser #data #field .topterms-holder td +{ + border: 1px solid #f0f0f0; + padding: 1px 4px; +} + +#content #schema-browser #data #field .topterms-holder thead tr +{ + background-color: #c0c0c0; +} + +#content #schema-browser #data #field .topterms-holder thead th +{ + text-align: left; +} + +#content #schema-browser #data #field .topterms-holder tbody +{ + display: none; +} + +#content #schema-browser #data #field .topterms-holder tbody .odd +{ + background-color: #f0f0f0; +} + +#content #schema-browser #data #field .topterms-holder tbody .position +{ + color: #c0c0c0; + text-align: right; +} + +#content #schema-browser #data #field .topterms-holder .navi +{ + margin-top: 5px; +} + +#content #schema-browser #data #field .topterms-holder .navi a +{ + color: #c0c0c0; + display: block; + padding-top: 2px; + padding-bottom: 2px; + width: 49%; +} + +#content #schema-browser #data #field .topterms-holder .navi a:hover +{ + background-color: #f8f8f8; + color: #333; +} + +#content #schema-browser #data #field .topterms-holder .navi .less +{ + float: left; +} + +#content #schema-browser #data #field .topterms-holder .navi .less span +{ + background-image: url( ../../img/ico/chevron-small.png ); + background-position: 0 50%; + padding-left: 18px; +} + +#content #schema-browser #data #field .topterms-holder .navi .more +{ + float: right; + text-align: right; +} + +#content #schema-browser #data #field .topterms-holder .navi .more span +{ + background-image: url( ../../img/ico/chevron-small-expand.png ); + background-position: 100% 50%; + padding-right: 18px; +} + +#content #schema-browser #data #field .histogram-holder +{ + display: none; + float: left; + margin-left: 50px; +} + +#content #schema-browser #data #field .histogram-holder .histogram +{ + height: 150px; +} + +#content #schema-browser #data #field .histogram-holder dt, +#content #schema-browser #data #field .histogram-holder dd +{ + float: left; + font-size: 10px; + text-align: center; +} + +#content #schema-browser #data #field .histogram-holder span +{ + background-color: #f0f0f0; + display: block; + width: 20px; +} + +#content #schema-browser #data #field .histogram-holder dt +{ + padding-right: 1px; +} + +#content #schema-browser #data #field .histogram-holder dd +{ + padding-right: 3px; +} + +#content #schema-browser #data #field .histogram-holder dd span +{ + width: 25px; +} diff --git a/solr/webapp/web/css/styles/threads.css b/solr/webapp/web/css/styles/threads.css new file mode 100644 index 00000000000..ee7ebbe0188 --- /dev/null +++ b/solr/webapp/web/css/styles/threads.css @@ -0,0 +1,167 @@ +#content #threads .loader +{ + background-position: 0 50%; + padding-left: 21px; +} + +#content #threads #thread-dump table +{ + border-collapse: collapse; + width: 100%; +} + +#content #threads #thread-dump table .spacer, +#content #threads #thread-dump tbody .state +{ + background-color: #fff; + border: 0; +} + +#content #threads #thread-dump table th, +#content #threads #thread-dump table td +{ + border: 1px solid #c0c0c0; + padding: 5px 3px; + vertical-align: top; +} + +#content #threads #thread-dump thead th +{ + background-color: #c8c8c8; + font-weight: bold; + text-align: left; +} + +#content #threads #thread-dump thead th.name +{ + width: 85%; +} + +#content #threads #thread-dump thead th.time +{ + text-align: right; + width: 15%; +} + +#content #threads #thread-dump tbody .odd +{ + background-color: #f0f0f0; +} + +#content #threads #thread-dump tbody .RUNNABLE a +{ + background-image: url( ../../img/ico/tick-circle.png ); +} + +#content #threads #thread-dump tbody .WAITING a, +#content #threads #thread-dump tbody .TIMED_WAITING .a +{ + background-image: url( ../../img/ico/hourglass.png ); +} + +#content #threads #thread-dump tbody .WAITING.lock a, +#content #threads #thread-dump tbody .TIMED_WAITING.lock a +{ + background-image: url( ../../img/ico/hourglass--exclamation.png ); +} + +#content #threads #thread-dump thead th:first-child, +#content #threads #thread-dump tbody td:first-child +{ + border-left: 0; +} + +#content #threads #thread-dump thead th:last-child, +#content #threads #thread-dump tbody td:last-child +{ + border-right: 0; +} + +#content #threads #thread-dump tbody .name a +{ + background-position: 0 50%; + cursor: auto; + display: block; + padding-left: 21px; +} + +#content #threads #thread-dump tbody .stacktrace .name a +{ + cursor: pointer; +} + +#content #threads #thread-dump tbody .stacktrace .name a span +{ + background-image: url( ../../img/ico/chevron-small-expand.png ); + background-position: 100% 50%; + padding-right: 21px; +} + +#content #threads #thread-dump tbody .stacktrace.open .name a span +{ + background-image: url( ../../img/ico/chevron-small.png ); +} + +#content #threads #thread-dump tbody .name p +{ + background-image: url( ../../img/ico/arrow-000-small.png ); + background-position: 0 50%; + color: #c0c0c0; + font-size: 11px; + margin-left: 21px; + padding-left: 21px; +} + +#content #threads #thread-dump tbody .name div +{ + border-top: 1px solid #c0c0c0; + display: none; + margin-left: 21px; + margin-top: 5px; + padding-top: 5px; +} + +#content #threads #thread-dump tbody .open .name div +{ + display: block; +} + +#content #threads #thread-dump tbody .name ul +{ + list-style-type: disc; + margin-left: 0.7em; + padding-left: 0.7em; +} + +#content #threads #thread-dump tbody .time +{ + text-align: right; +} + +#content #threads #thread-dump tbody .details +{ + display: none; +} + +#content #threads .controls +{ + padding-top: 5px; + padding-bottom: 5px; +} + +#content #threads .controls a +{ + background-image: url( ../../img/ico/chevron-small-expand.png ); + padding-left: 21px; +} + +#content #threads.expanded .controls a +{ + background-image: url( ../../img/ico/chevron-small.png ); +} + +#content #threads.expanded .controls .expand, +#content #threads.collapsed .controls .collapse +{ + display: none; +} \ No newline at end of file diff --git a/solr/webapp/web/index.jsp b/solr/webapp/web/index.jsp index ff04518c1c8..35b7b24c068 100644 --- a/solr/webapp/web/index.jsp +++ b/solr/webapp/web/index.jsp @@ -11,7 +11,7 @@ solr-admin - + - - - - - - - - - + + \ No newline at end of file diff --git a/solr/webapp/web/js/0_console.js b/solr/webapp/web/js/lib/console.js similarity index 100% rename from solr/webapp/web/js/0_console.js rename to solr/webapp/web/js/lib/console.js diff --git a/solr/webapp/web/js/highlight.js b/solr/webapp/web/js/lib/highlight.js similarity index 100% rename from solr/webapp/web/js/highlight.js rename to solr/webapp/web/js/lib/highlight.js diff --git a/solr/webapp/web/js/jquery.form.js b/solr/webapp/web/js/lib/jquery.form.js similarity index 100% rename from solr/webapp/web/js/jquery.form.js rename to solr/webapp/web/js/lib/jquery.form.js diff --git a/solr/webapp/web/js/jquery.jstree.js b/solr/webapp/web/js/lib/jquery.jstree.js similarity index 100% rename from solr/webapp/web/js/jquery.jstree.js rename to solr/webapp/web/js/lib/jquery.jstree.js diff --git a/solr/webapp/web/js/jquery.sammy.js b/solr/webapp/web/js/lib/jquery.sammy.js similarity index 100% rename from solr/webapp/web/js/jquery.sammy.js rename to solr/webapp/web/js/lib/jquery.sammy.js diff --git a/solr/webapp/web/js/jquery.sparkline.js b/solr/webapp/web/js/lib/jquery.sparkline.js similarity index 100% rename from solr/webapp/web/js/jquery.sparkline.js rename to solr/webapp/web/js/lib/jquery.sparkline.js diff --git a/solr/webapp/web/js/jquery.timeago.js b/solr/webapp/web/js/lib/jquery.timeago.js similarity index 100% rename from solr/webapp/web/js/jquery.timeago.js rename to solr/webapp/web/js/lib/jquery.timeago.js diff --git a/solr/webapp/web/js/lib/order.js b/solr/webapp/web/js/lib/order.js new file mode 100644 index 00000000000..5edd5ce0353 --- /dev/null +++ b/solr/webapp/web/js/lib/order.js @@ -0,0 +1,189 @@ +/** + * @license RequireJS order 1.0.5 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved. + * Available via the MIT or new BSD license. + * see: http://github.com/jrburke/requirejs for details + */ +/*jslint nomen: false, plusplus: false, strict: false */ +/*global require: false, define: false, window: false, document: false, + setTimeout: false */ + +//Specify that requirejs optimizer should wrap this code in a closure that +//maps the namespaced requirejs API to non-namespaced local variables. +/*requirejs namespace: true */ + +(function () { + + //Sadly necessary browser inference due to differences in the way + //that browsers load and execute dynamically inserted javascript + //and whether the script/cache method works when ordered execution is + //desired. Currently, Gecko and Opera do not load/fire onload for scripts with + //type="script/cache" but they execute injected scripts in order + //unless the 'async' flag is present. + //However, this is all changing in latest browsers implementing HTML5 + //spec. With compliant browsers .async true by default, and + //if false, then it will execute in order. Favor that test first for forward + //compatibility. + var testScript = typeof document !== "undefined" && + typeof window !== "undefined" && + document.createElement("script"), + + supportsInOrderExecution = testScript && (testScript.async || + ((window.opera && + Object.prototype.toString.call(window.opera) === "[object Opera]") || + //If Firefox 2 does not have to be supported, then + //a better check may be: + //('mozIsLocallyAvailable' in window.navigator) + ("MozAppearance" in document.documentElement.style))), + + //This test is true for IE browsers, which will load scripts but only + //execute them once the script is added to the DOM. + supportsLoadSeparateFromExecute = testScript && + testScript.readyState === 'uninitialized', + + readyRegExp = /^(complete|loaded)$/, + cacheWaiting = [], + cached = {}, + scriptNodes = {}, + scriptWaiting = []; + + //Done with the test script. + testScript = null; + + //Callback used by the type="script/cache" callback that indicates a script + //has finished downloading. + function scriptCacheCallback(evt) { + var node = evt.currentTarget || evt.srcElement, i, + moduleName, resource; + + if (evt.type === "load" || readyRegExp.test(node.readyState)) { + //Pull out the name of the module and the context. + moduleName = node.getAttribute("data-requiremodule"); + + //Mark this cache request as loaded + cached[moduleName] = true; + + //Find out how many ordered modules have loaded + for (i = 0; (resource = cacheWaiting[i]); i++) { + if (cached[resource.name]) { + resource.req([resource.name], resource.onLoad); + } else { + //Something in the ordered list is not loaded, + //so wait. + break; + } + } + + //If just loaded some items, remove them from cacheWaiting. + if (i > 0) { + cacheWaiting.splice(0, i); + } + + //Remove this script tag from the DOM + //Use a setTimeout for cleanup because some older IE versions vomit + //if removing a script node while it is being evaluated. + setTimeout(function () { + node.parentNode.removeChild(node); + }, 15); + } + } + + /** + * Used for the IE case, where fetching is done by creating script element + * but not attaching it to the DOM. This function will be called when that + * happens so it can be determined when the node can be attached to the + * DOM to trigger its execution. + */ + function onFetchOnly(node) { + var i, loadedNode, resourceName; + + //Mark this script as loaded. + node.setAttribute('data-orderloaded', 'loaded'); + + //Cycle through waiting scripts. If the matching node for them + //is loaded, and is in the right order, add it to the DOM + //to execute the script. + for (i = 0; (resourceName = scriptWaiting[i]); i++) { + loadedNode = scriptNodes[resourceName]; + if (loadedNode && + loadedNode.getAttribute('data-orderloaded') === 'loaded') { + delete scriptNodes[resourceName]; + require.addScriptToDom(loadedNode); + } else { + break; + } + } + + //If just loaded some items, remove them from waiting. + if (i > 0) { + scriptWaiting.splice(0, i); + } + } + + define({ + version: '1.0.5', + + load: function (name, req, onLoad, config) { + var hasToUrl = !!req.nameToUrl, + url, node, context; + + //If no nameToUrl, then probably a build with a loader that + //does not support it, and all modules are inlined. + if (!hasToUrl) { + req([name], onLoad); + return; + } + + url = req.nameToUrl(name, null); + + //Make sure the async attribute is not set for any pathway involving + //this script. + require.s.skipAsync[url] = true; + if (supportsInOrderExecution || config.isBuild) { + //Just a normal script tag append, but without async attribute + //on the script. + req([name], onLoad); + } else if (supportsLoadSeparateFromExecute) { + //Just fetch the URL, but do not execute it yet. The + //non-standards IE case. Really not so nice because it is + //assuming and touching requrejs internals. OK though since + //ordered execution should go away after a long while. + context = require.s.contexts._; + + if (!context.urlFetched[url] && !context.loaded[name]) { + //Indicate the script is being fetched. + context.urlFetched[url] = true; + + //Stuff from require.load + require.resourcesReady(false); + context.scriptCount += 1; + + //Fetch the script now, remember it. + node = require.attach(url, context, name, null, null, onFetchOnly); + scriptNodes[name] = node; + scriptWaiting.push(name); + } + + //Do a normal require for it, once it loads, use it as return + //value. + req([name], onLoad); + } else { + //Credit to LABjs author Kyle Simpson for finding that scripts + //with type="script/cache" allow scripts to be downloaded into + //browser cache but not executed. Use that + //so that subsequent addition of a real type="text/javascript" + //tag will cause the scripts to be executed immediately in the + //correct order. + if (req.specified(name)) { + req([name], onLoad); + } else { + cacheWaiting.push({ + name: name, + req: req, + onLoad: onLoad + }); + require.attach(url, null, name, scriptCacheCallback, "script/cache"); + } + } + } + }); +}()); diff --git a/solr/webapp/web/js/main.js b/solr/webapp/web/js/main.js new file mode 100644 index 00000000000..acaf2bb5d85 --- /dev/null +++ b/solr/webapp/web/js/main.js @@ -0,0 +1,36 @@ +require +( + [ + 'lib/order!lib/console', + 'lib/order!jquery', + 'lib/order!lib/jquery.form', + 'lib/order!lib/jquery.jstree', + 'lib/order!lib/jquery.sammy', + 'lib/order!lib/jquery.sparkline', + 'lib/order!lib/jquery.timeago', + 'lib/order!lib/highlight', + 'lib/order!scripts/app', + + 'lib/order!scripts/analysis', + 'lib/order!scripts/cloud', + 'lib/order!scripts/cores', + 'lib/order!scripts/dataimport', + 'lib/order!scripts/file', + 'lib/order!scripts/index', + 'lib/order!scripts/java-properties', + 'lib/order!scripts/logging', + 'lib/order!scripts/ping', + 'lib/order!scripts/plugins', + 'lib/order!scripts/query', + 'lib/order!scripts/replication', + 'lib/order!scripts/schema-browser', + 'lib/order!scripts/threads', + + 'lib/order!scripts/dashboard' + + ], + function( $ ) + { + app.run(); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/1_jquery.js b/solr/webapp/web/js/require.js similarity index 54% rename from solr/webapp/web/js/1_jquery.js rename to solr/webapp/web/js/require.js index 8e43e382407..ff858849258 100644 --- a/solr/webapp/web/js/1_jquery.js +++ b/solr/webapp/web/js/require.js @@ -1,5 +1,2058 @@ +/** vim: et:ts=4:sw=4:sts=4 + * @license RequireJS 1.0.6 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. + * Available via the MIT or new BSD license. + * see: http://github.com/jrburke/requirejs for details + */ +/*jslint strict: false, plusplus: false, sub: true */ +/*global window, navigator, document, importScripts, jQuery, setTimeout, opera */ + +var requirejs, require, define; +(function () { + //Change this version number for each release. + var version = "1.0.6", + commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, + cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g, + currDirRegExp = /^\.\//, + jsSuffixRegExp = /\.js$/, + ostring = Object.prototype.toString, + ap = Array.prototype, + aps = ap.slice, + apsp = ap.splice, + isBrowser = !!(typeof window !== "undefined" && navigator && document), + isWebWorker = !isBrowser && typeof importScripts !== "undefined", + //PS3 indicates loaded and complete, but need to wait for complete + //specifically. Sequence is "loading", "loaded", execution, + // then "complete". The UA check is unfortunate, but not sure how + //to feature test w/o causing perf issues. + readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? + /^complete$/ : /^(complete|loaded)$/, + defContextName = "_", + //Oh the tragedy, detecting opera. See the usage of isOpera for reason. + isOpera = typeof opera !== "undefined" && opera.toString() === "[object Opera]", + empty = {}, + contexts = {}, + globalDefQueue = [], + interactiveScript = null, + checkLoadedDepth = 0, + useInteractive = false, + reservedDependencies = { + require: true, + module: true, + exports: true + }, + req, cfg = {}, currentlyAddingScript, s, head, baseElement, scripts, script, + src, subPath, mainScript, dataMain, globalI, ctx, jQueryCheck, checkLoadedTimeoutId; + + function isFunction(it) { + return ostring.call(it) === "[object Function]"; + } + + function isArray(it) { + return ostring.call(it) === "[object Array]"; + } + + /** + * Simple function to mix in properties from source into target, + * but only if target does not already have a property of the same name. + * This is not robust in IE for transferring methods that match + * Object.prototype names, but the uses of mixin here seem unlikely to + * trigger a problem related to that. + */ + function mixin(target, source, force) { + for (var prop in source) { + if (!(prop in empty) && (!(prop in target) || force)) { + target[prop] = source[prop]; + } + } + return req; + } + + /** + * Constructs an error with a pointer to an URL with more information. + * @param {String} id the error ID that maps to an ID on a web page. + * @param {String} message human readable error. + * @param {Error} [err] the original error, if there is one. + * + * @returns {Error} + */ + function makeError(id, msg, err) { + var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id); + if (err) { + e.originalError = err; + } + return e; + } + + /** + * Used to set up package paths from a packagePaths or packages config object. + * @param {Object} pkgs the object to store the new package config + * @param {Array} currentPackages an array of packages to configure + * @param {String} [dir] a prefix dir to use. + */ + function configurePackageDir(pkgs, currentPackages, dir) { + var i, location, pkgObj; + + for (i = 0; (pkgObj = currentPackages[i]); i++) { + pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj; + location = pkgObj.location; + + //Add dir to the path, but avoid paths that start with a slash + //or have a colon (indicates a protocol) + if (dir && (!location || (location.indexOf("/") !== 0 && location.indexOf(":") === -1))) { + location = dir + "/" + (location || pkgObj.name); + } + + //Create a brand new object on pkgs, since currentPackages can + //be passed in again, and config.pkgs is the internal transformed + //state for all package configs. + pkgs[pkgObj.name] = { + name: pkgObj.name, + location: location || pkgObj.name, + //Remove leading dot in main, so main paths are normalized, + //and remove any trailing .js, since different package + //envs have different conventions: some use a module name, + //some use a file name. + main: (pkgObj.main || "main") + .replace(currDirRegExp, '') + .replace(jsSuffixRegExp, '') + }; + } + } + + /** + * jQuery 1.4.3-1.5.x use a readyWait/ready() pairing to hold DOM + * ready callbacks, but jQuery 1.6 supports a holdReady() API instead. + * At some point remove the readyWait/ready() support and just stick + * with using holdReady. + */ + function jQueryHoldReady($, shouldHold) { + if ($.holdReady) { + $.holdReady(shouldHold); + } else if (shouldHold) { + $.readyWait += 1; + } else { + $.ready(true); + } + } + + if (typeof define !== "undefined") { + //If a define is already in play via another AMD loader, + //do not overwrite. + return; + } + + if (typeof requirejs !== "undefined") { + if (isFunction(requirejs)) { + //Do not overwrite and existing requirejs instance. + return; + } else { + cfg = requirejs; + requirejs = undefined; + } + } + + //Allow for a require config object + if (typeof require !== "undefined" && !isFunction(require)) { + //assume it is a config object. + cfg = require; + require = undefined; + } + + /** + * Creates a new context for use in require and define calls. + * Handle most of the heavy lifting. Do not want to use an object + * with prototype here to avoid using "this" in require, in case it + * needs to be used in more super secure envs that do not want this. + * Also there should not be that many contexts in the page. Usually just + * one for the default context, but could be extra for multiversion cases + * or if a package needs a special context for a dependency that conflicts + * with the standard context. + */ + function newContext(contextName) { + var context, resume, + config = { + waitSeconds: 7, + baseUrl: "./", + paths: {}, + pkgs: {}, + catchError: {} + }, + defQueue = [], + specified = { + "require": true, + "exports": true, + "module": true + }, + urlMap = {}, + defined = {}, + loaded = {}, + waiting = {}, + waitAry = [], + urlFetched = {}, + managerCounter = 0, + managerCallbacks = {}, + plugins = {}, + //Used to indicate which modules in a build scenario + //need to be full executed. + needFullExec = {}, + fullExec = {}, + resumeDepth = 0; + + /** + * Trims the . and .. from an array of path segments. + * It will keep a leading path segment if a .. will become + * the first path segment, to help with module name lookups, + * which act like paths, but can be remapped. But the end result, + * all paths that use this function should look normalized. + * NOTE: this method MODIFIES the input array. + * @param {Array} ary the array of path segments. + */ + function trimDots(ary) { + var i, part; + for (i = 0; (part = ary[i]); i++) { + if (part === ".") { + ary.splice(i, 1); + i -= 1; + } else if (part === "..") { + if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { + //End of the line. Keep at least one non-dot + //path segment at the front so it can be mapped + //correctly to disk. Otherwise, there is likely + //no path mapping for a path starting with '..'. + //This can still fail, but catches the most reasonable + //uses of .. + break; + } else if (i > 0) { + ary.splice(i - 1, 2); + i -= 2; + } + } + } + } + + /** + * Given a relative module name, like ./something, normalize it to + * a real name that can be mapped to a path. + * @param {String} name the relative name + * @param {String} baseName a real name that the name arg is relative + * to. + * @returns {String} normalized name + */ + function normalize(name, baseName) { + var pkgName, pkgConfig; + + //Adjust any relative paths. + if (name && name.charAt(0) === ".") { + //If have a base name, try to normalize against it, + //otherwise, assume it is a top-level require that will + //be relative to baseUrl in the end. + if (baseName) { + if (config.pkgs[baseName]) { + //If the baseName is a package name, then just treat it as one + //name to concat the name with. + baseName = [baseName]; + } else { + //Convert baseName to array, and lop off the last part, + //so that . matches that "directory" and not name of the baseName's + //module. For instance, baseName of "one/two/three", maps to + //"one/two/three.js", but we want the directory, "one/two" for + //this normalization. + baseName = baseName.split("/"); + baseName = baseName.slice(0, baseName.length - 1); + } + + name = baseName.concat(name.split("/")); + trimDots(name); + + //Some use of packages may use a . path to reference the + //"main" module name, so normalize for that. + pkgConfig = config.pkgs[(pkgName = name[0])]; + name = name.join("/"); + if (pkgConfig && name === pkgName + '/' + pkgConfig.main) { + name = pkgName; + } + } else if (name.indexOf("./") === 0) { + // No baseName, so this is ID is resolved relative + // to baseUrl, pull off the leading dot. + name = name.substring(2); + } + } + return name; + } + + /** + * Creates a module mapping that includes plugin prefix, module + * name, and path. If parentModuleMap is provided it will + * also normalize the name via require.normalize() + * + * @param {String} name the module name + * @param {String} [parentModuleMap] parent module map + * for the module name, used to resolve relative names. + * + * @returns {Object} + */ + function makeModuleMap(name, parentModuleMap) { + var index = name ? name.indexOf("!") : -1, + prefix = null, + parentName = parentModuleMap ? parentModuleMap.name : null, + originalName = name, + normalizedName, url, pluginModule; + + if (index !== -1) { + prefix = name.substring(0, index); + name = name.substring(index + 1, name.length); + } + + if (prefix) { + prefix = normalize(prefix, parentName); + } + + //Account for relative paths if there is a base name. + if (name) { + if (prefix) { + pluginModule = defined[prefix]; + if (pluginModule && pluginModule.normalize) { + //Plugin is loaded, use its normalize method. + normalizedName = pluginModule.normalize(name, function (name) { + return normalize(name, parentName); + }); + } else { + normalizedName = normalize(name, parentName); + } + } else { + //A regular module. + normalizedName = normalize(name, parentName); + + url = urlMap[normalizedName]; + if (!url) { + //Calculate url for the module, if it has a name. + //Use name here since nameToUrl also calls normalize, + //and for relative names that are outside the baseUrl + //this causes havoc. Was thinking of just removing + //parentModuleMap to avoid extra normalization, but + //normalize() still does a dot removal because of + //issue #142, so just pass in name here and redo + //the normalization. Paths outside baseUrl are just + //messy to support. + url = context.nameToUrl(name, null, parentModuleMap); + + //Store the URL mapping for later. + urlMap[normalizedName] = url; + } + } + } + + return { + prefix: prefix, + name: normalizedName, + parentMap: parentModuleMap, + url: url, + originalName: originalName, + fullName: prefix ? prefix + "!" + (normalizedName || '') : normalizedName + }; + } + + /** + * Determine if priority loading is done. If so clear the priorityWait + */ + function isPriorityDone() { + var priorityDone = true, + priorityWait = config.priorityWait, + priorityName, i; + if (priorityWait) { + for (i = 0; (priorityName = priorityWait[i]); i++) { + if (!loaded[priorityName]) { + priorityDone = false; + break; + } + } + if (priorityDone) { + delete config.priorityWait; + } + } + return priorityDone; + } + + function makeContextModuleFunc(func, relModuleMap, enableBuildCallback) { + return function () { + //A version of a require function that passes a moduleName + //value for items that may need to + //look up paths relative to the moduleName + var args = aps.call(arguments, 0), lastArg; + if (enableBuildCallback && + isFunction((lastArg = args[args.length - 1]))) { + lastArg.__requireJsBuild = true; + } + args.push(relModuleMap); + return func.apply(null, args); + }; + } + + /** + * Helper function that creates a require function object to give to + * modules that ask for it as a dependency. It needs to be specific + * per module because of the implication of path mappings that may + * need to be relative to the module name. + */ + function makeRequire(relModuleMap, enableBuildCallback, altRequire) { + var modRequire = makeContextModuleFunc(altRequire || context.require, relModuleMap, enableBuildCallback); + + mixin(modRequire, { + nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap), + toUrl: makeContextModuleFunc(context.toUrl, relModuleMap), + defined: makeContextModuleFunc(context.requireDefined, relModuleMap), + specified: makeContextModuleFunc(context.requireSpecified, relModuleMap), + isBrowser: req.isBrowser + }); + return modRequire; + } + + /* + * Queues a dependency for checking after the loader is out of a + * "paused" state, for example while a script file is being loaded + * in the browser, where it may have many modules defined in it. + */ + function queueDependency(manager) { + context.paused.push(manager); + } + + function execManager(manager) { + var i, ret, err, errFile, errModuleTree, + cb = manager.callback, + map = manager.map, + fullName = map.fullName, + args = manager.deps, + listeners = manager.listeners, + cjsModule; + + //Call the callback to define the module, if necessary. + if (cb && isFunction(cb)) { + if (config.catchError.define) { + try { + ret = req.execCb(fullName, manager.callback, args, defined[fullName]); + } catch (e) { + err = e; + } + } else { + ret = req.execCb(fullName, manager.callback, args, defined[fullName]); + } + + if (fullName) { + //If setting exports via "module" is in play, + //favor that over return value and exports. After that, + //favor a non-undefined return value over exports use. + cjsModule = manager.cjsModule; + if (cjsModule && + cjsModule.exports !== undefined && + //Make sure it is not already the exports value + cjsModule.exports !== defined[fullName]) { + ret = defined[fullName] = manager.cjsModule.exports; + } else if (ret === undefined && manager.usingExports) { + //exports already set the defined value. + ret = defined[fullName]; + } else { + //Use the return value from the function. + defined[fullName] = ret; + //If this module needed full execution in a build + //environment, mark that now. + if (needFullExec[fullName]) { + fullExec[fullName] = true; + } + } + } + } else if (fullName) { + //May just be an object definition for the module. Only + //worry about defining if have a module name. + ret = defined[fullName] = cb; + + //If this module needed full execution in a build + //environment, mark that now. + if (needFullExec[fullName]) { + fullExec[fullName] = true; + } + } + + //Clean up waiting. Do this before error calls, and before + //calling back listeners, so that bookkeeping is correct + //in the event of an error and error is reported in correct order, + //since the listeners will likely have errors if the + //onError function does not throw. + if (waiting[manager.id]) { + delete waiting[manager.id]; + manager.isDone = true; + context.waitCount -= 1; + if (context.waitCount === 0) { + //Clear the wait array used for cycles. + waitAry = []; + } + } + + //Do not need to track manager callback now that it is defined. + delete managerCallbacks[fullName]; + + //Allow instrumentation like the optimizer to know the order + //of modules executed and their dependencies. + if (req.onResourceLoad && !manager.placeholder) { + req.onResourceLoad(context, map, manager.depArray); + } + + if (err) { + errFile = (fullName ? makeModuleMap(fullName).url : '') || + err.fileName || err.sourceURL; + errModuleTree = err.moduleTree; + err = makeError('defineerror', 'Error evaluating ' + + 'module "' + fullName + '" at location "' + + errFile + '":\n' + + err + '\nfileName:' + errFile + + '\nlineNumber: ' + (err.lineNumber || err.line), err); + err.moduleName = fullName; + err.moduleTree = errModuleTree; + return req.onError(err); + } + + //Let listeners know of this manager's value. + for (i = 0; (cb = listeners[i]); i++) { + cb(ret); + } + + return undefined; + } + + /** + * Helper that creates a callack function that is called when a dependency + * is ready, and sets the i-th dependency for the manager as the + * value passed to the callback generated by this function. + */ + function makeArgCallback(manager, i) { + return function (value) { + //Only do the work if it has not been done + //already for a dependency. Cycle breaking + //logic in forceExec could mean this function + //is called more than once for a given dependency. + if (!manager.depDone[i]) { + manager.depDone[i] = true; + manager.deps[i] = value; + manager.depCount -= 1; + if (!manager.depCount) { + //All done, execute! + execManager(manager); + } + } + }; + } + + function callPlugin(pluginName, depManager) { + var map = depManager.map, + fullName = map.fullName, + name = map.name, + plugin = plugins[pluginName] || + (plugins[pluginName] = defined[pluginName]), + load; + + //No need to continue if the manager is already + //in the process of loading. + if (depManager.loading) { + return; + } + depManager.loading = true; + + load = function (ret) { + depManager.callback = function () { + return ret; + }; + execManager(depManager); + + loaded[depManager.id] = true; + + //The loading of this plugin + //might have placed other things + //in the paused queue. In particular, + //a loader plugin that depends on + //a different plugin loaded resource. + resume(); + }; + + //Allow plugins to load other code without having to know the + //context or how to "complete" the load. + load.fromText = function (moduleName, text) { + /*jslint evil: true */ + var hasInteractive = useInteractive; + + //Indicate a the module is in process of loading. + loaded[moduleName] = false; + context.scriptCount += 1; + + //Indicate this is not a "real" module, so do not track it + //for builds, it does not map to a real file. + context.fake[moduleName] = true; + + //Turn off interactive script matching for IE for any define + //calls in the text, then turn it back on at the end. + if (hasInteractive) { + useInteractive = false; + } + + req.exec(text); + + if (hasInteractive) { + useInteractive = true; + } + + //Support anonymous modules. + context.completeLoad(moduleName); + }; + + //No need to continue if the plugin value has already been + //defined by a build. + if (fullName in defined) { + load(defined[fullName]); + } else { + //Use parentName here since the plugin's name is not reliable, + //could be some weird string with no path that actually wants to + //reference the parentName's path. + plugin.load(name, makeRequire(map.parentMap, true, function (deps, cb) { + var moduleDeps = [], + i, dep, depMap; + //Convert deps to full names and hold on to them + //for reference later, when figuring out if they + //are blocked by a circular dependency. + for (i = 0; (dep = deps[i]); i++) { + depMap = makeModuleMap(dep, map.parentMap); + deps[i] = depMap.fullName; + if (!depMap.prefix) { + moduleDeps.push(deps[i]); + } + } + depManager.moduleDeps = (depManager.moduleDeps || []).concat(moduleDeps); + return context.require(deps, cb); + }), load, config); + } + } + + /** + * Adds the manager to the waiting queue. Only fully + * resolved items should be in the waiting queue. + */ + function addWait(manager) { + if (!waiting[manager.id]) { + waiting[manager.id] = manager; + waitAry.push(manager); + context.waitCount += 1; + } + } + + /** + * Function added to every manager object. Created out here + * to avoid new function creation for each manager instance. + */ + function managerAdd(cb) { + this.listeners.push(cb); + } + + function getManager(map, shouldQueue) { + var fullName = map.fullName, + prefix = map.prefix, + plugin = prefix ? plugins[prefix] || + (plugins[prefix] = defined[prefix]) : null, + manager, created, pluginManager, prefixMap; + + if (fullName) { + manager = managerCallbacks[fullName]; + } + + if (!manager) { + created = true; + manager = { + //ID is just the full name, but if it is a plugin resource + //for a plugin that has not been loaded, + //then add an ID counter to it. + id: (prefix && !plugin ? + (managerCounter++) + '__p@:' : '') + + (fullName || '__r@' + (managerCounter++)), + map: map, + depCount: 0, + depDone: [], + depCallbacks: [], + deps: [], + listeners: [], + add: managerAdd + }; + + specified[manager.id] = true; + + //Only track the manager/reuse it if this is a non-plugin + //resource. Also only track plugin resources once + //the plugin has been loaded, and so the fullName is the + //true normalized value. + if (fullName && (!prefix || plugins[prefix])) { + managerCallbacks[fullName] = manager; + } + } + + //If there is a plugin needed, but it is not loaded, + //first load the plugin, then continue on. + if (prefix && !plugin) { + prefixMap = makeModuleMap(prefix); + + //Clear out defined and urlFetched if the plugin was previously + //loaded/defined, but not as full module (as in a build + //situation). However, only do this work if the plugin is in + //defined but does not have a module export value. + if (prefix in defined && !defined[prefix]) { + delete defined[prefix]; + delete urlFetched[prefixMap.url]; + } + + pluginManager = getManager(prefixMap, true); + pluginManager.add(function (plugin) { + //Create a new manager for the normalized + //resource ID and have it call this manager when + //done. + var newMap = makeModuleMap(map.originalName, map.parentMap), + normalizedManager = getManager(newMap, true); + + //Indicate this manager is a placeholder for the real, + //normalized thing. Important for when trying to map + //modules and dependencies, for instance, in a build. + manager.placeholder = true; + + normalizedManager.add(function (resource) { + manager.callback = function () { + return resource; + }; + execManager(manager); + }); + }); + } else if (created && shouldQueue) { + //Indicate the resource is not loaded yet if it is to be + //queued. + loaded[manager.id] = false; + queueDependency(manager); + addWait(manager); + } + + return manager; + } + + function main(inName, depArray, callback, relModuleMap) { + var moduleMap = makeModuleMap(inName, relModuleMap), + name = moduleMap.name, + fullName = moduleMap.fullName, + manager = getManager(moduleMap), + id = manager.id, + deps = manager.deps, + i, depArg, depName, depPrefix, cjsMod; + + if (fullName) { + //If module already defined for context, or already loaded, + //then leave. Also leave if jQuery is registering but it does + //not match the desired version number in the config. + if (fullName in defined || loaded[id] === true || + (fullName === "jquery" && config.jQuery && + config.jQuery !== callback().fn.jquery)) { + return; + } + + //Set specified/loaded here for modules that are also loaded + //as part of a layer, where onScriptLoad is not fired + //for those cases. Do this after the inline define and + //dependency tracing is done. + specified[id] = true; + loaded[id] = true; + + //If module is jQuery set up delaying its dom ready listeners. + if (fullName === "jquery" && callback) { + jQueryCheck(callback()); + } + } + + //Attach real depArray and callback to the manager. Do this + //only if the module has not been defined already, so do this after + //the fullName checks above. IE can call main() more than once + //for a module. + manager.depArray = depArray; + manager.callback = callback; + + //Add the dependencies to the deps field, and register for callbacks + //on the dependencies. + for (i = 0; i < depArray.length; i++) { + depArg = depArray[i]; + //There could be cases like in IE, where a trailing comma will + //introduce a null dependency, so only treat a real dependency + //value as a dependency. + if (depArg) { + //Split the dependency name into plugin and name parts + depArg = makeModuleMap(depArg, (name ? moduleMap : relModuleMap)); + depName = depArg.fullName; + depPrefix = depArg.prefix; + + //Fix the name in depArray to be just the name, since + //that is how it will be called back later. + depArray[i] = depName; + + //Fast path CommonJS standard dependencies. + if (depName === "require") { + deps[i] = makeRequire(moduleMap); + } else if (depName === "exports") { + //CommonJS module spec 1.1 + deps[i] = defined[fullName] = {}; + manager.usingExports = true; + } else if (depName === "module") { + //CommonJS module spec 1.1 + manager.cjsModule = cjsMod = deps[i] = { + id: name, + uri: name ? context.nameToUrl(name, null, relModuleMap) : undefined, + exports: defined[fullName] + }; + } else if (depName in defined && !(depName in waiting) && + (!(fullName in needFullExec) || + (fullName in needFullExec && fullExec[depName]))) { + //Module already defined, and not in a build situation + //where the module is a something that needs full + //execution and this dependency has not been fully + //executed. See r.js's requirePatch.js for more info + //on fullExec. + deps[i] = defined[depName]; + } else { + //Mark this dependency as needing full exec if + //the current module needs full exec. + if (fullName in needFullExec) { + needFullExec[depName] = true; + //Reset state so fully executed code will get + //picked up correctly. + delete defined[depName]; + urlFetched[depArg.url] = false; + } + + //Either a resource that is not loaded yet, or a plugin + //resource for either a plugin that has not + //loaded yet. + manager.depCount += 1; + manager.depCallbacks[i] = makeArgCallback(manager, i); + getManager(depArg, true).add(manager.depCallbacks[i]); + } + } + } + + //Do not bother tracking the manager if it is all done. + if (!manager.depCount) { + //All done, execute! + execManager(manager); + } else { + addWait(manager); + } + } + + /** + * Convenience method to call main for a define call that was put on + * hold in the defQueue. + */ + function callDefMain(args) { + main.apply(null, args); + } + + /** + * jQuery 1.4.3+ supports ways to hold off calling + * calling jQuery ready callbacks until all scripts are loaded. Be sure + * to track it if the capability exists.. Also, since jQuery 1.4.3 does + * not register as a module, need to do some global inference checking. + * Even if it does register as a module, not guaranteed to be the precise + * name of the global. If a jQuery is tracked for this context, then go + * ahead and register it as a module too, if not already in process. + */ + jQueryCheck = function (jqCandidate) { + if (!context.jQuery) { + var $ = jqCandidate || (typeof jQuery !== "undefined" ? jQuery : null); + + if ($) { + //If a specific version of jQuery is wanted, make sure to only + //use this jQuery if it matches. + if (config.jQuery && $.fn.jquery !== config.jQuery) { + return; + } + + if ("holdReady" in $ || "readyWait" in $) { + context.jQuery = $; + + //Manually create a "jquery" module entry if not one already + //or in process. Note this could trigger an attempt at + //a second jQuery registration, but does no harm since + //the first one wins, and it is the same value anyway. + callDefMain(["jquery", [], function () { + return jQuery; + }]); + + //Ask jQuery to hold DOM ready callbacks. + if (context.scriptCount) { + jQueryHoldReady($, true); + context.jQueryIncremented = true; + } + } + } + } + }; + + function findCycle(manager, traced) { + var fullName = manager.map.fullName, + depArray = manager.depArray, + fullyLoaded = true, + i, depName, depManager, result; + + if (manager.isDone || !fullName || !loaded[fullName]) { + return result; + } + + //Found the cycle. + if (traced[fullName]) { + return manager; + } + + traced[fullName] = true; + + //Trace through the dependencies. + if (depArray) { + for (i = 0; i < depArray.length; i++) { + //Some array members may be null, like if a trailing comma + //IE, so do the explicit [i] access and check if it has a value. + depName = depArray[i]; + if (!loaded[depName] && !reservedDependencies[depName]) { + fullyLoaded = false; + break; + } + depManager = waiting[depName]; + if (depManager && !depManager.isDone && loaded[depName]) { + result = findCycle(depManager, traced); + if (result) { + break; + } + } + } + if (!fullyLoaded) { + //Discard the cycle that was found, since it cannot + //be forced yet. Also clear this module from traced. + result = undefined; + delete traced[fullName]; + } + } + + return result; + } + + function forceExec(manager, traced) { + var fullName = manager.map.fullName, + depArray = manager.depArray, + i, depName, depManager, prefix, prefixManager, value; + + + if (manager.isDone || !fullName || !loaded[fullName]) { + return undefined; + } + + if (fullName) { + if (traced[fullName]) { + return defined[fullName]; + } + + traced[fullName] = true; + } + + //Trace through the dependencies. + if (depArray) { + for (i = 0; i < depArray.length; i++) { + //Some array members may be null, like if a trailing comma + //IE, so do the explicit [i] access and check if it has a value. + depName = depArray[i]; + if (depName) { + //First, make sure if it is a plugin resource that the + //plugin is not blocked. + prefix = makeModuleMap(depName).prefix; + if (prefix && (prefixManager = waiting[prefix])) { + forceExec(prefixManager, traced); + } + depManager = waiting[depName]; + if (depManager && !depManager.isDone && loaded[depName]) { + value = forceExec(depManager, traced); + manager.depCallbacks[i](value); + } + } + } + } + + return defined[fullName]; + } + + /** + * Checks if all modules for a context are loaded, and if so, evaluates the + * new ones in right dependency order. + * + * @private + */ + function checkLoaded() { + var waitInterval = config.waitSeconds * 1000, + //It is possible to disable the wait interval by using waitSeconds of 0. + expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), + noLoads = "", hasLoadedProp = false, stillLoading = false, + cycleDeps = [], + i, prop, err, manager, cycleManager, moduleDeps; + + //If there are items still in the paused queue processing wait. + //This is particularly important in the sync case where each paused + //item is processed right away but there may be more waiting. + if (context.pausedCount > 0) { + return undefined; + } + + //Determine if priority loading is done. If so clear the priority. If + //not, then do not check + if (config.priorityWait) { + if (isPriorityDone()) { + //Call resume, since it could have + //some waiting dependencies to trace. + resume(); + } else { + return undefined; + } + } + + //See if anything is still in flight. + for (prop in loaded) { + if (!(prop in empty)) { + hasLoadedProp = true; + if (!loaded[prop]) { + if (expired) { + noLoads += prop + " "; + } else { + stillLoading = true; + if (prop.indexOf('!') === -1) { + //No reason to keep looking for unfinished + //loading. If the only stillLoading is a + //plugin resource though, keep going, + //because it may be that a plugin resource + //is waiting on a non-plugin cycle. + cycleDeps = []; + break; + } else { + moduleDeps = managerCallbacks[prop] && managerCallbacks[prop].moduleDeps; + if (moduleDeps) { + cycleDeps.push.apply(cycleDeps, moduleDeps); + } + } + } + } + } + } + + //Check for exit conditions. + if (!hasLoadedProp && !context.waitCount) { + //If the loaded object had no items, then the rest of + //the work below does not need to be done. + return undefined; + } + if (expired && noLoads) { + //If wait time expired, throw error of unloaded modules. + err = makeError("timeout", "Load timeout for modules: " + noLoads); + err.requireType = "timeout"; + err.requireModules = noLoads; + err.contextName = context.contextName; + return req.onError(err); + } + + //If still loading but a plugin is waiting on a regular module cycle + //break the cycle. + if (stillLoading && cycleDeps.length) { + for (i = 0; (manager = waiting[cycleDeps[i]]); i++) { + if ((cycleManager = findCycle(manager, {}))) { + forceExec(cycleManager, {}); + break; + } + } + + } + + //If still waiting on loads, and the waiting load is something + //other than a plugin resource, or there are still outstanding + //scripts, then just try back later. + if (!expired && (stillLoading || context.scriptCount)) { + //Something is still waiting to load. Wait for it, but only + //if a timeout is not already in effect. + if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) { + checkLoadedTimeoutId = setTimeout(function () { + checkLoadedTimeoutId = 0; + checkLoaded(); + }, 50); + } + return undefined; + } + + //If still have items in the waiting cue, but all modules have + //been loaded, then it means there are some circular dependencies + //that need to be broken. + //However, as a waiting thing is fired, then it can add items to + //the waiting cue, and those items should not be fired yet, so + //make sure to redo the checkLoaded call after breaking a single + //cycle, if nothing else loaded then this logic will pick it up + //again. + if (context.waitCount) { + //Cycle through the waitAry, and call items in sequence. + for (i = 0; (manager = waitAry[i]); i++) { + forceExec(manager, {}); + } + + //If anything got placed in the paused queue, run it down. + if (context.paused.length) { + resume(); + } + + //Only allow this recursion to a certain depth. Only + //triggered by errors in calling a module in which its + //modules waiting on it cannot finish loading, or some circular + //dependencies that then may add more dependencies. + //The value of 5 is a bit arbitrary. Hopefully just one extra + //pass, or two for the case of circular dependencies generating + //more work that gets resolved in the sync node case. + if (checkLoadedDepth < 5) { + checkLoadedDepth += 1; + checkLoaded(); + } + } + + checkLoadedDepth = 0; + + //Check for DOM ready, and nothing is waiting across contexts. + req.checkReadyState(); + + return undefined; + } + + /** + * Resumes tracing of dependencies and then checks if everything is loaded. + */ + resume = function () { + var manager, map, url, i, p, args, fullName; + + //Any defined modules in the global queue, intake them now. + context.takeGlobalQueue(); + + resumeDepth += 1; + + if (context.scriptCount <= 0) { + //Synchronous envs will push the number below zero with the + //decrement above, be sure to set it back to zero for good measure. + //require() calls that also do not end up loading scripts could + //push the number negative too. + context.scriptCount = 0; + } + + //Make sure any remaining defQueue items get properly processed. + while (defQueue.length) { + args = defQueue.shift(); + if (args[0] === null) { + return req.onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); + } else { + callDefMain(args); + } + } + + //Skip the resume of paused dependencies + //if current context is in priority wait. + if (!config.priorityWait || isPriorityDone()) { + while (context.paused.length) { + p = context.paused; + context.pausedCount += p.length; + //Reset paused list + context.paused = []; + + for (i = 0; (manager = p[i]); i++) { + map = manager.map; + url = map.url; + fullName = map.fullName; + + //If the manager is for a plugin managed resource, + //ask the plugin to load it now. + if (map.prefix) { + callPlugin(map.prefix, manager); + } else { + //Regular dependency. + if (!urlFetched[url] && !loaded[fullName]) { + req.load(context, fullName, url); + + //Mark the URL as fetched, but only if it is + //not an empty: URL, used by the optimizer. + //In that case we need to be sure to call + //load() for each module that is mapped to + //empty: so that dependencies are satisfied + //correctly. + if (url.indexOf('empty:') !== 0) { + urlFetched[url] = true; + } + } + } + } + + //Move the start time for timeout forward. + context.startTime = (new Date()).getTime(); + context.pausedCount -= p.length; + } + } + + //Only check if loaded when resume depth is 1. It is likely that + //it is only greater than 1 in sync environments where a factory + //function also then calls the callback-style require. In those + //cases, the checkLoaded should not occur until the resume + //depth is back at the top level. + if (resumeDepth === 1) { + checkLoaded(); + } + + resumeDepth -= 1; + + return undefined; + }; + + //Define the context object. Many of these fields are on here + //just to make debugging easier. + context = { + contextName: contextName, + config: config, + defQueue: defQueue, + waiting: waiting, + waitCount: 0, + specified: specified, + loaded: loaded, + urlMap: urlMap, + urlFetched: urlFetched, + scriptCount: 0, + defined: defined, + paused: [], + pausedCount: 0, + plugins: plugins, + needFullExec: needFullExec, + fake: {}, + fullExec: fullExec, + managerCallbacks: managerCallbacks, + makeModuleMap: makeModuleMap, + normalize: normalize, + /** + * Set a configuration for the context. + * @param {Object} cfg config object to integrate. + */ + configure: function (cfg) { + var paths, prop, packages, pkgs, packagePaths, requireWait; + + //Make sure the baseUrl ends in a slash. + if (cfg.baseUrl) { + if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== "/") { + cfg.baseUrl += "/"; + } + } + + //Save off the paths and packages since they require special processing, + //they are additive. + paths = config.paths; + packages = config.packages; + pkgs = config.pkgs; + + //Mix in the config values, favoring the new values over + //existing ones in context.config. + mixin(config, cfg, true); + + //Adjust paths if necessary. + if (cfg.paths) { + for (prop in cfg.paths) { + if (!(prop in empty)) { + paths[prop] = cfg.paths[prop]; + } + } + config.paths = paths; + } + + packagePaths = cfg.packagePaths; + if (packagePaths || cfg.packages) { + //Convert packagePaths into a packages config. + if (packagePaths) { + for (prop in packagePaths) { + if (!(prop in empty)) { + configurePackageDir(pkgs, packagePaths[prop], prop); + } + } + } + + //Adjust packages if necessary. + if (cfg.packages) { + configurePackageDir(pkgs, cfg.packages); + } + + //Done with modifications, assing packages back to context config + config.pkgs = pkgs; + } + + //If priority loading is in effect, trigger the loads now + if (cfg.priority) { + //Hold on to requireWait value, and reset it after done + requireWait = context.requireWait; + + //Allow tracing some require calls to allow the fetching + //of the priority config. + context.requireWait = false; + //But first, call resume to register any defined modules that may + //be in a data-main built file before the priority config + //call. + resume(); + + context.require(cfg.priority); + + //Trigger a resume right away, for the case when + //the script with the priority load is done as part + //of a data-main call. In that case the normal resume + //call will not happen because the scriptCount will be + //at 1, since the script for data-main is being processed. + resume(); + + //Restore previous state. + context.requireWait = requireWait; + config.priorityWait = cfg.priority; + } + + //If a deps array or a config callback is specified, then call + //require with those args. This is useful when require is defined as a + //config object before require.js is loaded. + if (cfg.deps || cfg.callback) { + context.require(cfg.deps || [], cfg.callback); + } + }, + + requireDefined: function (moduleName, relModuleMap) { + return makeModuleMap(moduleName, relModuleMap).fullName in defined; + }, + + requireSpecified: function (moduleName, relModuleMap) { + return makeModuleMap(moduleName, relModuleMap).fullName in specified; + }, + + require: function (deps, callback, relModuleMap) { + var moduleName, fullName, moduleMap; + if (typeof deps === "string") { + if (isFunction(callback)) { + //Invalid call + return req.onError(makeError("requireargs", "Invalid require call")); + } + + //Synchronous access to one module. If require.get is + //available (as in the Node adapter), prefer that. + //In this case deps is the moduleName and callback is + //the relModuleMap + if (req.get) { + return req.get(context, deps, callback); + } + + //Just return the module wanted. In this scenario, the + //second arg (if passed) is just the relModuleMap. + moduleName = deps; + relModuleMap = callback; + + //Normalize module name, if it contains . or .. + moduleMap = makeModuleMap(moduleName, relModuleMap); + fullName = moduleMap.fullName; + + if (!(fullName in defined)) { + return req.onError(makeError("notloaded", "Module name '" + + moduleMap.fullName + + "' has not been loaded yet for context: " + + contextName)); + } + return defined[fullName]; + } + + //Call main but only if there are dependencies or + //a callback to call. + if (deps && deps.length || callback) { + main(null, deps, callback, relModuleMap); + } + + //If the require call does not trigger anything new to load, + //then resume the dependency processing. + if (!context.requireWait) { + while (!context.scriptCount && context.paused.length) { + resume(); + } + } + return context.require; + }, + + /** + * Internal method to transfer globalQueue items to this context's + * defQueue. + */ + takeGlobalQueue: function () { + //Push all the globalDefQueue items into the context's defQueue + if (globalDefQueue.length) { + //Array splice in the values since the context code has a + //local var ref to defQueue, so cannot just reassign the one + //on context. + apsp.apply(context.defQueue, + [context.defQueue.length - 1, 0].concat(globalDefQueue)); + globalDefQueue = []; + } + }, + + /** + * Internal method used by environment adapters to complete a load event. + * A load event could be a script load or just a load pass from a synchronous + * load call. + * @param {String} moduleName the name of the module to potentially complete. + */ + completeLoad: function (moduleName) { + var args; + + context.takeGlobalQueue(); + + while (defQueue.length) { + args = defQueue.shift(); + + if (args[0] === null) { + args[0] = moduleName; + break; + } else if (args[0] === moduleName) { + //Found matching define call for this script! + break; + } else { + //Some other named define call, most likely the result + //of a build layer that included many define calls. + callDefMain(args); + args = null; + } + } + if (args) { + callDefMain(args); + } else { + //A script that does not call define(), so just simulate + //the call for it. Special exception for jQuery dynamic load. + callDefMain([moduleName, [], + moduleName === "jquery" && typeof jQuery !== "undefined" ? + function () { + return jQuery; + } : null]); + } + + //Doing this scriptCount decrement branching because sync envs + //need to decrement after resume, otherwise it looks like + //loading is complete after the first dependency is fetched. + //For browsers, it works fine to decrement after, but it means + //the checkLoaded setTimeout 50 ms cost is taken. To avoid + //that cost, decrement beforehand. + if (req.isAsync) { + context.scriptCount -= 1; + } + resume(); + if (!req.isAsync) { + context.scriptCount -= 1; + } + }, + + /** + * Converts a module name + .extension into an URL path. + * *Requires* the use of a module name. It does not support using + * plain URLs like nameToUrl. + */ + toUrl: function (moduleNamePlusExt, relModuleMap) { + var index = moduleNamePlusExt.lastIndexOf("."), + ext = null; + + if (index !== -1) { + ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length); + moduleNamePlusExt = moduleNamePlusExt.substring(0, index); + } + + return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap); + }, + + /** + * Converts a module name to a file path. Supports cases where + * moduleName may actually be just an URL. + */ + nameToUrl: function (moduleName, ext, relModuleMap) { + var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url, + config = context.config; + + //Normalize module name if have a base relative module name to work from. + moduleName = normalize(moduleName, relModuleMap && relModuleMap.fullName); + + //If a colon is in the URL, it indicates a protocol is used and it is just + //an URL to a file, or if it starts with a slash or ends with .js, it is just a plain file. + //The slash is important for protocol-less URLs as well as full paths. + if (req.jsExtRegExp.test(moduleName)) { + //Just a plain path, not module name lookup, so just return it. + //Add extension if it is included. This is a bit wonky, only non-.js things pass + //an extension, this method probably needs to be reworked. + url = moduleName + (ext ? ext : ""); + } else { + //A module that needs to be converted to a path. + paths = config.paths; + pkgs = config.pkgs; + + syms = moduleName.split("/"); + //For each module name segment, see if there is a path + //registered for it. Start with most specific name + //and work up from it. + for (i = syms.length; i > 0; i--) { + parentModule = syms.slice(0, i).join("/"); + if (paths[parentModule]) { + syms.splice(0, i, paths[parentModule]); + break; + } else if ((pkg = pkgs[parentModule])) { + //If module name is just the package name, then looking + //for the main module. + if (moduleName === pkg.name) { + pkgPath = pkg.location + '/' + pkg.main; + } else { + pkgPath = pkg.location; + } + syms.splice(0, i, pkgPath); + break; + } + } + + //Join the path parts together, then figure out if baseUrl is needed. + url = syms.join("/") + (ext || ".js"); + url = (url.charAt(0) === '/' || url.match(/^\w+:/) ? "" : config.baseUrl) + url; + } + + return config.urlArgs ? url + + ((url.indexOf('?') === -1 ? '?' : '&') + + config.urlArgs) : url; + } + }; + + //Make these visible on the context so can be called at the very + //end of the file to bootstrap + context.jQueryCheck = jQueryCheck; + context.resume = resume; + + return context; + } + + /** + * Main entry point. + * + * If the only argument to require is a string, then the module that + * is represented by that string is fetched for the appropriate context. + * + * If the first argument is an array, then it will be treated as an array + * of dependency string names to fetch. An optional function callback can + * be specified to execute when all of those dependencies are available. + * + * Make a local req variable to help Caja compliance (it assumes things + * on a require that are not standardized), and to give a short + * name for minification/local scope use. + */ + req = requirejs = function (deps, callback) { + + //Find the right context, use default + var contextName = defContextName, + context, config; + + // Determine if have config object in the call. + if (!isArray(deps) && typeof deps !== "string") { + // deps is a config object + config = deps; + if (isArray(callback)) { + // Adjust args if there are dependencies + deps = callback; + callback = arguments[2]; + } else { + deps = []; + } + } + + if (config && config.context) { + contextName = config.context; + } + + context = contexts[contextName] || + (contexts[contextName] = newContext(contextName)); + + if (config) { + context.configure(config); + } + + return context.require(deps, callback); + }; + + /** + * Support require.config() to make it easier to cooperate with other + * AMD loaders on globally agreed names. + */ + req.config = function (config) { + return req(config); + }; + + /** + * Export require as a global, but only if it does not already exist. + */ + if (!require) { + require = req; + } + + /** + * Global require.toUrl(), to match global require, mostly useful + * for debugging/work in the global space. + */ + req.toUrl = function (moduleNamePlusExt) { + return contexts[defContextName].toUrl(moduleNamePlusExt); + }; + + req.version = version; + + //Used to filter out dependencies that are already paths. + req.jsExtRegExp = /^\/|:|\?|\.js$/; + s = req.s = { + contexts: contexts, + //Stores a list of URLs that should not get async script tag treatment. + skipAsync: {} + }; + + req.isAsync = req.isBrowser = isBrowser; + if (isBrowser) { + head = s.head = document.getElementsByTagName("head")[0]; + //If BASE tag is in play, using appendChild is a problem for IE6. + //When that browser dies, this can be removed. Details in this jQuery bug: + //http://dev.jquery.com/ticket/2709 + baseElement = document.getElementsByTagName("base")[0]; + if (baseElement) { + head = s.head = baseElement.parentNode; + } + } + + /** + * Any errors that require explicitly generates will be passed to this + * function. Intercept/override it if you want custom error handling. + * @param {Error} err the error object. + */ + req.onError = function (err) { + throw err; + }; + + /** + * Does the request to load a module for the browser case. + * Make this a separate function to allow other environments + * to override it. + * + * @param {Object} context the require context to find state. + * @param {String} moduleName the name of the module. + * @param {Object} url the URL to the module. + */ + req.load = function (context, moduleName, url) { + req.resourcesReady(false); + + context.scriptCount += 1; + req.attach(url, context, moduleName); + + //If tracking a jQuery, then make sure its ready callbacks + //are put on hold to prevent its ready callbacks from + //triggering too soon. + if (context.jQuery && !context.jQueryIncremented) { + jQueryHoldReady(context.jQuery, true); + context.jQueryIncremented = true; + } + }; + + function getInteractiveScript() { + var scripts, i, script; + if (interactiveScript && interactiveScript.readyState === 'interactive') { + return interactiveScript; + } + + scripts = document.getElementsByTagName('script'); + for (i = scripts.length - 1; i > -1 && (script = scripts[i]); i--) { + if (script.readyState === 'interactive') { + return (interactiveScript = script); + } + } + + return null; + } + + /** + * The function that handles definitions of modules. Differs from + * require() in that a string for the module should be the first argument, + * and the function to execute after dependencies are loaded should + * return a value to define the module corresponding to the first argument's + * name. + */ + define = function (name, deps, callback) { + var node, context; + + //Allow for anonymous functions + if (typeof name !== 'string') { + //Adjust args appropriately + callback = deps; + deps = name; + name = null; + } + + //This module may not have dependencies + if (!isArray(deps)) { + callback = deps; + deps = []; + } + + //If no name, and callback is a function, then figure out if it a + //CommonJS thing with dependencies. + if (!deps.length && isFunction(callback)) { + //Remove comments from the callback string, + //look for require calls, and pull them into the dependencies, + //but only if there are function args. + if (callback.length) { + callback + .toString() + .replace(commentRegExp, "") + .replace(cjsRequireRegExp, function (match, dep) { + deps.push(dep); + }); + + //May be a CommonJS thing even without require calls, but still + //could use exports, and module. Avoid doing exports and module + //work though if it just needs require. + //REQUIRES the function to expect the CommonJS variables in the + //order listed below. + deps = (callback.length === 1 ? ["require"] : ["require", "exports", "module"]).concat(deps); + } + } + + //If in IE 6-8 and hit an anonymous define() call, do the interactive + //work. + if (useInteractive) { + node = currentlyAddingScript || getInteractiveScript(); + if (node) { + if (!name) { + name = node.getAttribute("data-requiremodule"); + } + context = contexts[node.getAttribute("data-requirecontext")]; + } + } + + //Always save off evaluating the def call until the script onload handler. + //This allows multiple modules to be in a file without prematurely + //tracing dependencies, and allows for anonymous module support, + //where the module name is not known until the script onload event + //occurs. If no context, use the global queue, and get it processed + //in the onscript load callback. + (context ? context.defQueue : globalDefQueue).push([name, deps, callback]); + + return undefined; + }; + + define.amd = { + multiversion: true, + plugins: true, + jQuery: true + }; + + /** + * Executes the text. Normally just uses eval, but can be modified + * to use a more environment specific call. + * @param {String} text the text to execute/evaluate. + */ + req.exec = function (text) { + return eval(text); + }; + + /** + * Executes a module callack function. Broken out as a separate function + * solely to allow the build system to sequence the files in the built + * layer in the right sequence. + * + * @private + */ + req.execCb = function (name, callback, args, exports) { + return callback.apply(exports, args); + }; + + + /** + * Adds a node to the DOM. Public function since used by the order plugin. + * This method should not normally be called by outside code. + */ + req.addScriptToDom = function (node) { + //For some cache cases in IE 6-8, the script executes before the end + //of the appendChild execution, so to tie an anonymous define + //call to the module name (which is stored on the node), hold on + //to a reference to this node, but clear after the DOM insertion. + currentlyAddingScript = node; + if (baseElement) { + head.insertBefore(node, baseElement); + } else { + head.appendChild(node); + } + currentlyAddingScript = null; + }; + + /** + * callback for script loads, used to check status of loading. + * + * @param {Event} evt the event from the browser for the script + * that was loaded. + * + * @private + */ + req.onScriptLoad = function (evt) { + //Using currentTarget instead of target for Firefox 2.0's sake. Not + //all old browsers will be supported, but this one was easy enough + //to support and still makes sense. + var node = evt.currentTarget || evt.srcElement, contextName, moduleName, + context; + + if (evt.type === "load" || (node && readyRegExp.test(node.readyState))) { + //Reset interactive script so a script node is not held onto for + //to long. + interactiveScript = null; + + //Pull out the name of the module and the context. + contextName = node.getAttribute("data-requirecontext"); + moduleName = node.getAttribute("data-requiremodule"); + context = contexts[contextName]; + + contexts[contextName].completeLoad(moduleName); + + //Clean up script binding. Favor detachEvent because of IE9 + //issue, see attachEvent/addEventListener comment elsewhere + //in this file. + if (node.detachEvent && !isOpera) { + //Probably IE. If not it will throw an error, which will be + //useful to know. + node.detachEvent("onreadystatechange", req.onScriptLoad); + } else { + node.removeEventListener("load", req.onScriptLoad, false); + } + } + }; + + /** + * Attaches the script represented by the URL to the current + * environment. Right now only supports browser loading, + * but can be redefined in other environments to do the right thing. + * @param {String} url the url of the script to attach. + * @param {Object} context the context that wants the script. + * @param {moduleName} the name of the module that is associated with the script. + * @param {Function} [callback] optional callback, defaults to require.onScriptLoad + * @param {String} [type] optional type, defaults to text/javascript + * @param {Function} [fetchOnlyFunction] optional function to indicate the script node + * should be set up to fetch the script but do not attach it to the DOM + * so that it can later be attached to execute it. This is a way for the + * order plugin to support ordered loading in IE. Once the script is fetched, + * but not executed, the fetchOnlyFunction will be called. + */ + req.attach = function (url, context, moduleName, callback, type, fetchOnlyFunction) { + var node; + if (isBrowser) { + //In the browser so use a script tag + callback = callback || req.onScriptLoad; + node = context && context.config && context.config.xhtml ? + document.createElementNS("http://www.w3.org/1999/xhtml", "html:script") : + document.createElement("script"); + node.type = type || (context && context.config.scriptType) || + "text/javascript"; + node.charset = "utf-8"; + //Use async so Gecko does not block on executing the script if something + //like a long-polling comet tag is being run first. Gecko likes + //to evaluate scripts in DOM order, even for dynamic scripts. + //It will fetch them async, but only evaluate the contents in DOM + //order, so a long-polling script tag can delay execution of scripts + //after it. But telling Gecko we expect async gets us the behavior + //we want -- execute it whenever it is finished downloading. Only + //Helps Firefox 3.6+ + //Allow some URLs to not be fetched async. Mostly helps the order! + //plugin + node.async = !s.skipAsync[url]; + + if (context) { + node.setAttribute("data-requirecontext", context.contextName); + } + node.setAttribute("data-requiremodule", moduleName); + + //Set up load listener. Test attachEvent first because IE9 has + //a subtle issue in its addEventListener and script onload firings + //that do not match the behavior of all other browsers with + //addEventListener support, which fire the onload event for a + //script right after the script execution. See: + //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution + //UNFORTUNATELY Opera implements attachEvent but does not follow the script + //script execution mode. + if (node.attachEvent && !isOpera) { + //Probably IE. IE (at least 6-8) do not fire + //script onload right after executing the script, so + //we cannot tie the anonymous define call to a name. + //However, IE reports the script as being in "interactive" + //readyState at the time of the define call. + useInteractive = true; + + + if (fetchOnlyFunction) { + //Need to use old school onreadystate here since + //when the event fires and the node is not attached + //to the DOM, the evt.srcElement is null, so use + //a closure to remember the node. + node.onreadystatechange = function (evt) { + //Script loaded but not executed. + //Clear loaded handler, set the real one that + //waits for script execution. + if (node.readyState === 'loaded') { + node.onreadystatechange = null; + node.attachEvent("onreadystatechange", callback); + fetchOnlyFunction(node); + } + }; + } else { + node.attachEvent("onreadystatechange", callback); + } + } else { + node.addEventListener("load", callback, false); + } + node.src = url; + + //Fetch only means waiting to attach to DOM after loaded. + if (!fetchOnlyFunction) { + req.addScriptToDom(node); + } + + return node; + } else if (isWebWorker) { + //In a web worker, use importScripts. This is not a very + //efficient use of importScripts, importScripts will block until + //its script is downloaded and evaluated. However, if web workers + //are in play, the expectation that a build has been done so that + //only one script needs to be loaded anyway. This may need to be + //reevaluated if other use cases become common. + importScripts(url); + + //Account for anonymous modules + context.completeLoad(moduleName); + } + return null; + }; + + //Look for a data-main script attribute, which could also adjust the baseUrl. + if (isBrowser) { + //Figure out baseUrl. Get it from the script tag with require.js in it. + scripts = document.getElementsByTagName("script"); + + for (globalI = scripts.length - 1; globalI > -1 && (script = scripts[globalI]); globalI--) { + //Set the "head" where we can append children by + //using the script's parent. + if (!head) { + head = script.parentNode; + } + + //Look for a data-main attribute to set main script for the page + //to load. If it is there, the path to data main becomes the + //baseUrl, if it is not already set. + if ((dataMain = script.getAttribute('data-main'))) { + if (!cfg.baseUrl) { + //Pull off the directory of data-main for use as the + //baseUrl. + src = dataMain.split('/'); + mainScript = src.pop(); + subPath = src.length ? src.join('/') + '/' : './'; + + //Set final config. + cfg.baseUrl = subPath; + //Strip off any trailing .js since dataMain is now + //like a module name. + dataMain = mainScript.replace(jsSuffixRegExp, ''); + } + + //Put the data-main script in the files to load. + cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain]; + + break; + } + } + } + + //See if there is nothing waiting across contexts, and if not, trigger + //resourcesReady. + req.checkReadyState = function () { + var contexts = s.contexts, prop; + for (prop in contexts) { + if (!(prop in empty)) { + if (contexts[prop].waitCount) { + return; + } + } + } + req.resourcesReady(true); + }; + + /** + * Internal function that is triggered whenever all scripts/resources + * have been loaded by the loader. Can be overridden by other, for + * instance the domReady plugin, which wants to know when all resources + * are loaded. + */ + req.resourcesReady = function (isReady) { + var contexts, context, prop; + + //First, set the public variable indicating that resources are loading. + req.resourcesDone = isReady; + + if (req.resourcesDone) { + //If jQuery with DOM ready delayed, release it now. + contexts = s.contexts; + for (prop in contexts) { + if (!(prop in empty)) { + context = contexts[prop]; + if (context.jQueryIncremented) { + jQueryHoldReady(context.jQuery, false); + context.jQueryIncremented = false; + } + } + } + } + }; + + //FF < 3.6 readyState fix. Needed so that domReady plugin + //works well in that environment, since require.js is normally + //loaded via an HTML script tag so it will be there before window load, + //where the domReady plugin is more likely to be loaded after window load. + req.pageLoaded = function () { + if (document.readyState !== "complete") { + document.readyState = "complete"; + } + }; + if (isBrowser) { + if (document.addEventListener) { + if (!document.readyState) { + document.readyState = "loading"; + window.addEventListener("load", req.pageLoaded, false); + } + } + } + + //Set up default context. If require was a configuration object, use that as base config. + req(cfg); + + //If modules are built into require.js, then need to make sure dependencies are + //traced. Use a setTimeout in the browser world, to allow all the modules to register + //themselves. In a non-browser env, assume that modules are not built into require.js, + //which seems odd to do on the server. + if (req.isAsync && typeof setTimeout !== "undefined") { + ctx = s.contexts[(cfg.context || defContextName)]; + //Indicate that the script that includes require() is still loading, + //so that require()'d dependencies are not traced until the end of the + //file is parsed (approximated via the setTimeout call). + ctx.requireWait = true; + setTimeout(function () { + ctx.requireWait = false; + + if (!ctx.scriptCount) { + ctx.resume(); + } + req.checkReadyState(); + }, 0); + } +}()); /*! - * jQuery JavaScript Library v1.6.1 + * jQuery JavaScript Library v1.7.1 * http://jquery.com/ * * Copyright 2011, John Resig @@ -11,9 +2064,8 @@ * Copyright 2011, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * - * Date: Thu May 12 15:04:36 2011 -0400 + * Date: Mon Nov 21 21:11:03 2011 -0500 */ - (function( window, undefined ) { // Use the correct document accordingly with window argument (sandbox) @@ -38,8 +2090,8 @@ var jQuery = function( selector, context ) { rootjQuery, // A simple way to check for HTML strings or ID strings - // (both of which we optimize for) - quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + // Prioritize #id over to avoid XSS via location.hash (#9521) + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, // Check if a string has a non-whitespace character in it rnotwhite = /\S/, @@ -48,9 +2100,6 @@ var jQuery = function( selector, context ) { trimLeft = /^\s+/, trimRight = /\s+$/, - // Check for digits - rdigit = /\d/, - // Match a standalone tag rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, @@ -66,6 +2115,15 @@ var jQuery = function( selector, context ) { rmsie = /(msie) ([\w.]+)/, rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + // Matches dashed string for camelizing + rdashAlpha = /-([a-z]|[0-9])/ig, + rmsPrefix = /^-ms-/, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + // Keep a UserAgent string for use with jQuery.browser userAgent = navigator.userAgent, @@ -132,7 +2190,7 @@ jQuery.fn = jQuery.prototype = { // HANDLE: $(html) -> $(array) if ( match[1] ) { context = context instanceof jQuery ? context[0] : context; - doc = (context ? context.ownerDocument || context : document); + doc = ( context ? context.ownerDocument || context : document ); // If a single string is passed in and it's a single tag // just do a createElement and skip the rest @@ -149,7 +2207,7 @@ jQuery.fn = jQuery.prototype = { } else { ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); - selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes; + selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; } return jQuery.merge( this, selector ); @@ -179,7 +2237,7 @@ jQuery.fn = jQuery.prototype = { // HANDLE: $(expr, $(...)) } else if ( !context || context.jquery ) { - return (context || rootjQuery).find( selector ); + return ( context || rootjQuery ).find( selector ); // HANDLE: $(expr, context) // (which is just equivalent to: $(context).find(expr) @@ -193,7 +2251,7 @@ jQuery.fn = jQuery.prototype = { return rootjQuery.ready( selector ); } - if (selector.selector !== undefined) { + if ( selector.selector !== undefined ) { this.selector = selector.selector; this.context = selector.context; } @@ -205,7 +2263,7 @@ jQuery.fn = jQuery.prototype = { selector: "", // The current version of jQuery being used - jquery: "1.6.1", + jquery: "1.7.1", // The default length of a jQuery object is 0 length: 0, @@ -250,7 +2308,7 @@ jQuery.fn = jQuery.prototype = { ret.context = this.context; if ( name === "find" ) { - ret.selector = this.selector + (this.selector ? " " : "") + selector; + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; } else if ( name ) { ret.selector = this.selector + "." + name + "(" + selector + ")"; } @@ -271,15 +2329,16 @@ jQuery.fn = jQuery.prototype = { jQuery.bindReady(); // Add the callback - readyList.done( fn ); + readyList.add( fn ); return this; }, eq: function( i ) { + i = +i; return i === -1 ? this.slice( i ) : - this.slice( i, +i + 1 ); + this.slice( i, i + 1 ); }, first: function() { @@ -426,11 +2485,11 @@ jQuery.extend({ } // If there are functions bound, to execute - readyList.resolveWith( document, [ jQuery ] ); + readyList.fireWith( document, [ jQuery ] ); // Trigger any bound ready events if ( jQuery.fn.trigger ) { - jQuery( document ).trigger( "ready" ).unbind( "ready" ); + jQuery( document ).trigger( "ready" ).off( "ready" ); } } }, @@ -440,7 +2499,7 @@ jQuery.extend({ return; } - readyList = jQuery._Deferred(); + readyList = jQuery.Callbacks( "once memory" ); // Catch cases where $(document).ready() is called after the // browser event has already occurred. @@ -496,8 +2555,8 @@ jQuery.extend({ return obj && typeof obj === "object" && "setInterval" in obj; }, - isNaN: function( obj ) { - return obj == null || !rdigit.test( obj ) || isNaN( obj ); + isNumeric: function( obj ) { + return !isNaN( parseFloat(obj) ) && isFinite( obj ); }, type: function( obj ) { @@ -514,10 +2573,15 @@ jQuery.extend({ return false; } - // Not own constructor property must be Object - if ( obj.constructor && - !hasOwn.call(obj, "constructor") && - !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 return false; } @@ -538,7 +2602,7 @@ jQuery.extend({ }, error: function( msg ) { - throw msg; + throw new Error( msg ); }, parseJSON: function( data ) { @@ -560,31 +2624,30 @@ jQuery.extend({ .replace( rvalidtokens, "]" ) .replace( rvalidbraces, "")) ) { - return (new Function( "return " + data ))(); + return ( new Function( "return " + data ) )(); } jQuery.error( "Invalid JSON: " + data ); }, // Cross-browser xml parsing - // (xml & tmp used internally) - parseXML: function( data , xml , tmp ) { - - 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 ); + parseXML: function( data ) { + 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; } - - tmp = xml.documentElement; - - if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) { + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { jQuery.error( "Invalid XML: " + data ); } - return xml; }, @@ -604,6 +2667,12 @@ jQuery.extend({ } }, + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + nodeName: function( elem, name ) { return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); }, @@ -670,8 +2739,6 @@ jQuery.extend({ if ( array != null ) { // The window, strings (and functions) also have 'length' - // The extra typeof function check is to prevent crashes - // in Safari 2 (See: #3039) // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 var type = jQuery.type( array ); @@ -685,15 +2752,22 @@ jQuery.extend({ return ret; }, - inArray: function( elem, array ) { + inArray: function( elem, array, i ) { + var len; - if ( indexOf ) { - return indexOf.call( array, elem ); - } + if ( array ) { + if ( indexOf ) { + return indexOf.call( array, elem, i ); + } - for ( var i = 0, length = array.length; i < length; i++ ) { - if ( array[ i ] === elem ) { - return 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; + } } } @@ -800,7 +2874,7 @@ jQuery.extend({ }, // Mutifunctional method to get and set values to a collection - // The value/s can be optionally by executed if its a function + // The value/s can optionally be executed if it's a function access: function( elems, key, value, exec, fn, pass ) { var length = elems.length; @@ -829,7 +2903,7 @@ jQuery.extend({ }, now: function() { - return (new Date()).getTime(); + return ( new Date() ).getTime(); }, // Use of jQuery.browser is frowned upon. @@ -931,194 +3005,365 @@ function doScrollCheck() { jQuery.ready(); } -// Expose jQuery to the global object return jQuery; })(); -var // Promise methods - promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ), - // Static reference to slice +// String to Object flags format cache +var flagsCache = {}; + +// 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; +} + +/* + * Create a callback list using the following parameters: + * + * flags: an optional list of space-separated flags that will change how + * 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 be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( flags ) { + + // Convert flags from String-formatted to Object-formatted + // (we check in cache first) + flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; + + 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 is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // 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 callback is not in + if ( !flags.unique || !self.has( elem ) ) { + list.push( elem ); + } + } + } + }, + // Fire callbacks + fire = function( context, args ) { + args = args || []; + memory = !flags.memory || [ context, args ]; + firing = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { + memory = true; // Mark as halted + break; + } + } + firing = false; + if ( list ) { + if ( !flags.once ) { + if ( stack && stack.length ) { + memory = stack.shift(); + self.fireWith( memory[ 0 ], memory[ 1 ] ); + } + } else if ( memory === true ) { + self.disable(); + } else { + list = []; + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + var length = list.length; + add( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away, unless previous + // 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 ; argIndex++ ) { + for ( var i = 0; i < list.length; i++ ) { + if ( args[ argIndex ] === list[ i ] ) { + // Handle firingIndex and firingLength + if ( firing ) { + if ( i <= firingLength ) { + firingLength--; + if ( i <= firingIndex ) { + firingIndex--; + } + } + } + // Remove the element + list.splice( i--, 1 ); + // If we have some unicity property then + // we only need to do this once + if ( flags.unique ) { + 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 arguments + fireWith: function( context, args ) { + if ( stack ) { + if ( firing ) { + if ( !flags.once ) { + stack.push( [ context, args ] ); + } + } 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 at least once + fired: function() { + return !!memory; + } + }; + + return self; +}; + + + + +var // Static reference to slice sliceDeferred = [].slice; jQuery.extend({ - // Create a simple deferred (one callbacks list) - _Deferred: function() { - var // callbacks list - callbacks = [], - // stored [ context , args ] - fired, - // to avoid firing when already doing so - firing, - // flag to know if the deferred has been cancelled - cancelled, - // the deferred itself - deferred = { - // done( f1, f2, ...) - done: function() { - if ( !cancelled ) { - var args = arguments, - i, - length, - elem, - type, - _fired; - if ( fired ) { - _fired = fired; - fired = 0; - } - for ( i = 0, length = args.length; i < length; i++ ) { - elem = args[ i ]; - type = jQuery.type( elem ); - if ( type === "array" ) { - deferred.done.apply( deferred, elem ); - } else if ( type === "function" ) { - callbacks.push( elem ); - } - } - if ( _fired ) { - deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] ); - } - } - return this; - }, - - // resolve with given context and args - resolveWith: function( context, args ) { - if ( !cancelled && !fired && !firing ) { - // make sure args are available (#8421) - args = args || []; - firing = 1; - try { - while( callbacks[ 0 ] ) { - callbacks.shift().apply( context, args ); - } - } - finally { - fired = [ context, args ]; - firing = 0; - } - } - return this; - }, - - // resolve with this as context and given arguments - resolve: function() { - deferred.resolveWith( this, arguments ); - return this; - }, - - // Has this deferred been resolved? - isResolved: function() { - return !!( firing || fired ); - }, - - // Cancel - cancel: function() { - cancelled = 1; - callbacks = []; - return this; - } - }; - - return deferred; - }, - - // Full fledged deferred (two callbacks list) Deferred: function( func ) { - var deferred = jQuery._Deferred(), - failDeferred = jQuery._Deferred(), - promise; - // Add errorDeferred methods, then and promise - jQuery.extend( deferred, { - then: function( doneCallbacks, failCallbacks ) { - deferred.done( doneCallbacks ).fail( failCallbacks ); - return this; + var doneList = jQuery.Callbacks( "once memory" ), + failList = jQuery.Callbacks( "once memory" ), + progressList = jQuery.Callbacks( "memory" ), + state = "pending", + lists = { + resolve: doneList, + reject: failList, + notify: progressList }, - always: function() { - return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments ); - }, - fail: failDeferred.done, - rejectWith: failDeferred.resolveWith, - reject: failDeferred.resolve, - isRejected: failDeferred.isResolved, - pipe: function( fnDone, fnFail ) { - return jQuery.Deferred(function( newDefer ) { - jQuery.each( { - done: [ fnDone, "resolve" ], - fail: [ fnFail, "reject" ] - }, function( handler, data ) { - var fn = data[ 0 ], - action = data[ 1 ], - returned; - if ( jQuery.isFunction( fn ) ) { - deferred[ handler ](function() { - returned = fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise().then( newDefer.resolve, newDefer.reject ); - } else { - newDefer[ action ]( returned ); - } - }); - } else { - deferred[ handler ]( newDefer[ action ] ); + promise = { + done: doneList.add, + fail: failList.add, + progress: progressList.add, + + state: function() { + return state; + }, + + // Deprecated + isResolved: doneList.fired, + isRejected: failList.fired, + + then: function( doneCallbacks, failCallbacks, progressCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); + return this; + }, + always: function() { + deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); + return this; + }, + pipe: function( fnDone, fnFail, fnProgress ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ], + progress: [ fnProgress, "notify" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + }); + } else { + deferred[ handler ]( newDefer[ action ] ); + } + }); + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + obj = promise; + } else { + for ( var key in promise ) { + obj[ key ] = promise[ key ]; } - }); - }).promise(); - }, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj ) { - if ( obj == null ) { - if ( promise ) { - return promise; } - promise = obj = {}; + return obj; } - var i = promiseMethods.length; - while( i-- ) { - obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ]; - } - return obj; - } - }); - // Make sure only one callback list will be used - deferred.done( failDeferred.cancel ).fail( deferred.cancel ); - // Unexpose cancel - delete deferred.cancel; + }, + deferred = promise.promise({}), + key; + + for ( key in lists ) { + deferred[ key ] = lists[ key ].fire; + deferred[ key + "With" ] = lists[ key ].fireWith; + } + + // Handle state + deferred.done( function() { + state = "resolved"; + }, failList.disable, progressList.lock ).fail( function() { + state = "rejected"; + }, doneList.disable, progressList.lock ); + // Call given func if any if ( func ) { func.call( deferred, deferred ); } + + // All done! return deferred; }, // Deferred helper when: function( firstParam ) { - var args = arguments, + var args = sliceDeferred.call( arguments, 0 ), i = 0, length = args.length, + pValues = new Array( length ), count = length, + pCount = length, deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? firstParam : - jQuery.Deferred(); + jQuery.Deferred(), + promise = deferred.promise(); function resolveFunc( i ) { return function( value ) { args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; if ( !( --count ) ) { - // Strange bug in FF4: - // Values changed onto the arguments object sometimes end up as undefined values - // outside the $.when method. Cloning the object into a fresh array solves the issue - deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) ); + deferred.resolveWith( deferred, args ); } }; } + function progressFunc( i ) { + return function( value ) { + pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + deferred.notifyWith( promise, pValues ); + }; + } if ( length > 1 ) { - for( ; i < length; i++ ) { - if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) { - args[ i ].promise().then( resolveFunc(i), deferred.reject ); + for ( ; i < length; i++ ) { + if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); } else { --count; } @@ -1129,31 +3374,30 @@ jQuery.extend({ } else if ( deferred !== firstParam ) { deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); } - return deferred.promise(); + return promise; } }); + jQuery.support = (function() { - var div = document.createElement( "div" ), - documentElement = document.documentElement, + var support, all, a, select, opt, input, marginDiv, - support, fragment, - body, - bodyStyle, tds, events, eventName, i, - isSupported; + isSupported, + div = document.createElement( "div" ), + documentElement = document.documentElement; // Preliminary tests div.setAttribute("className", "t"); @@ -1178,11 +3422,11 @@ jQuery.support = (function() { // Make sure that tbody elements aren't automatically inserted // IE will insert them into empty tables - tbody: !div.getElementsByTagName( "tbody" ).length, + tbody: !div.getElementsByTagName("tbody").length, // Make sure that link elements get serialized correctly by innerHTML // This requires a wrapper element in IE - htmlSerialize: !!div.getElementsByTagName( "link" ).length, + htmlSerialize: !!div.getElementsByTagName("link").length, // Get the style information from getAttribute // (IE uses .cssText instead) @@ -1190,12 +3434,12 @@ jQuery.support = (function() { // Make sure that URLs aren't manipulated // (IE normalizes it by default) - hrefNormalized: ( a.getAttribute( "href" ) === "/a" ), + 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 ), + opacity: /^0.55/.test( a.style.opacity ), // Verify style float existence // (IE uses styleFloat instead of cssFloat) @@ -1213,6 +3457,13 @@ jQuery.support = (function() { // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) getSetAttribute: div.className !== "t", + // Tests for enctype support on a form(#6743) + enctype: !!document.createElement("form").enctype, + + // Makes sure cloning an html5 element does not cause problems + // Where outerHTML is undefined, this still works + html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", + // Will be defined later submitBubbles: true, changeBubbles: true, @@ -1242,16 +3493,15 @@ jQuery.support = (function() { } if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { - div.attachEvent( "onclick", function click() { + div.attachEvent( "onclick", function() { // Cloning a node shouldn't copy over any // bound event handlers (IE does this) support.noCloneEvent = false; - div.detachEvent( "onclick", click ); }); div.cloneNode( true ).fireEvent( "onclick" ); } - // Check if a radio maintains it's value + // Check if a radio maintains its value // after being appended to the DOM input = document.createElement("input"); input.value = "t"; @@ -1261,73 +3511,18 @@ jQuery.support = (function() { input.setAttribute("checked", "checked"); div.appendChild( input ); fragment = document.createDocumentFragment(); - fragment.appendChild( div.firstChild ); + fragment.appendChild( div.lastChild ); // WebKit doesn't clone checked state correctly in fragments support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; - div.innerHTML = ""; - - // Figure out if the W3C box model works as expected - div.style.width = div.style.paddingLeft = "1px"; - - // We use our own, invisible, body - body = document.createElement( "body" ); - bodyStyle = { - visibility: "hidden", - width: 0, - height: 0, - border: 0, - margin: 0, - // Set background to avoid IE crashes when removing (#9028) - background: "none" - }; - for ( i in bodyStyle ) { - body.style[ i ] = bodyStyle[ i ]; - } - body.appendChild( div ); - documentElement.insertBefore( body, documentElement.firstChild ); - // Check if a disconnected checkbox will retain its checked // value of true after appended to the DOM (IE6/7) support.appendChecked = input.checked; - support.boxModel = div.offsetWidth === 2; + fragment.removeChild( input ); + fragment.appendChild( div ); - if ( "zoom" in div.style ) { - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - // (IE < 8 does this) - div.style.display = "inline"; - div.style.zoom = 1; - support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); - - // Check if elements with layout shrink-wrap their children - // (IE 6 does this) - div.style.display = ""; - div.innerHTML = "
"; - support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); - } - - div.innerHTML = "
t
"; - tds = div.getElementsByTagName( "td" ); - - // Check if table cells still have offsetWidth/Height when they are set - // to display:none and there are still other visible table cells in a - // table row; if so, offsetWidth/Height are not reliable for use when - // determining if an element has been hidden directly using - // display:none (it is still safe to use offsets if a parent element is - // hidden; don safety goggles and see bug #4512 for more information). - // (only IE 8 fails this test) - isSupported = ( tds[ 0 ].offsetHeight === 0 ); - - tds[ 0 ].style.display = ""; - tds[ 1 ].style.display = "none"; - - // Check if empty table cells still have offsetWidth/Height - // (IE < 8 fail this test) - support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); div.innerHTML = ""; // Check if div with explicit width and no margin-right incorrectly @@ -1335,21 +3530,18 @@ jQuery.support = (function() { // info see bug #3333 // Fails in WebKit before Feb 2011 nightlies // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - if ( document.defaultView && document.defaultView.getComputedStyle ) { + if ( window.getComputedStyle ) { marginDiv = document.createElement( "div" ); marginDiv.style.width = "0"; marginDiv.style.marginRight = "0"; + div.style.width = "2px"; div.appendChild( marginDiv ); support.reliableMarginRight = - ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; + ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; } - // Remove the body element we added - body.innerHTML = ""; - documentElement.removeChild( body ); - // Technique from Juriy Zaytsev - // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ + // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ // We only care about the case where non-standard event systems // are used, namely in IE. Short-circuiting here helps us to // avoid an eval call (in setAttribute) which can cause CSP @@ -1359,7 +3551,7 @@ jQuery.support = (function() { submit: 1, change: 1, focusin: 1 - } ) { + }) { eventName = "on" + i; isSupported = ( eventName in div ); if ( !isSupported ) { @@ -1370,17 +3562,116 @@ jQuery.support = (function() { } } + fragment.removeChild( div ); + + // Null elements to avoid leaks in IE + fragment = select = opt = marginDiv = div = input = null; + + // Run tests that need a body at doc ready + jQuery(function() { + var container, outer, inner, table, td, offsetSupport, + conMarginTop, ptlm, vb, style, html, + body = document.getElementsByTagName("body")[0]; + + if ( !body ) { + // Return for frameset docs that don't have a body + return; + } + + conMarginTop = 1; + ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"; + vb = "visibility:hidden;border:0;"; + style = "style='" + ptlm + "border:5px solid #000;padding:0;'"; + html = "
" + + "" + + "
"; + + container = document.createElement("div"); + container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; + body.insertBefore( container, body.firstChild ); + + // Construct the test element + div = document.createElement("div"); + container.appendChild( div ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + div.innerHTML = "
t
"; + 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 ].offsetHeight === 0 ); + + // Figure out if the W3C box model works as expected + div.innerHTML = ""; + div.style.width = div.style.paddingLeft = "1px"; + jQuery.boxModel = support.boxModel = div.offsetWidth === 2; + + if ( typeof div.style.zoom !== "undefined" ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.style.display = "inline"; + div.style.zoom = 1; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = ""; + div.innerHTML = "
"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); + } + + div.style.cssText = ptlm + vb; + div.innerHTML = html; + + outer = div.firstChild; + inner = outer.firstChild; + td = outer.nextSibling.firstChild.firstChild; + + offsetSupport = { + doesNotAddBorder: ( inner.offsetTop !== 5 ), + doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) + }; + + inner.style.position = "fixed"; + inner.style.top = "20px"; + + // safari subtracts parent border width here which is 5px + offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); + inner.style.position = inner.style.top = ""; + + outer.style.overflow = "hidden"; + outer.style.position = "relative"; + + offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); + offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); + + body.removeChild( container ); + div = container = null; + + jQuery.extend( support, offsetSupport ); + }); + return support; })(); -// Keep track of boxModel -jQuery.boxModel = jQuery.support.boxModel; - var rbrace = /^(?:\{.*\}|\[.*\])$/, - rmultiDash = /([a-z])([A-Z])/g; + rmultiDash = /([A-Z])/g; jQuery.extend({ cache: {}, @@ -1403,7 +3694,6 @@ jQuery.extend({ hasData: function( elem ) { elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - return !!elem && !isEmptyDataObject( elem ); }, @@ -1412,7 +3702,9 @@ jQuery.extend({ return; } - var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache, + var privateCache, thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", // We have to handle DOM nodes and JS objects differently because IE6-7 // can't GC object references properly across the DOM-JS boundary @@ -1424,11 +3716,12 @@ jQuery.extend({ // Only defining an ID for JS objects if its cache already exists allows // the code to shortcut on the same path as a DOM node with no cache - id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando; + id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey, + isEvents = name === "events"; // Avoid doing any more work than we need to when trying to get data on an // object that has no data at all - if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) { + if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { return; } @@ -1436,18 +3729,17 @@ jQuery.extend({ // Only DOM nodes need a new unique ID for each element since their data // ends up in the global cache if ( isNode ) { - elem[ jQuery.expando ] = id = ++jQuery.uuid; + elem[ internalKey ] = id = ++jQuery.uuid; } else { - id = jQuery.expando; + id = internalKey; } } if ( !cache[ id ] ) { cache[ id ] = {}; - // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery - // metadata on plain JS objects when the object is serialized using - // JSON.stringify + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify if ( !isNode ) { cache[ id ].toJSON = jQuery.noop; } @@ -1457,37 +3749,53 @@ jQuery.extend({ // shallow copied over onto the existing cache if ( typeof name === "object" || typeof name === "function" ) { if ( pvt ) { - cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); + cache[ id ] = jQuery.extend( cache[ id ], name ); } else { - cache[ id ] = jQuery.extend(cache[ id ], name); + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); } } - thisCache = cache[ id ]; + privateCache = thisCache = cache[ id ]; - // Internal jQuery data is stored in a separate object inside the object's data + // jQuery data() is stored in a separate object inside the object's internal data // cache in order to avoid key collisions between internal data and user-defined - // data - if ( pvt ) { - if ( !thisCache[ internalKey ] ) { - thisCache[ internalKey ] = {}; + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; } - thisCache = thisCache[ internalKey ]; + thisCache = thisCache.data; } if ( data !== undefined ) { thisCache[ jQuery.camelCase( name ) ] = data; } - // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should - // not attempt to inspect the internal events object using jQuery.data, as this - // internal data object is undocumented and subject to change. - if ( name === "events" && !thisCache[name] ) { - return thisCache[ internalKey ] && thisCache[ internalKey ].events; + // Users should not attempt to inspect the internal events object using jQuery.data, + // it is undocumented and subject to change. But does anyone listen? No. + if ( isEvents && !thisCache[ name ] ) { + return privateCache.events; } - return getByName ? thisCache[ jQuery.camelCase( name ) ] : thisCache; + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; }, removeData: function( elem, name, pvt /* Internal Use Only */ ) { @@ -1495,13 +3803,18 @@ jQuery.extend({ return; } - var internalKey = jQuery.expando, isNode = elem.nodeType, + var thisCache, i, l, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, // See jQuery.data for more information cache = isNode ? jQuery.cache : elem, // See jQuery.data for more information - id = isNode ? elem[ jQuery.expando ] : jQuery.expando; + id = isNode ? elem[ internalKey ] : internalKey; // If there is already no cache entry for this object, there is no // purpose in continuing @@ -1510,22 +3823,44 @@ jQuery.extend({ } if ( name ) { - var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; + + thisCache = pvt ? cache[ id ] : cache[ id ].data; if ( thisCache ) { - delete thisCache[ name ]; + + // Support array or space separated string names for data keys + if ( !jQuery.isArray( name ) ) { + + // try the string as a key before any manipulation + if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces unless a key with the spaces exists + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split( " " ); + } + } + } + + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } // If there is no data left in the cache, we want to continue // and let the cache object itself get destroyed - if ( !isEmptyDataObject(thisCache) ) { + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { return; } } } // See jQuery.data for more information - if ( pvt ) { - delete cache[ id ][ internalKey ]; + if ( !pvt ) { + delete cache[ id ].data; // Don't destroy the parent cache unless the internal data object // had been the only thing left in it @@ -1534,43 +3869,28 @@ jQuery.extend({ } } - var internalCache = cache[ id ][ internalKey ]; - // Browsers that fail expando deletion also refuse to delete expandos on // the window, but it will allow it on all other JS objects; other browsers // don't care - if ( jQuery.support.deleteExpando || cache != window ) { + // 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 entire user cache at once because it's faster than - // iterating through each key, but we need to continue to persist internal - // data if it existed - if ( internalCache ) { - cache[ id ] = {}; - // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery - // metadata on plain JS objects when the object is serialized using - // JSON.stringify - if ( !isNode ) { - cache[ id ].toJSON = jQuery.noop; - } - - cache[ id ][ internalKey ] = internalCache; - - // Otherwise, we need to eliminate the expando on the node to avoid + // We destroyed the cache and need to eliminate the expando on the node to avoid // false lookups in the cache for entries that no longer exist - } else if ( isNode ) { + if ( isNode ) { // IE does not allow us to delete expando properties from nodes, // nor does it have a removeAttribute function on Document nodes; // we must handle all of these cases if ( jQuery.support.deleteExpando ) { - delete elem[ jQuery.expando ]; + delete elem[ internalKey ]; } else if ( elem.removeAttribute ) { - elem.removeAttribute( jQuery.expando ); + elem.removeAttribute( internalKey ); } else { - elem[ jQuery.expando ] = null; + elem[ internalKey ] = null; } } }, @@ -1596,14 +3916,15 @@ jQuery.extend({ jQuery.fn.extend({ data: function( key, value ) { - var data = null; + var parts, attr, name, + data = null; if ( typeof key === "undefined" ) { if ( this.length ) { data = jQuery.data( this[0] ); - if ( this[0].nodeType === 1 ) { - var attr = this[0].attributes, name; + if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) { + attr = this[0].attributes; for ( var i = 0, l = attr.length; i < l; i++ ) { name = attr[i].name; @@ -1613,6 +3934,7 @@ jQuery.fn.extend({ dataAttr( this[0], name, data[ name ] ); } } + jQuery._data( this[0], "parsedAttrs", true ); } } @@ -1624,7 +3946,7 @@ jQuery.fn.extend({ }); } - var parts = key.split("."); + parts = key.split("."); parts[1] = parts[1] ? "." + parts[1] : ""; if ( value === undefined ) { @@ -1642,12 +3964,12 @@ jQuery.fn.extend({ } else { return this.each(function() { - var $this = jQuery( this ), + var self = jQuery( this ), args = [ parts[0], value ]; - $this.triggerHandler( "setData" + parts[1] + "!", args ); + self.triggerHandler( "setData" + parts[1] + "!", args ); jQuery.data( this, key, value ); - $this.triggerHandler( "changeData" + parts[1] + "!", args ); + self.triggerHandler( "changeData" + parts[1] + "!", args ); }); } }, @@ -1663,7 +3985,8 @@ function dataAttr( elem, key, data ) { // If nothing was found internally, try to fetch any // data from the HTML5 data-* attribute if ( data === undefined && elem.nodeType === 1 ) { - var name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase(); + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); data = elem.getAttribute( name ); @@ -1672,7 +3995,7 @@ function dataAttr( elem, key, data ) { data = data === "true" ? true : data === "false" ? false : data === "null" ? null : - !jQuery.isNaN( data ) ? parseFloat( data ) : + jQuery.isNumeric( data ) ? parseFloat( data ) : rbrace.test( data ) ? jQuery.parseJSON( data ) : data; } catch( e ) {} @@ -1688,11 +4011,14 @@ function dataAttr( elem, key, data ) { return data; } -// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON -// property to be considered empty objects; this property always exists in -// order to make sure JSON.stringify does not expose internal metadata +// checks a cache object for emptiness function isEmptyDataObject( obj ) { for ( var name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } if ( name !== "toJSON" ) { return false; } @@ -1708,17 +4034,17 @@ function handleQueueMarkDefer( elem, type, src ) { var deferDataKey = type + "defer", queueDataKey = type + "queue", markDataKey = type + "mark", - defer = jQuery.data( elem, deferDataKey, undefined, true ); + defer = jQuery._data( elem, deferDataKey ); if ( defer && - ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) && - ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) { + ( 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, undefined, true ) && - !jQuery.data( elem, markDataKey, undefined, true ) ) { + if ( !jQuery._data( elem, queueDataKey ) && + !jQuery._data( elem, markDataKey ) ) { jQuery.removeData( elem, deferDataKey, true ); - defer.resolve(); + defer.fire(); } }, 0 ); } @@ -1728,8 +4054,8 @@ jQuery.extend({ _mark: function( elem, type ) { if ( elem ) { - type = (type || "fx") + "mark"; - jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true ); + type = ( type || "fx" ) + "mark"; + jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); } }, @@ -1742,9 +4068,9 @@ jQuery.extend({ if ( elem ) { type = type || "fx"; var key = type + "mark", - count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 ); + count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); if ( count ) { - jQuery.data( elem, key, count, true ); + jQuery._data( elem, key, count ); } else { jQuery.removeData( elem, key, true ); handleQueueMarkDefer( elem, type, "mark" ); @@ -1753,13 +4079,15 @@ jQuery.extend({ }, queue: function( elem, type, data ) { + var q; if ( elem ) { - type = (type || "fx") + "queue"; - var q = jQuery.data( elem, type, undefined, true ); + type = ( type || "fx" ) + "queue"; + q = jQuery._data( elem, type ); + // Speed up dequeue by getting out quickly if this is just a lookup if ( data ) { if ( !q || jQuery.isArray(data) ) { - q = jQuery.data( elem, type, jQuery.makeArray(data), true ); + q = jQuery._data( elem, type, jQuery.makeArray(data) ); } else { q.push( data ); } @@ -1773,7 +4101,7 @@ jQuery.extend({ var queue = jQuery.queue( elem, type ), fn = queue.shift(), - defer; + hooks = {}; // If the fx queue is dequeued, always remove the progress sentinel if ( fn === "inprogress" ) { @@ -1784,16 +4112,17 @@ jQuery.extend({ // Add a progress sentinel to prevent the fx queue from being // automatically dequeued if ( type === "fx" ) { - queue.unshift("inprogress"); + queue.unshift( "inprogress" ); } - fn.call(elem, function() { - jQuery.dequeue(elem, type); - }); + jQuery._data( elem, type + ".run", hooks ); + fn.call( elem, function() { + jQuery.dequeue( elem, type ); + }, hooks ); } if ( !queue.length ) { - jQuery.removeData( elem, type + "queue", true ); + jQuery.removeData( elem, type + "queue " + type + ".run", true ); handleQueueMarkDefer( elem, type, "queue" ); } } @@ -1825,14 +4154,14 @@ jQuery.fn.extend({ // 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; + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; type = type || "fx"; - return this.queue( type, function() { - var elem = this; - setTimeout(function() { - jQuery.dequeue( elem, type ); - }, time ); + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; }); }, clearQueue: function( type ) { @@ -1863,9 +4192,9 @@ jQuery.fn.extend({ if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && - jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) { + jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { count++; - tmp.done( resolve ); + tmp.add( resolve ); } } resolve(); @@ -1883,8 +4212,8 @@ var rclass = /[\n\t\r]/g, rfocusable = /^(?:button|input|object|select|textarea)$/i, rclickable = /^a(?:rea)?$/i, rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, - rinvalidChar = /\:/, - formHook, boolHook; + getSetAttribute = jQuery.support.getSetAttribute, + nodeHook, boolHook, fixSpecified; jQuery.fn.extend({ attr: function( name, value ) { @@ -1896,11 +4225,11 @@ jQuery.fn.extend({ jQuery.removeAttr( this, name ); }); }, - + prop: function( name, value ) { return jQuery.access( this, name, value, true, jQuery.prop ); }, - + removeProp: function( name ) { name = jQuery.propFix[ name ] || name; return this.each(function() { @@ -1913,30 +4242,31 @@ jQuery.fn.extend({ }, addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + if ( jQuery.isFunction( value ) ) { - return this.each(function(i) { - var self = jQuery(this); - self.addClass( value.call(this, i, self.attr("class") || "") ); + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); }); } if ( value && typeof value === "string" ) { - var classNames = (value || "").split( rspace ); + classNames = value.split( rspace ); - for ( var i = 0, l = this.length; i < l; i++ ) { - var elem = this[i]; + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; if ( elem.nodeType === 1 ) { - if ( !elem.className ) { + if ( !elem.className && classNames.length === 1 ) { elem.className = value; } else { - var className = " " + elem.className + " ", - setClass = elem.className; + setClass = " " + elem.className + " "; - for ( var c = 0, cl = classNames.length; c < cl; c++ ) { - if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { - setClass += " " + classNames[c]; + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { + setClass += classNames[ c ] + " "; } } elem.className = jQuery.trim( setClass ); @@ -1949,24 +4279,25 @@ jQuery.fn.extend({ }, removeClass: function( value ) { - if ( jQuery.isFunction(value) ) { - return this.each(function(i) { - var self = jQuery(this); - self.removeClass( value.call(this, i, self.attr("class")) ); + var classNames, i, l, elem, className, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); }); } if ( (value && typeof value === "string") || value === undefined ) { - var classNames = (value || "").split( rspace ); + classNames = ( value || "" ).split( rspace ); - for ( var i = 0, l = this.length; i < l; i++ ) { - var elem = this[i]; + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; if ( elem.nodeType === 1 && elem.className ) { if ( value ) { - var className = (" " + elem.className + " ").replace(rclass, " "); - for ( var c = 0, cl = classNames.length; c < cl; c++ ) { - className = className.replace(" " + classNames[c] + " ", " "); + className = (" " + elem.className + " ").replace( rclass, " " ); + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[ c ] + " ", " "); } elem.className = jQuery.trim( className ); @@ -1985,9 +4316,8 @@ jQuery.fn.extend({ isBool = typeof stateVal === "boolean"; if ( jQuery.isFunction( value ) ) { - return this.each(function(i) { - var self = jQuery(this); - self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal ); + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); }); } @@ -2019,9 +4349,11 @@ jQuery.fn.extend({ }, hasClass: function( selector ) { - var className = " " + selector + " "; - for ( var i = 0, l = this.length; i < l; i++ ) { - if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { return true; } } @@ -2030,9 +4362,9 @@ jQuery.fn.extend({ }, val: function( value ) { - var hooks, ret, + var hooks, ret, isFunction, elem = this[0]; - + if ( !arguments.length ) { if ( elem ) { hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; @@ -2041,13 +4373,19 @@ jQuery.fn.extend({ return ret; } - return (elem.value || "").replace(rreturn, ""); + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; } - return undefined; + return; } - var isFunction = jQuery.isFunction( value ); + isFunction = jQuery.isFunction( value ); return this.each(function( i ) { var self = jQuery(this), val; @@ -2095,7 +4433,7 @@ jQuery.extend({ }, select: { get: function( elem ) { - var value, + var value, i, max, option, index = elem.selectedIndex, values = [], options = elem.options, @@ -2107,8 +4445,10 @@ jQuery.extend({ } // Loop through all the selected options - for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { - var option = options[ i ]; + i = one ? index : 0; + max = one ? index + 1 : options.length; + for ( ; i < max; i++ ) { + option = options[ i ]; // Don't return options that are disabled or in a disabled optgroup if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && @@ -2160,18 +4500,14 @@ jQuery.extend({ height: true, offset: true }, - - attrFix: { - // Always normalize to ensure hook usage - tabindex: "tabIndex" - }, - + attr: function( elem, name, value, pass ) { - var nType = elem.nodeType; - + var ret, hooks, notxml, + nType = elem.nodeType; + // don't get/set attributes on text, comment and attribute nodes if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return undefined; + return; } if ( pass && name in jQuery.attrFn ) { @@ -2179,36 +4515,24 @@ jQuery.extend({ } // Fallback to prop when attributes are not supported - if ( !("getAttribute" in elem) ) { + if ( typeof elem.getAttribute === "undefined" ) { return jQuery.prop( elem, name, value ); } - var ret, hooks, - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - // Normalize the name if needed - name = notxml && jQuery.attrFix[ name ] || name; - - hooks = jQuery.attrHooks[ name ]; - - if ( !hooks ) { - // Use boolHook for boolean attributes - if ( rboolean.test( name ) && - (typeof value === "boolean" || value === undefined || value.toLowerCase() === name.toLowerCase()) ) { - - hooks = boolHook; - - // Use formHook for forms and if the name contains certain characters - } else if ( formHook && (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) { - hooks = formHook; - } + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( notxml ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); } if ( value !== undefined ) { if ( value === null ) { jQuery.removeAttr( elem, name ); - return undefined; + return; } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { return ret; @@ -2218,8 +4542,8 @@ jQuery.extend({ return value; } - } else if ( hooks && "get" in hooks && notxml ) { - return hooks.get( elem, name ); + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; } else { @@ -2232,22 +4556,29 @@ jQuery.extend({ } }, - removeAttr: function( elem, name ) { - var propName; - if ( elem.nodeType === 1 ) { - name = jQuery.attrFix[ name ] || name; - - if ( jQuery.support.getSetAttribute ) { - // Use removeAttribute in browsers that support it - elem.removeAttribute( name ); - } else { - jQuery.attr( elem, name, "" ); - elem.removeAttributeNode( elem.getAttributeNode( name ) ); - } + removeAttr: function( elem, value ) { + var propName, attrNames, name, l, + i = 0; - // Set corresponding property to false for boolean attributes - if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) { - elem[ propName ] = false; + if ( value && elem.nodeType === 1 ) { + attrNames = value.toLowerCase().split( rspace ); + l = attrNames.length; + + for ( ; i < l; i++ ) { + name = attrNames[ i ]; + + if ( name ) { + propName = jQuery.propFix[ name ] || name; + + // See #9699 for explanation of this approach (setting first, then removal) + jQuery.attr( elem, name, "" ); + elem.removeAttribute( getSetAttribute ? name : propName ); + + // Set corresponding property to false for boolean attributes + if ( rboolean.test( name ) && propName in elem ) { + elem[ propName ] = false; + } + } } } }, @@ -2271,17 +4602,23 @@ jQuery.extend({ } } }, - tabIndex: { - get: function( elem ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - var attributeNode = elem.getAttributeNode("tabIndex"); - - return attributeNode && attributeNode.specified ? - parseInt( attributeNode.value, 10 ) : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - undefined; + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; } } }, @@ -2300,33 +4637,34 @@ jQuery.extend({ frameborder: "frameBorder", contenteditable: "contentEditable" }, - + prop: function( elem, name, value ) { - var nType = elem.nodeType; + var ret, hooks, notxml, + nType = elem.nodeType; // don't get/set properties on text, comment and attribute nodes if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return undefined; + return; } - var ret, hooks, - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - // Try to normalize/fix the name - name = notxml && jQuery.propFix[ name ] || name; - - hooks = jQuery.propHooks[ name ]; + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } if ( value !== undefined ) { if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { return ret; } else { - return (elem[ name ] = value); + return ( elem[ name ] = value ); } } else { - if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== undefined ) { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { return ret; } else { @@ -2334,15 +4672,35 @@ jQuery.extend({ } } }, - - propHooks: {} + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } }); +// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) +jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; + // Hook for boolean attributes boolHook = { get: function( elem, name ) { // Align boolean attributes with corresponding properties - return elem[ jQuery.propFix[ name ] || name ] ? + // Fall back to attribute presence where some booleans are not supported + var attrNode, + property = jQuery.prop( elem, name ); + return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? name.toLowerCase() : undefined; }, @@ -2357,7 +4715,7 @@ boolHook = { propName = jQuery.propFix[ name ] || name; if ( propName in elem ) { // Only set the IDL specifically if it already exists on the element - elem[ propName ] = value; + elem[ propName ] = true; } elem.setAttribute( name, name.toLowerCase() ); @@ -2366,51 +4724,38 @@ boolHook = { } }; -// Use the value property for back compat -// Use the formHook for button elements in IE6/7 (#1954) -jQuery.attrHooks.value = { - get: function( elem, name ) { - if ( formHook && jQuery.nodeName( elem, "button" ) ) { - return formHook.get( elem, name ); - } - return elem.value; - }, - set: function( elem, value, name ) { - if ( formHook && jQuery.nodeName( elem, "button" ) ) { - return formHook.set( elem, value, name ); - } - // Does not return so that setAttribute is also used - elem.value = value; - } -}; - // IE6/7 do not support getting/setting some attributes with get/setAttribute -if ( !jQuery.support.getSetAttribute ) { +if ( !getSetAttribute ) { - // propFix is more comprehensive and contains all fixes - jQuery.attrFix = jQuery.propFix; - - // Use this for any attribute on a form in IE6/7 - formHook = jQuery.attrHooks.name = jQuery.valHooks.button = { + fixSpecified = { + name: true, + id: true + }; + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { get: function( elem, name ) { var ret; ret = elem.getAttributeNode( name ); - // Return undefined if nodeValue is empty string - return ret && ret.nodeValue !== "" ? + return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? ret.nodeValue : undefined; }, set: function( elem, value, name ) { - // Check form objects in IE (multiple bugs related) - // Only use nodeValue if the attribute node exists on the form + // Set the existing or create a new attribute node var ret = elem.getAttributeNode( name ); - if ( ret ) { - ret.nodeValue = value; - return value; + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); } + return ( ret.nodeValue = value + "" ); } }; + // Apply the nodeHook to tabindex + jQuery.attrHooks.tabindex.set = nodeHook.set; + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) // This is for removals jQuery.each([ "width", "height" ], function( i, name ) { @@ -2423,6 +4768,18 @@ if ( !jQuery.support.getSetAttribute ) { } }); }); + + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + if ( value === "" ) { + value = "false"; + } + nodeHook.set( elem, value, name ); + } + }; } @@ -2446,7 +4803,7 @@ if ( !jQuery.support.style ) { return elem.style.cssText.toLowerCase() || undefined; }, set: function( elem, value ) { - return (elem.style.cssText = "" + value); + return ( elem.style.cssText = "" + value ); } }; } @@ -2466,10 +4823,16 @@ if ( !jQuery.support.optSelected ) { parent.parentNode.selectedIndex; } } + return null; } }); } +// IE6/7 call enctype encoding +if ( !jQuery.support.enctype ) { + jQuery.propFix.enctype = "encoding"; +} + // Radios and checkboxes getter/setter if ( !jQuery.support.checkOn ) { jQuery.each([ "radio", "checkbox" ], function() { @@ -2485,7 +4848,7 @@ jQuery.each([ "radio", "checkbox" ], function() { jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { set: function( elem, value ) { if ( jQuery.isArray( value ) ) { - return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0); + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); } } }); @@ -2494,117 +4857,118 @@ jQuery.each([ "radio", "checkbox" ], function() { -var hasOwn = Object.prototype.hasOwnProperty, - rnamespaces = /\.(.*)$/, - rformElems = /^(?:textarea|input|select)$/i, - rperiod = /\./g, - rspaces = / /g, - rescape = /[^\w\s.|`]/g, - fcleanup = function( nm ) { - return nm.replace(rescape, "\\$&"); +var rformElems = /^(?:textarea|input|select)$/i, + rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, + rhoverHack = /\bhover(\.\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[3] + "(?:\\s|$)" ); + } + 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( rhoverHack, "mouseenter$1 mouseleave$1" ); }; /* - * A number of helper functions used for managing events. - * Many of the ideas behind this code originated from - * Dean Edwards' addEvent library. + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. */ jQuery.event = { - // Bind an event to an element - // Original by Dean Edwards - add: function( elem, types, handler, data ) { - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + add: function( elem, types, handler, data, selector ) { + + var elemData, eventHandle, events, + t, tns, type, namespaces, handleObj, + handleObjIn, quick, handlers, special; + + // Don't attach events to noData or text/comment nodes (allow plain objects tho) + if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { return; } - if ( handler === false ) { - handler = returnFalse; - } else if ( !handler ) { - // Fixes bug #7229. Fix recommended by jdalton - return; - } - - var handleObjIn, handleObj; - + // Caller can pass in an object of custom data in lieu of the handler if ( handler.handler ) { handleObjIn = handler; handler = handleObjIn.handler; } - // Make sure that the function being executed has a unique ID + // Make sure that the handler has a unique ID, used to find/remove it later if ( !handler.guid ) { handler.guid = jQuery.guid++; } - // Init the element's event structure - var elemData = jQuery._data( elem ); - - // If no elemData is found then we must be trying to bind to one of the - // banned noData elements - if ( !elemData ) { - return; - } - - var events = elemData.events, - eventHandle = elemData.handle; - + // Init the element's event structure and main handler, if this is the first + events = elemData.events; if ( !events ) { elemData.events = events = {}; } - + eventHandle = elemData.handle; if ( !eventHandle ) { elemData.handle = eventHandle = function( e ) { // Discard the second event of a jQuery.event.trigger() and // when an event is called after a page has unloaded return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? - jQuery.event.handle.apply( eventHandle.elem, arguments ) : + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : undefined; }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; } - // Add elem as a property of the handle function - // This is to prevent a memory leak with non-native events in IE. - eventHandle.elem = elem; - // Handle multiple events separated by a space // jQuery(...).bind("mouseover mouseout", fn); - types = types.split(" "); + types = jQuery.trim( hoverHack(types) ).split( " " ); + for ( t = 0; t < types.length; t++ ) { - var type, i = 0, namespaces; + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = ( tns[2] || "" ).split( "." ).sort(); - while ( (type = types[ i++ ]) ) { - handleObj = handleObjIn ? - jQuery.extend({}, handleObjIn) : - { handler: handler, data: data }; + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; - // Namespaced event handlers - if ( type.indexOf(".") > -1 ) { - namespaces = type.split("."); - type = namespaces.shift(); - handleObj.namespace = namespaces.slice(0).sort().join("."); + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; - } else { - namespaces = []; - handleObj.namespace = ""; - } + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; - handleObj.type = type; - if ( !handleObj.guid ) { - handleObj.guid = handler.guid; - } + // 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: quickParse( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); - // Get the current list of functions bound to this event - var handlers = events[ type ], - special = jQuery.event.special[ type ] || {}; - - // Init the event handler queue + // Init the event handler queue if we're the first + handlers = events[ type ]; if ( !handlers ) { handlers = events[ type ] = []; + handlers.delegateCount = 0; - // Check for a special event handler - // Only use addEventListener/attachEvent if the special - // events handler returns false + // Only use addEventListener/attachEvent if the special events handler returns false if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { // Bind the global event handler to the element if ( elem.addEventListener ) { @@ -2624,10 +4988,14 @@ jQuery.event = { } } - // Add the function to the element's handler list - handlers.push( handleObj ); + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } - // Keep track of which events have been used, for event optimization + // Keep track of which events have ever been used, for event optimization jQuery.event.global[ type ] = true; } @@ -2638,129 +5006,80 @@ jQuery.event = { global: {}, // Detach an event or set of events from an element - remove: function( elem, types, handler, pos ) { - // don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + remove: function( elem, types, handler, selector, mappedTypes ) { + + var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + t, tns, type, origType, namespaces, origCount, + j, events, special, handle, eventType, handleObj; + + if ( !elemData || !(events = elemData.events) ) { return; } - if ( handler === false ) { - handler = returnFalse; - } + // 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]; - var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, - elemData = jQuery.hasData( elem ) && jQuery._data( elem ), - events = elemData && elemData.events; - - if ( !elemData || !events ) { - return; - } - - // types is actually an event object here - if ( types && types.type ) { - handler = types.handler; - types = types.type; - } - - // Unbind all events for the element - if ( !types || typeof types === "string" && types.charAt(0) === "." ) { - types = types || ""; - - for ( type in events ) { - jQuery.event.remove( elem, type + types ); - } - - return; - } - - // Handle multiple events separated by a space - // jQuery(...).unbind("mouseover mouseout", fn); - types = types.split(" "); - - while ( (type = types[ i++ ]) ) { - origType = type; - handleObj = null; - all = type.indexOf(".") < 0; - namespaces = []; - - if ( !all ) { - // Namespaced event handlers - namespaces = type.split("."); - type = namespaces.shift(); - - namespace = new RegExp("(^|\\.)" + - jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); - } - - eventType = events[ type ]; - - if ( !eventType ) { - continue; - } - - if ( !handler ) { - for ( j = 0; j < eventType.length; j++ ) { - handleObj = eventType[ j ]; - - if ( all || namespace.test( handleObj.namespace ) ) { - jQuery.event.remove( elem, origType, handleObj.handler, j ); - eventType.splice( j--, 1 ); - } + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); } - continue; } special = jQuery.event.special[ type ] || {}; + type = ( selector? special.delegateType : special.bindType ) || type; + eventType = events[ type ] || []; + origCount = eventType.length; + namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; - for ( j = pos || 0; j < eventType.length; j++ ) { + // Remove matching events + for ( j = 0; j < eventType.length; j++ ) { handleObj = eventType[ j ]; - if ( handler.guid === handleObj.guid ) { - // remove the given handler for the given type - if ( all || namespace.test( handleObj.namespace ) ) { - if ( pos == null ) { - eventType.splice( j--, 1 ); - } + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !namespaces || namespaces.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + eventType.splice( j--, 1 ); - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } + if ( handleObj.selector ) { + eventType.delegateCount--; } - - if ( pos != null ) { - break; + if ( special.remove ) { + special.remove.call( elem, handleObj ); } } } - // remove generic event handler if no more handlers exist - if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( eventType.length === 0 && origCount !== eventType.length ) { if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { jQuery.removeEvent( elem, type, elemData.handle ); } - ret = null; delete events[ type ]; } } // Remove the expando if it's no longer used if ( jQuery.isEmptyObject( events ) ) { - var handle = elemData.handle; + handle = elemData.handle; if ( handle ) { handle.elem = null; } - delete elemData.events; - delete elemData.handle; - - if ( jQuery.isEmptyObject( elemData ) ) { - jQuery.removeData( elem, undefined, true ); - } + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery.removeData( elem, [ "events", "handle" ], true ); } }, - + // Events that are safe to short-circuit if no handlers are attached. // Native DOM events should not be added, they may have inline handlers. customEvent: { @@ -2770,18 +5089,28 @@ jQuery.event = { }, 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 = [], - exclusive; + cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; - if ( type.indexOf("!") >= 0 ) { + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf( "!" ) >= 0 ) { // Exclusive events trigger only for the exact event (no namespaces) type = type.slice(0, -1); exclusive = true; } - if ( type.indexOf(".") >= 0 ) { + if ( type.indexOf( "." ) >= 0 ) { // Namespaced trigger; create a regexp to match event type in handle() namespaces = type.split("."); type = namespaces.shift(); @@ -2803,230 +5132,299 @@ jQuery.event = { new jQuery.Event( type ); event.type = type; + event.isTrigger = true; event.exclusive = exclusive; - event.namespace = namespaces.join("."); - event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); - - // triggerHandler() and global events don't bubble or run the default action - if ( onlyHandlers || !elem ) { - event.preventDefault(); - event.stopPropagation(); - } + event.namespace = namespaces.join( "." ); + event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; // Handle a global trigger if ( !elem ) { - // TODO: Stop taunting the data cache; remove global events and always attach to document - jQuery.each( jQuery.cache, function() { - // internalKey variable is just used to make it easier to find - // and potentially change this stuff later; currently it just - // points to jQuery.expando - var internalKey = jQuery.expando, - internalCache = this[ internalKey ]; - if ( internalCache && internalCache.events && internalCache.events[ type ] ) { - jQuery.event.trigger( event, data, internalCache.handle.elem ); - } - }); - return; - } - // Don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + // TODO: Stop taunting the data cache; remove global events and always attach to document + cache = jQuery.cache; + for ( i in cache ) { + if ( cache[ i ].events && cache[ i ].events[ type ] ) { + jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); + } + } return; } // Clean up the event in case it is being reused event.result = undefined; - event.target = elem; + if ( !event.target ) { + event.target = elem; + } // Clone any incoming data and prepend the event, creating the handler arg list - data = data ? jQuery.makeArray( data ) : []; + data = data != null ? jQuery.makeArray( data ) : []; data.unshift( event ); - var cur = elem, - // IE doesn't like method names with a colon (#3533, #8272) - ontype = type.indexOf(":") < 0 ? "on" + type : ""; + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } - // Fire event on the current element, then bubble up the DOM tree - do { - var handle = jQuery._data( cur, "handle" ); + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + eventPath = [[ elem, special.bindType || type ]]; + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { - event.currentTarget = cur; + bubbleType = special.delegateType || type; + cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; + old = null; + for ( ; cur; cur = cur.parentNode ) { + eventPath.push([ cur, bubbleType ]); + old = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( old && old === elem.ownerDocument ) { + eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); + } + } + + // Fire handlers on the event path + for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { + + cur = eventPath[i][0]; + event.type = eventPath[i][1]; + + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); if ( handle ) { handle.apply( cur, data ); } - - // Trigger an inline bound script - if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) { - event.result = false; + // Note that this is a bare JS function and not a jQuery handler + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { event.preventDefault(); } - - // Bubble up to document, then to window - cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window; - } while ( cur && !event.isPropagationStopped() ); + } + event.type = type; // If nobody prevented the default action, do it now - if ( !event.isDefaultPrevented() ) { - var old, - special = jQuery.event.special[ type ] || {}; + if ( !onlyHandlers && !event.isDefaultPrevented() ) { - if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) && + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction)() check here because IE6/7 fails that test. - // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch. - try { - if ( ontype && elem[ type ] ) { - // Don't re-trigger an onFOO event when we call its FOO() method - old = elem[ ontype ]; + // Can't use an .isFunction() check here because IE6/7 fails that test. + // Don't do default actions on window, that's where global variables be (#6170) + // IE<9 dies on focus/blur to hidden element (#1486) + if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { - if ( old ) { - elem[ ontype ] = null; - } + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; - jQuery.event.triggered = type; - elem[ type ](); + if ( old ) { + elem[ ontype ] = null; } - } catch ( ieError ) {} - if ( old ) { - elem[ ontype ] = old; + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( old ) { + elem[ ontype ] = old; + } } - - jQuery.event.triggered = undefined; } } - + return event.result; }, - handle: function( event ) { + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object event = jQuery.event.fix( event || window.event ); - // Snapshot the handlers list since a called handler may add/remove events. - var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0), + + var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), + delegateCount = handlers.delegateCount, + args = [].slice.call( arguments, 0 ), run_all = !event.exclusive && !event.namespace, - args = Array.prototype.slice.call( arguments, 0 ); + handlerQueue = [], + i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related; - // Use the fix-ed Event rather than the (read-only) native event + // Use the fix-ed jQuery.Event rather than the (read-only) native event args[0] = event; - event.currentTarget = this; + event.delegateTarget = this; - for ( var j = 0, l = handlers.length; j < l; j++ ) { - var handleObj = handlers[ j ]; + // Determine handlers that should run if there are delegated events + // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) + if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { - // Triggered event must 1) be non-exclusive and have no namespace, or - // 2) have namespace(s) a subset or equal to those in the bound event. - if ( run_all || event.namespace_re.test( handleObj.namespace ) ) { - // Pass in a reference to the handler function itself - // So that we can later remove it - event.handler = handleObj.handler; - event.data = handleObj.data; - event.handleObj = handleObj; + // Pregenerate a single jQuery object for reuse with .is() + jqcur = jQuery(this); + jqcur.context = this.ownerDocument || this; - var ret = handleObj.handler.apply( this, args ); + for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { + selMatch = {}; + matches = []; + jqcur[0] = cur; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + sel = handleObj.selector; - if ( ret !== undefined ) { - event.result = ret; - if ( ret === false ) { - event.preventDefault(); - event.stopPropagation(); + if ( selMatch[ sel ] === undefined ) { + selMatch[ sel ] = ( + handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) + ); + } + if ( selMatch[ sel ] ) { + matches.push( handleObj ); } } - - if ( event.isImmediatePropagationStopped() ) { - break; + if ( matches.length ) { + handlerQueue.push({ elem: cur, matches: matches }); } } } + + // Add the remaining (directly-bound) handlers + if ( handlers.length > delegateCount ) { + handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); + } + + // Run delegates first; they may want to stop propagation beneath us + for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { + matched = handlerQueue[ i ]; + event.currentTarget = matched.elem; + + for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { + handleObj = matched.matches[ j ]; + + // Triggered event must either 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { + + event.data = handleObj.data; + event.handleObj = handleObj; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + return event.result; }, - props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), + // Includes some event props shared by KeyEvent and MouseEvent + // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, fix: function( event ) { if ( event[ jQuery.expando ] ) { return event; } - // store a copy of the original event object - // and "clone" to set read-only properties - var originalEvent = event; + // Create a writable copy of the event object and normalize some properties + var i, prop, + originalEvent = event, + fixHook = jQuery.event.fixHooks[ event.type ] || {}, + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + event = jQuery.Event( originalEvent ); - for ( var i = this.props.length, prop; i; ) { - prop = this.props[ --i ]; + for ( i = copy.length; i; ) { + prop = copy[ --i ]; event[ prop ] = originalEvent[ prop ]; } - // Fix target property, if necessary + // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) if ( !event.target ) { - // Fixes #1925 where srcElement might not be defined either - event.target = event.srcElement || document; + event.target = originalEvent.srcElement || document; } - // check if target is a textnode (safari) + // Target should not be a text node (#504, Safari) if ( event.target.nodeType === 3 ) { event.target = event.target.parentNode; } - // Add relatedTarget, if necessary - if ( !event.relatedTarget && event.fromElement ) { - event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; - } - - // Calculate pageX/Y if missing and clientX/Y available - if ( event.pageX == null && event.clientX != null ) { - var eventDocument = event.target.ownerDocument || document, - doc = eventDocument.documentElement, - body = eventDocument.body; - - event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); - event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); - } - - // Add which for key events - if ( event.which == null && (event.charCode != null || event.keyCode != null) ) { - event.which = event.charCode != null ? event.charCode : event.keyCode; - } - - // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) - if ( !event.metaKey && event.ctrlKey ) { + // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) + if ( event.metaKey === undefined ) { event.metaKey = event.ctrlKey; } - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if ( !event.which && event.button !== undefined ) { - event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); - } - - return event; + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; }, - // Deprecated, use jQuery.guid instead - guid: 1E8, - - // Deprecated, use jQuery.proxy instead - proxy: jQuery.proxy, - special: { ready: { // Make sure the ready event is setup - setup: jQuery.bindReady, - teardown: jQuery.noop + setup: jQuery.bindReady }, - live: { - add: function( handleObj ) { - jQuery.event.add( this, - liveConvert( handleObj.origType, handleObj.selector ), - jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); - }, + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, - remove: function( handleObj ) { - jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj ); - } + focus: { + delegateType: "focusin" + }, + blur: { + delegateType: "focusout" }, beforeunload: { @@ -3043,9 +5441,35 @@ jQuery.event = { } } } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } } }; +// Some plugins are using, but it's undocumented/deprecated and will be removed. +// The 1.7 special event interface should provide all the hooks needed now. +jQuery.event.handle = jQuery.event.dispatch; + jQuery.removeEvent = document.removeEventListener ? function( elem, type, handle ) { if ( elem.removeEventListener ) { @@ -3060,7 +5484,7 @@ jQuery.removeEvent = document.removeEventListener ? jQuery.Event = function( src, props ) { // Allow instantiation without the 'new' keyword - if ( !this.preventDefault ) { + if ( !(this instanceof jQuery.Event) ) { return new jQuery.Event( src, props ); } @@ -3071,8 +5495,8 @@ jQuery.Event = function( src, props ) { // Events bubbling up the document may have been marked as prevented // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || - src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; // Event type } else { @@ -3084,9 +5508,8 @@ jQuery.Event = function( src, props ) { jQuery.extend( this, props ); } - // timeStamp is buggy for some events on Firefox(#3843) - // So we won't rely on the native value - this.timeStamp = jQuery.now(); + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); // Mark it as fixed this[ jQuery.expando ] = true; @@ -3142,221 +5565,130 @@ jQuery.Event.prototype = { isImmediatePropagationStopped: returnFalse }; -// Checks if an event happened on an element within another element -// Used in jQuery.event.special.mouseenter and mouseleave handlers -var withinElement = function( event ) { - // Check if mouse(over|out) are still within the same parent element - var parent = event.relatedTarget; - - // set the correct event type - event.type = event.data; - - // Firefox sometimes assigns relatedTarget a XUL element - // which we cannot access the parentNode property of - try { - - // Chrome does something similar, the parentNode property - // can be accessed but is null. - if ( parent && parent !== document && !parent.parentNode ) { - return; - } - - // Traverse up the tree - while ( parent && parent !== this ) { - parent = parent.parentNode; - } - - if ( parent !== this ) { - // handle event if we actually just moused on to a non sub-element - jQuery.event.handle.apply( this, arguments ); - } - - // assuming we've left the element since we most likely mousedover a xul element - } catch(e) { } -}, - -// In case of event delegation, we only need to rename the event.type, -// liveHandler will take care of the rest. -delegate = function( event ) { - event.type = event.data; - jQuery.event.handle.apply( this, arguments ); -}; - -// Create mouseenter and mouseleave events +// Create mouseenter/leave events using mouseover/out and event-time checks jQuery.each({ mouseenter: "mouseover", mouseleave: "mouseout" }, function( orig, fix ) { jQuery.event.special[ orig ] = { - setup: function( data ) { - jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig ); - }, - teardown: function( data ) { - jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement ); + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var target = this, + related = event.relatedTarget, + handleObj = event.handleObj, + selector = handleObj.selector, + ret; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; } }; }); -// submit delegation +// IE submit delegation if ( !jQuery.support.submitBubbles ) { jQuery.event.special.submit = { - setup: function( data, namespaces ) { - if ( !jQuery.nodeName( this, "form" ) ) { - jQuery.event.add(this, "click.specialSubmit", function( e ) { - var elem = e.target, - type = elem.type; - - if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { - trigger( "submit", this, arguments ); - } - }); - - jQuery.event.add(this, "keypress.specialSubmit", function( e ) { - var elem = e.target, - type = elem.type; - - if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { - trigger( "submit", this, arguments ); - } - }); - - } else { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { return false; } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !form._submit_attached ) { + jQuery.event.add( form, "submit._submit", function( event ) { + // If form was submitted by the user, bubble the event up the tree + if ( this.parentNode && !event.isTrigger ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + }); + form._submit_attached = true; + } + }); + // return undefined since we don't need an event listener }, - teardown: function( namespaces ) { - jQuery.event.remove( this, ".specialSubmit" ); + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); } }; - } -// change delegation, happens here so we have bind. +// IE change delegation and checkbox/radio fix if ( !jQuery.support.changeBubbles ) { - var changeFilters, - - getVal = function( elem ) { - var type = elem.type, val = elem.value; - - if ( type === "radio" || type === "checkbox" ) { - val = elem.checked; - - } else if ( type === "select-multiple" ) { - val = elem.selectedIndex > -1 ? - jQuery.map( elem.options, function( elem ) { - return elem.selected; - }).join("-") : - ""; - - } else if ( jQuery.nodeName( elem, "select" ) ) { - val = elem.selectedIndex; - } - - return val; - }, - - testChange = function testChange( e ) { - var elem = e.target, data, val; - - if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) { - return; - } - - data = jQuery._data( elem, "_change_data" ); - val = getVal(elem); - - // the current data will be also retrieved by beforeactivate - if ( e.type !== "focusout" || elem.type !== "radio" ) { - jQuery._data( elem, "_change_data", val ); - } - - if ( data === undefined || val === data ) { - return; - } - - if ( data != null || val ) { - e.type = "change"; - e.liveFired = undefined; - jQuery.event.trigger( e, arguments[1], elem ); - } - }; - jQuery.event.special.change = { - filters: { - focusout: testChange, - beforedeactivate: testChange, + setup: function() { - click: function( e ) { - var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; - - if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) { - testChange.call( this, e ); + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed && !event.isTrigger ) { + this._just_changed = false; + jQuery.event.simulate( "change", this, event, true ); + } + }); } - }, - - // Change has to be called before submit - // Keydown will be called before keypress, which is used in submit-event delegation - keydown: function( e ) { - var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; - - if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) || - (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || - type === "select-multiple" ) { - testChange.call( this, e ); - } - }, - - // Beforeactivate happens also before the previous element is blurred - // with this event you can't trigger a change event, but you can store - // information - beforeactivate: function( e ) { - var elem = e.target; - jQuery._data( elem, "_change_data", getVal(elem) ); - } - }, - - setup: function( data, namespaces ) { - if ( this.type === "file" ) { return false; } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; - for ( var type in changeFilters ) { - jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); - } - - return rformElems.test( this.nodeName ); + if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + elem._change_attached = true; + } + }); }, - teardown: function( namespaces ) { - jQuery.event.remove( this, ".specialChange" ); + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); return rformElems.test( this.nodeName ); } }; - - changeFilters = jQuery.event.special.change.filters; - - // Handle when the input is .focus()'d - changeFilters.focus = changeFilters.beforeactivate; -} - -function trigger( type, elem, args ) { - // Piggyback on a donor event to simulate a different one. - // Fake originalEvent to avoid donor's stopPropagation, but if the - // simulated event prevents default then we do the same on the donor. - // Don't pass args or remember liveFired; they apply to the donor event. - var event = jQuery.extend( {}, args[ 0 ] ); - event.type = type; - event.originalEvent = {}; - event.liveFired = undefined; - jQuery.event.handle.call( elem, event ); - if ( event.isDefaultPrevented() ) { - args[ 0 ].preventDefault(); - } } // Create "bubbling" focus and blur events @@ -3364,7 +5696,10 @@ if ( !jQuery.support.focusinBubbles ) { jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { // Attach a single capturing handler while someone wants focusin/focusout - var attaches = 0; + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; jQuery.event.special[ fix ] = { setup: function() { @@ -3378,89 +5713,120 @@ if ( !jQuery.support.focusinBubbles ) { } } }; - - function handler( donor ) { - // Donor event is always a native one; fix it and switch its type. - // Let focusin/out handler cancel the donor focus/blur event. - var e = jQuery.event.fix( donor ); - e.type = fix; - e.originalEvent = {}; - jQuery.event.trigger( e, null, e.target ); - if ( e.isDefaultPrevented() ) { - donor.preventDefault(); - } - } }); } -jQuery.each(["bind", "one"], function( i, name ) { - jQuery.fn[ name ] = function( type, data, fn ) { - var handler; +jQuery.fn.extend({ - // Handle object literals - if ( typeof type === "object" ) { - for ( var key in type ) { - this[ name ](key, data, type[key], fn); + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); } return this; } - if ( arguments.length === 2 || data === false ) { - fn = data; - data = undefined; + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; } - if ( name === "one" ) { - handler = function( event ) { - jQuery( this ).unbind( event, handler ); - return fn.apply( this, arguments ); + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); }; - handler.guid = fn.guid || jQuery.guid++; - } else { - handler = fn; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); } - - if ( type === "unload" && name !== "one" ) { - this.one( type, data, fn ); - - } else { - for ( var i = 0, l = this.length; i < l; i++ ) { - jQuery.event.add( this[i], type, handler, data ); + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on.call( this, 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.type + "." + handleObj.namespace : handleObj.type, + 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 ); + }); + }, + bind: function( types, data, fn ) { + return this.on( types, null, data, fn ); + }, + unbind: function( types, fn ) { + return this.off( types, null, fn ); + }, + + live: function( types, data, fn ) { + jQuery( this.context ).on( types, this.selector, data, fn ); return this; - }; -}); - -jQuery.fn.extend({ - unbind: function( type, fn ) { - // Handle object literals - if ( typeof type === "object" && !type.preventDefault ) { - for ( var key in type ) { - this.unbind(key, type[key]); - } - - } else { - for ( var i = 0, l = this.length; i < l; i++ ) { - jQuery.event.remove( this[i], type, fn ); - } - } - + }, + die: function( types, fn ) { + jQuery( this.context ).off( types, this.selector || "**", fn ); return this; }, delegate: function( selector, types, data, fn ) { - return this.live( types, data, fn, selector ); + return this.on( types, selector, data, fn ); }, - undelegate: function( selector, types, fn ) { - if ( arguments.length === 0 ) { - return this.unbind( "live" ); - - } else { - return this.die( types, null, fn, selector ); - } + // ( namespace ) or ( selector, types [, fn] ) + return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); }, trigger: function( type, data ) { @@ -3468,7 +5834,6 @@ jQuery.fn.extend({ jQuery.event.trigger( type, data, this ); }); }, - triggerHandler: function( type, data ) { if ( this[0] ) { return jQuery.event.trigger( type, data, this[0], true ); @@ -3482,8 +5847,8 @@ jQuery.fn.extend({ i = 0, toggler = function( event ) { // Figure out which function to execute - var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; - jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); // Make sure that clicks stop event.preventDefault(); @@ -3506,178 +5871,9 @@ jQuery.fn.extend({ } }); -var liveMap = { - focus: "focusin", - blur: "focusout", - mouseenter: "mouseover", - mouseleave: "mouseout" -}; - -jQuery.each(["live", "die"], function( i, name ) { - jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) { - var type, i = 0, match, namespaces, preType, - selector = origSelector || this.selector, - context = origSelector ? this : jQuery( this.context ); - - if ( typeof types === "object" && !types.preventDefault ) { - for ( var key in types ) { - context[ name ]( key, data, types[key], selector ); - } - - return this; - } - - if ( name === "die" && !types && - origSelector && origSelector.charAt(0) === "." ) { - - context.unbind( origSelector ); - - return this; - } - - if ( data === false || jQuery.isFunction( data ) ) { - fn = data || returnFalse; - data = undefined; - } - - types = (types || "").split(" "); - - while ( (type = types[ i++ ]) != null ) { - match = rnamespaces.exec( type ); - namespaces = ""; - - if ( match ) { - namespaces = match[0]; - type = type.replace( rnamespaces, "" ); - } - - if ( type === "hover" ) { - types.push( "mouseenter" + namespaces, "mouseleave" + namespaces ); - continue; - } - - preType = type; - - if ( liveMap[ type ] ) { - types.push( liveMap[ type ] + namespaces ); - type = type + namespaces; - - } else { - type = (liveMap[ type ] || type) + namespaces; - } - - if ( name === "live" ) { - // bind live handler - for ( var j = 0, l = context.length; j < l; j++ ) { - jQuery.event.add( context[j], "live." + liveConvert( type, selector ), - { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); - } - - } else { - // unbind live handler - context.unbind( "live." + liveConvert( type, selector ), fn ); - } - } - - return this; - }; -}); - -function liveHandler( event ) { - var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, - elems = [], - selectors = [], - events = jQuery._data( this, "events" ); - - // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) - if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) { - return; - } - - if ( event.namespace ) { - namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); - } - - event.liveFired = this; - - var live = events.live.slice(0); - - for ( j = 0; j < live.length; j++ ) { - handleObj = live[j]; - - if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) { - selectors.push( handleObj.selector ); - - } else { - live.splice( j--, 1 ); - } - } - - match = jQuery( event.target ).closest( selectors, event.currentTarget ); - - for ( i = 0, l = match.length; i < l; i++ ) { - close = match[i]; - - for ( j = 0; j < live.length; j++ ) { - handleObj = live[j]; - - if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) { - elem = close.elem; - related = null; - - // Those two events require additional checking - if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { - event.type = handleObj.preType; - related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; - - // Make sure not to accidentally match a child element with the same selector - if ( related && jQuery.contains( elem, related ) ) { - related = elem; - } - } - - if ( !related || related !== elem ) { - elems.push({ elem: elem, handleObj: handleObj, level: close.level }); - } - } - } - } - - for ( i = 0, l = elems.length; i < l; i++ ) { - match = elems[i]; - - if ( maxLevel && match.level > maxLevel ) { - break; - } - - event.currentTarget = match.elem; - event.data = match.handleObj.data; - event.handleObj = match.handleObj; - - ret = match.handleObj.origHandler.apply( match.elem, arguments ); - - if ( ret === false || event.isPropagationStopped() ) { - maxLevel = match.level; - - if ( ret === false ) { - stop = false; - } - if ( event.isImmediatePropagationStopped() ) { - break; - } - } - } - - return stop; -} - -function liveConvert( type, selector ) { - return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&"); -} - jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup error").split(" "), function( i, name ) { + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { // Handle event binding jQuery.fn[ name ] = function( data, fn ) { @@ -3687,13 +5883,21 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl } return arguments.length > 0 ? - this.bind( name, data, fn ) : + 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; + } + + if ( rmouseEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; + } }); @@ -3707,11 +5911,13 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl (function(){ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + 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 @@ -3763,7 +5969,7 @@ var Sizzle = function( selector, context, results, seed ) { if ( parts.length > 1 && origPOS.exec( selector ) ) { if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { - set = posProcess( parts[0] + parts[1], context ); + set = posProcess( parts[0] + parts[1], context, seed ); } else { set = Expr.relative[ parts[0] ] ? @@ -3777,7 +5983,7 @@ var Sizzle = function( selector, context, results, seed ) { selector += parts.shift(); } - set = posProcess( selector, set ); + set = posProcess( selector, set, seed ); } } @@ -3896,18 +6102,17 @@ Sizzle.matchesSelector = function( node, expr ) { }; Sizzle.find = function( expr, context, isXML ) { - var set; + var set, i, len, match, type, left; if ( !expr ) { return []; } - for ( var i = 0, l = Expr.order.length; i < l; i++ ) { - var match, - type = Expr.order[i]; + for ( i = 0, len = Expr.order.length; i < len; i++ ) { + type = Expr.order[i]; if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { - var left = match[1]; + left = match[1]; match.splice( 1, 1 ); if ( left.substr( left.length - 1 ) !== "\\" ) { @@ -3933,17 +6138,18 @@ Sizzle.find = function( expr, context, isXML ) { 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] ); while ( expr && set.length ) { - for ( var type in Expr.filter ) { + for ( type in Expr.filter ) { if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { - var found, item, - filter = Expr.filter[ type ], - left = match[1]; + filter = Expr.filter[ type ]; + left = match[1]; anyFound = false; @@ -3969,10 +6175,10 @@ Sizzle.filter = function( expr, set, inplace, not ) { } if ( match ) { - for ( var i = 0; (item = curLoop[i]) != null; i++ ) { + for ( i = 0; (item = curLoop[i]) != null; i++ ) { if ( item ) { found = filter( item, match, i, curLoop ); - var pass = not ^ !!found; + pass = not ^ found; if ( inplace && found != null ) { if ( pass ) { @@ -4023,7 +6229,46 @@ Sizzle.filter = function( expr, set, inplace, not ) { }; Sizzle.error = function( msg ) { - throw "Syntax error, unrecognized expression: " + msg; + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * 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 ) { + // 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, '' ); + } else { + // Traverse it's children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { + ret += getText( elem ); + } + } + } 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 ); + } + } + } + return ret; }; var Expr = Sizzle.selectors = { @@ -4413,7 +6658,7 @@ var Expr = Sizzle.selectors = { return filter( elem, i, match, array ); } else if ( name === "contains" ) { - return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0; + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; } else if ( name === "not" ) { var not = match[3]; @@ -4432,7 +6677,10 @@ var Expr = Sizzle.selectors = { }, CHILD: function( elem, match ) { - var type = match[1], + var first, last, + doneName, parent, cache, + count, diff, + type = match[1], node = elem; switch ( type ) { @@ -4460,18 +6708,18 @@ var Expr = Sizzle.selectors = { return true; case "nth": - var first = match[2], - last = match[3]; + first = match[2]; + last = match[3]; if ( first === 1 && last === 0 ) { return true; } - var doneName = match[0], - parent = elem.parentNode; + doneName = match[0]; + parent = elem.parentNode; - if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { - var count = 0; + if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { + count = 0; for ( node = parent.firstChild; node; node = node.nextSibling ) { if ( node.nodeType === 1 ) { @@ -4479,10 +6727,10 @@ var Expr = Sizzle.selectors = { } } - parent.sizcache = doneName; + parent[ expando ] = doneName; } - var diff = elem.nodeIndex - last; + diff = elem.nodeIndex - last; if ( first === 0 ) { return diff === 0; @@ -4498,7 +6746,7 @@ var Expr = Sizzle.selectors = { }, TAG: function( elem, match ) { - return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; + return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; }, CLASS: function( elem, match ) { @@ -4508,7 +6756,9 @@ var Expr = Sizzle.selectors = { ATTR: function( elem, match ) { var name = match[1], - result = Expr.attrHandle[ name ] ? + result = Sizzle.attr ? + Sizzle.attr( elem, name ) : + Expr.attrHandle[ name ] ? Expr.attrHandle[ name ]( elem ) : elem[ name ] != null ? elem[ name ] : @@ -4519,6 +6769,8 @@ var Expr = Sizzle.selectors = { return result == null ? type === "!=" : + !type && Sizzle.attr ? + result != null : type === "=" ? value === check : type === "*=" ? @@ -4699,26 +6951,6 @@ if ( document.documentElement.compareDocumentPosition ) { }; } -// Utility function for retreiving the text value of an array of DOM nodes -Sizzle.getText = function( elems ) { - var ret = "", elem; - - for ( var i = 0; elems[i]; i++ ) { - elem = elems[i]; - - // Get the text from text nodes and CDATA nodes - if ( elem.nodeType === 3 || elem.nodeType === 4 ) { - ret += elem.nodeValue; - - // Traverse everything else, except comment nodes - } else if ( elem.nodeType !== 8 ) { - ret += Sizzle.getText( elem.childNodes ); - } - } - - return ret; -}; - // Check to see if the browser returns elements by name when // querying by getElementById (and provide a workaround) (function(){ @@ -4996,13 +7228,13 @@ function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { elem = elem[dir]; while ( elem ) { - if ( elem.sizcache === doneName ) { + if ( elem[ expando ] === doneName ) { match = checkSet[elem.sizset]; break; } if ( elem.nodeType === 1 && !isXML ){ - elem.sizcache = doneName; + elem[ expando ] = doneName; elem.sizset = i; } @@ -5029,14 +7261,14 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { elem = elem[dir]; while ( elem ) { - if ( elem.sizcache === doneName ) { + if ( elem[ expando ] === doneName ) { match = checkSet[elem.sizset]; break; } if ( elem.nodeType === 1 ) { if ( !isXML ) { - elem.sizcache = doneName; + elem[ expando ] = doneName; elem.sizset = i; } @@ -5084,7 +7316,7 @@ Sizzle.isXML = function( elem ) { return documentElement ? documentElement.nodeName !== "HTML" : false; }; -var posProcess = function( selector, context ) { +var posProcess = function( selector, context, seed ) { var match, tmpSet = [], later = "", @@ -5100,13 +7332,16 @@ var posProcess = function( selector, context ) { selector = Expr.relative[selector] ? selector + "*" : selector; for ( var i = 0, l = root.length; i < l; i++ ) { - Sizzle( selector, root[i], tmpSet ); + Sizzle( selector, root[i], tmpSet, seed ); } return Sizzle.filter( later, tmpSet ); }; // EXPOSE +// Override sizzle attribute retrieval +Sizzle.attr = jQuery.attr; +Sizzle.selectors.attrMap = {}; jQuery.find = Sizzle; jQuery.expr = Sizzle.selectors; jQuery.expr[":"] = jQuery.expr.filters; @@ -5192,43 +7427,33 @@ jQuery.fn.extend({ }, is: function( selector ) { - return !!selector && ( typeof selector === "string" ? - jQuery.filter( selector, this ).length > 0 : - this.filter( selector ).length > 0 ); + return !!selector && ( + typeof selector === "string" ? + // If this is a positional selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + POS.test( selector ) ? + jQuery( selector, this.context ).index( this[0] ) >= 0 : + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); }, closest: function( selectors, context ) { var ret = [], i, l, cur = this[0]; - // Array + // Array (deprecated as of jQuery 1.7) if ( jQuery.isArray( selectors ) ) { - var match, selector, - matches = {}, - level = 1; + var level = 1; - if ( cur && selectors.length ) { - for ( i = 0, l = selectors.length; i < l; i++ ) { - selector = selectors[i]; + while ( cur && cur.ownerDocument && cur !== context ) { + for ( i = 0; i < selectors.length; i++ ) { - if ( !matches[ selector ] ) { - matches[ selector ] = POS.test( selector ) ? - jQuery( selector, context || this.context ) : - selector; + if ( jQuery( cur ).is( selectors[ i ] ) ) { + ret.push({ selector: selectors[ i ], elem: cur, level: level }); } } - while ( cur && cur.ownerDocument && cur !== context ) { - for ( selector in matches ) { - match = matches[ selector ]; - - if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) { - ret.push({ selector: selector, elem: cur, level: level }); - } - } - - cur = cur.parentNode; - level++; - } + cur = cur.parentNode; + level++; } return ret; @@ -5264,12 +7489,17 @@ jQuery.fn.extend({ // Determine the position of an element within // the matched set of elements index: function( elem ) { - if ( !elem || typeof elem === "string" ) { - return jQuery.inArray( this[0], - // If it receives a string, the selector is used - // If it receives nothing, the siblings are used - elem ? jQuery( elem ) : this.parent().children() ); + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + // Locate the position of the desired element return jQuery.inArray( // If it receives a jQuery object, the first element is used @@ -5340,12 +7570,7 @@ jQuery.each({ } }, function( name, fn ) { jQuery.fn[ name ] = function( until, selector ) { - var ret = jQuery.map( this, fn, until ), - // The variable 'args' was introduced in - // https://github.com/jquery/jquery/commit/52a0238 - // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. - // http://code.google.com/p/v8/issues/detail?id=1050 - args = slice.call(arguments); + var ret = jQuery.map( this, fn, until ); if ( !runtil.test( name ) ) { selector = until; @@ -5361,7 +7586,7 @@ jQuery.each({ ret = ret.reverse(); } - return this.pushStack( ret, name, args.join(",") ); + return this.pushStack( ret, name, slice.call( arguments ).join(",") ); }; }); @@ -5430,7 +7655,7 @@ function winnow( elements, qualifier, keep ) { } else if ( qualifier.nodeType ) { return jQuery.grep(elements, function( elem, i ) { - return (elem === qualifier) === keep; + return ( elem === qualifier ) === keep; }); } else if ( typeof qualifier === "string" ) { @@ -5446,20 +7671,38 @@ function winnow( elements, qualifier, keep ) { } return jQuery.grep(elements, function( elem, i ) { - return (jQuery.inArray( elem, qualifier ) >= 0) === keep; + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; }); } -var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, +function createSafeFragment( document ) { + var list = nodeNames.split( "|" ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; +} + +var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" + + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", + rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rleadingWhitespace = /^\s+/, rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, rtagName = /<([\w:]+)/, rtbody = /", "" ], area: [ 1, "", "" ], _default: [ 0, "", "" ] - }; + }, + safeFragment = createSafeFragment( document ); wrapMap.optgroup = wrapMap.option; wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; @@ -5551,8 +7795,10 @@ jQuery.fn.extend({ }, wrap: function( html ) { - return this.each(function() { - jQuery( this ).wrapAll( html ); + var isFunction = jQuery.isFunction( html ); + + return this.each(function(i) { + jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); }); }, @@ -5586,7 +7832,7 @@ jQuery.fn.extend({ this.parentNode.insertBefore( elem, this ); }); } else if ( arguments.length ) { - var set = jQuery(arguments[0]); + var set = jQuery.clean( arguments ); set.push.apply( set, this.toArray() ); return this.pushStack( set, "before", arguments ); } @@ -5599,7 +7845,7 @@ jQuery.fn.extend({ }); } else if ( arguments.length ) { var set = this.pushStack( this, "after", arguments ); - set.push.apply( set, jQuery(arguments[0]).toArray() ); + set.push.apply( set, jQuery.clean(arguments) ); return set; } }, @@ -5654,7 +7900,7 @@ jQuery.fn.extend({ null; // See if we can take a shortcut and just use innerHTML - } else if ( typeof value === "string" && !rnocache.test( value ) && + } else if ( typeof value === "string" && !rnoInnerhtml.test( value ) && (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { @@ -5780,7 +8026,7 @@ jQuery.fn.extend({ // in certain situations (Bug #8070). // Fragments from the fragment cache must always be cloned and never used // in place. - results.cacheable || (l > 1 && i < lastIndex) ? + results.cacheable || ( l > 1 && i < lastIndex ) ? jQuery.clone( fragment, true, true ) : fragment ); @@ -5809,27 +8055,26 @@ function cloneCopyEvent( src, dest ) { return; } - var internalKey = jQuery.expando, - oldData = jQuery.data( src ), - curData = jQuery.data( dest, oldData ); + var type, i, l, + oldData = jQuery._data( src ), + curData = jQuery._data( dest, oldData ), + events = oldData.events; - // Switch to use the internal data object, if it exists, for the next - // stage of data copying - if ( (oldData = oldData[ internalKey ]) ) { - var events = oldData.events; - curData = curData[ internalKey ] = jQuery.extend({}, oldData); + if ( events ) { + delete curData.handle; + curData.events = {}; - if ( events ) { - delete curData.handle; - curData.events = {}; - - for ( var type in events ) { - for ( var i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data ); - } + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data ); } } } + + // make the cloned public data object a copy from the original + if ( curData.data ) { + curData.data = jQuery.extend( {}, curData.data ); + } } function cloneFixAttributes( src, dest ) { @@ -5891,19 +8136,36 @@ function cloneFixAttributes( src, dest ) { } jQuery.buildFragment = function( args, nodes, scripts ) { - var fragment, cacheable, cacheresults, - doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); + var fragment, cacheable, cacheresults, doc, + first = args[ 0 ]; + + // 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]; + } + + // Ensure that an attr object doesn't incorrectly stand in as a document object + // Chrome and Firefox seem to allow this to occur and will throw exception + // Fixes #8950 + if ( !doc.createDocumentFragment ) { + doc = document; + } // Only cache "small" (1/2 KB) HTML strings that are associated with the main document // Cloning options loses the selected state, so don't cache them // IE 6 doesn't like it when you put or elements in a fragment // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache - if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document && - args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) { + // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 + if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document && + first.charAt(0) === "<" && !rnocache.test( first ) && + (jQuery.support.checkClone || !rchecked.test( first )) && + (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) { cacheable = true; - cacheresults = jQuery.fragments[ args[0] ]; + cacheresults = jQuery.fragments[ first ]; if ( cacheresults && cacheresults !== 1 ) { fragment = cacheresults; } @@ -5915,7 +8177,7 @@ jQuery.buildFragment = function( args, nodes, scripts ) { } if ( cacheable ) { - jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; + jQuery.fragments[ first ] = cacheresults ? fragment : 1; } return { fragment: fragment, cacheable: cacheable }; @@ -5941,7 +8203,7 @@ jQuery.each({ } else { for ( var i = 0, l = insert.length; i < l; i++ ) { - var elems = (i > 0 ? this.clone(true) : this).get(); + var elems = ( i > 0 ? this.clone(true) : this ).get(); jQuery( insert[i] )[ original ]( elems ); ret = ret.concat( elems ); } @@ -5952,10 +8214,10 @@ jQuery.each({ }); function getAll( elem ) { - if ( "getElementsByTagName" in elem ) { + if ( typeof elem.getElementsByTagName !== "undefined" ) { return elem.getElementsByTagName( "*" ); - } else if ( "querySelectorAll" in elem ) { + } else if ( typeof elem.querySelectorAll !== "undefined" ) { return elem.querySelectorAll( "*" ); } else { @@ -5971,19 +8233,33 @@ function fixDefaultChecked( elem ) { } // Finds all inputs and passes them to fixDefaultChecked function findInputs( elem ) { - if ( jQuery.nodeName( elem, "input" ) ) { + var nodeName = ( elem.nodeName || "" ).toLowerCase(); + if ( nodeName === "input" ) { fixDefaultChecked( elem ); - } else if ( elem.getElementsByTagName ) { + // Skip scripts, get other children + } else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) { jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked ); } } +// 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({ clone: function( elem, dataAndEvents, deepDataAndEvents ) { - var clone = elem.cloneNode(true), - srcElements, - destElements, - i; + var srcElements, + destElements, + i, + // IE<=8 does not properly clone detached, unknown element nodes + clone = jQuery.support.html5Clone || !rnoshimcache.test( "<" + elem.nodeName ) ? + elem.cloneNode( true ) : + shimCloneNode( elem ); if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { @@ -5995,8 +8271,7 @@ jQuery.extend({ cloneFixAttributes( elem, clone ); - // Using Sizzle here is crazy slow, so we use getElementsByTagName - // instead + // Using Sizzle here is crazy slow, so we use getElementsByTagName instead srcElements = getAll( elem ); destElements = getAll( clone ); @@ -6004,7 +8279,10 @@ jQuery.extend({ // with an element if you are cloning the body and one of the // elements on the page has a name or id of "length" for ( i = 0; srcElements[i]; ++i ) { - cloneFixAttributes( srcElements[i], destElements[i] ); + // Ensure that the destination node is not null; Fixes #9587 + if ( destElements[i] ) { + cloneFixAttributes( srcElements[i], destElements[i] ); + } } } @@ -6022,6 +8300,8 @@ jQuery.extend({ } } + srcElements = destElements = null; + // Return the cloned set return clone; }, @@ -6056,11 +8336,20 @@ jQuery.extend({ elem = elem.replace(rxhtmlTag, "<$1>"); // Trim whitespace, otherwise indexOf won't work as expected - var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), + var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(), wrap = wrapMap[ tag ] || wrapMap._default, depth = wrap[0], div = context.createElement("div"); + // Append wrapper element to unknown element safe doc fragment + if ( context === document ) { + // Use the fragment we've already created for this document + safeFragment.appendChild( div ); + } else { + // Use a fragment created with the owner document + createSafeFragment( context ).appendChild( div ); + } + // Go to html and back, then peel off extra wrappers div.innerHTML = wrap[1] + elem + wrap[2]; @@ -6141,7 +8430,9 @@ jQuery.extend({ }, cleanData: function( elems ) { - var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special, + var data, id, + cache = jQuery.cache, + special = jQuery.event.special, deleteExpando = jQuery.support.deleteExpando; for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { @@ -6152,7 +8443,7 @@ jQuery.extend({ id = elem[ jQuery.expando ]; if ( id ) { - data = cache[ id ] && cache[ id ][ internalKey ]; + data = cache[ id ]; if ( data && data.events ) { for ( var type in data.events ) { @@ -6205,13 +8496,11 @@ function evalScript( i, elem ) { var ralpha = /alpha\([^)]*\)/i, ropacity = /opacity=([^)]*)/, - rdashAlpha = /-([a-z])/ig, // fixed for IE9, see #8346 rupper = /([A-Z]|^ms)/g, rnumpx = /^-?\d+(?:px)?$/i, rnum = /^-?\d/, - rrelNum = /^[+\-]=/, - rrelNumFilter = /[^+\-\.\de]+/g, + rrelNum = /^([\-+])=([\-+.\de]+)/, cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssWidth = [ "Left", "Right" ], @@ -6219,11 +8508,7 @@ var ralpha = /alpha\([^)]*\)/i, curCSS, getComputedStyle, - currentStyle, - - fcamelCase = function( all, letter ) { - return letter.toUpperCase(); - }; + currentStyle; jQuery.fn.css = function( name, value ) { // Setting 'undefined' is a no-op @@ -6258,13 +8543,14 @@ jQuery.extend({ // Exclude the following css properties to add px cssNumber: { - "zIndex": true, + "fillOpacity": true, "fontWeight": true, - "opacity": true, - "zoom": true, "lineHeight": true, + "opacity": true, + "orphans": true, "widows": true, - "orphans": true + "zIndex": true, + "zoom": true }, // Add in properties whose names you wish to fix before @@ -6291,14 +8577,16 @@ jQuery.extend({ if ( value !== undefined ) { type = typeof value; - // Make sure that NaN and null values aren't set. See: #7116 - if ( type === "number" && isNaN( value ) || value == null ) { - return; + // convert relative number strings (+= or -=) to relative numbers. #7345 + if ( type === "string" && (ret = rrelNum.exec( value )) ) { + value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) ); + // Fixes bug #9237 + type = "number"; } - // convert relative number strings (+= or -=) to relative numbers. #7345 - if ( type === "string" && rrelNum.test( value ) ) { - value = +value.replace( rrelNumFilter, "" ) + parseFloat( jQuery.css( elem, name ) ); + // Make sure that NaN and null values aren't set. See: #7116 + if ( value == null || type === "number" && isNaN( value ) ) { + return; } // If a number was passed in, add 'px' to the (except for certain CSS properties) @@ -6365,10 +8653,6 @@ jQuery.extend({ for ( name in options ) { elem.style[ name ] = old[ name ]; } - }, - - camelCase: function( string ) { - return string.replace( rdashAlpha, fcamelCase ); } }); @@ -6382,44 +8666,21 @@ jQuery.each(["height", "width"], function( i, name ) { if ( computed ) { if ( elem.offsetWidth !== 0 ) { - val = getWH( elem, name, extra ); - + return getWH( elem, name, extra ); } else { jQuery.swap( elem, cssShow, function() { val = getWH( elem, name, extra ); }); } - if ( val <= 0 ) { - val = curCSS( elem, name, name ); - - if ( val === "0px" && currentStyle ) { - val = currentStyle( elem, name, name ); - } - - if ( val != null ) { - // Should return "auto" instead of 0, use 0 for - // temporary backwards-compat - return val === "" || val === "auto" ? "0px" : val; - } - } - - if ( val < 0 || val == null ) { - val = elem.style[ name ]; - - // Should return "auto" instead of 0, use 0 for - // temporary backwards-compat - return val === "" || val === "auto" ? "0px" : val; - } - - return typeof val === "string" ? val : val + "px"; + return val; } }, set: function( elem, value ) { if ( rnumpx.test( value ) ) { // ignore negative width and height values #1599 - value = parseFloat(value); + value = parseFloat( value ); if ( value >= 0 ) { return value + "px"; @@ -6443,18 +8704,29 @@ if ( !jQuery.support.opacity ) { set: function( elem, value ) { var style = elem.style, - currentStyle = elem.currentStyle; + currentStyle = elem.currentStyle, + opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", + filter = currentStyle && currentStyle.filter || style.filter || ""; // IE has trouble with opacity if it does not have layout // Force it by setting the zoom level style.zoom = 1; - // Set the alpha filter to set the opacity - var opacity = jQuery.isNaN( value ) ? - "" : - "alpha(opacity=" + value * 100 + ")", - filter = currentStyle && currentStyle.filter || style.filter || ""; + // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 + if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) { + // Setting style.filter to null, "" & " " still leave "filter:" in the cssText + // if "filter:" is present at all, clearType is disabled, we want to avoid this + // style.removeAttribute is IE Only, but so apparently is this code path... + style.removeAttribute( "filter" ); + + // if there there is no filter style applied in a css rule, we are done + if ( currentStyle && !currentStyle.filter ) { + return; + } + } + + // otherwise, set new filter values style.filter = ralpha.test( filter ) ? filter.replace( ralpha, opacity ) : filter + " " + opacity; @@ -6490,11 +8762,8 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) { name = name.replace( rupper, "-$1" ).toLowerCase(); - if ( !(defaultView = elem.ownerDocument.defaultView) ) { - return undefined; - } - - if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) { + if ( (defaultView = elem.ownerDocument.defaultView) && + (computedStyle = defaultView.getComputedStyle( elem, null )) ) { ret = computedStyle.getPropertyValue( name ); if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) { ret = jQuery.style( elem, name ); @@ -6507,25 +8776,32 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) { if ( document.documentElement.currentStyle ) { currentStyle = function( elem, name ) { - var left, + var left, rsLeft, uncomputed, ret = elem.currentStyle && elem.currentStyle[ name ], - rsLeft = elem.runtimeStyle && elem.runtimeStyle[ 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; + } + // From the awesome hack by Dean Edwards // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 // If we're not dealing with a regular pixel number // but a number that has a weird ending, we need to convert it to pixels if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { + // Remember the original values left = style.left; + rsLeft = elem.runtimeStyle && elem.runtimeStyle.left; // Put in the new values to get a computed value out if ( rsLeft ) { elem.runtimeStyle.left = elem.currentStyle.left; } - style.left = name === "fontSize" ? "1em" : (ret || 0); + style.left = name === "fontSize" ? "1em" : ( ret || 0 ); ret = style.pixelLeft + "px"; // Revert the changed values @@ -6542,27 +8818,52 @@ if ( document.documentElement.currentStyle ) { curCSS = getComputedStyle || currentStyle; function getWH( elem, name, extra ) { - var which = name === "width" ? cssWidth : cssHeight, - val = name === "width" ? elem.offsetWidth : elem.offsetHeight; - if ( extra === "border" ) { - return val; + // Start with offset property + var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, + which = name === "width" ? cssWidth : cssHeight, + i = 0, + len = which.length; + + if ( val > 0 ) { + if ( extra !== "border" ) { + for ( ; i < len; i++ ) { + if ( !extra ) { + val -= parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0; + } + if ( extra === "margin" ) { + val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0; + } else { + val -= parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0; + } + } + } + + return val + "px"; } - jQuery.each( which, function() { - if ( !extra ) { - val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0; + // Fall back to computed then uncomputed css if necessary + val = curCSS( elem, name, name ); + if ( val < 0 || val == null ) { + val = elem.style[ name ] || 0; + } + // Normalize "", auto, and prepare for extra + val = parseFloat( val ) || 0; + + // Add padding, border, margin + if ( extra ) { + for ( ; i < len; i++ ) { + val += parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0; + if ( extra !== "padding" ) { + val += parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0; + } + if ( extra === "margin" ) { + val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0; + } } + } - if ( extra === "margin" ) { - val += parseFloat(jQuery.css( elem, "margin" + this )) || 0; - - } else { - val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0; - } - }); - - return val; + return val + "px"; } if ( jQuery.expr && jQuery.expr.filters ) { @@ -6570,7 +8871,7 @@ if ( jQuery.expr && jQuery.expr.filters ) { var width = elem.offsetWidth, height = elem.offsetHeight; - return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none"); + return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none"); }; jQuery.expr.filters.visible = function( elem ) { @@ -6586,9 +8887,9 @@ var r20 = /%20/g, rCRLF = /\r?\n/g, rhash = /#.*$/, rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL - rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, + rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, // #7653, #8125, #8152: local protocol detection - rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/, + rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, rnoContent = /^(?:GET|HEAD)$/, rprotocol = /^\/\//, rquery = /\?/, @@ -6623,7 +8924,10 @@ var r20 = /%20/g, ajaxLocation, // Document location segments - ajaxLocParts; + ajaxLocParts, + + // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression + allTypes = ["*/"] + ["*"]; // #8138, IE may throw an exception when accessing // a field from window.location if document.domain has been set @@ -6660,7 +8964,7 @@ function addToPrefiltersOrTransports( structure ) { placeBefore; // For each dataType in the dataTypeExpression - for(; i < length; i++ ) { + for ( ; i < length; i++ ) { dataType = dataTypes[ i ]; // We control if we're asked to add before // any existing element @@ -6691,7 +8995,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX executeOnly = ( structure === prefilters ), selection; - for(; i < length && ( executeOnly || !selection ); i++ ) { + 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 @@ -6716,6 +9020,22 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX return selection; } +// A special extend for ajax options +// that takes "flat" options (not to be deep extended) +// Fixes #9887 +function ajaxExtend( target, src ) { + var key, deep, + flatOptions = jQuery.ajaxSettings.flatOptions || {}; + for ( key in src ) { + if ( src[ key ] !== undefined ) { + ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; + } + } + if ( deep ) { + jQuery.extend( true, target, deep ); + } +} + jQuery.fn.extend({ load: function( url, params, callback ) { if ( typeof url !== "string" && _load ) { @@ -6823,7 +9143,7 @@ jQuery.fn.extend({ // Attach a bunch of functions for handling common AJAX events jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ jQuery.fn[ o ] = function( f ){ - return this.bind( o, f ); + return this.on( o, f ); }; }); @@ -6859,23 +9179,16 @@ jQuery.extend({ // 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 ) { - // Only one parameter, we extend ajaxSettings - settings = target; - target = jQuery.extend( true, jQuery.ajaxSettings, settings ); + ajaxSetup: function( target, settings ) { + if ( settings ) { + // Building a settings object + ajaxExtend( target, jQuery.ajaxSettings ); } else { - // target was provided, we extend into it - jQuery.extend( true, target, jQuery.ajaxSettings, settings ); - } - // Flatten fields we don't want deep extended - for( var field in { context: 1, url: 1 } ) { - if ( field in settings ) { - target[ field ] = settings[ field ]; - } else if( field in jQuery.ajaxSettings ) { - target[ field ] = jQuery.ajaxSettings[ field ]; - } + // Extending ajaxSettings + settings = target; + target = jQuery.ajaxSettings; } + ajaxExtend( target, settings ); return target; }, @@ -6903,7 +9216,7 @@ jQuery.extend({ html: "text/html", text: "text/plain", json: "application/json, text/javascript", - "*": "*/*" + "*": allTypes }, contents: { @@ -6933,6 +9246,15 @@ jQuery.extend({ // Parse text as xml "text xml": jQuery.parseXML + }, + + // For options that shouldn't be deep extended: + // you can add your own custom options here if + // and when you create one that shouldn't be + // deep extended (see ajaxExtend) + flatOptions: { + context: true, + url: true } }, @@ -6963,7 +9285,7 @@ jQuery.extend({ jQuery( callbackContext ) : jQuery.event, // Deferreds deferred = jQuery.Deferred(), - completeDeferred = jQuery._Deferred(), + completeDeferred = jQuery.Callbacks( "once memory" ), // Status-dependent callbacks statusCode = s.statusCode || {}, // ifModified key @@ -7043,7 +9365,7 @@ jQuery.extend({ // Callback for when everything is done // It is defined here because jslint complains if it is declared // at the end of the function (which would be more logical and readable) - function done( status, statusText, responses, headers ) { + function done( status, nativeStatusText, responses, headers ) { // Called once if ( state === 2 ) { @@ -7066,11 +9388,12 @@ jQuery.extend({ responseHeadersString = headers || ""; // Set readyState - jqXHR.readyState = status ? 4 : 0; + jqXHR.readyState = status > 0 ? 4 : 0; var isSuccess, success, error, + statusText = nativeStatusText, response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, lastModified, etag; @@ -7112,7 +9435,7 @@ jQuery.extend({ // We extract error from statusText // then normalize statusText and status for non-aborts error = statusText; - if( !statusText || status ) { + if ( !statusText || status ) { statusText = "error"; if ( status < 0 ) { status = 0; @@ -7122,7 +9445,7 @@ jQuery.extend({ // Set data for the fake xhr object jqXHR.status = status; - jqXHR.statusText = statusText; + jqXHR.statusText = "" + ( nativeStatusText || statusText ); // Success/Error if ( isSuccess ) { @@ -7141,10 +9464,10 @@ jQuery.extend({ } // Complete - completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] ); + completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); if ( fireGlobals ) { - globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] ); + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); // Handle the global AJAX counter if ( !( --jQuery.active ) ) { jQuery.event.trigger( "ajaxStop" ); @@ -7156,14 +9479,14 @@ jQuery.extend({ deferred.promise( jqXHR ); jqXHR.success = jqXHR.done; jqXHR.error = jqXHR.fail; - jqXHR.complete = completeDeferred.done; + jqXHR.complete = completeDeferred.add; // Status-dependent callbacks jqXHR.statusCode = function( map ) { if ( map ) { var tmp; if ( state < 2 ) { - for( tmp in map ) { + for ( tmp in map ) { statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; } } else { @@ -7225,6 +9548,8 @@ jQuery.extend({ // If data is available, append data to url if ( s.data ) { s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; + // #9682: remove data so that it's not used in an eventual retry + delete s.data; } // Get ifModifiedKey before adding the anti-cache parameter @@ -7238,7 +9563,7 @@ jQuery.extend({ ret = s.url.replace( rts, "$1_=" + ts ); // if nothing was replaced, add timestamp to the end - s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); + s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); } } @@ -7262,7 +9587,7 @@ jQuery.extend({ jqXHR.setRequestHeader( "Accept", s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? - s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) : + s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : s.accepts[ "*" ] ); @@ -7308,11 +9633,11 @@ jQuery.extend({ transport.send( requestHeaders, done ); } catch (e) { // Propagate exception as error if not done - if ( status < 2 ) { + if ( state < 2 ) { done( -1, e ); // Simply rethrow otherwise } else { - jQuery.error( e ); + throw e; } } } @@ -7416,7 +9741,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) { firstDataType; // Fill responseXXX fields - for( type in responseFields ) { + for ( type in responseFields ) { if ( type in responses ) { jqXHR[ responseFields[type] ] = responses[ type ]; } @@ -7495,13 +9820,13 @@ function ajaxConvert( s, response ) { conv2; // For each dataType in the chain - for( i = 1; i < length; i++ ) { + for ( i = 1; i < length; i++ ) { // Create converters map // with lowercased keys if ( i === 1 ) { - for( key in s.converters ) { - if( typeof key === "string" ) { + for ( key in s.converters ) { + if ( typeof key === "string" ) { converters[ key.toLowerCase() ] = s.converters[ key ]; } } @@ -7512,7 +9837,7 @@ function ajaxConvert( s, response ) { current = dataTypes[ i ]; // If current is auto dataType, update it to prev - if( current === "*" ) { + if ( current === "*" ) { current = prev; // If no auto and dataTypes are actually different } else if ( prev !== "*" && prev !== current ) { @@ -7524,7 +9849,7 @@ function ajaxConvert( s, response ) { // If there is no direct converter, search transitively if ( !conv ) { conv2 = undefined; - for( conv1 in converters ) { + for ( conv1 in converters ) { tmp = conv1.split( " " ); if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) { conv2 = converters[ tmp[1] + " " + current ]; @@ -7956,21 +10281,18 @@ var elemdisplay = {}, // opacity animations [ "opacity" ] ], - fxNow, - requestAnimationFrame = window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame; + fxNow; jQuery.fn.extend({ show: function( speed, easing, callback ) { var elem, display; if ( speed || speed === 0 ) { - return this.animate( genFx("show", 3), speed, easing, callback); + return this.animate( genFx("show", 3), speed, easing, callback ); } else { for ( var i = 0, j = this.length; i < j; i++ ) { - elem = this[i]; + elem = this[ i ]; if ( elem.style ) { display = elem.style.display; @@ -7984,8 +10306,8 @@ jQuery.fn.extend({ // Set elements which have been overridden with display: none // in a stylesheet to whatever the default browser style is // for such an element - if ( display === "" && jQuery.css( elem, "display" ) === "none" ) { - jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName)); + if ( display === "" && jQuery.css(elem, "display") === "none" ) { + jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) ); } } } @@ -7993,13 +10315,13 @@ jQuery.fn.extend({ // Set the display of most of the elements in a second loop // to avoid the constant reflow for ( i = 0; i < j; i++ ) { - elem = this[i]; + elem = this[ i ]; if ( elem.style ) { display = elem.style.display; if ( display === "" || display === "none" ) { - elem.style.display = jQuery._data(elem, "olddisplay") || ""; + elem.style.display = jQuery._data( elem, "olddisplay" ) || ""; } } } @@ -8013,12 +10335,17 @@ jQuery.fn.extend({ return this.animate( genFx("hide", 3), speed, easing, callback); } else { - for ( var i = 0, j = this.length; i < j; i++ ) { - if ( this[i].style ) { - var display = jQuery.css( this[i], "display" ); + var elem, display, + i = 0, + j = this.length; - if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) { - jQuery._data( this[i], "olddisplay", display ); + for ( ; i < j; i++ ) { + elem = this[i]; + if ( elem.style ) { + display = jQuery.css( elem, "display" ); + + if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) { + jQuery._data( elem, "olddisplay", display ); } } } @@ -8063,7 +10390,7 @@ jQuery.fn.extend({ }, animate: function( prop, speed, easing, callback ) { - var optall = jQuery.speed(speed, easing, callback); + var optall = jQuery.speed( speed, easing, callback ); if ( jQuery.isEmptyObject( prop ) ) { return this.each( optall.complete, [ false ] ); @@ -8072,7 +10399,7 @@ jQuery.fn.extend({ // Do not change referenced properties as per-property easing will be lost prop = jQuery.extend( {}, prop ); - return this[ optall.queue === false ? "each" : "queue" ](function() { + function doAnimation() { // XXX 'this' does not always have a nodeName when running the // test suite @@ -8083,9 +10410,9 @@ jQuery.fn.extend({ var opt = jQuery.extend( {}, optall ), isElement = this.nodeType === 1, hidden = isElement && jQuery(this).is(":hidden"), - name, val, p, - display, e, - parts, start, end, unit; + name, val, p, e, + parts, start, end, unit, + method; // will store per property easing and be used to determine when an animation is complete opt.animatedProperties = {}; @@ -8121,25 +10448,17 @@ jQuery.fn.extend({ opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ]; // Set display property to inline-block for height/width - // animations on inline elements that are having width/height - // animated + // animations on inline elements that are having width/height animated if ( jQuery.css( this, "display" ) === "inline" && jQuery.css( this, "float" ) === "none" ) { - if ( !jQuery.support.inlineBlockNeedsLayout ) { + + // inline-level elements accept inline-block; + // block-level elements need to be inline with layout + if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) { this.style.display = "inline-block"; } else { - display = defaultDisplay( this.nodeName ); - - // inline-level elements accept inline-block; - // block-level elements need to be inline with layout - if ( display === "inline" ) { - this.style.display = "inline-block"; - - } else { - this.style.display = "inline"; - this.style.zoom = 1; - } + this.style.zoom = 1; } } } @@ -8153,8 +10472,17 @@ jQuery.fn.extend({ e = new jQuery.fx( this, opt, p ); val = prop[ p ]; - if ( rfxtypes.test(val) ) { - e[ val === "toggle" ? hidden ? "show" : "hide" : val ](); + if ( rfxtypes.test( val ) ) { + + // Tracks whether to show or hide based on private + // data attached to the element + method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 ); + if ( method ) { + jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" ); + e[ method ](); + } else { + e[ val ](); + } } else { parts = rfxnum.exec( val ); @@ -8167,7 +10495,7 @@ jQuery.fn.extend({ // We need to compute starting value if ( unit !== "px" ) { jQuery.style( this, p, (end || 1) + unit); - start = ((end || 1) / e.cur()) * start; + start = ( (end || 1) / e.cur() ) * start; jQuery.style( this, p, start + unit); } @@ -8186,39 +10514,71 @@ jQuery.fn.extend({ // For JS strict compliance return true; - }); - }, - - stop: function( clearQueue, gotoEnd ) { - if ( clearQueue ) { - this.queue([]); } - this.each(function() { - var timers = jQuery.timers, - i = timers.length; + return optall.queue === false ? + this.each( doAnimation ) : + this.queue( optall.queue, doAnimation ); + }, + + stop: function( type, clearQueue, gotoEnd ) { + if ( typeof type !== "string" ) { + gotoEnd = clearQueue; + clearQueue = type; + type = undefined; + } + if ( clearQueue && type !== false ) { + this.queue( type || "fx", [] ); + } + + 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 ); } - while ( i-- ) { - if ( timers[i].elem === this ) { - if (gotoEnd) { - // force the next step to be the last - timers[i](true); - } - timers.splice(i, 1); + function stopQueue( elem, data, index ) { + var hooks = data[ index ]; + jQuery.removeData( elem, index, true ); + hooks.stop( gotoEnd ); + } + + if ( type == null ) { + for ( index in data ) { + if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) { + stopQueue( this, data, index ); + } + } + } else if ( data[ index = type + ".run" ] && data[ index ].stop ){ + stopQueue( this, data, index ); + } + + for ( index = timers.length; index--; ) { + if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { + if ( gotoEnd ) { + + // force the next step to be the last + timers[ index ]( true ); + } else { + timers[ index ].saveState(); + } + hadTimers = true; + timers.splice( index, 1 ); } } + + // start the next in the queue if the last step wasn't forced + // timers currently will call their complete callbacks, which will dequeue + // but only if they were gotoEnd + if ( !( gotoEnd && hadTimers ) ) { + jQuery.dequeue( this, type ); + } }); - - // start the next in the queue if the last step wasn't forced - if ( !gotoEnd ) { - this.dequeue(); - } - - return this; } }); @@ -8237,7 +10597,7 @@ function clearFxNow() { function genFx( type, num ) { var obj = {}; - jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() { + jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() { obj[ this ] = type; }); @@ -8246,9 +10606,9 @@ function genFx( type, num ) { // Generate shortcuts for custom animations jQuery.each({ - slideDown: genFx("show", 1), - slideUp: genFx("hide", 1), - slideToggle: genFx("toggle", 1), + slideDown: genFx( "show", 1 ), + slideUp: genFx( "hide", 1 ), + slideToggle: genFx( "toggle", 1 ), fadeIn: { opacity: "show" }, fadeOut: { opacity: "hide" }, fadeToggle: { opacity: "toggle" } @@ -8260,28 +10620,34 @@ jQuery.each({ jQuery.extend({ speed: function( speed, easing, fn ) { - var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : { + var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { complete: fn || !fn && easing || jQuery.isFunction( speed ) && speed, duration: speed, - easing: fn && easing || easing && !jQuery.isFunction(easing) && easing + easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing }; opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : - opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default; + opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; + + // normalize opt.queue - true/undefined/null -> "fx" + if ( opt.queue == null || opt.queue === true ) { + opt.queue = "fx"; + } // Queueing opt.old = opt.complete; - opt.complete = function( noUnmark ) { - if ( opt.queue !== false ) { - jQuery.dequeue( this ); - } else if ( noUnmark !== false ) { - jQuery._unmark( this ); - } + opt.complete = function( noUnmark ) { if ( jQuery.isFunction( opt.old ) ) { opt.old.call( this ); } + + if ( opt.queue ) { + jQuery.dequeue( this, opt.queue ); + } else if ( noUnmark !== false ) { + jQuery._unmark( this ); + } }; return opt; @@ -8292,7 +10658,7 @@ jQuery.extend({ return firstNum + diff * p; }, swing: function( p, n, firstNum, diff ) { - return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; + return ( ( -Math.cos( p*Math.PI ) / 2 ) + 0.5 ) * diff + firstNum; } }, @@ -8315,12 +10681,12 @@ jQuery.fx.prototype = { this.options.step.call( this.elem, this.now, this ); } - (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); + ( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this ); }, // Get the current size cur: function() { - if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) { + if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) { return this.elem[ this.prop ]; } @@ -8335,50 +10701,47 @@ jQuery.fx.prototype = { // Start an animation from one number to another custom: function( from, to, unit ) { var self = this, - fx = jQuery.fx, - raf; + fx = jQuery.fx; this.startTime = fxNow || createFxNow(); - this.start = from; this.end = to; - this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); - this.now = this.start; + this.now = this.start = from; this.pos = this.state = 0; + this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); function t( gotoEnd ) { - return self.step(gotoEnd); + return self.step( gotoEnd ); } + t.queue = this.options.queue; t.elem = this.elem; + t.saveState = function() { + if ( self.options.hide && jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) { + jQuery._data( self.elem, "fxshow" + self.prop, self.start ); + } + }; if ( t() && jQuery.timers.push(t) && !timerId ) { - // Use requestAnimationFrame instead of setInterval if available - if ( requestAnimationFrame ) { - timerId = 1; - raf = function() { - // When timerId gets set to null at any point, this stops - if ( timerId ) { - requestAnimationFrame( raf ); - fx.tick(); - } - }; - requestAnimationFrame( raf ); - } else { - timerId = setInterval( fx.tick, fx.interval ); - } + 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 later - this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); + this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop ); this.options.show = true; // Begin the animation - // Make sure that we start at a small width/height to avoid any - // flash of content - this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur()); + // Make sure that we start at a small width/height to avoid any flash of content + if ( dataShow !== undefined ) { + // This show is picking up where a previous hide or show left off + this.custom( this.cur(), dataShow ); + } else { + this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() ); + } // Start by showing the element jQuery( this.elem ).show(); @@ -8387,20 +10750,20 @@ jQuery.fx.prototype = { // Simple 'hide' function hide: function() { // Remember where we started, so that we can go back to it later - this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); + this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop ); this.options.hide = true; // Begin the animation - this.custom(this.cur(), 0); + this.custom( this.cur(), 0 ); }, // Each step of an animation step: function( gotoEnd ) { - var t = fxNow || createFxNow(), + var p, n, complete, + t = fxNow || createFxNow(), done = true, elem = this.elem, - options = this.options, - i, n; + options = this.options; if ( gotoEnd || t >= options.duration + this.startTime ) { this.now = this.end; @@ -8409,8 +10772,8 @@ jQuery.fx.prototype = { options.animatedProperties[ this.prop ] = true; - for ( i in options.animatedProperties ) { - if ( options.animatedProperties[i] !== true ) { + for ( p in options.animatedProperties ) { + if ( options.animatedProperties[ p ] !== true ) { done = false; } } @@ -8419,25 +10782,36 @@ jQuery.fx.prototype = { // Reset the overflow if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) { - jQuery.each( [ "", "X", "Y" ], function (index, value) { - elem.style[ "overflow" + value ] = options.overflow[index]; + jQuery.each( [ "", "X", "Y" ], function( index, value ) { + elem.style[ "overflow" + value ] = options.overflow[ index ]; }); } // Hide the element if the "hide" operation was done if ( options.hide ) { - jQuery(elem).hide(); + jQuery( elem ).hide(); } // Reset the properties, if the item has been hidden or shown if ( options.hide || options.show ) { - for ( var p in options.animatedProperties ) { - jQuery.style( elem, p, options.orig[p] ); + for ( p in options.animatedProperties ) { + jQuery.style( elem, p, options.orig[ p ] ); + jQuery.removeData( elem, "fxshow" + p, true ); + // Toggle data is no longer needed + jQuery.removeData( elem, "toggle" + p, true ); } } // Execute the complete function - options.complete.call( elem ); + // in the event that the complete function throws an exception + // we must ensure it won't be called twice. #5684 + + complete = options.complete; + if ( complete ) { + + options.complete = false; + complete.call( elem ); + } } return false; @@ -8451,8 +10825,8 @@ jQuery.fx.prototype = { this.state = n / options.duration; // Perform the easing function, defaults to swing - this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration ); - this.now = this.start + ((this.end - this.start) * this.pos); + this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration ); + this.now = this.start + ( (this.end - this.start) * this.pos ); } // Perform the next step of the animation this.update(); @@ -8464,9 +10838,15 @@ jQuery.fx.prototype = { jQuery.extend( jQuery.fx, { tick: function() { - for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) { - if ( !timers[i]() ) { - timers.splice(i--, 1); + var timer, + timers = jQuery.timers, + i = 0; + + for ( ; i < timers.length; i++ ) { + timer = timers[ i ]; + // Checks the timer has not already been removed + if ( !timer() && timers[ i ] === timer ) { + timers.splice( i--, 1 ); } } @@ -8496,7 +10876,7 @@ jQuery.extend( jQuery.fx, { _default: function( fx ) { if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) { - fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit; + fx.elem.style[ fx.prop ] = fx.now + fx.unit; } else { fx.elem[ fx.prop ] = fx.now; } @@ -8504,6 +10884,14 @@ jQuery.extend( jQuery.fx, { } }); +// Adds width/height step functions +// Do not set anything below 0 +jQuery.each([ "width", "height" ], function( i, prop ) { + jQuery.fx.step[ prop ] = function( fx ) { + jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit ); + }; +}); + if ( jQuery.expr && jQuery.expr.filters ) { jQuery.expr.filters.animated = function( elem ) { return jQuery.grep(jQuery.timers, function( fn ) { @@ -8517,9 +10905,9 @@ function defaultDisplay( nodeName ) { if ( !elemdisplay[ nodeName ] ) { - var elem = jQuery( "<" + nodeName + ">" ).appendTo( "body" ), + var body = document.body, + elem = jQuery( "<" + nodeName + ">" ).appendTo( body ), display = elem.css( "display" ); - elem.remove(); // If the simple way fails, @@ -8531,14 +10919,15 @@ function defaultDisplay( nodeName ) { iframe.frameBorder = iframe.width = iframe.height = 0; } - document.body.appendChild( iframe ); + body.appendChild( iframe ); // Create a cacheable copy of the iframe document on first call. - // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake html - // document to it, Webkit & Firefox won't allow reusing the iframe document + // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML + // document to it; WebKit & Firefox won't allow reusing the iframe document. if ( !iframeDoc || !iframe.createElement ) { iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; - iframeDoc.write( "" ); + iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "" : "" ) + "" ); + iframeDoc.close(); } elem = iframeDoc.createElement( nodeName ); @@ -8546,8 +10935,7 @@ function defaultDisplay( nodeName ) { iframeDoc.body.appendChild( elem ); display = jQuery.css( elem, "display" ); - - document.body.removeChild( iframe ); + body.removeChild( iframe ); } // Store the correct default display @@ -8623,8 +11011,6 @@ if ( "getBoundingClientRect" in document.documentElement ) { return jQuery.offset.bodyOffset( elem ); } - jQuery.offset.initialize(); - var computedStyle, offsetParent = elem.offsetParent, prevOffsetParent = elem, @@ -8637,7 +11023,7 @@ if ( "getBoundingClientRect" in document.documentElement ) { left = elem.offsetLeft; while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { - if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { + if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) { break; } @@ -8649,7 +11035,7 @@ if ( "getBoundingClientRect" in document.documentElement ) { top += elem.offsetTop; left += elem.offsetLeft; - if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) { + if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) { top += parseFloat( computedStyle.borderTopWidth ) || 0; left += parseFloat( computedStyle.borderLeftWidth ) || 0; } @@ -8658,7 +11044,7 @@ if ( "getBoundingClientRect" in document.documentElement ) { offsetParent = elem.offsetParent; } - if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { + if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { top += parseFloat( computedStyle.borderTopWidth ) || 0; left += parseFloat( computedStyle.borderLeftWidth ) || 0; } @@ -8671,7 +11057,7 @@ if ( "getBoundingClientRect" in document.documentElement ) { left += body.offsetLeft; } - if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { + if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) { top += Math.max( docElem.scrollTop, body.scrollTop ); left += Math.max( docElem.scrollLeft, body.scrollLeft ); } @@ -8681,46 +11067,12 @@ if ( "getBoundingClientRect" in document.documentElement ) { } jQuery.offset = { - initialize: function() { - var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0, - html = "
"; - - jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } ); - - container.innerHTML = html; - body.insertBefore( container, body.firstChild ); - innerDiv = container.firstChild; - checkDiv = innerDiv.firstChild; - td = innerDiv.nextSibling.firstChild.firstChild; - - this.doesNotAddBorder = (checkDiv.offsetTop !== 5); - this.doesAddBorderForTableAndCells = (td.offsetTop === 5); - - checkDiv.style.position = "fixed"; - checkDiv.style.top = "20px"; - - // safari subtracts parent border width here which is 5px - this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); - checkDiv.style.position = checkDiv.style.top = ""; - - innerDiv.style.overflow = "hidden"; - innerDiv.style.position = "relative"; - - this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); - - this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); - - body.removeChild( container ); - jQuery.offset.initialize = jQuery.noop; - }, bodyOffset: function( body ) { var top = body.offsetTop, left = body.offsetLeft; - jQuery.offset.initialize(); - - if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { + if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) { top += parseFloat( jQuery.css(body, "marginTop") ) || 0; left += parseFloat( jQuery.css(body, "marginLeft") ) || 0; } @@ -8740,7 +11092,7 @@ jQuery.offset = { curOffset = curElem.offset(), curCSSTop = jQuery.css( elem, "top" ), curCSSLeft = jQuery.css( elem, "left" ), - calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, + calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, props = {}, curPosition = {}, curTop, curLeft; // need to be able to calculate position if either top or left is auto and position is either absolute or fixed @@ -8757,11 +11109,11 @@ jQuery.offset = { options = options.call( elem, i, curOffset ); } - if (options.top != null) { - props.top = (options.top - curOffset.top) + curTop; + if ( options.top != null ) { + props.top = ( options.top - curOffset.top ) + curTop; } - if (options.left != null) { - props.left = (options.left - curOffset.left) + curLeft; + if ( options.left != null ) { + props.left = ( options.left - curOffset.left ) + curLeft; } if ( "using" in options ) { @@ -8774,6 +11126,7 @@ jQuery.offset = { jQuery.fn.extend({ + position: function() { if ( !this[0] ) { return null; @@ -8868,22 +11221,28 @@ function getWindow( elem ) { -// Create innerHeight, innerWidth, outerHeight and outerWidth methods +// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods jQuery.each([ "Height", "Width" ], function( i, name ) { var type = name.toLowerCase(); // innerHeight and innerWidth - jQuery.fn["inner" + name] = function() { - return this[0] ? - parseFloat( jQuery.css( this[0], type, "padding" ) ) : + jQuery.fn[ "inner" + name ] = function() { + var elem = this[0]; + return elem ? + elem.style ? + parseFloat( jQuery.css( elem, type, "padding" ) ) : + this[ type ]() : null; }; // outerHeight and outerWidth - jQuery.fn["outer" + name] = function( margin ) { - return this[0] ? - parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) : + jQuery.fn[ "outer" + name ] = function( margin ) { + var elem = this[0]; + return elem ? + elem.style ? + parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) : + this[ type ]() : null; }; @@ -8904,9 +11263,10 @@ jQuery.each([ "Height", "Width" ], function( i, name ) { if ( jQuery.isWindow( elem ) ) { // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat - var docElemProp = elem.document.documentElement[ "client" + name ]; + var docElemProp = elem.document.documentElement[ "client" + name ], + body = elem.document.body; return elem.document.compatMode === "CSS1Compat" && docElemProp || - elem.document.body[ "client" + name ] || docElemProp; + body && body[ "client" + name ] || docElemProp; // Get document width or height } else if ( elem.nodeType === 9 ) { @@ -8922,7 +11282,7 @@ jQuery.each([ "Height", "Width" ], function( i, name ) { var orig = jQuery.css( elem, type ), ret = parseFloat( orig ); - return jQuery.isNaN( ret ) ? orig : ret; + return jQuery.isNumeric( ret ) ? ret : orig; // Set the width or height on the element (default to pixels if value is unitless) } else { @@ -8933,5 +11293,27 @@ jQuery.each([ "Height", "Width" ], function( i, name ) { }); + + +// Expose jQuery to the global object window.jQuery = window.$ = jQuery; -})(window); + +// Expose jQuery as an AMD module, but only for AMD loaders that +// understand the issues with loading multiple versions of jQuery +// in a page that all might call define(). The loader will indicate +// they have special allowances for multiple jQuery versions by +// specifying define.amd.jQuery = true. Register as a named module, +// since jQuery can be concatenated with other files that may use define, +// but not use a proper concatenation script that understands anonymous +// AMD modules. A named AMD is safest and most robust way to register. +// Lowercase jquery is used because AMD module names are derived from +// file names, and jQuery is normally delivered in a lowercase file name. +// Do this after creating the global so that if an AMD module wants to call +// noConflict to hide this version of jQuery, it will work. +if ( typeof define === "function" && define.amd && define.amd.jQuery ) { + define( "jquery", [], function () { return jQuery; } ); +} + + + +})( window ); diff --git a/solr/webapp/web/js/script.js b/solr/webapp/web/js/script.js deleted file mode 100644 index 5c4fa82cb02..00000000000 --- a/solr/webapp/web/js/script.js +++ /dev/null @@ -1,4681 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -var loader = { - - show : function( element ) - { - $( element ) - .addClass( 'loader' ); - }, - - hide : function( element ) - { - $( element ) - .removeClass( 'loader' ); - } - -}; - -Number.prototype.esc = function() -{ - return new String( this ).esc(); -} - -String.prototype.esc = function() -{ - return this.replace( //g, '>' ); -} - -var sammy = $.sammy -( - function() - { - this.bind - ( - 'run', - function( event, config ) - { - if( 0 === config.start_url.length ) - { - location.href = '#/'; - return false; - } - } - ); - - this.bind - ( - 'ping', - function( event ) - { - $.ajax - ( - { - url : $( this.params.element ).attr( 'rel' ) + '?wt=json&ts=' + (new Date).getTime(), - dataType : 'json', - context: this.params.element, - beforeSend : function( arr, form, options ) - { - loader.show( this ); - }, - success : function( response, text_status, xhr ) - { - $( this ) - .removeAttr( 'title' ); - - $( this ).parents( 'li' ) - .removeClass( 'error' ); - - var qtime_element = $( '.qtime', this ); - - if( 0 === qtime_element.size() ) - { - qtime_element = $( ' ()' ); - - $( this ) - .append - ( - qtime_element - ); - } - - $( 'span', qtime_element ) - .html( response.responseHeader.QTime + 'ms' ); - }, - error : function( xhr, text_status, error_thrown ) - { - $( this ) - .attr( 'title', '/admin/ping is not configured (' + xhr.status + ': ' + error_thrown + ')' ); - - $( this ).parents( 'li' ) - .addClass( 'error' ); - }, - complete : function( xhr, text_status ) - { - loader.hide( this ); - } - } - ); - - return false; - } - ); - - // activate_core - this.before - ( - {}, - function() - { - $( 'li[id].active', app.menu_element ) - .removeClass( 'active' ); - - $( 'ul li.active', app.menu_element ) - .removeClass( 'active' ); - - if( this.params.splat ) - { - var active_element = $( '#' + this.params.splat[0], app.menu_element ); - - active_element - .addClass( 'active' ); - - if( this.params.splat[1] ) - { - $( '.' + this.params.splat[1], active_element ) - .addClass( 'active' ); - } - - if( !active_element.hasClass( 'global' ) ) - { - this.active_core = active_element; - } - } - } - ); - - // #/cloud - this.get - ( - /^#\/(cloud)$/, - function( context ) - { - var content_element = $( '#content' ); - - $.get - ( - 'tpl/cloud.html', - function( template ) - { - content_element - .html( template ); - - var zookeeper_element = $( '#zookeeper', content_element ); - - $.ajax - ( - { - url : app.config.zookeeper_path, - dataType : 'json', - context : $( '.content', zookeeper_element ), - beforeSend : function( xhr, settings ) - { - this - .html( '
Loading ...
' ); - }, - success : function( response, text_status, xhr ) - { - this - .html( '
' ); - - $( '#zookeeper-tree', this ) - .jstree - ( - { - "plugins" : [ "json_data" ], - "json_data" : { - "data" : response.tree, - "progressive_render" : true - }, - "core" : { - "animation" : 0 - } - } - ); - }, - error : function( xhr, text_status, error_thrown ) - { - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - ); - } - ); - - this.bind - ( - 'cores_load_data', - function( event, params ) - { - if( app.cores_data ) - { - params.callback( app.cores_data ); - return true; - } - - $.ajax - ( - { - url : app.config.solr_path + app.config.core_admin_path + '?wt=json', - dataType : 'json', - beforeSend : function( xhr, settings ) - { - }, - success : function( response, text_status, xhr ) - { - app.cores_data = response.status; - params.callback( app.cores_data ); - }, - error : function( xhr, text_status, error_thrown) - { - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - ); - - this.bind - ( - 'cores_build_navigation', - function( event, params ) - { - var navigation_content = ['
    ']; - - for( var core in params.cores ) - { - navigation_content.push( '
  • ' + core + '
  • ' ); - } - - params.navigation_element - .html( navigation_content.join( "\n" ) ); - - $( 'a[href="' + params.basepath + params.current_core + '"]', params.navigation_element ).parent() - .addClass( 'current' ); - } - ); - - this.bind - ( - 'cores_load_template', - function( event, params ) - { - if( app.cores_template ) - { - params.callback(); - return true; - } - - $.get - ( - 'tpl/cores.html', - function( template ) - { - params.content_element - .html( template ); - - app.cores_template = template; - params.callback(); - } - ); - } - ); - - // #/cores - this.get - ( - /^#\/(cores)$/, - function( context ) - { - delete app.cores_template; - - sammy.trigger - ( - 'cores_load_data', - { - callback : function( cores ) - { - var first_core = null; - for( var key in cores ) - { - if( !first_core ) - { - first_core = key; - } - continue; - } - context.redirect( context.path + '/' + first_core ); - } - } - ); - } - ); - - // #/cores - this.get - ( - /^#\/(cores)\//, - function( context ) - { - var content_element = $( '#content' ); - - var path_parts = this.path.match( /^(.+\/cores\/)(.*)$/ ); - var current_core = path_parts[2]; - - sammy.trigger - ( - 'cores_load_data', - { - callback : function( cores ) - { - sammy.trigger - ( - 'cores_load_template', - { - content_element : content_element, - callback : function() - { - var cores_element = $( '#cores', content_element ); - var navigation_element = $( '#navigation', cores_element ); - var list_element = $( '#list', navigation_element ); - var data_element = $( '#data', cores_element ); - var core_data_element = $( '#core-data', data_element ); - var index_data_element = $( '#index-data', data_element ); - - sammy.trigger - ( - 'cores_build_navigation', - { - cores : cores, - basepath : path_parts[1], - current_core : current_core, - navigation_element : list_element - } - ); - - var core_data = cores[current_core]; - var core_basepath = $( '#' + current_core, app.menu_element ).attr( 'data-basepath' ); - - // core-data - - $( 'h2 span', core_data_element ) - .html( core_data.name ); - - $( '.startTime dd', core_data_element ) - .html( core_data.startTime ); - - $( '.instanceDir dd', core_data_element ) - .html( core_data.instanceDir ); - - $( '.dataDir dd', core_data_element ) - .html( core_data.dataDir ); - - // index-data - - $( '.lastModified dd', index_data_element ) - .html( core_data.index.lastModified ); - - $( '.version dd', index_data_element ) - .html( core_data.index.version ); - - $( '.numDocs dd', index_data_element ) - .html( core_data.index.numDocs ); - - $( '.maxDoc dd', index_data_element ) - .html( core_data.index.maxDoc ); - - $( '.optimized dd', index_data_element ) - .addClass( core_data.index.optimized ? 'ico-1' : 'ico-0' ); - - $( '#actions .optimize', cores_element ) - .show(); - - $( '.optimized dd span', index_data_element ) - .html( core_data.index.optimized ? 'yes' : 'no' ); - - $( '.current dd', index_data_element ) - .addClass( core_data.index.current ? 'ico-1' : 'ico-0' ); - - $( '.current dd span', index_data_element ) - .html( core_data.index.current ? 'yes' : 'no' ); - - $( '.hasDeletions dd', index_data_element ) - .addClass( core_data.index.hasDeletions ? 'ico-1' : 'ico-0' ); - - $( '.hasDeletions dd span', index_data_element ) - .html( core_data.index.hasDeletions ? 'yes' : 'no' ); - - $( '.directory dd', index_data_element ) - .html - ( - core_data.index.directory - .replace( /:/g, ':​' ) - .replace( /@/g, '@​' ) - ); - - var core_names = []; - var core_selects = $( '#actions select', cores_element ); - - for( var key in cores ) - { - core_names.push( '' ) - } - - core_selects - .html( core_names.join( "\n") ); - - $( 'option[value="' + current_core + '"]', core_selects.filter( '#swap_core' ) ) - .attr( 'selected', 'selected' ); - - $( 'option[value="' + current_core + '"]', core_selects.filter( '.other' ) ) - .attr( 'disabled', 'disabled' ) - .addClass( 'disabled' ); - - $( 'input[name="core"]', cores_element ) - .val( current_core ); - - // layout - - var actions_element = $( '.actions', cores_element ); - var button_holder_element = $( '.button-holder.options', actions_element ); - - button_holder_element - .die( 'toggle' ) - .live - ( - 'toggle', - function( event ) - { - var element = $( this ); - - element - .toggleClass( 'active' ); - - if( element.hasClass( 'active' ) ) - { - button_holder_element - .not( element ) - .removeClass( 'active' ); - } - } - ); - - $( '.button a', button_holder_element ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( this ).parents( '.button-holder' ) - .trigger( 'toggle' ); - } - ); - - $( 'form a.submit', button_holder_element ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - var element = $( this ); - var form_element = element.parents( 'form' ); - var action = $( 'input[name="action"]', form_element ).val().toLowerCase(); - - form_element - .ajaxSubmit - ( - { - url : app.config.solr_path + app.config.core_admin_path + '?wt=json', - dataType : 'json', - beforeSubmit : function( array, form, options ) - { - //loader - }, - success : function( response, status_text, xhr, form ) - { - delete app.cores_data; - - if( 'rename' === action ) - { - context.redirect( path_parts[1] + $( 'input[name="other"]', form_element ).val() ); - } - else if( 'swap' === action ) - { - window.location.reload(); - } - - $( 'a.reset', form ) - .trigger( 'click' ); - }, - error : function( xhr, text_status, error_thrown ) - { - }, - complete : function() - { - //loader - } - } - ); - - return false; - } - ); - - $( 'form a.reset', button_holder_element ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( this ).parents( 'form' ) - .resetForm(); - - $( this ).parents( '.button-holder' ) - .trigger( 'toggle' ); - - return false; - } - ); - - var reload_button = $( '#actions .reload', cores_element ); - reload_button - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $.ajax - ( - { - url : app.config.solr_path + app.config.core_admin_path + '?wt=json&action=RELOAD&core=' + current_core, - dataType : 'json', - context : $( this ), - beforeSend : function( xhr, settings ) - { - this - .addClass( 'loader' ); - }, - success : function( response, text_status, xhr ) - { - this - .addClass( 'success' ); - - window.setTimeout - ( - function() - { - reload_button - .removeClass( 'success' ); - }, - 5000 - ); - }, - error : function( xhr, text_status, error_thrown ) - { - }, - complete : function( xhr, text_status ) - { - this - .removeClass( 'loader' ); - } - } - ); - } - ); - - $( '#actions .unload', cores_element ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $.ajax - ( - { - url : app.config.solr_path + app.config.core_admin_path + '?wt=json&action=UNLOAD&core=' + current_core, - dataType : 'json', - context : $( this ), - beforeSend : function( xhr, settings ) - { - this - .addClass( 'loader' ); - }, - success : function( response, text_status, xhr ) - { - delete app.cores_data; - context.redirect( path_parts[1].substr( 0, path_parts[1].length - 1 ) ); - }, - error : function( xhr, text_status, error_thrown ) - { - }, - complete : function( xhr, text_status ) - { - this - .removeClass( 'loader' ); - } - } - ); - } - ); - - var optimize_button = $( '#actions .optimize', cores_element ); - optimize_button - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $.ajax - ( - { - url : core_basepath + '/update?optimize=true&waitFlush=true&wt=json', - dataType : 'json', - context : $( this ), - beforeSend : function( xhr, settings ) - { - this - .addClass( 'loader' ); - }, - success : function( response, text_status, xhr ) - { - this - .addClass( 'success' ); - - window.setTimeout - ( - function() - { - optimize_button - .removeClass( 'success' ); - }, - 5000 - ); - - $( '.optimized dd.ico-0', index_data_element ) - .removeClass( 'ico-0' ) - .addClass( 'ico-1' ); - }, - error : function( xhr, text_status, error_thrown) - { - console.warn( 'd0h, optimize broken!' ); - }, - complete : function( xhr, text_status ) - { - this - .removeClass( 'loader' ); - } - } - ); - } - ); - - $( '.timeago', data_element ) - .timeago(); - - $( 'ul', data_element ) - .each - ( - function( i, element ) - { - $( 'li:odd', element ) - .addClass( 'odd' ); - } - ) - } - } - ); - } - } - ); - } - ); - - // #/logging - this.get - ( - /^#\/(logging)$/, - function( context ) - { - var content_element = $( '#content' ); - - content_element - .html( '
    ' ); - - $.ajax - ( - { - url : 'logging.json', - dataType : 'json', - context : $( '#logging', content_element ), - beforeSend : function( xhr, settings ) - { - this - .html( '
    Loading ...
    ' ); - }, - success : function( response, text_status, xhr ) - { - var logger = response.logger; - - var loglevel = '
    ' + "\n"; - loglevel += '%effective_level%' + "\n"; - loglevel += '
      ' + "\n"; - - for( var key in response.levels ) - { - var level = response.levels[key].esc(); - loglevel += '
    • ' + level + '
    • ' + "\n"; - } - - loglevel += '
    • UNSET
    • ' + "\n"; - loglevel += '
    ' + "\n"; - loglevel += '
    '; - - var logger_tree = function( filter ) - { - var logger_content = ''; - var filter_regex = new RegExp( '^' + filter + '\\.\\w+$' ); - - for( var logger_name in logger ) - { - var continue_matcher = false; - - if( !filter ) - { - continue_matcher = logger_name.indexOf( '.' ) !== -1; - } - else - { - continue_matcher = !logger_name.match( filter_regex ); - } - - if( continue_matcher ) - { - continue; - } - - var has_logger_instance = !!logger[logger_name]; - - var classes = []; - - has_logger_instance - ? classes.push( 'active' ) - : classes.push( 'inactive' ); - - logger_content += '
  • '; - logger_content += ' '; - logger_content += '' + "\n" + - logger_name.split( '.' ).pop().esc() + "\n" + - ''; - - logger_content += loglevel - .replace - ( - /%class%/g, - classes.join( ' ' ) - ) - .replace - ( - /%effective_level%/g, - has_logger_instance - ? logger[logger_name].effective_level - : 'null' - ); - - var child_logger_content = logger_tree( logger_name ); - if( child_logger_content ) - { - logger_content += '
      '; - logger_content += child_logger_content; - logger_content += '
    '; - } - - logger_content += '
  • '; - } - - return logger_content; - } - - var logger_content = logger_tree( null ); - - this - .html( '
      ' + logger_content + '
    ' ); - - $( 'li:last-child', this ) - .addClass( 'jstree-last' ); - - $( '.loglevel', this ) - .each - ( - function( index, element ) - { - var element = $( element ); - var effective_level = $( '.effective_level span', element ).text(); - - element - .css( 'z-index', 800 - index ); - - $( 'ul .' + effective_level, element ) - .addClass( 'selected' ); - } - ); - - $( '.trigger', this ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( '.loglevel', $( this ).parents( 'li' ).first() ).first() - .trigger( 'toggle' ); - } - ); - - $( '.loglevel', this ) - .die( 'toggle') - .live - ( - 'toggle', - function( event ) - { - $( this ) - .toggleClass( 'open' ); - } - ); - }, - error : function( xhr, text_status, error_thrown) - { - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - ); - - // #/java-properties - this.get - ( - /^#\/(java-properties)$/, - function( context ) - { - var core_basepath = $( 'li[data-basepath]', app.menu_element ).attr( 'data-basepath' ); - var content_element = $( '#content' ); - - content_element - .html( '
    ' ); - - $.ajax - ( - { - url : core_basepath + '/admin/properties?wt=json', - dataType : 'json', - context : $( '#java-properties', content_element ), - beforeSend : function( xhr, settings ) - { - this - .html( '
    Loading ...
    ' ); - }, - success : function( response, text_status, xhr ) - { - var system_properties = response['system.properties']; - var properties_data = {}; - var properties_content = []; - var properties_order = []; - - for( var key in system_properties ) - { - var displayed_key = key.replace( /\./g, '.​' ); - var displayed_value = [ system_properties[key] ]; - var item_class = 'clearfix'; - - if( -1 !== key.indexOf( '.path' ) ) - { - displayed_value = system_properties[key].split( system_properties['path.separator'] ); - if( 1 < displayed_value.length ) - { - item_class += ' multi'; - } - } - - var item_content = '
  • ' + "\n" + - '
    ' + displayed_key.esc() + '
    ' + "\n"; - - for( var i in displayed_value ) - { - item_content += '
    ' + displayed_value[i].esc() + '
    ' + "\n"; - } - - item_content += '
  • '; - - properties_data[key] = item_content; - properties_order.push( key ); - } - - properties_order.sort(); - for( var i in properties_order ) - { - properties_content.push( properties_data[properties_order[i]] ); - } - - this - .html( '
      ' + properties_content.join( "\n" ) + '
    ' ); - - $( 'li:odd', this ) - .addClass( 'odd' ); - - $( '.multi dd:odd', this ) - .addClass( 'odd' ); - }, - error : function( xhr, text_status, error_thrown) - { - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - ); - - // #/threads - this.get - ( - /^#\/(threads)$/, - function( context ) - { - var core_basepath = $( 'li[data-basepath]', app.menu_element ).attr( 'data-basepath' ); - var content_element = $( '#content' ); - - $.get - ( - 'tpl/threads.html', - function( template ) - { - content_element - .html( template ); - - $.ajax - ( - { - url : core_basepath + '/admin/threads?wt=json', - dataType : 'json', - context : $( '#threads', content_element ), - beforeSend : function( xhr, settings ) - { - }, - success : function( response, text_status, xhr ) - { - var self = this; - - var threadDumpData = response.system.threadDump; - var threadDumpContent = []; - var c = 0; - for( var i = 1; i < threadDumpData.length; i += 2 ) - { - var state = threadDumpData[i].state.esc(); - var name = '' + threadDumpData[i].name.esc() + ''; - - var classes = [state]; - var details = ''; - - if( 0 !== c % 2 ) - { - classes.push( 'odd' ); - } - - if( threadDumpData[i].lock ) - { - classes.push( 'lock' ); - name += "\n" + '

    ' + threadDumpData[i].lock.esc() + '

    '; - } - - if( threadDumpData[i].stackTrace && 0 !== threadDumpData[i].stackTrace.length ) - { - classes.push( 'stacktrace' ); - - var stack_trace = threadDumpData[i].stackTrace - .join( '###' ) - .esc() - .replace( /\(/g, '​(' ) - .replace( /###/g, '
  • ' ); - - name += '
    ' + "\n" - + '
      ' + "\n" - + '
    • ' + stack_trace + '
    • ' - + '
    ' + "\n" - + '
    '; - } - - var item = '' + "\n" - - + '' + state +'' + "\n" - + '' + threadDumpData[i].id.esc() + '' + "\n" - + '' + name + '' + "\n" - + '' + threadDumpData[i].cpuTime.esc() + '' + "\n" - + '' + threadDumpData[i].userTime.esc() + '' + "\n" - - + ''; - - threadDumpContent.push( item ); - c++; - } - - var threadDumpBody = $( '#thread-dump tbody', this ); - - threadDumpBody - .html( threadDumpContent.join( "\n" ) ); - - $( '.name a', threadDumpBody ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( this ).closest( 'tr' ) - .toggleClass( 'open' ); - } - ); - - $( '.controls a', this ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - var threads_element = $( self ); - var is_collapsed = threads_element.hasClass( 'collapsed' ); - var thread_rows = $( 'tr', threads_element ); - - thread_rows - .each - ( - function( index, element ) - { - if( is_collapsed ) - { - $( element ) - .addClass( 'open' ); - } - else - { - $( element ) - .removeClass( 'open' ); - } - } - ); - - threads_element - .toggleClass( 'collapsed' ) - .toggleClass( 'expanded' ); - } - ); - }, - error : function( xhr, text_status, error_thrown) - { - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - ); - } - ); - - // #/:core/replication - this.get - ( - /^#\/([\w\d-]+)\/(replication)$/, - function( context ) - { - var core_basepath = this.active_core.attr( 'data-basepath' ); - var content_element = $( '#content' ); - - $.get - ( - 'tpl/replication.html', - function( template ) - { - content_element - .html( template ); - - var replication_element = $( '#replication', content_element ); - var navigation_element = $( '#navigation', replication_element ); - - function convert_seconds_to_readable_time( value ) - { - var text = []; - value = parseInt( value ); - - var minutes = Math.floor( value / 60 ); - var hours = Math.floor( minutes / 60 ); - - if( 0 !== hours ) - { - text.push( hours + 'h' ); - value -= hours * 60 * 60; - minutes -= hours * 60; - } - - if( 0 !== minutes ) - { - text.push( minutes + 'm' ); - value -= minutes * 60; - } - - text.push( value + 's' ); - - return text.join( ' ' ); - } - - function replication_fetch_status() - { - $.ajax - ( - { - url : core_basepath + '/replication?command=details&wt=json', - dataType : 'json', - beforeSend : function( xhr, settings ) - { - $( '.refresh-status', navigation_element ) - .addClass( 'loader' ); - }, - success : function( response, text_status, xhr ) - { - $( '.refresh-status', navigation_element ) - .removeClass( 'loader' ); - - var data = response.details; - var is_slave = 'true' === data.isSlave; - - replication_element - .addClass( is_slave ? 'slave' : 'master' ); - - if( is_slave ) - { - var error_element = $( '#error', replication_element ); - - if( data.slave.ERROR ) - { - error_element - .html( data.slave.ERROR ) - .show(); - } - else - { - error_element - .hide() - .empty(); - } - - var progress_element = $( '#progress', replication_element ); - - var start_element = $( '#start', progress_element ); - $( 'span', start_element ) - .text( data.slave.replicationStartTime ); - - var eta_element = $( '#eta', progress_element ); - $( 'span', eta_element ) - .text( convert_seconds_to_readable_time( data.slave.timeRemaining ) ); - - var bar_element = $( '#bar', progress_element ); - $( '.files span', bar_element ) - .text( data.slave.numFilesToDownload ); - $( '.size span', bar_element ) - .text( data.slave.bytesToDownload ); - - var speed_element = $( '#speed', progress_element ); - $( 'span', speed_element ) - .text( data.slave.downloadSpeed ); - - var done_element = $( '#done', progress_element ); - $( '.files span', done_element ) - .text( data.slave.numFilesDownloaded ); - $( '.size span', done_element ) - .text( data.slave.bytesDownloaded ); - $( '.percent span', done_element ) - .text( parseInt(data.slave.totalPercent ) ); - - var percent = parseInt( data.slave.totalPercent ); - if( 0 === percent ) - { - done_element - .css( 'width', '1px' ); - } - else - { - done_element - .css( 'width', percent + '%' ); - } - - var current_file_element = $( '#current-file', replication_element ); - $( '.file', current_file_element ) - .text( data.slave.currentFile ); - $( '.done', current_file_element ) - .text( data.slave.currentFileSizeDownloaded ); - $( '.total', current_file_element ) - .text( data.slave.currentFileSize ); - $( '.percent', current_file_element ) - .text( parseInt( data.slave.currentFileSizePercent ) ); - - if( !data.slave.indexReplicatedAtList ) - { - data.slave.indexReplicatedAtList = []; - } - - if( !data.slave.replicationFailedAtList ) - { - data.slave.replicationFailedAtList = []; - } - - var iterations_element = $( '#iterations', replication_element ); - var iterations_list = $( '.iterations ul', iterations_element ); - - var iterations_data = []; - $.merge( iterations_data, data.slave.indexReplicatedAtList ); - $.merge( iterations_data, data.slave.replicationFailedAtList ); - - if( 0 !== iterations_data.length ) - { - var iterations = []; - for( var i = 0; i < iterations_data.length; i++ ) - { - iterations.push - ( - '
  • ' + - iterations_data[i] + '
  • ' - ); - } - - iterations_list - .html( iterations.join( "\n" ) ) - .show(); - - $( data.slave.indexReplicatedAtList ) - .each - ( - function( key, value ) - { - $( 'li[data-date="' + value + '"]', iterations_list ) - .addClass( 'replicated' ); - } - ); - - if( data.slave.indexReplicatedAt ) - { - $( - 'li[data-date="' + data.slave.indexReplicatedAt + '"]', - iterations_list - ) - .addClass( 'latest' ); - } - - $( data.slave.replicationFailedAtList ) - .each - ( - function( key, value ) - { - $( 'li[data-date="' + value + '"]', iterations_list ) - .addClass( 'failed' ); - } - ); - - if( data.slave.replicationFailedAt ) - { - $( - 'li[data-date="' + data.slave.replicationFailedAt + '"]', - iterations_list - ) - .addClass( 'latest' ); - } - - if( 0 !== $( 'li:hidden', iterations_list ).size() ) - { - $( 'a', iterations_element ) - .show(); - } - else - { - $( 'a', iterations_element ) - .hide(); - } - } - } - - var details_element = $( '#details', replication_element ); - var current_type_element = $( ( is_slave ? '.slave' : '.master' ), details_element ); - - $( '.version div', current_type_element ) - .html( data.indexVersion ); - $( '.generation div', current_type_element ) - .html( data.generation ); - $( '.size div', current_type_element ) - .html( data.indexSize ); - - if( is_slave ) - { - var master_element = $( '.master', details_element ); - $( '.version div', master_element ) - .html( data.slave.masterDetails.indexVersion ); - $( '.generation div', master_element ) - .html( data.slave.masterDetails.generation ); - $( '.size div', master_element ) - .html( data.slave.masterDetails.indexSize ); - - if( data.indexVersion !== data.slave.masterDetails.indexVersion ) - { - $( '.version', details_element ) - .addClass( 'diff' ); - } - else - { - $( '.version', details_element ) - .removeClass( 'diff' ); - } - - if( data.generation !== data.slave.masterDetails.generation ) - { - $( '.generation', details_element ) - .addClass( 'diff' ); - } - else - { - $( '.generation', details_element ) - .removeClass( 'diff' ); - } - } - - if( is_slave ) - { - var settings_element = $( '#settings', replication_element ); - - if( data.slave.masterUrl ) - { - $( '.masterUrl dd', settings_element ) - .html( response.details.slave.masterUrl ) - .parents( 'li' ).show(); - } - - var polling_content = ' '; - var polling_ico = 'ico-1'; - - if( 'true' === data.slave.isPollingDisabled ) - { - polling_ico = 'ico-0'; - - $( '.disable-polling', navigation_element ).hide(); - $( '.enable-polling', navigation_element ).show(); - } - else - { - $( '.disable-polling', navigation_element ).show(); - $( '.enable-polling', navigation_element ).hide(); - - if( data.slave.pollInterval ) - { - polling_content = '(interval: ' + data.slave.pollInterval + ')'; - } - } - - $( '.isPollingDisabled dd', settings_element ) - .removeClass( 'ico-0' ) - .removeClass( 'ico-1' ) - .addClass( polling_ico ) - .html( polling_content ) - .parents( 'li' ).show(); - } - - var master_settings_element = $( '#master-settings', replication_element ); - - var master_data = is_slave - ? data.slave.masterDetails.master - : data.master; - - var replication_icon = 'ico-0'; - if( 'true' === master_data.replicationEnabled ) - { - replication_icon = 'ico-1'; - - $( '.disable-replication', navigation_element ).show(); - $( '.enable-replication', navigation_element ).hide(); - } - else - { - $( '.disable-replication', navigation_element ).hide(); - $( '.enable-replication', navigation_element ).show(); - } - - $( '.replicationEnabled dd', master_settings_element ) - .removeClass( 'ico-0' ) - .removeClass( 'ico-1' ) - .addClass( replication_icon ) - .parents( 'li' ).show(); - - $( '.replicateAfter dd', master_settings_element ) - .html( master_data.replicateAfter.join( ', ' ) ) - .parents( 'li' ).show(); - - if( master_data.confFiles ) - { - var conf_files = []; - var conf_data = master_data.confFiles.split( ',' ); - - for( var i = 0; i < conf_data.length; i++ ) - { - var item = conf_data[i]; - - if( - 1 !== item.indexOf( ':' ) ) - { - info = item.split( ':' ); - item = '' - + ( is_slave ? info[1] : info[0] ) - + ''; - } - - conf_files.push( item ); - } - - $( '.confFiles dd', master_settings_element ) - .html( conf_files.join( ', ' ) ) - .parents( 'li' ).show(); - } - - - $( '.block', replication_element ).last() - .addClass( 'last' ); - - - - - if( 'true' === data.slave.isReplicating ) - { - replication_element - .addClass( 'replicating' ); - - $( '.replicate-now', navigation_element ).hide(); - $( '.abort-replication', navigation_element ).show(); - - window.setTimeout( replication_fetch_status, 1000 ); - } - else - { - replication_element - .removeClass( 'replicating' ); - - $( '.replicate-now', navigation_element ).show(); - $( '.abort-replication', navigation_element ).hide(); - } - }, - error : function( xhr, text_status, error_thrown ) - { - $( '#content' ) - .html( 'sorry, no replication-handler defined!' ); - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - replication_fetch_status(); - - $( '#iterations a', content_element ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( this ).parents( '.iterations' ) - .toggleClass( 'expanded' ); - - return false; - } - ); - - $( 'button', navigation_element ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - var button = $( this ); - var command = button.data( 'command' ); - - if( button.hasClass( 'refresh-status' ) && !button.hasClass( 'loader' ) ) - { - replication_fetch_status(); - } - else if( command ) - { - $.get - ( - core_basepath + '/replication?command=' + command + '&wt=json', - function() - { - replication_fetch_status(); - } - ); - } - return false; - } - ); - } - ); - } - ); - - this.bind - ( - 'schema_browser_navi', - function( event, params ) - { - var related_navigation_element = $( '#related dl#f-df-t', params.schema_browser_element ); - var related_navigation_meta = $( '#related dl.ukf-dsf', params.schema_browser_element ); - var related_select_element = $( '#related select', params.schema_browser_element ) - var type = 'index'; - - var sammy_basepath = '#/' + $( 'p a', params.active_core ).html() + '/schema-browser'; - - if( !related_navigation_meta.hasClass( 'done' ) ) - { - if( app.schema_browser_data.unique_key_field ) - { - $( '.unique-key-field', related_navigation_meta ) - .show() - .after - ( - '
    ' + - app.schema_browser_data.unique_key_field + '
    ' - ); - } - - if( app.schema_browser_data.default_search_field ) - { - $( '.default-search-field', related_navigation_meta ) - .show() - .after - ( - '
    ' + - app.schema_browser_data.default_search_field + '
    ' - ); - } - - related_navigation_meta - .addClass( 'done' ); - } - - if( params.route_params ) - { - var type = params.route_params.splat[3]; - var value = params.route_params.splat[4]; - - var navigation_data = { - 'fields' : [], - 'copyfield_source' : [], - 'copyfield_dest' : [], - 'dynamic_fields' : [], - 'types' : [] - } - - $( 'option[value="' + params.route_params.splat[2] + '"]', related_select_element ) - .attr( 'selected', 'selected' ); - - if( 'field' === type ) - { - navigation_data.fields.push( value ); - navigation_data.types.push( app.schema_browser_data.relations.f_t[value] ); - - if( app.schema_browser_data.relations.f_df[value] ) - { - navigation_data.dynamic_fields.push( app.schema_browser_data.relations.f_df[value] ); - } - - if( 0 !== app.schema_browser_data.fields[value].copySources.length ) - { - navigation_data.copyfield_source = app.schema_browser_data.fields[value].copySources; - } - - if( 0 !== app.schema_browser_data.fields[value].copyDests.length ) - { - navigation_data.copyfield_dest = app.schema_browser_data.fields[value].copyDests; - } - } - else if( 'dynamic-field' === type ) - { - navigation_data.dynamic_fields.push( value ); - navigation_data.types.push( app.schema_browser_data.relations.df_t[value] ); - - if( app.schema_browser_data.relations.df_f[value] ) - { - navigation_data.fields = app.schema_browser_data.relations.df_f[value]; - } - } - else if( 'type' === type ) - { - navigation_data.types.push( value ); - - if( app.schema_browser_data.relations.t_f[value] ) - { - navigation_data.fields = app.schema_browser_data.relations.t_f[value]; - } - - if( app.schema_browser_data.relations.t_df[value] ) - { - navigation_data.dynamic_fields = app.schema_browser_data.relations.t_df[value]; - } - } - - var navigation_content = ''; - - if( 0 !== navigation_data.fields.length ) - { - navigation_data.fields.sort(); - navigation_content += '
    Fields
    ' + "\n"; - for( var i in navigation_data.fields ) - { - var href = sammy_basepath + '/field/' + navigation_data.fields[i]; - navigation_content += '
    ' + - navigation_data.fields[i] + '
    ' + "\n"; - } - } - - if( 0 !== navigation_data.copyfield_source.length ) - { - navigation_data.copyfield_source.sort(); - navigation_content += '
    Copied from
    ' + "\n"; - for( var i in navigation_data.copyfield_source ) - { - var href = sammy_basepath + '/field/' + navigation_data.copyfield_source[i]; - navigation_content += '
    ' + - navigation_data.copyfield_source[i] + '
    ' + "\n"; - } - } - - if( 0 !== navigation_data.copyfield_dest.length ) - { - navigation_data.copyfield_dest.sort(); - navigation_content += '
    Copied to
    ' + "\n"; - for( var i in navigation_data.copyfield_dest ) - { - var href = sammy_basepath + '/field/' + navigation_data.copyfield_dest[i]; - navigation_content += '
    ' + - navigation_data.copyfield_dest[i] + '
    ' + "\n"; - } - } - - if( 0 !== navigation_data.dynamic_fields.length ) - { - navigation_data.dynamic_fields.sort(); - navigation_content += '
    Dynamic Fields
    ' + "\n"; - for( var i in navigation_data.dynamic_fields ) - { - var href = sammy_basepath + '/dynamic-field/' + navigation_data.dynamic_fields[i]; - navigation_content += '
    ' + - navigation_data.dynamic_fields[i] + '
    ' + "\n"; - } - } - - if( 0 !== navigation_data.types.length ) - { - navigation_data.types.sort(); - navigation_content += '
    Types
    ' + "\n"; - for( var i in navigation_data.types ) - { - var href = sammy_basepath + '/type/' + navigation_data.types[i]; - navigation_content += '
    ' + - navigation_data.types[i] + '
    ' + "\n"; - } - } - - related_navigation_element - .show() - .attr( 'class', type ) - .html( navigation_content ); - } - else - { - related_navigation_element - .hide(); - - $( 'option:selected', related_select_element ) - .removeAttr( 'selected' ); - } - - if( 'field' === type && value === app.schema_browser_data.unique_key_field ) - { - $( '.unique-key-field', related_navigation_meta ) - .addClass( 'active' ); - } - else - { - $( '.unique-key-field', related_navigation_meta ) - .removeClass( 'active' ); - } - - if( 'field' === type && value === app.schema_browser_data.default_search_field ) - { - $( '.default-search-field', related_navigation_meta ) - .addClass( 'active' ); - } - else - { - $( '.default-search-field', related_navigation_meta ) - .removeClass( 'active' ); - } - - if( params.callback ) - { - params.callback( app.schema_browser_data, $( '#data', params.schema_browser_element ) ); - } - } - ); - - this.bind - ( - 'schema_browser_load', - function( event, params ) - { - var core_basepath = params.active_core.attr( 'data-basepath' ); - var content_element = $( '#content' ); - - if( app.schema_browser_data ) - { - params.schema_browser_element = $( '#schema-browser', content_element ); - - sammy.trigger - ( - 'schema_browser_navi', - params - ); - } - else - { - content_element - .html( '
    Loading ...
    ' ); - - $.ajax - ( - { - url : core_basepath + '/admin/luke?numTerms=0&wt=json', - dataType : 'json', - beforeSend : function( xhr, settings ) - { - }, - success : function( response, text_status, xhr ) - { - app.schema_browser_data = { - default_search_field : null, - unique_key_field : null, - key : {}, - fields : {}, - dynamic_fields : {}, - types : {}, - relations : { - f_df : {}, - f_t : {}, - df_f : {}, - df_t : {}, - t_f : {}, - t_df : {} - } - }; - - app.schema_browser_data.fields = response.fields; - app.schema_browser_data.key = response.info.key; - - $.ajax - ( - { - url : core_basepath + '/admin/luke?show=schema&wt=json', - dataType : 'json', - beforeSend : function( xhr, settings ) - { - }, - success : function( response, text_status, xhr ) - { - app.schema_browser_data.default_search_field = response.schema.defaultSearchField; - app.schema_browser_data.unique_key_field = response.schema.uniqueKeyField; - - app.schema_browser_data.dynamic_fields = response.schema.dynamicFields; - app.schema_browser_data.types = response.schema.types; - - var luke_array_to_struct = function( array ) - { - var struct = { - keys : [], - values : [] - }; - for( var i = 0; i < array.length; i += 2 ) - { - struct.keys.push( array[i] ); - struct.values.push( array[i+1] ); - } - return struct; - } - - var luke_array_to_hash = function( array ) - { - var hash = {}; - for( var i = 0; i < array.length; i += 2 ) - { - hash[ array[i] ] = array[i+1]; - } - return hash; - } - - for( var field in response.schema.fields ) - { - app.schema_browser_data.fields[field] = $.extend - ( - {}, - app.schema_browser_data.fields[field], - response.schema.fields[field] - ); - } - - for( var field in app.schema_browser_data.fields ) - { - app.schema_browser_data.fields[field].copySourcesRaw = null; - - if( app.schema_browser_data.fields[field].copySources && - 0 !== app.schema_browser_data.fields[field].copySources.length ) - { - app.schema_browser_data.fields[field].copySourcesRaw = - app.schema_browser_data.fields[field].copySources; - } - - app.schema_browser_data.fields[field].copyDests = []; - app.schema_browser_data.fields[field].copySources = []; - } - - for( var field in app.schema_browser_data.fields ) - { - if( app.schema_browser_data.fields[field].copySourcesRaw ) - { - var copy_sources = app.schema_browser_data.fields[field].copySourcesRaw; - for( var i in copy_sources ) - { - var target = copy_sources[i].replace( /^.+:(.+)\{.+$/, '$1' ); - - app.schema_browser_data.fields[field].copySources.push( target ); - app.schema_browser_data.fields[target].copyDests.push( field ); - } - } - - app.schema_browser_data.relations.f_t[field] = app.schema_browser_data.fields[field].type; - - if( !app.schema_browser_data.relations.t_f[app.schema_browser_data.fields[field].type] ) - { - app.schema_browser_data.relations.t_f[app.schema_browser_data.fields[field].type] = []; - } - app.schema_browser_data.relations.t_f[app.schema_browser_data.fields[field].type].push( field ); - - if( app.schema_browser_data.fields[field].dynamicBase ) - { - app.schema_browser_data.relations.f_df[field] = app.schema_browser_data.fields[field].dynamicBase; - - if( !app.schema_browser_data.relations.df_f[app.schema_browser_data.fields[field].dynamicBase] ) - { - app.schema_browser_data.relations.df_f[app.schema_browser_data.fields[field].dynamicBase] = []; - } - app.schema_browser_data.relations.df_f[app.schema_browser_data.fields[field].dynamicBase].push( field ); - } - } - - for( var dynamic_field in app.schema_browser_data.dynamic_fields ) - { - app.schema_browser_data.relations.df_t[dynamic_field] = app.schema_browser_data.dynamic_fields[dynamic_field].type; - - if( !app.schema_browser_data.relations.t_df[app.schema_browser_data.dynamic_fields[dynamic_field].type] ) - { - app.schema_browser_data.relations.t_df[app.schema_browser_data.dynamic_fields[dynamic_field].type] = []; - } - app.schema_browser_data.relations.t_df[app.schema_browser_data.dynamic_fields[dynamic_field].type].push( dynamic_field ); - } - - $.get - ( - 'tpl/schema-browser.html', - function( template ) - { - content_element - .html( template ); - - var schema_browser_element = $( '#schema-browser', content_element ); - var related_element = $( '#related', schema_browser_element ); - var related_select_element = $( 'select', related_element ); - var data_element = $( '#data', schema_browser_element ); - - var related_options = ''; - - var fields = []; - for( var field_name in app.schema_browser_data.fields ) - { - fields.push - ( - '' - ); - } - if( 0 !== fields.length ) - { - fields.sort(); - related_options += '' + "\n"; - related_options += fields.sort().join( "\n" ) + "\n"; - related_options += '' + "\n"; - } - - var dynamic_fields = []; - for( var type_name in app.schema_browser_data.dynamic_fields ) - { - dynamic_fields.push - ( - '' - ); - } - if( 0 !== dynamic_fields.length ) - { - dynamic_fields.sort(); - related_options += '' + "\n"; - related_options += dynamic_fields.sort().join( "\n" ) + "\n"; - related_options += '' + "\n"; - } - - var types = []; - for( var type_name in app.schema_browser_data.types ) - { - types.push - ( - '' - ); - } - if( 0 !== types.length ) - { - types.sort(); - related_options += '' + "\n"; - related_options += types.sort().join( "\n" ) + "\n"; - related_options += '' + "\n"; - } - - related_select_element - .attr( 'rel', '#/' + $( 'p a', params.active_core ).html() + '/schema-browser' ) - .append( related_options ); - - related_select_element - .die( 'change' ) - .live - ( - 'change', - function( event ) - { - var select_element = $( this ); - var option_element = $( 'option:selected', select_element ); - - location.href = select_element.attr( 'rel' ) + option_element.val(); - return false; - } - ); - - params.schema_browser_element = schema_browser_element; - sammy.trigger - ( - 'schema_browser_navi', - params - ); - } - ); - }, - error : function( xhr, text_status, error_thrown) - { - }, - complete : function( xhr, text_status ) - { - } - } - ); - - }, - error : function( xhr, text_status, error_thrown) - { - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - } - ); - - // #/:core/schema-browser - this.get - ( - /^#\/([\w\d-]+)\/(schema-browser)$/, - function( context ) - { - var callback = function( schema_browser_data, data_element ) - { - data_element - .hide(); - }; - - delete app.schema_browser_data; - - sammy.trigger - ( - 'schema_browser_load', - { - callback : callback, - active_core : this.active_core - } - ); - } - ); - - // #/:core/schema-browser/field|dynamic-field|type/$field - this.get - ( - /^#\/([\w\d-]+)\/(schema-browser)(\/(field|dynamic-field|type)\/(.+))$/, - function( context ) - { - var callback = function( schema_browser_data, data_element ) - { - var field = context.params.splat[4]; - - var type = context.params.splat[3]; - var is_f = 'field' === type; - var is_df = 'dynamic-field' === type; - var is_t = 'type' === type; - - var options_element = $( '.options', data_element ); - var sammy_basepath = context.path.indexOf( '/', context.path.indexOf( '/', 2 ) + 1 ); - - data_element - .show(); - - var keystring_to_list = function( keystring, element_class ) - { - var key_list = keystring.replace( /-/g, '' ).split( '' ); - var list = []; - - for( var i in key_list ) - { - var option_key = schema_browser_data.key[key_list[i]]; - - if( !option_key ) - { - option_key = schema_browser_data.key[key_list[i].toLowerCase()]; - } - - if( !option_key ) - { - option_key = schema_browser_data.key[key_list[i].toUpperCase()]; - } - - if( option_key ) - { - list.push - ( - '
    ' + - option_key + - ',
    ' - ); - } - } - - list[list.length-1] = list[key_list.length-1].replace( /,/, '' ); - - return list; - } - - var flags = null; - - if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].flags ) - { - flags = schema_browser_data.fields[field].flags; - } - else if( is_df && schema_browser_data.dynamic_fields[field] && schema_browser_data.dynamic_fields[field].flags ) - { - flags = schema_browser_data.dynamic_fields[field].flags; - } - - // -- properties - var properties_element = $( 'dt.properties', options_element ); - if( flags ) - { - var properties_keys = keystring_to_list( flags, 'properties' ); - - $( 'dd.properties', options_element ) - .remove(); - - properties_element - .show() - .after( properties_keys.join( "\n" ) ); - } - else - { - $( '.properties', options_element ) - .hide(); - } - - // -- schema - var schema_element = $( 'dt.schema', options_element ); - if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].schema ) - { - var schema_keys = keystring_to_list( schema_browser_data.fields[field].schema, 'schema' ); - - $( 'dd.schema', options_element ) - .remove(); - - schema_element - .show() - .after( schema_keys.join( "\n" ) ); - } - else - { - $( '.schema', options_element ) - .hide(); - } - - // -- index - var index_element = $( 'dt.index', options_element ); - if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].index ) - { - var index_keys = []; - - if( 0 === schema_browser_data.fields[field].index.indexOf( '(' ) ) - { - index_keys.push( '
    ' + schema_browser_data.fields[field].index + '
    ' ); - } - else - { - index_keys = keystring_to_list( schema_browser_data.fields[field].index, 'index' ); - } - - $( 'dd.index', options_element ) - .remove(); - - index_element - .show() - .after( index_keys.join( "\n" ) ); - } - else - { - $( '.index', options_element ) - .hide(); - } - - // -- docs - var docs_element = $( 'dt.docs', options_element ); - if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].docs ) - { - $( 'dd.docs', options_element ) - .remove(); - - docs_element - .show() - .after( '
    ' + schema_browser_data.fields[field].docs + '
    ' ); - } - else - { - $( '.docs', options_element ) - .hide(); - } - - // -- distinct - var distinct_element = $( 'dt.distinct', options_element ); - if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].distinct ) - { - $( 'dd.distinct', options_element ) - .remove(); - - distinct_element - .show() - .after( '
    ' + schema_browser_data.fields[field].distinct + '
    ' ); - } - else - { - $( '.distinct', options_element ) - .hide(); - } - - // -- position-increment-gap - var pig_element = $( 'dt.position-increment-gap', options_element ); - if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].positionIncrementGap ) - { - $( 'dt.position-increment-gap', options_element ) - .remove(); - - pig_element - .show() - .after( '
    ' + schema_browser_data.fields[field].positionIncrementGap + '
    ' ); - } - else - { - $( '.position-increment-gap', options_element ) - .hide(); - } - - var analyzer_element = $( '.analyzer', data_element ); - var analyzer_data = null; - - if( is_f ) - { - analyzer_data = schema_browser_data.types[schema_browser_data.relations.f_t[field]]; - } - else if( is_df ) - { - analyzer_data = schema_browser_data.types[schema_browser_data.relations.df_t[field]]; - } - else if( is_t ) - { - analyzer_data = schema_browser_data.types[field]; - } - - if( analyzer_data ) - { - var transform_analyzer_data_into_list = function( analyzer_data ) - { - var args = []; - for( var key in analyzer_data.args ) - { - var arg_class = ''; - var arg_content = ''; - - if( 'true' === analyzer_data.args[key] || '1' === analyzer_data.args[key] ) - { - arg_class = 'ico-1'; - arg_content = key; - } - else if( 'false' === analyzer_data.args[key] || '0' === analyzer_data.args[key] ) - { - arg_class = 'ico-0'; - arg_content = key; - } - else - { - arg_content = key + ': '; - - if( 'synonyms' === key || 'words' === key ) - { - // @TODO: set link target for file - arg_content += '' + analyzer_data.args[key] + ''; - } - else - { - arg_content += analyzer_data.args[key]; - } - } - - args.push( '
    ' + arg_content + '
    ' ); - } - - var list_content = '
    ' + analyzer_data.className + '
    '; - if( 0 !== args.length ) - { - args.sort(); - list_content += args.join( "\n" ); - } - - return list_content; - } - - // -- field-type - var field_type_element = $( 'dt.field-type', options_element ); - - $( 'dd.field-type', options_element ) - .remove(); - - field_type_element - .show() - .after( '
    ' + analyzer_data.className + '
    ' ); - - - for( var key in analyzer_data ) - { - var key_match = key.match( /^(.+)Analyzer$/ ); - if( !key_match ) - { - continue; - } - - var analyzer_key_element = $( '.' + key_match[1], analyzer_element ); - var analyzer_key_data = analyzer_data[key]; - - analyzer_element.show(); - analyzer_key_element.show(); - - if( analyzer_key_data.className ) - { - $( 'dl:first dt', analyzer_key_element ) - .html( analyzer_key_data.className ); - } - - $( 'ul li', analyzer_key_element ) - .hide(); - - for( var type in analyzer_key_data ) - { - if( 'object' !== typeof analyzer_key_data[type] ) - { - continue; - } - - var type_element = $( '.' + type, analyzer_key_element ); - var type_content = []; - - type_element.show(); - - if( analyzer_key_data[type].className ) - { - type_content.push( transform_analyzer_data_into_list( analyzer_key_data[type] ) ); - } - else - { - for( var entry in analyzer_key_data[type] ) - { - type_content.push( transform_analyzer_data_into_list( analyzer_key_data[type][entry] ) ); - } - } - - $( 'dl', type_element ) - .empty() - .append( type_content.join( "\n" ) ); - } - } - } - - var terminfo_element = $( '.terminfo-holder', data_element ); - - if( is_f ) { - // ideally we would have a checkbox to enable loading topterms - // stored as a cookie? so it stays the same - // TopTerms on a big index is really a DOS attack! - - core_basepath = "/solr"; // TODO????? - var status_holder_element = $( '.status-holder', terminfo_element ); - var topterms_holder_element = $( '.topterms-holder', terminfo_element ); - var histogram_holder_element = $( '.histogram-holder', terminfo_element ); - topterms_holder_element.hide(); - histogram_holder_element.hide(); - - $.ajax - ( - { - url : core_basepath + '/admin/luke?numTerms=50&wt=json&fl=' + field, - dataType : 'json', - context : status_holder_element, - beforeSend : function( xhr, settings ) - { - this.show(); - this - .html( '
    Loading Term Info...
    ' ) - .addClass( 'loader' ); - }, - success : function( response, text_status, xhr ) - { - var finfo = response['fields'][field]; - if( finfo ) { - this - .html( '
    '+field+' in '+finfo['docs']+' docs. '+finfo['distinct']+' distinct terms.

    ' ) - .removeClass( 'loader' ); - - console.log(finfo); - - // TODO!!! this is duplicate code!!!! - var luke_array_to_struct = function( array ) - { - var struct = { - keys : [], - values : [] - }; - for( var i = 0; i < array.length; i += 2 ) - { - struct.keys.push( array[i] ); - struct.values.push( array[i+1] ); - } - return struct; - } - - var luke_array_to_hash = function( array ) - { - var hash = {}; - for( var i = 0; i < array.length; i += 2 ) - { - hash[ array[i] ] = array[i+1]; - } - return hash; - } - - - if( finfo.histogram ) - { - var histogram = luke_array_to_struct( finfo.histogram ); - var histogram_values = luke_array_to_hash ( finfo.histogram ); - - histogram_holder_element.show(); - - var histogram_element = $( '.histogram', histogram_holder_element ); - - var histogram_legend = ''; - - for( var key in histogram_values ) - { - histogram_legend += '
    ' + key + '
    ' + "\n" + - '
    ' + - '' + histogram_values[key] + '' + - '
    ' + "\n"; - } - - $( 'dl', histogram_holder_element ) - .html( histogram_legend ); - - histogram_element.sparkline - ( - histogram.values, - { - type : 'bar', - barColor : '#c0c0c0', - zeroColor : '#ffffff', - height : histogram_element.height(), - barWidth : 46, - barSpacing : 3 - } - ); - } - - if( finfo.topTerms ) - { - var topterms = luke_array_to_struct( finfo.topTerms ); - var topterms_hash = luke_array_to_hash ( finfo.topTerms ); - var topterms_count = topterms.keys.length; - - topterms_holder_element.show(); - - var topterms_table_element = $( 'table', topterms_holder_element ); - - var topterms_navi_less = $( 'p.navi .less', topterms_holder_element ); - var topterms_navi_more = $( 'p.navi .more', topterms_holder_element ); - - var topterms_content = ''; - - var i = 1; - for( var term in topterms_hash ) - { - topterms_content += '' + "\n" + - '' + i + '' + "\n" + - '' + term + '' + "\n" + - '' + topterms_hash[term] + '' + "\n" + - '' + "\n"; - - if( i !== topterms_count && 0 === i % 10 ) - { - topterms_content += ''; - } - - i++; - } - - topterms_content += ''; - - topterms_table_element - .empty() - .append( topterms_content ); - - $( 'tbody', topterms_table_element ) - .die( 'change' ) - .live - ( - 'change', - function() - { - var blocks = $( 'tbody', topterms_table_element ); - var visible_blocks = blocks.filter( ':visible' ); - var hidden_blocks = blocks.filter( ':hidden' ); - - $( 'p.head .shown', topterms_holder_element ) - .html( $( 'tr', visible_blocks ).size() ); - - 0 < hidden_blocks.size() - ? topterms_navi_more.show() - : topterms_navi_more.hide(); - - 1 < visible_blocks.size() - ? topterms_navi_less.show() - : topterms_navi_less.hide(); - } - ); - - $( 'tbody tr:odd', topterms_table_element ) - .addClass( 'odd' ); - - $( 'tbody:first', topterms_table_element ) - .show() - .trigger( 'change' ); - - $( 'p.head .max', topterms_holder_element ) - .html( schema_browser_data.fields[field].distinct ); - - topterms_navi_less - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( 'tbody:visible', topterms_table_element ).last() - .hide() - .trigger( 'change' ); - } - ); - - topterms_navi_more - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( 'tbody:hidden', topterms_table_element ).first() - .show() - .trigger( 'change' ); - } - ); - } // end has Top Terms - } - else { - terminfo_element.hide(); - } - }, - error : function( xhr, text_status, error_thrown) - { - terminfo_element.hide(); - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - else { - terminfo_element.hide(); - } - } - - sammy.trigger - ( - 'schema_browser_load', - { - callback : callback, - active_core : this.active_core, - route_params : this.params - } - ); - } - ); - - this.bind - ( - 'dataimport_queryhandler_load', - function( event, params ) - { - var core_basepath = params.active_core.attr( 'data-basepath' ); - - $.ajax - ( - { - url : core_basepath + '/admin/mbeans?cat=QUERYHANDLER&wt=json', - dataType : 'json', - beforeSend : function( xhr, settings ) - { - }, - success : function( response, text_status, xhr ) - { - var handlers = response['solr-mbeans'][1]; - var dataimport_handlers = []; - for( var key in handlers ) - { - if( handlers[key]['class'] !== key && - handlers[key]['class'] === 'org.apache.solr.handler.dataimport.DataImportHandler' ) - { - dataimport_handlers.push( key ); - } - } - params.callback( dataimport_handlers ); - }, - error : function( xhr, text_status, error_thrown) - { - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - ); - - // #/:core/dataimport - this.get - ( - /^#\/([\w\d-]+)\/(dataimport)$/, - function( context ) - { - sammy.trigger - ( - 'dataimport_queryhandler_load', - { - active_core : this.active_core, - callback : function( dataimport_handlers ) - { - if( 0 === dataimport_handlers.length ) - { - $( '#content' ) - .html( 'sorry, no dataimport-handler defined!' ); - - return false; - } - - context.redirect( context.path + '/' + dataimport_handlers[0] ); - } - } - ); - } - ); - - // #/:core/dataimport - this.get - ( - /^#\/([\w\d-]+)\/(dataimport)\//, - function( context ) - { - var core_basepath = this.active_core.attr( 'data-basepath' ); - var content_element = $( '#content' ); - - var path_parts = this.path.match( /^(.+\/dataimport\/)(.*)$/ ); - var current_handler = path_parts[2]; - - $( 'li.dataimport', this.active_core ) - .addClass( 'active' ); - - $.get - ( - 'tpl/dataimport.html', - function( template ) - { - content_element - .html( template ); - - var dataimport_element = $( '#dataimport', content_element ); - var form_element = $( '#form', dataimport_element ); - var config_element = $( '#config', dataimport_element ); - var config_error_element = $( '#config-error', dataimport_element ); - - // handler - - sammy.trigger - ( - 'dataimport_queryhandler_load', - { - active_core : context.active_core, - callback : function( dataimport_handlers ) - { - - var handlers_element = $( '.handler', form_element ); - var handlers = []; - - for( var i = 0; i < dataimport_handlers.length; i++ ) - { - handlers.push - ( - '
  • ' + - dataimport_handlers[i] + - '
  • ' - ); - } - - $( 'ul', handlers_element ) - .html( handlers.join( "\n") ) ; - - $( 'a[href="' + context.path + '"]', handlers_element ).parent() - .addClass( 'active' ); - - handlers_element - .show(); - } - } - ); - - // config - - function dataimport_fetch_config() - { - $.ajax - ( - { - url : core_basepath + '/select?qt=' + current_handler + '&command=show-config', - dataType : 'xml', - context : $( '#dataimport_config', config_element ), - beforeSend : function( xhr, settings ) - { - }, - success : function( config, text_status, xhr ) - { - dataimport_element - .removeClass( 'error' ); - - config_error_element - .hide(); - - config_element - .addClass( 'hidden' ); - - - var entities = []; - - $( 'document > entity', config ) - .each - ( - function( i, element ) - { - entities.push( '' ); - } - ); - - $( '#entity', form_element ) - .append( entities.join( "\n" ) ); - }, - error : function( xhr, text_status, error_thrown ) - { - if( 'parsererror' === error_thrown ) - { - dataimport_element - .addClass( 'error' ); - - config_error_element - .show(); - - config_element - .removeClass( 'hidden' ); - } - }, - complete : function( xhr, text_status ) - { - var code = $( - '
    ' +
    -                                            xhr.responseText.replace( /\/g, '>' ) +
    -                                            '
    ' - ); - this.html( code ); - - if( 'success' === text_status ) - { - hljs.highlightBlock( code.get(0) ); - } - } - } - ); - } - dataimport_fetch_config(); - - $( '.toggle', config_element ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( this ).parents( '.block' ) - .toggleClass( 'hidden' ); - - return false; - } - ) - - var reload_config_element = $( '.reload_config', config_element ); - reload_config_element - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $.ajax - ( - { - url : core_basepath + '/select?qt=' + current_handler + '&command=reload-config', - dataType : 'xml', - context: $( this ), - beforeSend : function( xhr, settings ) - { - this - .addClass( 'loader' ); - }, - success : function( response, text_status, xhr ) - { - this - .addClass( 'success' ); - - window.setTimeout - ( - function() - { - reload_config_element - .removeClass( 'success' ); - }, - 5000 - ); - }, - error : function( xhr, text_status, error_thrown ) - { - this - .addClass( 'error' ); - }, - complete : function( xhr, text_status ) - { - this - .removeClass( 'loader' ); - - dataimport_fetch_config(); - } - } - ); - return false; - } - ) - - // state - - function dataimport_fetch_status() - { - $.ajax - ( - { - url : core_basepath + '/select?qt=' + current_handler + '&command=status', - dataType : 'xml', - beforeSend : function( xhr, settings ) - { - }, - success : function( response, text_status, xhr ) - { - var state_element = $( '#current_state', content_element ); - - var status = $( 'str[name="status"]', response ).text(); - var rollback_element = $( 'str[name="Rolledback"]', response ); - var messages_count = $( 'lst[name="statusMessages"] str', response ).size(); - - var started_at = $( 'str[name="Full Dump Started"]', response ).text(); - if( !started_at ) - { - started_at = (new Date()).toGMTString(); - } - - function dataimport_compute_details( response, details_element ) - { - var details = []; - - var requests = parseInt( $( 'str[name="Total Requests made to DataSource"]', response ).text() ); - if( NaN !== requests ) - { - details.push - ( - 'Requests: ' + - requests - ); - } - - var fetched = parseInt( $( 'str[name="Total Rows Fetched"]', response ).text() ); - if( NaN !== fetched ) - { - details.push - ( - 'Fetched: ' + - fetched - ); - } - - var skipped = parseInt( $( 'str[name="Total Documents Skipped"]', response ).text() ); - if( NaN !== requests ) - { - details.push - ( - 'Skipped: ' + - skipped - ); - } - - var processed = parseInt( $( 'str[name="Total Documents Processed"]', response ).text() ); - if( NaN !== processed ) - { - details.push - ( - 'Processed: ' + - processed - ); - } - - details_element - .html( details.join( ', ' ) ); - } - - state_element - .removeClass( 'indexing' ) - .removeClass( 'success' ) - .removeClass( 'failure' ); - - $( '.info', state_element ) - .removeClass( 'loader' ); - - if( 0 !== rollback_element.size() ) - { - state_element - .addClass( 'failure' ) - .show(); - - $( '.info strong', state_element ) - .text( $( 'str[name=""]', response ).text() ); - - console.debug( 'rollback @ ', rollback_element.text() ); - } - else if( 'idle' === status && 0 !== messages_count ) - { - state_element - .addClass( 'success' ) - .show(); - - $( '.time', state_element ) - .text( started_at ) - .timeago(); - - $( '.info strong', state_element ) - .text( $( 'str[name=""]', response ).text() ); - - dataimport_compute_details( response, $( '.info .details', state_element ) ); - } - else if( 'busy' === status ) - { - state_element - .addClass( 'indexing' ) - .show(); - - $( '.time', state_element ) - .text( started_at ) - .timeago(); - - $( '.info', state_element ) - .addClass( 'loader' ); - - $( '.info strong', state_element ) - .text( 'Indexing ...' ); - - dataimport_compute_details( response, $( '.info .details', state_element ) ); - - window.setTimeout( dataimport_fetch_status, 2000 ); - } - else - { - state_element.hide(); - } - }, - error : function( xhr, text_status, error_thrown ) - { - console.debug( arguments ); - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - dataimport_fetch_status(); - - // form - - $( 'form', form_element ) - .die( 'submit' ) - .live - ( - 'submit', - function( event ) - { - $.ajax - ( - { - url : core_basepath + '/select?qt=' + current_handler + '&command=full-import', - dataType : 'xml', - beforeSend : function( xhr, settings ) - { - }, - success : function( response, text_status, xhr ) - { - console.debug( response ); - dataimport_fetch_status(); - }, - error : function( xhr, text_status, error_thrown ) - { - console.debug( arguments ); - }, - complete : function( xhr, text_status ) - { - } - } - ); - return false; - } - ); - } - ); - } - ); - - - - this.bind - ( - 'plugins_load', - function( event, params ) - { - var callback = function() - { - params.callback( app.plugin_data.plugin_data, app.plugin_data.sort_table, app.plugin_data.types ); - } - - if( app.plugin_data ) - { - callback( app.plugin_data ); - return true; - } - - var core_basepath = params.active_core.attr( 'data-basepath' ); - $.ajax - ( - { - url : core_basepath + '/admin/mbeans?stats=true&wt=json', - dataType : 'json', - beforeSend : function( xhr, settings ) - { - }, - success : function( response, text_status, xhr ) - { - var types = []; - var sort_table = {}; - var plugin_data = {}; - - var types_obj = {}; - var plugin_key = null; - - for( var i = 0; i < response['solr-mbeans'].length; i++ ) - { - if( !( i % 2 ) ) - { - plugin_key = response['solr-mbeans'][i]; - } - else - { - plugin_data[plugin_key] = response['solr-mbeans'][i]; - } - } - - for( var key in plugin_data ) - { - sort_table[key] = { - url : [], - component : [], - handler : [] - }; - for( var part_key in plugin_data[key] ) - { - if( 0 < part_key.indexOf( '.' ) ) - { - types_obj[key] = true; - sort_table[key]['handler'].push( part_key ); - } - else if( 0 === part_key.indexOf( '/' ) ) - { - types_obj[key] = true; - sort_table[key]['url'].push( part_key ); - } - else - { - types_obj[key] = true; - sort_table[key]['component'].push( part_key ); - } - } - } - - for( var type in types_obj ) - { - types.push( type ); - } - types.sort(); - - app.plugin_data = { - 'plugin_data' : plugin_data, - 'sort_table' : sort_table, - 'types' : types - } - - $.get - ( - 'tpl/plugins.html', - function( template ) - { - $( '#content' ) - .html( template ); - - callback( app.plugin_data ); - } - ); - }, - error : function( xhr, text_status, error_thrown) - { - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - ); - - // #/:core/plugins/$type - this.get - ( - /^#\/([\w\d-]+)\/(plugins)\/(\w+)$/, - function( context ) - { - var content_element = $( '#content' ); - var type = context.params.splat[2].toUpperCase(); - var context_path = context.path.split( '?' ).shift(); - - sammy.trigger - ( - 'plugins_load', - { - active_core : this.active_core, - callback : function( plugin_data, plugin_sort, types ) - { - var frame_element = $( '#frame', content_element ); - var navigation_element = $( '#navigation ul', content_element ); - - var navigation_content = []; - for( var i = 0; i < types.length; i++ ) - { - var type_url = context.params.splat[0] + '/' + - context.params.splat[1] + '/' + - types[i].toLowerCase(); - - navigation_content.push - ( - '
  • ' + - '' + types[i] + '' + - '
  • ' - ); - } - - navigation_element - .html( navigation_content.join( "\n" ) ); - - $( 'a[href="' + context_path + '"]', navigation_element ) - .parent().addClass( 'current' ); - - var content = '
      '; - for( var sort_key in plugin_sort[type] ) - { - plugin_sort[type][sort_key].sort(); - var plugin_type_length = plugin_sort[type][sort_key].length; - - for( var i = 0; i < plugin_type_length; i++ ) - { - content += '
    • ' + "\n"; - content += ''; - content += plugin_sort[type][sort_key][i] - content += '' + "\n"; - content += '
        ' + "\n"; - - var details = plugin_data[type][ plugin_sort[type][sort_key][i] ]; - for( var detail_key in details ) - { - if( 'stats' !== detail_key ) - { - var detail_value = details[detail_key]; - - if( 'description' === detail_key ) - { - detail_value = detail_value.replace( /,/g, ',​' ); - } - else if( 'src' === detail_key ) - { - detail_value = detail_value.replace( /\//g, '/​' ); - } - - content += '
      • ' + "\n"; - content += '
        ' + detail_key + ':
        ' + "\n"; - content += '
        ' + detail_value + '
        ' + "\n"; - content += '
      • ' + "\n"; - } - else if( 'stats' === detail_key && details[detail_key] ) - { - content += '
      • ' + "\n"; - content += '' + detail_key + ':' + "\n"; - content += '
          ' + "\n"; - - for( var stats_key in details[detail_key] ) - { - var stats_value = details[detail_key][stats_key]; - - if( 'readerDir' === stats_key ) - { - stats_value = stats_value.replace( /@/g, '@​' ); - } - - content += '
        • ' + "\n"; - content += '
          ' + stats_key + ':
          ' + "\n"; - content += '
          ' + stats_value + '
          ' + "\n"; - content += '
        • ' + "\n"; - } - - content += '
      • ' + "\n"; - } - } - - content += '
      ' + "\n"; - } - } - content += '
    ' + "\n"; - - frame_element - .html( content ); - - $( 'a[href="' + decodeURIComponent( context.path ) + '"]', frame_element ) - .parent().addClass( 'expanded' ); - - $( '.entry', frame_element ) - .each - ( - function( i, entry ) - { - $( '.detail > li', entry ).not( '.stats' ).filter( ':even' ) - .addClass( 'odd' ); - - $( '.stats li:odd', entry ) - .addClass( 'odd' ); - } - ); - } - } - ); - } - ); - - // #/:core/plugins - this.get - ( - /^#\/([\w\d-]+)\/(plugins)$/, - function( context ) - { - delete app.plugin_data; - - sammy.trigger - ( - 'plugins_load', - { - active_core : this.active_core, - callback : function( plugin_data, plugin_sort, types ) - { - context.redirect( context.path + '/' + types[0].toLowerCase() ); - } - } - ); - } - ); - - // #/:core/query - this.get - ( - /^#\/([\w\d-]+)\/(query)$/, - function( context ) - { - var core_basepath = this.active_core.attr( 'data-basepath' ); - var content_element = $( '#content' ); - - $.get - ( - 'tpl/query.html', - function( template ) - { - content_element - .html( template ); - - var query_element = $( '#query', content_element ); - var query_form = $( '#form form', query_element ); - var url_element = $( '#url input', query_element ); - var result_element = $( '#result', query_element ); - var response_element = $( '#response iframe', result_element ); - - url_element - .die( 'change' ) - .live - ( - 'change', - function( event ) - { - var check_iframe_ready_state = function() - { - var iframe_element = response_element.get(0).contentWindow.document || - response_element.get(0).document; - - if( !iframe_element ) - { - console.debug( 'no iframe_element found', response_element ); - return false; - } - - url_element - .addClass( 'loader' ); - - if( 'complete' === iframe_element.readyState ) - { - url_element - .removeClass( 'loader' ); - } - else - { - window.setTimeout( check_iframe_ready_state, 100 ); - } - } - check_iframe_ready_state(); - - response_element - .attr( 'src', this.value ) - - if( !response_element.hasClass( 'resized' ) ) - { - response_element - .addClass( 'resized' ) - .css( 'height', $( '#main' ).height() - 60 ); - } - } - ) - - $( '.optional legend input[type=checkbox]', query_form ) - .die( 'change' ) - .live - ( - 'change', - function( event ) - { - var fieldset = $( this ).parents( 'fieldset' ); - - this.checked - ? fieldset.addClass( 'expanded' ) - : fieldset.removeClass( 'expanded' ); - } - ) - - for( var key in context.params ) - { - if( 'string' === typeof context.params[key] ) - { - $( '[name="' + key + '"]', query_form ) - .val( context.params[key] ); - } - } - - query_form - .die( 'submit' ) - .live - ( - 'submit', - function( event ) - { - var form_map = {}; - var form_values = []; - var all_form_values = query_form.formToArray(); - - for( var i = 0; i < all_form_values.length; i++ ) - { - if( !all_form_values[i].value || 0 === all_form_values[i].value.length ) - { - continue; - } - - var name_parts = all_form_values[i].name.split( '.' ); - if( 1 < name_parts.length && !form_map[name_parts[0]] ) - { - console.debug( 'skip "' + all_form_values[i].name + '", parent missing' ); - continue; - } - - form_map[all_form_values[i].name] = all_form_values[i].value; - form_values.push( all_form_values[i] ); - } - - var query_url = window.location.protocol + '//' + - window.location.host + - core_basepath + - '/select?' + - $.param( form_values ); - - url_element - .val( query_url ) - .trigger( 'change' ); - - result_element - .show(); - - return false; - } - ); - } - ); - } - ); - - // #/:core/analysis - this.get - ( - /^#\/([\w\d-]+)\/(analysis)$/, - function( context ) - { - var core_basepath = this.active_core.attr( 'data-basepath' ); - var content_element = $( '#content' ); - - $.get - ( - 'tpl/analysis.html', - function( template ) - { - content_element - .html( template ); - - var analysis_element = $( '#analysis', content_element ); - var analysis_form = $( 'form', analysis_element ); - var analysis_result = $( '#analysis-result', analysis_element ); - analysis_result.hide(); - - $.ajax - ( - { - url : core_basepath + '/admin/luke?wt=json&show=schema', - dataType : 'json', - context : $( '#type_or_name', analysis_form ), - beforeSend : function( xhr, settings ) - { - this - .html( '' ) - .addClass( 'loader' ); - }, - success : function( response, text_status, xhr ) - { - var content = ''; - - var fields = []; - for( var field_name in response.schema.fields ) - { - fields.push - ( - '' - ); - } - if( 0 !== fields.length ) - { - content += '' + "\n"; - content += fields.sort().join( "\n" ) + "\n"; - content += '' + "\n"; - } - - var types = []; - for( var type_name in response.schema.types ) - { - types.push - ( - '' - ); - } - if( 0 !== types.length ) - { - content += '' + "\n"; - content += types.sort().join( "\n" ) + "\n"; - content += '' + "\n"; - } - - this - .html( content ); - - $( 'option[value="fieldname\=' + response.schema.defaultSearchField + '"]', this ) - .attr( 'selected', 'selected' ); - }, - error : function( xhr, text_status, error_thrown) - { - }, - complete : function( xhr, text_status ) - { - this - .removeClass( 'loader' ); - } - } - ); - - $( '.verbose_output a', analysis_element ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( this ).parent() - .toggleClass( 'active' ); - - analysis_result - .toggleClass( 'verbose_output' ); - - check_empty_spacer(); - } - ); - - var check_empty_spacer = function() - { - var spacer_holder = $( 'td.part.data.spacer .holder', analysis_result ); - - if( 0 === spacer_holder.size() ) - { - return false; - } - - var verbose_output = analysis_result.hasClass( 'verbose_output' ); - - spacer_holder - .each - ( - function( index, element ) - { - element = $( element ); - - if( verbose_output ) - { - var cell = element.parent(); - element.height( cell.height() ); - } - else - { - element.removeAttr( 'style' ); - } - } - ); - } - - var button = $( 'button', analysis_form ) - - analysis_form - .ajaxForm - ( - { - url : core_basepath + '/analysis/field?wt=json', - dataType : 'json', - beforeSubmit : function( array, form, options ) - { - loader.show( button ); - button.attr( 'disabled', true ); - - array.push( { name: 'analysis.showmatch', value: 'true' } ); - - var type_or_name = $( '#type_or_name', form ).val().split( '=' ); - - array.push( { name: 'analysis.' + type_or_name[0], value: type_or_name[1] } ); - }, - success : function( response, status_text, xhr, form ) - { - analysis_result - .empty() - .show(); - - for( var name in response.analysis.field_names ) - { - build_analysis_table( 'name', name, response.analysis.field_names[name] ); - } - - for( var name in response.analysis.field_types ) - { - build_analysis_table( 'type', name, response.analysis.field_types[name] ); - } - - check_empty_spacer(); - }, - error : function( xhr, text_status, error_thrown ) - { - $( '#analysis-error', analysis_element ) - .show(); - }, - complete : function() - { - loader.hide( $( 'button', analysis_form ) ); - button.removeAttr( 'disabled' ); - } - } - ); - - var generate_class_name = function( type ) - { - var classes = [type]; - if( 'text' !== type ) - { - classes.push( 'verbose_output' ); - } - return classes.join( ' ' ); - } - - var build_analysis_table = function( field_or_name, name, analysis_data ) - { - for( var type in analysis_data ) - { - var type_length = analysis_data[type].length; - if( 0 !== type_length ) - { - var global_elements_count = 0; - for( var i = 0; i < analysis_data[type].length; i += 2 ) - { - if( 'string' === typeof analysis_data[type][i+1] ) - { - analysis_data[type][i+1] = [{ 'text': analysis_data[type][i+1] }] - } - global_elements_count = Math.max( global_elements_count, - analysis_data[type][i+1].length ); - } - - var content = '
    ' + "\n"; - content += '' + "\n"; - - for( var i = 0; i < analysis_data[type].length; i += 2 ) - { - var colspan = 1; - var elements = analysis_data[type][i+1]; - var elements_count = global_elements_count; - - if( !elements[0].positionHistory ) - { - colspan = elements_count; - elements_count = 1; - } - - var legend = []; - for( var key in elements[0] ) - { - var key_parts = key.split( '#' ); - var used_key = key_parts.pop(); - var short_key = used_key; - - if( 1 === key_parts.length ) - { - used_key = '' + used_key + ''; - } - - if( 'positionHistory' === short_key || 'match' === short_key ) - { - continue; - } - - legend.push - ( - '' + - '' + - '' - ); - } - - content += '' + "\n"; - content += '' + "\n"; - - // analyzer - var analyzer_name = analysis_data[type][i] - .replace( /(\$1)+$/g, '' ); - - var analyzer_short = -1 !== analyzer_name.indexOf( '$' ) - ? analyzer_name.split( '$' )[1] - : analyzer_name.split( '.' ).pop(); - analyzer_short = analyzer_short.match( /[A-Z]/g ).join( '' ); - - content += '' + "\n"; - - // legend - content += '' + "\n"; - - // data - var cell_content = ''; - var cells = new Array( elements_count + 1 ).join( cell_content ); - content += cells + "\n"; - - content += '' + "\n"; - content += '' + "\n"; - } - content += '
    ' + used_key + '
    ' + "\n"; - content += '' + "\n"; - content += analyzer_short + '
    ' + "\n"; - content += '' + "\n"; - content += '
    ' + "\n"; - content += '' + "\n"; - content += legend.join( "\n" ) + "\n"; - content += '
    ' - + '
     
    ' - + '
    ' + "\n"; - content += '
    ' + "\n"; - - $( '.' + type, analysis_result ) - .remove(); - - analysis_result - .append( content ); - - var analysis_result_type = $( '.' + type, analysis_result ); - - for( var i = 0; i < analysis_data[type].length; i += 2 ) - { - for( var j = 0; j < analysis_data[type][i+1].length; j += 1 ) - { - var pos = analysis_data[type][i+1][j].positionHistory - ? analysis_data[type][i+1][j].positionHistory[0] - : 1; - var selector = 'tr.step:eq(' + ( i / 2 ) +') ' - + 'td.data:eq(' + ( pos - 1 ) + ') ' - + '.holder'; - var cell = $( selector, analysis_result_type ); - - cell.parent() - .removeClass( 'spacer' ); - - var table = $( 'table tr.details', cell ); - if( 0 === table.size() ) - { - cell - .html - ( - '' + - '
    ' - ); - var table = $( 'table tr.details', cell ); - } - - var tokens = []; - for( var key in analysis_data[type][i+1][j] ) - { - var short_key = key.split( '#' ).pop(); - - if( 'positionHistory' === short_key || 'match' === short_key ) - { - continue; - } - - var classes = []; - classes.push( generate_class_name( short_key ) ); - - var data = analysis_data[type][i+1][j][key]; - if( 'object' === typeof data && data instanceof Array ) - { - data = data.join( ' ' ); - } - if( 'string' === typeof data ) - { - data = data.esc(); - } - - if( null === data || 0 === data.length ) - { - classes.push( 'empty' ); - data = '∅'; - } - - if( analysis_data[type][i+1][j].match && - ( 'text' === short_key || 'raw_bytes' === short_key ) ) - { - classes.push( 'match' ); - } - - tokens.push - ( - '' + - '' + data + '' + - '' - ); - } - table - .append - ( - '' + - '' + - tokens.join( "\n" ) + - '
    ' - ); - } - } - - } - } - } - - } - ); - } - ); - - // #/:core/schema, #/:core/config - this.get - ( - /^#\/([\w\d-]+)\/(schema|config)$/, - function( context ) - { - var core_basepath = this.active_core.attr( 'data-basepath' ); - - $.ajax - ( - { - url : core_basepath + app.config[context.params.splat[1] + '_path'], - dataType : 'xml', - context : $( '#content' ), - beforeSend : function( xhr, settings ) - { - this - .html( '
    Loading ...
    ' ); - }, - complete : function( xhr, text_status ) - { - var code = $( - '
    ' +
    -                                xhr.responseText.replace( /\/g, '>' ) +
    -                                '
    ' - ); - this.html( code ); - - if( 'success' === text_status ) - { - hljs.highlightBlock( code.get(0) ); - } - } - } - ); - } - ); - - // #/:core - this.get - ( - /^#\/([\w\d-]+)$/, - function( context ) - { - var core_basepath = this.active_core.attr( 'data-basepath' ); - var content_element = $( '#content' ); - - content_element - .removeClass( 'single' ); - - var core_menu = $( 'ul', this.active_core ); - if( !core_menu.data( 'admin-extra-loaded' ) ) - { - core_menu.data( 'admin-extra-loaded', new Date() ); - - $.get - ( - core_basepath + '/admin/file/?file=admin-extra.menu-top.html', - function( menu_extra ) - { - core_menu - .prepend( menu_extra ); - } - ); - - $.get - ( - core_basepath + '/admin/file/?file=admin-extra.menu-bottom.html', - function( menu_extra ) - { - core_menu - .append( menu_extra ); - } - ); - } - - $.get - ( - 'tpl/dashboard.html', - function( template ) - { - content_element - .html( template ); - - var dashboard_element = $( '#dashboard' ); - - $.ajax - ( - { - url : core_basepath + '/admin/luke?wt=json&show=index&numTerms=0', - dataType : 'json', - context : $( '#statistics', dashboard_element ), - beforeSend : function( xhr, settings ) - { - $( 'h2', this ) - .addClass( 'loader' ); - - $( '.message', this ) - .show() - .html( 'Loading ...' ); - - $( '.content' ) - .hide(); - }, - success : function( response, text_status, xhr ) - { - $( '.message', this ) - .empty() - .hide(); - - $( '.content', this ) - .show(); - - var data = { - 'index_num-docs' : response['index']['numDocs'], - 'index_max-doc' : response['index']['maxDoc'], - 'index_version' : response['index']['version'], - 'index_segmentCount' : response['index']['segmentCount'], - 'index_last-modified' : response['index']['lastModified'] - }; - - for( var key in data ) - { - $( '.' + key, this ) - .show(); - - $( '.value.' + key, this ) - .html( data[key] ); - } - - var optimized_element = $( '.value.index_optimized', this ); - if( !response['index']['hasDeletions'] ) - { - optimized_element - .addClass( 'ico-1' ); - - $( 'span', optimized_element ) - .html( 'yes' ); - } - else - { - optimized_element - .addClass( 'ico-0' ); - - $( 'span', optimized_element ) - .html( 'no' ); - } - - var current_element = $( '.value.index_current', this ); - if( response['index']['current'] ) - { - current_element - .addClass( 'ico-1' ); - - $( 'span', current_element ) - .html( 'yes' ); - } - else - { - current_element - .addClass( 'ico-0' ); - - $( 'span', current_element ) - .html( 'no' ); - } - - $( 'a', optimized_element ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $.ajax - ( - { - url : core_basepath + '/update?optimize=true&waitFlush=true&wt=json', - dataType : 'json', - context : $( this ), - beforeSend : function( xhr, settings ) - { - this - .addClass( 'loader' ); - }, - success : function( response, text_status, xhr ) - { - this.parents( 'dd' ) - .removeClass( 'ico-0' ) - .addClass( 'ico-1' ); - }, - error : function( xhr, text_status, error_thrown) - { - console.warn( 'd0h, optimize broken!' ); - }, - complete : function( xhr, text_status ) - { - this - .removeClass( 'loader' ); - } - } - ); - } - ); - - $( '.timeago', this ) - .timeago(); - }, - error : function( xhr, text_status, error_thrown ) - { - this - .addClass( 'disabled' ); - - $( '.message', this ) - .show() - .html( 'Luke is not configured' ); - }, - complete : function( xhr, text_status ) - { - $( 'h2', this ) - .removeClass( 'loader' ); - } - } - ); - - $.ajax - ( - { - url : core_basepath + '/replication?command=details&wt=json', - dataType : 'json', - context : $( '#replication', dashboard_element ), - beforeSend : function( xhr, settings ) - { - $( 'h2', this ) - .addClass( 'loader' ); - - $( '.message', this ) - .show() - .html( 'Loading' ); - - $( '.content', this ) - .hide(); - }, - success : function( response, text_status, xhr ) - { - $( '.message', this ) - .empty() - .hide(); - - $( '.content', this ) - .show(); - - $( '.replication', context.active_core ) - .show(); - - var data = response.details; - var is_slave = 'undefined' !== typeof( data.slave ); - var headline = $( 'h2 span', this ); - var details_element = $( '#details', this ); - var current_type_element = $( ( is_slave ? '.slave' : '.master' ), this ); - - if( is_slave ) - { - this - .addClass( 'slave' ); - - headline - .html( headline.html() + ' (Slave)' ); - } - else - { - this - .addClass( 'master' ); - - headline - .html( headline.html() + ' (Master)' ); - } - - $( '.version div', current_type_element ) - .html( data.indexVersion ); - $( '.generation div', current_type_element ) - .html( data.generation ); - $( '.size div', current_type_element ) - .html( data.indexSize ); - - if( is_slave ) - { - var master_element = $( '.master', details_element ); - $( '.version div', master_element ) - .html( data.slave.masterDetails.indexVersion ); - $( '.generation div', master_element ) - .html( data.slave.masterDetails.generation ); - $( '.size div', master_element ) - .html( data.slave.masterDetails.indexSize ); - - if( data.indexVersion !== data.slave.masterDetails.indexVersion ) - { - $( '.version', details_element ) - .addClass( 'diff' ); - } - else - { - $( '.version', details_element ) - .removeClass( 'diff' ); - } - - if( data.generation !== data.slave.masterDetails.generation ) - { - $( '.generation', details_element ) - .addClass( 'diff' ); - } - else - { - $( '.generation', details_element ) - .removeClass( 'diff' ); - } - } - }, - error : function( xhr, text_status, error_thrown) - { - this - .addClass( 'disabled' ); - - $( '.message', this ) - .show() - .html( 'Replication is not configured' ); - }, - complete : function( xhr, text_status ) - { - $( 'h2', this ) - .removeClass( 'loader' ); - } - } - ); - - $.ajax - ( - { - url : core_basepath + '/dataimport?command=details&wt=json', - dataType : 'json', - context : $( '#dataimport', dashboard_element ), - beforeSend : function( xhr, settings ) - { - $( 'h2', this ) - .addClass( 'loader' ); - - $( '.message', this ) - .show() - .html( 'Loading' ); - }, - success : function( response, text_status, xhr ) - { - $( '.message', this ) - .empty() - .hide(); - - $( 'dl', this ) - .show(); - - var data = { - 'status' : response['status'], - 'info' : response['statusMessages'][''] - }; - - for( var key in data ) - { - $( '.' + key, this ) - .show(); - - $( '.value.' + key, this ) - .html( data[key] ); - } - }, - error : function( xhr, text_status, error_thrown) - { - this - .addClass( 'disabled' ); - - $( '.message', this ) - .show() - .html( 'Dataimport is not configured' ); - }, - complete : function( xhr, text_status ) - { - $( 'h2', this ) - .removeClass( 'loader' ); - } - } - ); - - $.ajax - ( - { - url : core_basepath + '/admin/file/?file=admin-extra.html', - dataType : 'html', - context : $( '#admin-extra', dashboard_element ), - beforeSend : function( xhr, settings ) - { - $( 'h2', this ) - .addClass( 'loader' ); - - $( '.message', this ) - .show() - .html( 'Loading' ); - - $( '.content', this ) - .hide(); - }, - success : function( response, text_status, xhr ) - { - $( '.message', this ) - .hide() - .empty(); - - $( '.content', this ) - .show() - .html( response ); - }, - error : function( xhr, text_status, error_thrown) - { - this - .addClass( 'disabled' ); - - $( '.message', this ) - .show() - .html( 'We found no "admin-extra.html" file.' ); - }, - complete : function( xhr, text_status ) - { - $( 'h2', this ) - .removeClass( 'loader' ); - } - } - ); - - } - ); - } - ); - - // #/ - this.get - ( - /^#\/$/, - function( context ) - { - var content_element = $( '#content' ); - - $( '#index', app.menu_element ) - .addClass( 'active' ); - - content_element - .html( '
    ' ); - - $.ajax - ( - { - url : 'tpl/index.html', - context : $( '#index', content_element ), - beforeSend : function( arr, form, options ) - { - }, - success : function( template ) - { - this - .html( template ); - - var jvm_memory = $.extend - ( - { - 'free' : null, - 'total' : null, - 'max' : null, - 'used' : null, - 'raw' : { - 'free' : null, - 'total' : null, - 'max' : null, - 'used' : null, - 'used%' : null - } - }, - app.dashboard_values['jvm']['memory'] - ); - - var parse_memory_value = function( value ) - { - if( value !== Number( value ) ) - { - var units = 'BKMGTPEZY'; - var match = value.match( /^(\d+([,\.]\d+)?) (\w)\w?$/ ); - var value = parseFloat( match[1] ) * Math.pow( 1024, units.indexOf( match[3].toUpperCase() ) ); - } - - return value; - }; - var memory_data = { - 'memory-bar-max' : parse_memory_value( jvm_memory['raw']['max'] || jvm_memory['max'] ), - 'memory-bar-total' : parse_memory_value( jvm_memory['raw']['total'] || jvm_memory['total'] ), - 'memory-bar-used' : parse_memory_value( jvm_memory['raw']['used'] || jvm_memory['used'] ) - }; - - for( var key in memory_data ) - { - $( '.value.' + key, this ) - .text( memory_data[key] ); - } - - var data = { - 'start_time' : app.dashboard_values['jvm']['jmx']['startTime'], - 'host' : app.dashboard_values['core']['host'], - 'jvm' : app.dashboard_values['jvm']['name'] + ' (' + app.dashboard_values['jvm']['version'] + ')', - 'solr_spec_version' : app.dashboard_values['lucene']['solr-spec-version'], - 'solr_impl_version' : app.dashboard_values['lucene']['solr-impl-version'], - 'lucene_spec_version' : app.dashboard_values['lucene']['lucene-spec-version'], - 'lucene_impl_version' : app.dashboard_values['lucene']['lucene-impl-version'] - }; - - if( app.dashboard_values['core']['directory']['cwd'] ) - { - data['cwd'] = app.dashboard_values['core']['directory']['cwd']; - } - - for( var key in data ) - { - var value_element = $( '.' + key + ' dd', this ); - - value_element - .text( data[key] ); - - value_element.closest( 'li' ) - .show(); - } - - var commandLineArgs = app.dashboard_values['jvm']['jmx']['commandLineArgs']; - if( 0 !== commandLineArgs.length ) - { - var cmd_arg_element = $( '.command_line_args dt', this ); - var cmd_arg_key_element = $( '.command_line_args dt', this ); - var cmd_arg_element = $( '.command_line_args dd', this ); - - for( var key in commandLineArgs ) - { - cmd_arg_element = cmd_arg_element.clone(); - cmd_arg_element.text( commandLineArgs[key] ); - - cmd_arg_key_element - .after( cmd_arg_element ); - } - - cmd_arg_key_element.closest( 'li' ) - .show(); - - $( '.command_line_args dd:last', this ) - .remove(); - - $( '.command_line_args dd:odd', this ) - .addClass( 'odd' ); - } - - $( '.timeago', this ) - .timeago(); - - $( 'li:visible:odd', this ) - .addClass( 'odd' ); - - // -- memory bar - - var max_height = Math.round( $( '#memory-bar-max', this ).height() ); - var total_height = Math.round( ( memory_data['memory-bar-total'] * max_height ) / memory_data['memory-bar-max'] ); - var used_height = Math.round( ( memory_data['memory-bar-used'] * max_height ) / memory_data['memory-bar-max'] ); - - var memory_bar_total_value = $( '#memory-bar-total span', this ).first(); - - $( '#memory-bar-total', this ) - .height( total_height ); - - $( '#memory-bar-used', this ) - .height( used_height ); - - if( used_height < total_height + memory_bar_total_value.height() ) - { - memory_bar_total_value - .addClass( 'upper' ) - .css( 'margin-top', memory_bar_total_value.height() * -1 ); - } - - var memory_percentage = ( ( memory_data['memory-bar-used'] / memory_data['memory-bar-max'] ) * 100 ).toFixed(1); - var headline = $( '#memory h2 span', this ); - - headline - .text( headline.html() + ' (' + memory_percentage + '%)' ); - - $( '#memory-bar .value', this ) - .each - ( - function() - { - var self = $( this ); - - var byte_value = parseInt( self.html() ); - - self - .attr( 'title', 'raw: ' + byte_value + ' B' ); - - byte_value /= 1024; - byte_value /= 1024; - byte_value = byte_value.toFixed( 2 ) + ' MB'; - - self - .text( byte_value ); - } - ); - }, - error : function( xhr, text_status, error_thrown ) - { - }, - complete : function( xhr, text_status ) - { - } - } - ); - } - ); - } -); - -var solr_admin = function( app_config ) -{ - menu_element = null, - - is_multicore = null, - cores_data = null, - active_core = null, - environment_basepath = null, - - config = app_config, - params = null, - dashboard_values = null, - schema_browser_data = null, - - plugin_data = null, - - this.init_menu = function() - { - $( '.ping a', menu_element ) - .live - ( - 'click', - function() - { - sammy.trigger - ( - 'ping', - { element : this } - ); - return false; - } - ); - } - - this.init_cores = function() - { - var self = this; - - $.ajax - ( - { - url : config.solr_path + config.core_admin_path + '?wt=json', - dataType : 'json', - beforeSend : function( arr, form, options ) - { - $( '#content' ) - .html( '
    Loading ...
    ' ); - }, - success : function( response ) - { - self.cores_data = response.status; - is_multicore = 'undefined' === typeof response.status['']; - - if( is_multicore ) - { - menu_element - .addClass( 'multicore' ); - - $( '#cores', menu_element ) - .show(); - } - else - { - menu_element - .addClass( 'singlecore' ); - } - - for( var core_name in response.status ) - { - var core_path = config.solr_path + '/' + core_name; - - if( !core_name ) - { - core_name = 'singlecore'; - core_path = config.solr_path - } - - if( !environment_basepath ) - { - environment_basepath = core_path; - } - - var core_tpl = '
  • ' + "\n" - + '

    ' + core_name + '

    ' + "\n" - + ' ' + "\n" - + '
  • '; - - menu_element - .append( core_tpl ); - } - - $.ajax - ( - { - url : environment_basepath + '/admin/system?wt=json', - dataType : 'json', - beforeSend : function( arr, form, options ) - { - }, - success : function( response ) - { - self.dashboard_values = response; - - var environment_args = null; - var cloud_args = null; - - if( response.jvm && response.jvm.jmx && response.jvm.jmx.commandLineArgs ) - { - var command_line_args = response.jvm.jmx.commandLineArgs.join( ' | ' ); - - environment_args = command_line_args - .match( /-Dsolr.environment=((dev|test|prod)?[\w\d]*)/i ); - - cloud_args = command_line_args - .match( /-Dzk/i ); - } - - // environment - - var environment_element = $( '#environment' ); - if( environment_args ) - { - environment_element - .show(); - - if( environment_args[1] ) - { - environment_element - .html( environment_args[1] ); - } - - if( environment_args[2] ) - { - environment_element - .addClass( environment_args[2] ); - } - } - else - { - environment_element - .remove(); - } - - // cloud - - var cloud_nav_element = $( '#menu #cloud' ); - if( cloud_args ) - { - cloud_nav_element - .show(); - } - - // application - - sammy.run( location.hash ); - }, - error : function() - { - }, - complete : function() - { - loader.hide( this ); - } - } - ); - }, - error : function() - { - }, - complete : function() - { - } - } - ); - } - - this.__construct = function() - { - menu_element = $( '#menu ul' ); - - this.init_menu(); - this.init_cores(); - - this.menu_element = menu_element; - this.config = config; - } - this.__construct(); -} - -var app; -$( document ).ready -( - function() - { - jQuery.timeago.settings.allowFuture = true; - - app = new solr_admin( app_config ); - } -); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/analysis.js b/solr/webapp/web/js/scripts/analysis.js new file mode 100644 index 00000000000..2025ee6f92d --- /dev/null +++ b/solr/webapp/web/js/scripts/analysis.js @@ -0,0 +1,420 @@ +// #/:core/analysis +sammy.get +( + /^#\/([\w\d-]+)\/(analysis)$/, + function( context ) + { + var core_basepath = this.active_core.attr( 'data-basepath' ); + var content_element = $( '#content' ); + + $.get + ( + 'tpl/analysis.html', + function( template ) + { + content_element + .html( template ); + + var analysis_element = $( '#analysis', content_element ); + var analysis_form = $( 'form', analysis_element ); + var analysis_result = $( '#analysis-result', analysis_element ); + analysis_result.hide(); + + $.ajax + ( + { + url : core_basepath + '/admin/luke?wt=json&show=schema', + dataType : 'json', + context : $( '#type_or_name', analysis_form ), + beforeSend : function( xhr, settings ) + { + this + .html( '' ) + .addClass( 'loader' ); + }, + success : function( response, text_status, xhr ) + { + var content = ''; + + var fields = []; + for( var field_name in response.schema.fields ) + { + fields.push + ( + '' + ); + } + if( 0 !== fields.length ) + { + content += '' + "\n"; + content += fields.sort().join( "\n" ) + "\n"; + content += '' + "\n"; + } + + var types = []; + for( var type_name in response.schema.types ) + { + types.push + ( + '' + ); + } + if( 0 !== types.length ) + { + content += '' + "\n"; + content += types.sort().join( "\n" ) + "\n"; + content += '' + "\n"; + } + + this + .html( content ); + + $( 'option[value="fieldname\=' + response.schema.defaultSearchField + '"]', this ) + .attr( 'selected', 'selected' ); + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + this + .removeClass( 'loader' ); + } + } + ); + + $( '.analysis-error .head a', analysis_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( this ).parents( '.analysis-error' ) + .toggleClass( 'expanded' ); + } + ); + + $( '.verbose_output a', analysis_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( this ).parent() + .toggleClass( 'active' ); + + analysis_result + .toggleClass( 'verbose_output' ); + + check_empty_spacer(); + } + ); + + var check_empty_spacer = function() + { + var spacer_holder = $( 'td.part.data.spacer .holder', analysis_result ); + + if( 0 === spacer_holder.size() ) + { + return false; + } + + var verbose_output = analysis_result.hasClass( 'verbose_output' ); + + spacer_holder + .each + ( + function( index, element ) + { + element = $( element ); + + if( verbose_output ) + { + var cell = element.parent(); + element.height( cell.height() ); + } + else + { + element.removeAttr( 'style' ); + } + } + ); + } + + var button = $( 'button', analysis_form ) + + analysis_form + .ajaxForm + ( + { + url : core_basepath + '/analysis/field?wt=json', + dataType : 'json', + beforeSubmit : function( array, form, options ) + { + loader.show( button ); + button.attr( 'disabled', true ); + + array.push( { name: 'analysis.showmatch', value: 'true' } ); + + var type_or_name = $( '#type_or_name', form ).val().split( '=' ); + + array.push( { name: 'analysis.' + type_or_name[0], value: type_or_name[1] } ); + }, + success : function( response, status_text, xhr, form ) + { + $( '.analysis-error', analysis_element ) + .hide(); + + analysis_result + .empty() + .show(); + + for( var name in response.analysis.field_names ) + { + build_analysis_table( 'name', name, response.analysis.field_names[name] ); + } + + for( var name in response.analysis.field_types ) + { + build_analysis_table( 'type', name, response.analysis.field_types[name] ); + } + + check_empty_spacer(); + }, + error : function( xhr, text_status, error_thrown ) + { + analysis_result + .empty() + .hide(); + + if( 404 === xhr.status ) + { + $( '#analysis-handler-missing', analysis_element ) + .show(); + } + else + { + var error_message = error_thrown.match( /^(.+Exception):\s+(.*)$/ ); + + $( '#analysis-error', analysis_element ) + .show(); + + $( '#analysis-error .head a span', analysis_element ) + .text( error_message[1] ); + + $( '#analysis-error .body', analysis_element ) + .text( error_message[2].replace( /(\s+at\s+)/g, " at\n" ) ); + } + }, + complete : function() + { + loader.hide( $( 'button', analysis_form ) ); + button.removeAttr( 'disabled' ); + } + } + ); + + var generate_class_name = function( type ) + { + var classes = [type]; + if( 'text' !== type ) + { + classes.push( 'verbose_output' ); + } + return classes.join( ' ' ); + } + + var build_analysis_table = function( field_or_name, name, analysis_data ) + { + for( var type in analysis_data ) + { + var type_length = analysis_data[type].length; + if( 0 !== type_length ) + { + var global_elements_count = 0; + for( var i = 0; i < analysis_data[type].length; i += 2 ) + { + if( 'string' === typeof analysis_data[type][i+1] ) + { + analysis_data[type][i+1] = [{ 'text': analysis_data[type][i+1] }] + } + global_elements_count = Math.max( global_elements_count, + analysis_data[type][i+1].length ); + } + + var content = '
    ' + "\n"; + content += '' + "\n"; + + for( var i = 0; i < analysis_data[type].length; i += 2 ) + { + var colspan = 1; + var elements = analysis_data[type][i+1]; + var elements_count = global_elements_count; + + if( !elements[0].positionHistory ) + { + colspan = elements_count; + elements_count = 1; + } + + var legend = []; + for( var key in elements[0] ) + { + var key_parts = key.split( '#' ); + var used_key = key_parts.pop(); + var short_key = used_key; + + if( 1 === key_parts.length ) + { + used_key = '' + used_key + ''; + } + + if( 'positionHistory' === short_key || 'match' === short_key ) + { + continue; + } + + legend.push + ( + '' + + '' + + '' + ); + } + + content += '' + "\n"; + content += '' + "\n"; + + // analyzer + var analyzer_name = analysis_data[type][i] + .replace( /(\$1)+$/g, '' ); + + var analyzer_short = -1 !== analyzer_name.indexOf( '$' ) + ? analyzer_name.split( '$' )[1] + : analyzer_name.split( '.' ).pop(); + analyzer_short = analyzer_short.match( /[A-Z]/g ).join( '' ); + + content += '' + "\n"; + + // legend + content += '' + "\n"; + + // data + var cell_content = ''; + var cells = new Array( elements_count + 1 ).join( cell_content ); + content += cells + "\n"; + + content += '' + "\n"; + content += '' + "\n"; + } + content += '
    ' + used_key + '
    ' + "\n"; + content += '' + "\n"; + content += analyzer_short + '
    ' + "\n"; + content += '' + "\n"; + content += '
    ' + "\n"; + content += '' + "\n"; + content += legend.join( "\n" ) + "\n"; + content += '
    ' + + '
     
    ' + + '
    ' + "\n"; + content += '
    ' + "\n"; + + $( '.' + type, analysis_result ) + .remove(); + + analysis_result + .append( content ); + + var analysis_result_type = $( '.' + type, analysis_result ); + + for( var i = 0; i < analysis_data[type].length; i += 2 ) + { + for( var j = 0; j < analysis_data[type][i+1].length; j += 1 ) + { + var pos = analysis_data[type][i+1][j].positionHistory + ? analysis_data[type][i+1][j].positionHistory[0] + : 1; + var selector = 'tr.step:eq(' + ( i / 2 ) +') ' + + 'td.data:eq(' + ( pos - 1 ) + ') ' + + '.holder'; + var cell = $( selector, analysis_result_type ); + + cell.parent() + .removeClass( 'spacer' ); + + var table = $( 'table tr.details', cell ); + if( 0 === table.size() ) + { + cell + .html + ( + '' + + '
    ' + ); + var table = $( 'table tr.details', cell ); + } + + var tokens = []; + for( var key in analysis_data[type][i+1][j] ) + { + var short_key = key.split( '#' ).pop(); + + if( 'positionHistory' === short_key || 'match' === short_key ) + { + continue; + } + + var classes = []; + classes.push( generate_class_name( short_key ) ); + + var data = analysis_data[type][i+1][j][key]; + if( 'object' === typeof data && data instanceof Array ) + { + data = data.join( ' ' ); + } + if( 'string' === typeof data ) + { + data = data.esc(); + } + + if( null === data || 0 === data.length ) + { + classes.push( 'empty' ); + data = '∅'; + } + + if( analysis_data[type][i+1][j].match && + ( 'text' === short_key || 'raw_bytes' === short_key ) ) + { + classes.push( 'match' ); + } + + tokens.push + ( + '' + + '' + data + '' + + '' + ); + } + table + .append + ( + '' + + '' + + tokens.join( "\n" ) + + '
    ' + ); + } + } + + } + } + } + + } + ); + } +); diff --git a/solr/webapp/web/js/scripts/app.js b/solr/webapp/web/js/scripts/app.js new file mode 100644 index 00000000000..5c53cf13c27 --- /dev/null +++ b/solr/webapp/web/js/scripts/app.js @@ -0,0 +1,263 @@ +var loader = { + + show : function( element ) + { + $( element ) + .addClass( 'loader' ); + }, + + hide : function( element ) + { + $( element ) + .removeClass( 'loader' ); + } + +}; + +Number.prototype.esc = function() +{ + return new String( this ).esc(); +} + +String.prototype.esc = function() +{ + return this.replace( //g, '>' ); +} + +var sammy = $.sammy +( + function() + { + this.bind + ( + 'run', + function( event, config ) + { + if( 0 === config.start_url.length ) + { + location.href = '#/'; + return false; + } + } + ); + + // activate_core + this.before + ( + {}, + function( context ) + { + $( 'li[id].active', app.menu_element ) + .removeClass( 'active' ); + + $( 'ul li.active', app.menu_element ) + .removeClass( 'active' ); + + if( this.params.splat ) + { + var active_element = $( '#' + this.params.splat[0], app.menu_element ); + + if( 0 === active_element.size() ) + { + var first_core = $( 'li[data-basepath]', app.menu_element ).attr( 'id' ); + var first_core_url = context.path.replace( new RegExp( '/' + this.params.splat[0] + '/' ), '/' + first_core + '/' ); + + context.redirect( first_core_url ); + return false; + } + + active_element + .addClass( 'active' ); + + if( this.params.splat[1] ) + { + $( '.' + this.params.splat[1], active_element ) + .addClass( 'active' ); + } + + if( !active_element.hasClass( 'global' ) ) + { + this.active_core = active_element; + } + } + } + ); + } +); + +var solr_admin = function( app_config ) +{ + self = this, + + menu_element = null, + + is_multicore = null, + cores_data = null, + active_core = null, + environment_basepath = null, + + config = app_config, + params = null, + dashboard_values = null, + schema_browser_data = null, + + plugin_data = null, + + this.menu_element = $( '#menu ul' ); + this.config = config; + + this.run = function() + { + $.ajax + ( + { + url : config.solr_path + config.core_admin_path + '?wt=json', + dataType : 'json', + beforeSend : function( arr, form, options ) + { + $( '#content' ) + .html( '
    Loading ...
    ' ); + }, + success : function( response ) + { + self.cores_data = response.status; + is_multicore = 'undefined' === typeof response.status['']; + + if( is_multicore ) + { + self.menu_element + .addClass( 'multicore' ); + + $( '#cores', menu_element ) + .show(); + } + else + { + self.menu_element + .addClass( 'singlecore' ); + } + + for( var core_name in response.status ) + { + var core_path = config.solr_path + '/' + core_name; + + if( !core_name ) + { + core_name = 'singlecore'; + core_path = config.solr_path + } + + if( !environment_basepath ) + { + environment_basepath = core_path; + } + + var core_tpl = '
  • ' + "\n" + + '

    ' + core_name + '

    ' + "\n" + + ' ' + "\n" + + '
  • '; + + self.menu_element + .append( core_tpl ); + } + + $.ajax + ( + { + url : environment_basepath + '/admin/system?wt=json', + dataType : 'json', + beforeSend : function( arr, form, options ) + { + }, + success : function( response ) + { + self.dashboard_values = response; + + var environment_args = null; + var cloud_args = null; + + if( response.jvm && response.jvm.jmx && response.jvm.jmx.commandLineArgs ) + { + var command_line_args = response.jvm.jmx.commandLineArgs.join( ' | ' ); + + environment_args = command_line_args + .match( /-Dsolr.environment=((dev|test|prod)?[\w\d]*)/i ); + + cloud_args = command_line_args + .match( /-Dzk/i ); + } + + // environment + + var environment_element = $( '#environment' ); + if( environment_args ) + { + environment_element + .show(); + + if( environment_args[1] ) + { + environment_element + .html( environment_args[1] ); + } + + if( environment_args[2] ) + { + environment_element + .addClass( environment_args[2] ); + } + } + else + { + environment_element + .remove(); + } + + // cloud + + var cloud_nav_element = $( '#menu #cloud' ); + if( cloud_args ) + { + cloud_nav_element + .show(); + } + + // sammy + + sammy.run( location.hash ); + }, + error : function() + { + }, + complete : function() + { + loader.hide( this ); + } + } + ); + }, + error : function() + { + }, + complete : function() + { + } + } + ); + } + +}; + +var app = new solr_admin( app_config ); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/cloud.js b/solr/webapp/web/js/scripts/cloud.js new file mode 100644 index 00000000000..c5281f66fce --- /dev/null +++ b/solr/webapp/web/js/scripts/cloud.js @@ -0,0 +1,174 @@ +// #/cloud +sammy.get +( + /^#\/(cloud)$/, + function( context ) + { + var content_element = $( '#content' ); + + $.get + ( + 'tpl/cloud.html', + function( template ) + { + content_element + .html( template ); + + var cloud_element = $( '#cloud', content_element ); + var cloud_content = $( '.content', cloud_element ); + + $.ajax + ( + { + url : app.config.zookeeper_path, + dataType : 'json', + context : cloud_content, + beforeSend : function( xhr, settings ) + { + //this + // .html( '
    Loading ...
    ' ); + }, + success : function( response, text_status, xhr ) + { + var self = this; + + $( '#tree', this ) + .jstree + ( + { + "plugins" : [ "json_data" ], + "json_data" : { + "data" : response.tree, + "progressive_render" : true + }, + "core" : { + "animation" : 0 + } + } + ); + + var tree_links = $( '#tree a', this ); + + tree_links + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( 'a.active', $( this ).parents( '#tree' ) ) + .removeClass( 'active' ); + + $( this ) + .addClass( 'active' ); + + cloud_content + .addClass( 'show' ); + + var file_content = $( '#file-content' ); + + $( 'a.close', file_content ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( '#tree a.active' ) + .removeClass( 'active' ); + + cloud_content + .removeClass( 'show' ); + + return false; + } + ); + + $.ajax + ( + { + url : this.href, + dataType : 'json', + context : file_content, + beforeSend : function( xhr, settings ) + { + //this + // .html( 'loading' ) + // .show(); + }, + success : function( response, text_status, xhr ) + { + //this + // .html( '
    ' + response.znode.data + '
    ' ); + + var props = []; + for( var key in response.znode.prop ) + { + props.push + ( + '
  • ' + "\n" + + '
    ' + key.esc() + '
    ' + "\n" + + '
    ' + response.znode.prop[key].esc() + '
    ' + "\n" + + '
  • ' + ); + } + + $( '#prop ul', this ) + .empty() + .html( props.join( "\n" ) ); + + $( '#prop ul li:odd', this ) + .addClass( 'odd' ); + + var data_element = $( '#data', this ); + + if( 0 !== parseInt( response.znode.prop.children_count ) ) + { + data_element.hide(); + } + else + { + var data = response.znode.data + ? '
    ' + response.znode.data.esc() + '
    ' + : 'File "' + response.znode.path + '" has no Content'; + + data_element + .show() + .html( data ); + } + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + + return false; + } + ); + }, + error : function( xhr, text_status, error_thrown ) + { + var message = 'Loading of ' + app.config.zookeeper_path + ' failed with "' + text_status + '" ' + + '(' + error_thrown.message + ')'; + + if( 200 !== xhr.status ) + { + message = 'Loading of ' + app.config.zookeeper_path + ' failed with HTTP-Status ' + xhr.status + ' '; + } + + this + .html( '
    ' + message + '
    ' ); + }, + complete : function( xhr, text_status ) + { + } + } + ); + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/cores.js b/solr/webapp/web/js/scripts/cores.js new file mode 100644 index 00000000000..39ff25172d2 --- /dev/null +++ b/solr/webapp/web/js/scripts/cores.js @@ -0,0 +1,495 @@ +sammy.bind +( + 'cores_load_data', + function( event, params ) + { + if( app.cores_data ) + { + params.callback( app.cores_data ); + return true; + } + + $.ajax + ( + { + url : app.config.solr_path + app.config.core_admin_path + '?wt=json', + dataType : 'json', + beforeSend : function( xhr, settings ) + { + }, + success : function( response, text_status, xhr ) + { + app.cores_data = response.status; + params.callback( app.cores_data ); + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + } +); + +sammy.bind +( + 'cores_build_navigation', + function( event, params ) + { + var navigation_content = ['
      ']; + + for( var core in params.cores ) + { + navigation_content.push( '
    • ' + core + '
    • ' ); + } + + params.navigation_element + .html( navigation_content.join( "\n" ) ); + + $( 'a[href="' + params.basepath + params.current_core + '"]', params.navigation_element ).parent() + .addClass( 'current' ); + } +); + +sammy.bind +( + 'cores_load_template', + function( event, params ) + { + if( app.cores_template ) + { + params.callback(); + return true; + } + + $.get + ( + 'tpl/cores.html', + function( template ) + { + params.content_element + .html( template ); + + app.cores_template = template; + params.callback(); + } + ); + } +); + +// #/cores +sammy.get +( + /^#\/(cores)$/, + function( context ) + { + delete app.cores_template; + + sammy.trigger + ( + 'cores_load_data', + { + callback : function( cores ) + { + var first_core = null; + for( var key in cores ) + { + if( !first_core ) + { + first_core = key; + } + continue; + } + context.redirect( context.path + '/' + first_core ); + } + } + ); + } +); + +// #/cores +sammy.get +( + /^#\/(cores)\//, + function( context ) + { + var content_element = $( '#content' ); + + var path_parts = this.path.match( /^(.+\/cores\/)(.*)$/ ); + var current_core = path_parts[2]; + + sammy.trigger + ( + 'cores_load_data', + { + callback : function( cores ) + { + sammy.trigger + ( + 'cores_load_template', + { + content_element : content_element, + callback : function() + { + var cores_element = $( '#cores', content_element ); + var navigation_element = $( '#navigation', cores_element ); + var list_element = $( '#list', navigation_element ); + var data_element = $( '#data', cores_element ); + var core_data_element = $( '#core-data', data_element ); + var index_data_element = $( '#index-data', data_element ); + + sammy.trigger + ( + 'cores_build_navigation', + { + cores : cores, + basepath : path_parts[1], + current_core : current_core, + navigation_element : list_element + } + ); + + var core_data = cores[current_core]; + var core_basepath = $( '#' + current_core, app.menu_element ).attr( 'data-basepath' ); + + // core-data + + $( 'h2 span', core_data_element ) + .html( core_data.name ); + + $( '.startTime dd', core_data_element ) + .html( core_data.startTime ); + + $( '.instanceDir dd', core_data_element ) + .html( core_data.instanceDir ); + + $( '.dataDir dd', core_data_element ) + .html( core_data.dataDir ); + + // index-data + + $( '.lastModified dd', index_data_element ) + .html( core_data.index.lastModified ); + + $( '.version dd', index_data_element ) + .html( core_data.index.version ); + + $( '.numDocs dd', index_data_element ) + .html( core_data.index.numDocs ); + + $( '.maxDoc dd', index_data_element ) + .html( core_data.index.maxDoc ); + + $( '.optimized dd', index_data_element ) + .addClass( core_data.index.optimized ? 'ico-1' : 'ico-0' ); + + $( '#actions .optimize', cores_element ) + .show(); + + $( '.optimized dd span', index_data_element ) + .html( core_data.index.optimized ? 'yes' : 'no' ); + + $( '.current dd', index_data_element ) + .addClass( core_data.index.current ? 'ico-1' : 'ico-0' ); + + $( '.current dd span', index_data_element ) + .html( core_data.index.current ? 'yes' : 'no' ); + + $( '.hasDeletions dd', index_data_element ) + .addClass( core_data.index.hasDeletions ? 'ico-1' : 'ico-0' ); + + $( '.hasDeletions dd span', index_data_element ) + .html( core_data.index.hasDeletions ? 'yes' : 'no' ); + + $( '.directory dd', index_data_element ) + .html + ( + core_data.index.directory + .replace( /:/g, ':​' ) + .replace( /@/g, '@​' ) + ); + + var core_names = []; + var core_selects = $( '#actions select', cores_element ); + + for( var key in cores ) + { + core_names.push( '' ) + } + + core_selects + .html( core_names.join( "\n") ); + + $( 'option[value="' + current_core + '"]', core_selects.filter( '#swap_core' ) ) + .attr( 'selected', 'selected' ); + + $( 'option[value="' + current_core + '"]', core_selects.filter( '.other' ) ) + .attr( 'disabled', 'disabled' ) + .addClass( 'disabled' ); + + $( 'input[name="core"]', cores_element ) + .val( current_core ); + + // layout + + var actions_element = $( '.actions', cores_element ); + var button_holder_element = $( '.button-holder.options', actions_element ); + + button_holder_element + .die( 'toggle' ) + .live + ( + 'toggle', + function( event ) + { + var element = $( this ); + + element + .toggleClass( 'active' ); + + if( element.hasClass( 'active' ) ) + { + button_holder_element + .not( element ) + .removeClass( 'active' ); + } + } + ); + + $( '.button a', button_holder_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( this ).parents( '.button-holder' ) + .trigger( 'toggle' ); + } + ); + + $( 'form a.submit', button_holder_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + var element = $( this ); + var form_element = element.parents( 'form' ); + var action = $( 'input[name="action"]', form_element ).val().toLowerCase(); + + form_element + .ajaxSubmit + ( + { + url : app.config.solr_path + app.config.core_admin_path + '?wt=json', + dataType : 'json', + beforeSubmit : function( array, form, options ) + { + //loader + }, + success : function( response, status_text, xhr, form ) + { + delete app.cores_data; + + if( 'rename' === action ) + { + context.redirect( path_parts[1] + $( 'input[name="other"]', form_element ).val() ); + } + else if( 'swap' === action ) + { + window.location.reload(); + } + + $( 'a.reset', form ) + .trigger( 'click' ); + }, + error : function( xhr, text_status, error_thrown ) + { + }, + complete : function() + { + //loader + } + } + ); + + return false; + } + ); + + $( 'form a.reset', button_holder_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( this ).parents( 'form' ) + .resetForm(); + + $( this ).parents( '.button-holder' ) + .trigger( 'toggle' ); + + return false; + } + ); + + var reload_button = $( '#actions .reload', cores_element ); + reload_button + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $.ajax + ( + { + url : app.config.solr_path + app.config.core_admin_path + '?wt=json&action=RELOAD&core=' + current_core, + dataType : 'json', + context : $( this ), + beforeSend : function( xhr, settings ) + { + this + .addClass( 'loader' ); + }, + success : function( response, text_status, xhr ) + { + this + .addClass( 'success' ); + + window.setTimeout + ( + function() + { + reload_button + .removeClass( 'success' ); + }, + 5000 + ); + }, + error : function( xhr, text_status, error_thrown ) + { + }, + complete : function( xhr, text_status ) + { + this + .removeClass( 'loader' ); + } + } + ); + } + ); + + $( '#actions .unload', cores_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $.ajax + ( + { + url : app.config.solr_path + app.config.core_admin_path + '?wt=json&action=UNLOAD&core=' + current_core, + dataType : 'json', + context : $( this ), + beforeSend : function( xhr, settings ) + { + this + .addClass( 'loader' ); + }, + success : function( response, text_status, xhr ) + { + delete app.cores_data; + context.redirect( path_parts[1].substr( 0, path_parts[1].length - 1 ) ); + }, + error : function( xhr, text_status, error_thrown ) + { + }, + complete : function( xhr, text_status ) + { + this + .removeClass( 'loader' ); + } + } + ); + } + ); + + var optimize_button = $( '#actions .optimize', cores_element ); + optimize_button + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $.ajax + ( + { + url : core_basepath + '/update?optimize=true&waitFlush=true&wt=json', + dataType : 'json', + context : $( this ), + beforeSend : function( xhr, settings ) + { + this + .addClass( 'loader' ); + }, + success : function( response, text_status, xhr ) + { + this + .addClass( 'success' ); + + window.setTimeout + ( + function() + { + optimize_button + .removeClass( 'success' ); + }, + 5000 + ); + + $( '.optimized dd.ico-0', index_data_element ) + .removeClass( 'ico-0' ) + .addClass( 'ico-1' ); + }, + error : function( xhr, text_status, error_thrown) + { + console.warn( 'd0h, optimize broken!' ); + }, + complete : function( xhr, text_status ) + { + this + .removeClass( 'loader' ); + } + } + ); + } + ); + + $( '.timeago', data_element ) + .timeago(); + + $( 'ul', data_element ) + .each + ( + function( i, element ) + { + $( 'li:odd', element ) + .addClass( 'odd' ); + } + ) + } + } + ); + } + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/dashboard.js b/solr/webapp/web/js/scripts/dashboard.js new file mode 100644 index 00000000000..7cb0957be7f --- /dev/null +++ b/solr/webapp/web/js/scripts/dashboard.js @@ -0,0 +1,400 @@ +// #/:core +sammy.get +( + /^#\/([\w\d-]+)$/, + function( context ) + { + var core_basepath = this.active_core.attr( 'data-basepath' ); + var content_element = $( '#content' ); + + content_element + .removeClass( 'single' ); + + var core_menu = $( 'ul', this.active_core ); + if( !core_menu.data( 'admin-extra-loaded' ) ) + { + core_menu.data( 'admin-extra-loaded', new Date() ); + + $.get + ( + core_basepath + '/admin/file/?file=admin-extra.menu-top.html', + function( menu_extra ) + { + core_menu + .prepend( menu_extra ); + } + ); + + $.get + ( + core_basepath + '/admin/file/?file=admin-extra.menu-bottom.html', + function( menu_extra ) + { + core_menu + .append( menu_extra ); + } + ); + } + + $.get + ( + 'tpl/dashboard.html', + function( template ) + { + content_element + .html( template ); + + var dashboard_element = $( '#dashboard' ); + + $.ajax + ( + { + url : core_basepath + '/admin/luke?wt=json&show=index&numTerms=0', + dataType : 'json', + context : $( '#statistics', dashboard_element ), + beforeSend : function( xhr, settings ) + { + $( 'h2', this ) + .addClass( 'loader' ); + + $( '.message', this ) + .show() + .html( 'Loading ...' ); + + $( '.content' ) + .hide(); + }, + success : function( response, text_status, xhr ) + { + $( '.message', this ) + .empty() + .hide(); + + $( '.content', this ) + .show(); + + var data = { + 'index_num-docs' : response['index']['numDocs'], + 'index_max-doc' : response['index']['maxDoc'], + 'index_version' : response['index']['version'], + 'index_segmentCount' : response['index']['segmentCount'], + 'index_last-modified' : response['index']['lastModified'] + }; + + for( var key in data ) + { + $( '.' + key, this ) + .show(); + + $( '.value.' + key, this ) + .html( data[key] ); + } + + var optimized_element = $( '.value.index_optimized', this ); + if( !response['index']['hasDeletions'] ) + { + optimized_element + .addClass( 'ico-1' ); + + $( 'span', optimized_element ) + .html( 'yes' ); + } + else + { + optimized_element + .addClass( 'ico-0' ); + + $( 'span', optimized_element ) + .html( 'no' ); + } + + var current_element = $( '.value.index_current', this ); + if( response['index']['current'] ) + { + current_element + .addClass( 'ico-1' ); + + $( 'span', current_element ) + .html( 'yes' ); + } + else + { + current_element + .addClass( 'ico-0' ); + + $( 'span', current_element ) + .html( 'no' ); + } + + $( 'a', optimized_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $.ajax + ( + { + url : core_basepath + '/update?optimize=true&waitFlush=true&wt=json', + dataType : 'json', + context : $( this ), + beforeSend : function( xhr, settings ) + { + this + .addClass( 'loader' ); + }, + success : function( response, text_status, xhr ) + { + this.parents( 'dd' ) + .removeClass( 'ico-0' ) + .addClass( 'ico-1' ); + }, + error : function( xhr, text_status, error_thrown) + { + console.warn( 'd0h, optimize broken!' ); + }, + complete : function( xhr, text_status ) + { + this + .removeClass( 'loader' ); + } + } + ); + } + ); + + $( '.timeago', this ) + .timeago(); + }, + error : function( xhr, text_status, error_thrown ) + { + this + .addClass( 'disabled' ); + + $( '.message', this ) + .show() + .html( 'Luke is not configured' ); + }, + complete : function( xhr, text_status ) + { + $( 'h2', this ) + .removeClass( 'loader' ); + } + } + ); + + $.ajax + ( + { + url : core_basepath + '/replication?command=details&wt=json', + dataType : 'json', + context : $( '#replication', dashboard_element ), + beforeSend : function( xhr, settings ) + { + $( 'h2', this ) + .addClass( 'loader' ); + + $( '.message', this ) + .show() + .html( 'Loading' ); + + $( '.content', this ) + .hide(); + }, + success : function( response, text_status, xhr ) + { + $( '.message', this ) + .empty() + .hide(); + + $( '.content', this ) + .show(); + + $( '.replication', context.active_core ) + .show(); + + var data = response.details; + var is_slave = 'undefined' !== typeof( data.slave ); + var headline = $( 'h2 span', this ); + var details_element = $( '#details', this ); + var current_type_element = $( ( is_slave ? '.slave' : '.master' ), this ); + + if( is_slave ) + { + this + .addClass( 'slave' ); + + headline + .html( headline.html() + ' (Slave)' ); + } + else + { + this + .addClass( 'master' ); + + headline + .html( headline.html() + ' (Master)' ); + } + + $( '.version div', current_type_element ) + .html( data.indexVersion ); + $( '.generation div', current_type_element ) + .html( data.generation ); + $( '.size div', current_type_element ) + .html( data.indexSize ); + + if( is_slave ) + { + var master_element = $( '.master', details_element ); + $( '.version div', master_element ) + .html( data.slave.masterDetails.indexVersion ); + $( '.generation div', master_element ) + .html( data.slave.masterDetails.generation ); + $( '.size div', master_element ) + .html( data.slave.masterDetails.indexSize ); + + if( data.indexVersion !== data.slave.masterDetails.indexVersion ) + { + $( '.version', details_element ) + .addClass( 'diff' ); + } + else + { + $( '.version', details_element ) + .removeClass( 'diff' ); + } + + if( data.generation !== data.slave.masterDetails.generation ) + { + $( '.generation', details_element ) + .addClass( 'diff' ); + } + else + { + $( '.generation', details_element ) + .removeClass( 'diff' ); + } + } + }, + error : function( xhr, text_status, error_thrown) + { + this + .addClass( 'disabled' ); + + $( '.message', this ) + .show() + .html( 'Replication is not configured' ); + }, + complete : function( xhr, text_status ) + { + $( 'h2', this ) + .removeClass( 'loader' ); + } + } + ); + + $.ajax + ( + { + url : core_basepath + '/dataimport?command=details&wt=json', + dataType : 'json', + context : $( '#dataimport', dashboard_element ), + beforeSend : function( xhr, settings ) + { + $( 'h2', this ) + .addClass( 'loader' ); + + $( '.message', this ) + .show() + .html( 'Loading' ); + }, + success : function( response, text_status, xhr ) + { + $( '.message', this ) + .empty() + .hide(); + + $( 'dl', this ) + .show(); + + var data = { + 'status' : response['status'], + 'info' : response['statusMessages'][''] + }; + + for( var key in data ) + { + $( '.' + key, this ) + .show(); + + $( '.value.' + key, this ) + .html( data[key] ); + } + }, + error : function( xhr, text_status, error_thrown) + { + this + .addClass( 'disabled' ); + + $( '.message', this ) + .show() + .html( 'Dataimport is not configured' ); + }, + complete : function( xhr, text_status ) + { + $( 'h2', this ) + .removeClass( 'loader' ); + } + } + ); + + $.ajax + ( + { + url : core_basepath + '/admin/file/?file=admin-extra.html', + dataType : 'html', + context : $( '#admin-extra', dashboard_element ), + beforeSend : function( xhr, settings ) + { + $( 'h2', this ) + .addClass( 'loader' ); + + $( '.message', this ) + .show() + .html( 'Loading' ); + + $( '.content', this ) + .hide(); + }, + success : function( response, text_status, xhr ) + { + $( '.message', this ) + .hide() + .empty(); + + $( '.content', this ) + .show() + .html( response ); + }, + error : function( xhr, text_status, error_thrown) + { + this + .addClass( 'disabled' ); + + $( '.message', this ) + .show() + .html( 'We found no "admin-extra.html" file.' ); + }, + complete : function( xhr, text_status ) + { + $( 'h2', this ) + .removeClass( 'loader' ); + } + } + ); + + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/dataimport.js b/solr/webapp/web/js/scripts/dataimport.js new file mode 100644 index 00000000000..1078a841583 --- /dev/null +++ b/solr/webapp/web/js/scripts/dataimport.js @@ -0,0 +1,452 @@ +sammy.bind +( + 'dataimport_queryhandler_load', + function( event, params ) + { + var core_basepath = params.active_core.attr( 'data-basepath' ); + + $.ajax + ( + { + url : core_basepath + '/admin/mbeans?cat=QUERYHANDLER&wt=json', + dataType : 'json', + beforeSend : function( xhr, settings ) + { + }, + success : function( response, text_status, xhr ) + { + var handlers = response['solr-mbeans'][1]; + var dataimport_handlers = []; + for( var key in handlers ) + { + if( handlers[key]['class'] !== key && + handlers[key]['class'] === 'org.apache.solr.handler.dataimport.DataImportHandler' ) + { + dataimport_handlers.push( key ); + } + } + params.callback( dataimport_handlers ); + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + } +); + +// #/:core/dataimport +sammy.get +( + /^#\/([\w\d-]+)\/(dataimport)$/, + function( context ) + { + sammy.trigger + ( + 'dataimport_queryhandler_load', + { + active_core : this.active_core, + callback : function( dataimport_handlers ) + { + if( 0 === dataimport_handlers.length ) + { + $( '#content' ) + .html( 'sorry, no dataimport-handler defined!' ); + + return false; + } + + context.redirect( context.path + '/' + dataimport_handlers[0] ); + } + } + ); + } +); + +// #/:core/dataimport +sammy.get +( + /^#\/([\w\d-]+)\/(dataimport)\//, + function( context ) + { + var core_basepath = this.active_core.attr( 'data-basepath' ); + var content_element = $( '#content' ); + + var path_parts = this.path.match( /^(.+\/dataimport\/)(.*)$/ ); + var handler_url = core_basepath + path_parts[2]; + + $( 'li.dataimport', this.active_core ) + .addClass( 'active' ); + + $.get + ( + 'tpl/dataimport.html', + function( template ) + { + content_element + .html( template ); + + var dataimport_element = $( '#dataimport', content_element ); + var form_element = $( '#form', dataimport_element ); + var config_element = $( '#config', dataimport_element ); + var config_error_element = $( '#config-error', dataimport_element ); + + // handler + + sammy.trigger + ( + 'dataimport_queryhandler_load', + { + active_core : context.active_core, + callback : function( dataimport_handlers ) + { + + var handlers_element = $( '.handler', form_element ); + var handlers = []; + + for( var i = 0; i < dataimport_handlers.length; i++ ) + { + handlers.push + ( + '
    • ' + + dataimport_handlers[i] + + '
    • ' + ); + } + + $( 'ul', handlers_element ) + .html( handlers.join( "\n") ) ; + + $( 'a[href="' + context.path + '"]', handlers_element ).parent() + .addClass( 'active' ); + + handlers_element + .show(); + } + } + ); + + // config + + function dataimport_fetch_config() + { + $.ajax + ( + { + url : handler_url + '?command=show-config', + dataType : 'xml', + context : $( '#dataimport_config', config_element ), + beforeSend : function( xhr, settings ) + { + }, + success : function( config, text_status, xhr ) + { + dataimport_element + .removeClass( 'error' ); + + config_error_element + .hide(); + + config_element + .addClass( 'hidden' ); + + + var entities = []; + + $( 'document > entity', config ) + .each + ( + function( i, element ) + { + entities.push( '' ); + } + ); + + $( '#entity', form_element ) + .append( entities.join( "\n" ) ); + }, + error : function( xhr, text_status, error_thrown ) + { + if( 'parsererror' === error_thrown ) + { + dataimport_element + .addClass( 'error' ); + + config_error_element + .show(); + + config_element + .removeClass( 'hidden' ); + } + }, + complete : function( xhr, text_status ) + { + var code = $( + '
      ' +
      +                                    xhr.responseText.replace( /\/g, '>' ) +
      +                                    '
      ' + ); + this.html( code ); + + if( 'success' === text_status ) + { + hljs.highlightBlock( code.get(0) ); + } + } + } + ); + } + dataimport_fetch_config(); + + $( '.toggle', config_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( this ).parents( '.block' ) + .toggleClass( 'hidden' ); + + return false; + } + ) + + var reload_config_element = $( '.reload_config', config_element ); + reload_config_element + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $.ajax + ( + { + url : handler_url + '?command=reload-config', + dataType : 'xml', + context: $( this ), + beforeSend : function( xhr, settings ) + { + this + .addClass( 'loader' ); + }, + success : function( response, text_status, xhr ) + { + this + .addClass( 'success' ); + + window.setTimeout + ( + function() + { + reload_config_element + .removeClass( 'success' ); + }, + 5000 + ); + }, + error : function( xhr, text_status, error_thrown ) + { + this + .addClass( 'error' ); + }, + complete : function( xhr, text_status ) + { + this + .removeClass( 'loader' ); + + dataimport_fetch_config(); + } + } + ); + return false; + } + ) + + // state + + function dataimport_fetch_status() + { + $.ajax + ( + { + url : handler_url + '?command=status', + dataType : 'xml', + beforeSend : function( xhr, settings ) + { + }, + success : function( response, text_status, xhr ) + { + var state_element = $( '#current_state', content_element ); + + var status = $( 'str[name="status"]', response ).text(); + var rollback_element = $( 'str[name="Rolledback"]', response ); + var messages_count = $( 'lst[name="statusMessages"] str', response ).size(); + + var started_at = $( 'str[name="Full Dump Started"]', response ).text(); + if( !started_at ) + { + started_at = (new Date()).toGMTString(); + } + + function dataimport_compute_details( response, details_element ) + { + var details = []; + + var requests = parseInt( $( 'str[name="Total Requests made to DataSource"]', response ).text() ); + if( NaN !== requests ) + { + details.push + ( + 'Requests: ' + + requests + ); + } + + var fetched = parseInt( $( 'str[name="Total Rows Fetched"]', response ).text() ); + if( NaN !== fetched ) + { + details.push + ( + 'Fetched: ' + + fetched + ); + } + + var skipped = parseInt( $( 'str[name="Total Documents Skipped"]', response ).text() ); + if( NaN !== requests ) + { + details.push + ( + 'Skipped: ' + + skipped + ); + } + + var processed = parseInt( $( 'str[name="Total Documents Processed"]', response ).text() ); + if( NaN !== processed ) + { + details.push + ( + 'Processed: ' + + processed + ); + } + + details_element + .html( details.join( ', ' ) ); + } + + state_element + .removeClass( 'indexing' ) + .removeClass( 'success' ) + .removeClass( 'failure' ); + + $( '.info', state_element ) + .removeClass( 'loader' ); + + if( 0 !== rollback_element.size() ) + { + state_element + .addClass( 'failure' ) + .show(); + + $( '.info strong', state_element ) + .text( $( 'str[name=""]', response ).text() ); + + console.debug( 'rollback @ ', rollback_element.text() ); + } + else if( 'idle' === status && 0 !== messages_count ) + { + state_element + .addClass( 'success' ) + .show(); + + $( '.time', state_element ) + .text( started_at ) + .timeago(); + + $( '.info strong', state_element ) + .text( $( 'str[name=""]', response ).text() ); + + dataimport_compute_details( response, $( '.info .details', state_element ) ); + } + else if( 'busy' === status ) + { + state_element + .addClass( 'indexing' ) + .show(); + + $( '.time', state_element ) + .text( started_at ) + .timeago(); + + $( '.info', state_element ) + .addClass( 'loader' ); + + $( '.info strong', state_element ) + .text( 'Indexing ...' ); + + dataimport_compute_details( response, $( '.info .details', state_element ) ); + + window.setTimeout( dataimport_fetch_status, 2000 ); + } + else + { + state_element.hide(); + } + }, + error : function( xhr, text_status, error_thrown ) + { + console.debug( arguments ); + }, + complete : function( xhr, text_status ) + { + } + } + ); + } + dataimport_fetch_status(); + + // form + + $( 'form', form_element ) + .die( 'submit' ) + .live + ( + 'submit', + function( event ) + { + $.ajax + ( + { + url : handler_url + '?command=full-import', + dataType : 'xml', + beforeSend : function( xhr, settings ) + { + }, + success : function( response, text_status, xhr ) + { + console.debug( response ); + dataimport_fetch_status(); + }, + error : function( xhr, text_status, error_thrown ) + { + console.debug( arguments ); + }, + complete : function( xhr, text_status ) + { + } + } + ); + return false; + } + ); + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/file.js b/solr/webapp/web/js/scripts/file.js new file mode 100644 index 00000000000..57e7269c3ab --- /dev/null +++ b/solr/webapp/web/js/scripts/file.js @@ -0,0 +1,37 @@ +// #/:core/schema, #/:core/config +sammy.get +( + /^#\/([\w\d-]+)\/(schema|config)$/, + function( context ) + { + var core_basepath = this.active_core.attr( 'data-basepath' ); + + $.ajax + ( + { + url : core_basepath + app.config[ context.params.splat[1] + '_path' ], + dataType : 'xml', + context : $( '#content' ), + beforeSend : function( xhr, settings ) + { + this + .html( '
      Loading ...
      ' ); + }, + complete : function( xhr, text_status ) + { + var code = $( + '
      ' +
      +                        xhr.responseText.esc() +
      +                        '
      ' + ); + this.html( code ); + + if( 'success' === text_status ) + { + hljs.highlightBlock( code.get(0) ); + } + } + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/index.js b/solr/webapp/web/js/scripts/index.js new file mode 100644 index 00000000000..e4a1d69a02e --- /dev/null +++ b/solr/webapp/web/js/scripts/index.js @@ -0,0 +1,184 @@ +// #/ +sammy.get +( + /^#\/$/, + function( context ) + { + var content_element = $( '#content' ); + + $( '#index', app.menu_element ) + .addClass( 'active' ); + + content_element + .html( '
      ' ); + + $.ajax + ( + { + url : 'tpl/index.html', + context : $( '#index', content_element ), + beforeSend : function( arr, form, options ) + { + }, + success : function( template ) + { + this + .html( template ); + + var jvm_memory = $.extend + ( + { + 'free' : null, + 'total' : null, + 'max' : null, + 'used' : null, + 'raw' : { + 'free' : null, + 'total' : null, + 'max' : null, + 'used' : null, + 'used%' : null + } + }, + app.dashboard_values['jvm']['memory'] + ); + + var parse_memory_value = function( value ) + { + if( value !== Number( value ) ) + { + var units = 'BKMGTPEZY'; + var match = value.match( /^(\d+([,\.]\d+)?) (\w)\w?$/ ); + var value = parseFloat( match[1] ) * Math.pow( 1024, units.indexOf( match[3].toUpperCase() ) ); + } + + return value; + }; + var memory_data = { + 'memory-bar-max' : parse_memory_value( jvm_memory['raw']['max'] || jvm_memory['max'] ), + 'memory-bar-total' : parse_memory_value( jvm_memory['raw']['total'] || jvm_memory['total'] ), + 'memory-bar-used' : parse_memory_value( jvm_memory['raw']['used'] || jvm_memory['used'] ) + }; + + for( var key in memory_data ) + { + $( '.value.' + key, this ) + .text( memory_data[key] ); + } + + var data = { + 'start_time' : app.dashboard_values['jvm']['jmx']['startTime'], + 'host' : app.dashboard_values['core']['host'], + 'jvm' : app.dashboard_values['jvm']['name'] + ' (' + app.dashboard_values['jvm']['version'] + ')', + 'solr_spec_version' : app.dashboard_values['lucene']['solr-spec-version'], + 'solr_impl_version' : app.dashboard_values['lucene']['solr-impl-version'], + 'lucene_spec_version' : app.dashboard_values['lucene']['lucene-spec-version'], + 'lucene_impl_version' : app.dashboard_values['lucene']['lucene-impl-version'] + }; + + if( app.dashboard_values['core']['directory']['cwd'] ) + { + data['cwd'] = app.dashboard_values['core']['directory']['cwd']; + } + + for( var key in data ) + { + var value_element = $( '.' + key + ' dd', this ); + + value_element + .text( data[key] ); + + value_element.closest( 'li' ) + .show(); + } + + var commandLineArgs = app.dashboard_values['jvm']['jmx']['commandLineArgs']; + if( 0 !== commandLineArgs.length ) + { + var cmd_arg_element = $( '.command_line_args dt', this ); + var cmd_arg_key_element = $( '.command_line_args dt', this ); + var cmd_arg_element = $( '.command_line_args dd', this ); + + for( var key in commandLineArgs ) + { + cmd_arg_element = cmd_arg_element.clone(); + cmd_arg_element.text( commandLineArgs[key] ); + + cmd_arg_key_element + .after( cmd_arg_element ); + } + + cmd_arg_key_element.closest( 'li' ) + .show(); + + $( '.command_line_args dd:last', this ) + .remove(); + + $( '.command_line_args dd:odd', this ) + .addClass( 'odd' ); + } + + $( '.timeago', this ) + .timeago(); + + $( 'li:visible:odd', this ) + .addClass( 'odd' ); + + // -- memory bar + + var max_height = Math.round( $( '#memory-bar-max', this ).height() ); + var total_height = Math.round( ( memory_data['memory-bar-total'] * max_height ) / memory_data['memory-bar-max'] ); + var used_height = Math.round( ( memory_data['memory-bar-used'] * max_height ) / memory_data['memory-bar-max'] ); + + var memory_bar_total_value = $( '#memory-bar-total span', this ).first(); + + $( '#memory-bar-total', this ) + .height( total_height ); + + $( '#memory-bar-used', this ) + .height( used_height ); + + if( used_height < total_height + memory_bar_total_value.height() ) + { + memory_bar_total_value + .addClass( 'upper' ) + .css( 'margin-top', memory_bar_total_value.height() * -1 ); + } + + var memory_percentage = ( ( memory_data['memory-bar-used'] / memory_data['memory-bar-max'] ) * 100 ).toFixed(1); + var headline = $( '#memory h2 span', this ); + + headline + .text( headline.html() + ' (' + memory_percentage + '%)' ); + + $( '#memory-bar .value', this ) + .each + ( + function() + { + var self = $( this ); + + var byte_value = parseInt( self.html() ); + + self + .attr( 'title', 'raw: ' + byte_value + ' B' ); + + byte_value /= 1024; + byte_value /= 1024; + byte_value = byte_value.toFixed( 2 ) + ' MB'; + + self + .text( byte_value ); + } + ); + }, + error : function( xhr, text_status, error_thrown ) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/java-properties.js b/solr/webapp/web/js/scripts/java-properties.js new file mode 100644 index 00000000000..bdd90675859 --- /dev/null +++ b/solr/webapp/web/js/scripts/java-properties.js @@ -0,0 +1,84 @@ +// #/java-properties +sammy.get +( + /^#\/(java-properties)$/, + function( context ) + { + var core_basepath = $( 'li[data-basepath]', app.menu_element ).attr( 'data-basepath' ); + var content_element = $( '#content' ); + + content_element + .html( '
      ' ); + + $.ajax + ( + { + url : core_basepath + '/admin/properties?wt=json', + dataType : 'json', + context : $( '#java-properties', content_element ), + beforeSend : function( xhr, settings ) + { + this + .html( '
      Loading ...
      ' ); + }, + success : function( response, text_status, xhr ) + { + var system_properties = response['system.properties']; + var properties_data = {}; + var properties_content = []; + var properties_order = []; + + for( var key in system_properties ) + { + var displayed_key = key.replace( /\./g, '.​' ); + var displayed_value = [ system_properties[key] ]; + var item_class = 'clearfix'; + + if( -1 !== key.indexOf( '.path' ) || -1 !== key.indexOf( '.dirs' ) ) + { + displayed_value = system_properties[key].split( system_properties['path.separator'] ); + if( 1 < displayed_value.length ) + { + item_class += ' multi'; + } + } + + var item_content = '
    • ' + "\n" + + '
      ' + displayed_key.esc() + '
      ' + "\n"; + + for( var i in displayed_value ) + { + item_content += '
      ' + displayed_value[i].esc() + '
      ' + "\n"; + } + + item_content += '
    • '; + + properties_data[key] = item_content; + properties_order.push( key ); + } + + properties_order.sort(); + for( var i in properties_order ) + { + properties_content.push( properties_data[properties_order[i]] ); + } + + this + .html( '
        ' + properties_content.join( "\n" ) + '
      ' ); + + $( 'li:odd', this ) + .addClass( 'odd' ); + + $( '.multi dd:odd', this ) + .addClass( 'odd' ); + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/logging.js b/solr/webapp/web/js/scripts/logging.js new file mode 100644 index 00000000000..8184507866c --- /dev/null +++ b/solr/webapp/web/js/scripts/logging.js @@ -0,0 +1,164 @@ +// #/logging +sammy.get +( + /^#\/(logging)$/, + function( context ) + { + var content_element = $( '#content' ); + + content_element + .html( '
      ' ); + + $.ajax + ( + { + url : 'logging.json', + dataType : 'json', + context : $( '#logging', content_element ), + beforeSend : function( xhr, settings ) + { + this + .html( '
      Loading ...
      ' ); + }, + success : function( response, text_status, xhr ) + { + var logger = response.logger; + + var loglevel = '
      ' + "\n"; + loglevel += '%effective_level%' + "\n"; + loglevel += '
        ' + "\n"; + + for( var key in response.levels ) + { + var level = response.levels[key].esc(); + loglevel += '
      • ' + level + '
      • ' + "\n"; + } + + loglevel += '
      • UNSET
      • ' + "\n"; + loglevel += '
      ' + "\n"; + loglevel += '
      '; + + var logger_tree = function( filter ) + { + var logger_content = ''; + var filter_regex = new RegExp( '^' + filter + '\\.\\w+$' ); + + for( var logger_name in logger ) + { + var continue_matcher = false; + + if( !filter ) + { + continue_matcher = logger_name.indexOf( '.' ) !== -1; + } + else + { + continue_matcher = !logger_name.match( filter_regex ); + } + + if( continue_matcher ) + { + continue; + } + + var has_logger_instance = !!logger[logger_name]; + + var classes = []; + + has_logger_instance + ? classes.push( 'active' ) + : classes.push( 'inactive' ); + + logger_content += '
    • '; + logger_content += ' '; + logger_content += '' + "\n" + + logger_name.split( '.' ).pop().esc() + "\n" + + ''; + + logger_content += loglevel + .replace + ( + /%class%/g, + classes.join( ' ' ) + ) + .replace + ( + /%effective_level%/g, + has_logger_instance + ? logger[logger_name].effective_level + : 'null' + ); + + var child_logger_content = logger_tree( logger_name ); + if( child_logger_content ) + { + logger_content += '
        '; + logger_content += child_logger_content; + logger_content += '
      '; + } + + logger_content += '
    • '; + } + + return logger_content; + } + + var logger_content = logger_tree( null ); + + this + .html( '
        ' + logger_content + '
      ' ); + + $( 'li:last-child', this ) + .addClass( 'jstree-last' ); + + $( '.loglevel', this ) + .each + ( + function( index, element ) + { + var element = $( element ); + var effective_level = $( '.effective_level span', element ).text(); + + element + .css( 'z-index', 800 - index ); + + $( 'ul .' + effective_level, element ) + .addClass( 'selected' ); + } + ); + + $( '.trigger', this ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( '.loglevel', $( this ).parents( 'li' ).first() ).first() + .trigger( 'toggle' ); + } + ); + + $( '.loglevel', this ) + .die( 'toggle') + .live + ( + 'toggle', + function( event ) + { + $( this ) + .toggleClass( 'open' ); + } + ); + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/ping.js b/solr/webapp/web/js/scripts/ping.js new file mode 100644 index 00000000000..5542f638df0 --- /dev/null +++ b/solr/webapp/web/js/scripts/ping.js @@ -0,0 +1,58 @@ +$( '.ping a', app.menu_element ) + .live + ( + 'click', + function( event ) + { + $.ajax + ( + { + url : $( this ).attr( 'rel' ) + '?wt=json&ts=' + (new Date).getTime(), + dataType : 'json', + context: this, + beforeSend : function( arr, form, options ) + { + loader.show( this ); + }, + success : function( response, text_status, xhr ) + { + $( this ) + .removeAttr( 'title' ); + + $( this ).parents( 'li' ) + .removeClass( 'error' ); + + var qtime_element = $( '.qtime', this ); + + if( 0 === qtime_element.size() ) + { + qtime_element = $( ' ()' ); + + $( this ) + .append + ( + qtime_element + ); + } + + $( 'span', qtime_element ) + .html( response.responseHeader.QTime + 'ms' ); + }, + error : function( xhr, text_status, error_thrown ) + { + $( this ) + .attr( 'title', '/admin/ping is not configured (' + xhr.status + ': ' + error_thrown + ')' ); + + $( this ).parents( 'li' ) + .addClass( 'error' ); + }, + complete : function( xhr, text_status ) + { + loader.hide( this ); + } + } + ); + + return false; + } + ); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/plugins.js b/solr/webapp/web/js/scripts/plugins.js new file mode 100644 index 00000000000..a15e18a68a4 --- /dev/null +++ b/solr/webapp/web/js/scripts/plugins.js @@ -0,0 +1,259 @@ +sammy.bind +( + 'plugins_load', + function( event, params ) + { + var callback = function() + { + params.callback( app.plugin_data.plugin_data, app.plugin_data.sort_table, app.plugin_data.types ); + } + + if( app.plugin_data ) + { + callback( app.plugin_data ); + return true; + } + + var core_basepath = params.active_core.attr( 'data-basepath' ); + $.ajax + ( + { + url : core_basepath + '/admin/mbeans?stats=true&wt=json', + dataType : 'json', + beforeSend : function( xhr, settings ) + { + }, + success : function( response, text_status, xhr ) + { + var types = []; + var sort_table = {}; + var plugin_data = {}; + + var types_obj = {}; + var plugin_key = null; + + for( var i = 0; i < response['solr-mbeans'].length; i++ ) + { + if( !( i % 2 ) ) + { + plugin_key = response['solr-mbeans'][i]; + } + else + { + plugin_data[plugin_key] = response['solr-mbeans'][i]; + } + } + + for( var key in plugin_data ) + { + sort_table[key] = { + url : [], + component : [], + handler : [] + }; + for( var part_key in plugin_data[key] ) + { + if( 0 < part_key.indexOf( '.' ) ) + { + types_obj[key] = true; + sort_table[key]['handler'].push( part_key ); + } + else if( 0 === part_key.indexOf( '/' ) ) + { + types_obj[key] = true; + sort_table[key]['url'].push( part_key ); + } + else + { + types_obj[key] = true; + sort_table[key]['component'].push( part_key ); + } + } + } + + for( var type in types_obj ) + { + types.push( type ); + } + types.sort(); + + app.plugin_data = { + 'plugin_data' : plugin_data, + 'sort_table' : sort_table, + 'types' : types + } + + $.get + ( + 'tpl/plugins.html', + function( template ) + { + $( '#content' ) + .html( template ); + + callback( app.plugin_data ); + } + ); + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + } +); + +// #/:core/plugins/$type +sammy.get +( + /^#\/([\w\d-]+)\/(plugins)\/(\w+)$/, + function( context ) + { + var content_element = $( '#content' ); + var type = context.params.splat[2].toUpperCase(); + var context_path = context.path.split( '?' ).shift(); + + sammy.trigger + ( + 'plugins_load', + { + active_core : this.active_core, + callback : function( plugin_data, plugin_sort, types ) + { + var frame_element = $( '#frame', content_element ); + var navigation_element = $( '#navigation ul', content_element ); + + var navigation_content = []; + for( var i = 0; i < types.length; i++ ) + { + var type_url = context.params.splat[0] + '/' + + context.params.splat[1] + '/' + + types[i].toLowerCase(); + + navigation_content.push + ( + '
    • ' + + '' + types[i] + '' + + '
    • ' + ); + } + + navigation_element + .html( navigation_content.join( "\n" ) ); + + $( 'a[href="' + context_path + '"]', navigation_element ) + .parent().addClass( 'current' ); + + var content = '
        '; + for( var sort_key in plugin_sort[type] ) + { + plugin_sort[type][sort_key].sort(); + var plugin_type_length = plugin_sort[type][sort_key].length; + + for( var i = 0; i < plugin_type_length; i++ ) + { + content += '
      • ' + "\n"; + content += ''; + content += plugin_sort[type][sort_key][i] + content += '' + "\n"; + content += '
          ' + "\n"; + + var details = plugin_data[type][ plugin_sort[type][sort_key][i] ]; + for( var detail_key in details ) + { + if( 'stats' !== detail_key ) + { + var detail_value = details[detail_key]; + + if( 'description' === detail_key ) + { + detail_value = detail_value.replace( /,/g, ',​' ); + } + else if( 'src' === detail_key ) + { + detail_value = detail_value.replace( /\//g, '/​' ); + } + + content += '
        • ' + "\n"; + content += '
          ' + detail_key + ':
          ' + "\n"; + content += '
          ' + detail_value + '
          ' + "\n"; + content += '
        • ' + "\n"; + } + else if( 'stats' === detail_key && details[detail_key] ) + { + content += '
        • ' + "\n"; + content += '' + detail_key + ':' + "\n"; + content += '
            ' + "\n"; + + for( var stats_key in details[detail_key] ) + { + var stats_value = details[detail_key][stats_key]; + + if( 'readerDir' === stats_key ) + { + stats_value = stats_value.replace( /@/g, '@​' ); + } + + content += '
          • ' + "\n"; + content += '
            ' + stats_key + ':
            ' + "\n"; + content += '
            ' + stats_value + '
            ' + "\n"; + content += '
          • ' + "\n"; + } + + content += '
        • ' + "\n"; + } + } + + content += '
        ' + "\n"; + } + } + content += '
      ' + "\n"; + + frame_element + .html( content ); + + $( 'a[href="' + decodeURIComponent( context.path ) + '"]', frame_element ) + .parent().addClass( 'expanded' ); + + $( '.entry', frame_element ) + .each + ( + function( i, entry ) + { + $( '.detail > li', entry ).not( '.stats' ).filter( ':even' ) + .addClass( 'odd' ); + + $( '.stats li:odd', entry ) + .addClass( 'odd' ); + } + ); + } + } + ); + } +); + +// #/:core/plugins +sammy.get +( + /^#\/([\w\d-]+)\/(plugins)$/, + function( context ) + { + delete app.plugin_data; + + sammy.trigger + ( + 'plugins_load', + { + active_core : this.active_core, + callback : function( plugin_data, plugin_sort, types ) + { + context.redirect( context.path + '/' + types[0].toLowerCase() ); + } + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/query.js b/solr/webapp/web/js/scripts/query.js new file mode 100644 index 00000000000..012c317da80 --- /dev/null +++ b/solr/webapp/web/js/scripts/query.js @@ -0,0 +1,142 @@ +// #/:core/query +sammy.get +( + /^#\/([\w\d-]+)\/(query)$/, + function( context ) + { + var core_basepath = this.active_core.attr( 'data-basepath' ); + var content_element = $( '#content' ); + + $.get + ( + 'tpl/query.html', + function( template ) + { + content_element + .html( template ); + + var query_element = $( '#query', content_element ); + var query_form = $( '#form form', query_element ); + var url_element = $( '#url', query_element ); + var result_element = $( '#result', query_element ); + var response_element = $( '#response iframe', result_element ); + + url_element + .die( 'change' ) + .live + ( + 'change', + function( event ) + { + var check_iframe_ready_state = function() + { + var iframe_element = response_element.get(0).contentWindow.document || + response_element.get(0).document; + + if( !iframe_element ) + { + console.debug( 'no iframe_element found', response_element ); + return false; + } + + url_element + .addClass( 'loader' ); + + if( 'complete' === iframe_element.readyState ) + { + url_element + .removeClass( 'loader' ); + } + else + { + window.setTimeout( check_iframe_ready_state, 100 ); + } + } + check_iframe_ready_state(); + + response_element + .attr( 'src', this.href ); + + if( !response_element.hasClass( 'resized' ) ) + { + response_element + .addClass( 'resized' ) + .css( 'height', $( '#main' ).height() - 60 ); + } + } + ) + + $( '.optional legend input[type=checkbox]', query_form ) + .die( 'change' ) + .live + ( + 'change', + function( event ) + { + var fieldset = $( this ).parents( 'fieldset' ); + + this.checked + ? fieldset.addClass( 'expanded' ) + : fieldset.removeClass( 'expanded' ); + } + ) + + for( var key in context.params ) + { + if( 'string' === typeof context.params[key] ) + { + $( '[name="' + key + '"]', query_form ) + .val( context.params[key] ); + } + } + + query_form + .die( 'submit' ) + .live + ( + 'submit', + function( event ) + { + var form_map = {}; + var form_values = []; + var all_form_values = query_form.formToArray(); + + for( var i = 0; i < all_form_values.length; i++ ) + { + if( !all_form_values[i].value || 0 === all_form_values[i].value.length ) + { + continue; + } + + var name_parts = all_form_values[i].name.split( '.' ); + if( 1 < name_parts.length && !form_map[name_parts[0]] ) + { + console.debug( 'skip "' + all_form_values[i].name + '", parent missing' ); + continue; + } + + form_map[all_form_values[i].name] = all_form_values[i].value; + form_values.push( all_form_values[i] ); + } + + var query_url = window.location.protocol + '//' + + window.location.host + + core_basepath + + '/select?' + + $.param( form_values ); + + url_element + .attr( 'href', query_url ) + .text( query_url ) + .trigger( 'change' ); + + result_element + .show(); + + return false; + } + ); + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/replication.js b/solr/webapp/web/js/scripts/replication.js new file mode 100644 index 00000000000..ec715fe86a2 --- /dev/null +++ b/solr/webapp/web/js/scripts/replication.js @@ -0,0 +1,443 @@ +// #/:core/replication +sammy.get +( + /^#\/([\w\d-]+)\/(replication)$/, + function( context ) + { + var core_basepath = this.active_core.attr( 'data-basepath' ); + var content_element = $( '#content' ); + + $.get + ( + 'tpl/replication.html', + function( template ) + { + content_element + .html( template ); + + var replication_element = $( '#replication', content_element ); + var navigation_element = $( '#navigation', replication_element ); + + function convert_seconds_to_readable_time( value ) + { + var text = []; + value = parseInt( value ); + + var minutes = Math.floor( value / 60 ); + var hours = Math.floor( minutes / 60 ); + + if( 0 !== hours ) + { + text.push( hours + 'h' ); + value -= hours * 60 * 60; + minutes -= hours * 60; + } + + if( 0 !== minutes ) + { + text.push( minutes + 'm' ); + value -= minutes * 60; + } + + text.push( value + 's' ); + + return text.join( ' ' ); + } + + function replication_fetch_status() + { + $.ajax + ( + { + url : core_basepath + '/replication?command=details&wt=json', + dataType : 'json', + beforeSend : function( xhr, settings ) + { + $( '.refresh-status', navigation_element ) + .addClass( 'loader' ); + }, + success : function( response, text_status, xhr ) + { + $( '.refresh-status', navigation_element ) + .removeClass( 'loader' ); + + var data = response.details; + var is_slave = 'true' === data.isSlave; + + replication_element + .addClass( is_slave ? 'slave' : 'master' ); + + if( is_slave ) + { + var error_element = $( '#error', replication_element ); + + if( data.slave.ERROR ) + { + error_element + .html( data.slave.ERROR ) + .show(); + } + else + { + error_element + .hide() + .empty(); + } + + var progress_element = $( '#progress', replication_element ); + + var start_element = $( '#start', progress_element ); + $( 'span', start_element ) + .text( data.slave.replicationStartTime ); + + var eta_element = $( '#eta', progress_element ); + $( 'span', eta_element ) + .text( convert_seconds_to_readable_time( data.slave.timeRemaining ) ); + + var bar_element = $( '#bar', progress_element ); + $( '.files span', bar_element ) + .text( data.slave.numFilesToDownload ); + $( '.size span', bar_element ) + .text( data.slave.bytesToDownload ); + + var speed_element = $( '#speed', progress_element ); + $( 'span', speed_element ) + .text( data.slave.downloadSpeed ); + + var done_element = $( '#done', progress_element ); + $( '.files span', done_element ) + .text( data.slave.numFilesDownloaded ); + $( '.size span', done_element ) + .text( data.slave.bytesDownloaded ); + $( '.percent span', done_element ) + .text( parseInt(data.slave.totalPercent ) ); + + var percent = parseInt( data.slave.totalPercent ); + if( 0 === percent ) + { + done_element + .css( 'width', '1px' ); + } + else + { + done_element + .css( 'width', percent + '%' ); + } + + var current_file_element = $( '#current-file', replication_element ); + $( '.file', current_file_element ) + .text( data.slave.currentFile ); + $( '.done', current_file_element ) + .text( data.slave.currentFileSizeDownloaded ); + $( '.total', current_file_element ) + .text( data.slave.currentFileSize ); + $( '.percent', current_file_element ) + .text( parseInt( data.slave.currentFileSizePercent ) ); + + if( !data.slave.indexReplicatedAtList ) + { + data.slave.indexReplicatedAtList = []; + } + + if( !data.slave.replicationFailedAtList ) + { + data.slave.replicationFailedAtList = []; + } + + var iterations_element = $( '#iterations', replication_element ); + var iterations_list = $( '.iterations ul', iterations_element ); + + var iterations_data = []; + $.merge( iterations_data, data.slave.indexReplicatedAtList ); + $.merge( iterations_data, data.slave.replicationFailedAtList ); + + if( 0 !== iterations_data.length ) + { + var iterations = []; + for( var i = 0; i < iterations_data.length; i++ ) + { + iterations.push + ( + '
    • ' + + iterations_data[i] + '
    • ' + ); + } + + iterations_list + .html( iterations.join( "\n" ) ) + .show(); + + $( data.slave.indexReplicatedAtList ) + .each + ( + function( key, value ) + { + $( 'li[data-date="' + value + '"]', iterations_list ) + .addClass( 'replicated' ); + } + ); + + if( data.slave.indexReplicatedAt ) + { + $( + 'li[data-date="' + data.slave.indexReplicatedAt + '"]', + iterations_list + ) + .addClass( 'latest' ); + } + + $( data.slave.replicationFailedAtList ) + .each + ( + function( key, value ) + { + $( 'li[data-date="' + value + '"]', iterations_list ) + .addClass( 'failed' ); + } + ); + + if( data.slave.replicationFailedAt ) + { + $( + 'li[data-date="' + data.slave.replicationFailedAt + '"]', + iterations_list + ) + .addClass( 'latest' ); + } + + if( 0 !== $( 'li:hidden', iterations_list ).size() ) + { + $( 'a', iterations_element ) + .show(); + } + else + { + $( 'a', iterations_element ) + .hide(); + } + } + } + + var details_element = $( '#details', replication_element ); + var current_type_element = $( ( is_slave ? '.slave' : '.master' ), details_element ); + + $( '.version div', current_type_element ) + .html( data.indexVersion ); + $( '.generation div', current_type_element ) + .html( data.generation ); + $( '.size div', current_type_element ) + .html( data.indexSize ); + + if( is_slave ) + { + var master_element = $( '.master', details_element ); + $( '.version div', master_element ) + .html( data.slave.masterDetails.indexVersion ); + $( '.generation div', master_element ) + .html( data.slave.masterDetails.generation ); + $( '.size div', master_element ) + .html( data.slave.masterDetails.indexSize ); + + if( data.indexVersion !== data.slave.masterDetails.indexVersion ) + { + $( '.version', details_element ) + .addClass( 'diff' ); + } + else + { + $( '.version', details_element ) + .removeClass( 'diff' ); + } + + if( data.generation !== data.slave.masterDetails.generation ) + { + $( '.generation', details_element ) + .addClass( 'diff' ); + } + else + { + $( '.generation', details_element ) + .removeClass( 'diff' ); + } + } + + if( is_slave ) + { + var settings_element = $( '#settings', replication_element ); + + if( data.slave.masterUrl ) + { + $( '.masterUrl dd', settings_element ) + .html( response.details.slave.masterUrl ) + .parents( 'li' ).show(); + } + + var polling_content = ' '; + var polling_ico = 'ico-1'; + + if( 'true' === data.slave.isPollingDisabled ) + { + polling_ico = 'ico-0'; + + $( '.disable-polling', navigation_element ).hide(); + $( '.enable-polling', navigation_element ).show(); + } + else + { + $( '.disable-polling', navigation_element ).show(); + $( '.enable-polling', navigation_element ).hide(); + + if( data.slave.pollInterval ) + { + polling_content = '(interval: ' + data.slave.pollInterval + ')'; + } + } + + $( '.isPollingDisabled dd', settings_element ) + .removeClass( 'ico-0' ) + .removeClass( 'ico-1' ) + .addClass( polling_ico ) + .html( polling_content ) + .parents( 'li' ).show(); + } + + var master_settings_element = $( '#master-settings', replication_element ); + + var master_data = is_slave + ? data.slave.masterDetails.master + : data.master; + + var replication_icon = 'ico-0'; + if( 'true' === master_data.replicationEnabled ) + { + replication_icon = 'ico-1'; + + $( '.disable-replication', navigation_element ).show(); + $( '.enable-replication', navigation_element ).hide(); + } + else + { + $( '.disable-replication', navigation_element ).hide(); + $( '.enable-replication', navigation_element ).show(); + } + + $( '.replicationEnabled dd', master_settings_element ) + .removeClass( 'ico-0' ) + .removeClass( 'ico-1' ) + .addClass( replication_icon ) + .parents( 'li' ).show(); + + $( '.replicateAfter dd', master_settings_element ) + .html( master_data.replicateAfter.join( ', ' ) ) + .parents( 'li' ).show(); + + if( master_data.confFiles ) + { + var conf_files = []; + var conf_data = master_data.confFiles.split( ',' ); + + for( var i = 0; i < conf_data.length; i++ ) + { + var item = conf_data[i]; + + if( - 1 !== item.indexOf( ':' ) ) + { + info = item.split( ':' ); + item = '' + + ( is_slave ? info[1] : info[0] ) + + ''; + } + + conf_files.push( item ); + } + + $( '.confFiles dd', master_settings_element ) + .html( conf_files.join( ', ' ) ) + .parents( 'li' ).show(); + } + + + $( '.block', replication_element ).last() + .addClass( 'last' ); + + + + + if( 'true' === data.slave.isReplicating ) + { + replication_element + .addClass( 'replicating' ); + + $( '.replicate-now', navigation_element ).hide(); + $( '.abort-replication', navigation_element ).show(); + + window.setTimeout( replication_fetch_status, 1000 ); + } + else + { + replication_element + .removeClass( 'replicating' ); + + $( '.replicate-now', navigation_element ).show(); + $( '.abort-replication', navigation_element ).hide(); + } + }, + error : function( xhr, text_status, error_thrown ) + { + $( '#content' ) + .html( 'sorry, no replication-handler defined!' ); + }, + complete : function( xhr, text_status ) + { + } + } + ); + } + replication_fetch_status(); + + $( '#iterations a', content_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( this ).parents( '.iterations' ) + .toggleClass( 'expanded' ); + + return false; + } + ); + + $( 'button', navigation_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + var button = $( this ); + var command = button.data( 'command' ); + + if( button.hasClass( 'refresh-status' ) && !button.hasClass( 'loader' ) ) + { + replication_fetch_status(); + } + else if( command ) + { + $.get + ( + core_basepath + '/replication?command=' + command + '&wt=json', + function() + { + replication_fetch_status(); + } + ); + } + return false; + } + ); + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/schema-browser.js b/solr/webapp/web/js/scripts/schema-browser.js new file mode 100644 index 00000000000..23fc815d0ca --- /dev/null +++ b/solr/webapp/web/js/scripts/schema-browser.js @@ -0,0 +1,1052 @@ +sammy.bind +( + 'schema_browser_navi', + function( event, params ) + { + var related_navigation_element = $( '#related dl#f-df-t', params.schema_browser_element ); + var related_navigation_meta = $( '#related dl.ukf-dsf', params.schema_browser_element ); + var related_select_element = $( '#related select', params.schema_browser_element ) + var type = 'index'; + + var sammy_basepath = '#/' + $( 'p a', params.active_core ).html() + '/schema-browser'; + + if( !related_navigation_meta.hasClass( 'done' ) ) + { + if( app.schema_browser_data.unique_key_field ) + { + $( '.unique-key-field', related_navigation_meta ) + .show() + .after + ( + '
      ' + + app.schema_browser_data.unique_key_field + '
      ' + ); + } + + if( app.schema_browser_data.default_search_field ) + { + $( '.default-search-field', related_navigation_meta ) + .show() + .after + ( + '
      ' + + app.schema_browser_data.default_search_field + '
      ' + ); + } + + related_navigation_meta + .addClass( 'done' ); + } + + if( params.route_params ) + { + var type = params.route_params.splat[3]; + var value = params.route_params.splat[4]; + + var navigation_data = { + 'fields' : [], + 'copyfield_source' : [], + 'copyfield_dest' : [], + 'dynamic_fields' : [], + 'types' : [] + } + + $( 'option[value="' + params.route_params.splat[2] + '"]', related_select_element ) + .attr( 'selected', 'selected' ); + + if( 'field' === type ) + { + navigation_data.fields.push( value ); + navigation_data.types.push( app.schema_browser_data.relations.f_t[value] ); + + if( app.schema_browser_data.relations.f_df[value] ) + { + navigation_data.dynamic_fields.push( app.schema_browser_data.relations.f_df[value] ); + } + + if( 0 !== app.schema_browser_data.fields[value].copySources.length ) + { + navigation_data.copyfield_source = app.schema_browser_data.fields[value].copySources; + } + + if( 0 !== app.schema_browser_data.fields[value].copyDests.length ) + { + navigation_data.copyfield_dest = app.schema_browser_data.fields[value].copyDests; + } + } + else if( 'dynamic-field' === type ) + { + navigation_data.dynamic_fields.push( value ); + navigation_data.types.push( app.schema_browser_data.relations.df_t[value] ); + + if( app.schema_browser_data.relations.df_f[value] ) + { + navigation_data.fields = app.schema_browser_data.relations.df_f[value]; + } + } + else if( 'type' === type ) + { + navigation_data.types.push( value ); + + if( app.schema_browser_data.relations.t_f[value] ) + { + navigation_data.fields = app.schema_browser_data.relations.t_f[value]; + } + + if( app.schema_browser_data.relations.t_df[value] ) + { + navigation_data.dynamic_fields = app.schema_browser_data.relations.t_df[value]; + } + } + + var navigation_content = ''; + + if( 0 !== navigation_data.fields.length ) + { + navigation_data.fields.sort(); + navigation_content += '
      Fields
      ' + "\n"; + for( var i in navigation_data.fields ) + { + var href = sammy_basepath + '/field/' + navigation_data.fields[i]; + navigation_content += '
      ' + + navigation_data.fields[i] + '
      ' + "\n"; + } + } + + if( 0 !== navigation_data.copyfield_source.length ) + { + navigation_data.copyfield_source.sort(); + navigation_content += '
      Copied from
      ' + "\n"; + for( var i in navigation_data.copyfield_source ) + { + var href = sammy_basepath + '/field/' + navigation_data.copyfield_source[i]; + navigation_content += '
      ' + + navigation_data.copyfield_source[i] + '
      ' + "\n"; + } + } + + if( 0 !== navigation_data.copyfield_dest.length ) + { + navigation_data.copyfield_dest.sort(); + navigation_content += '
      Copied to
      ' + "\n"; + for( var i in navigation_data.copyfield_dest ) + { + var href = sammy_basepath + '/field/' + navigation_data.copyfield_dest[i]; + navigation_content += '
      ' + + navigation_data.copyfield_dest[i] + '
      ' + "\n"; + } + } + + if( 0 !== navigation_data.dynamic_fields.length ) + { + navigation_data.dynamic_fields.sort(); + navigation_content += '
      Dynamic Fields
      ' + "\n"; + for( var i in navigation_data.dynamic_fields ) + { + var href = sammy_basepath + '/dynamic-field/' + navigation_data.dynamic_fields[i]; + navigation_content += '
      ' + + navigation_data.dynamic_fields[i] + '
      ' + "\n"; + } + } + + if( 0 !== navigation_data.types.length ) + { + navigation_data.types.sort(); + navigation_content += '
      Types
      ' + "\n"; + for( var i in navigation_data.types ) + { + var href = sammy_basepath + '/type/' + navigation_data.types[i]; + navigation_content += '
      ' + + navigation_data.types[i] + '
      ' + "\n"; + } + } + + related_navigation_element + .show() + .attr( 'class', type ) + .html( navigation_content ); + } + else + { + related_navigation_element + .hide(); + + $( 'option:selected', related_select_element ) + .removeAttr( 'selected' ); + } + + if( 'field' === type && value === app.schema_browser_data.unique_key_field ) + { + $( '.unique-key-field', related_navigation_meta ) + .addClass( 'active' ); + } + else + { + $( '.unique-key-field', related_navigation_meta ) + .removeClass( 'active' ); + } + + if( 'field' === type && value === app.schema_browser_data.default_search_field ) + { + $( '.default-search-field', related_navigation_meta ) + .addClass( 'active' ); + } + else + { + $( '.default-search-field', related_navigation_meta ) + .removeClass( 'active' ); + } + + if( params.callback ) + { + params.callback( app.schema_browser_data, $( '#data', params.schema_browser_element ) ); + } + } +); + +sammy.bind +( + 'schema_browser_load', + function( event, params ) + { + var core_basepath = params.active_core.attr( 'data-basepath' ); + var content_element = $( '#content' ); + + if( app.schema_browser_data ) + { + params.schema_browser_element = $( '#schema-browser', content_element ); + + sammy.trigger + ( + 'schema_browser_navi', + params + ); + } + else + { + content_element + .html( '
      Loading ...
      ' ); + + $.ajax + ( + { + url : core_basepath + '/admin/luke?numTerms=0&wt=json', + dataType : 'json', + beforeSend : function( xhr, settings ) + { + }, + success : function( response, text_status, xhr ) + { + app.schema_browser_data = { + default_search_field : null, + unique_key_field : null, + key : {}, + fields : {}, + dynamic_fields : {}, + types : {}, + relations : { + f_df : {}, + f_t : {}, + df_f : {}, + df_t : {}, + t_f : {}, + t_df : {} + } + }; + + app.schema_browser_data.fields = response.fields; + app.schema_browser_data.key = response.info.key; + + $.ajax + ( + { + url : core_basepath + '/admin/luke?show=schema&wt=json', + dataType : 'json', + beforeSend : function( xhr, settings ) + { + }, + success : function( response, text_status, xhr ) + { + app.schema_browser_data.default_search_field = response.schema.defaultSearchField; + app.schema_browser_data.unique_key_field = response.schema.uniqueKeyField; + + app.schema_browser_data.dynamic_fields = response.schema.dynamicFields; + app.schema_browser_data.types = response.schema.types; + + var luke_array_to_struct = function( array ) + { + var struct = { + keys : [], + values : [] + }; + for( var i = 0; i < array.length; i += 2 ) + { + struct.keys.push( array[i] ); + struct.values.push( array[i+1] ); + } + return struct; + } + + var luke_array_to_hash = function( array ) + { + var hash = {}; + for( var i = 0; i < array.length; i += 2 ) + { + hash[ array[i] ] = array[i+1]; + } + return hash; + } + + for( var field in response.schema.fields ) + { + app.schema_browser_data.fields[field] = $.extend + ( + {}, + app.schema_browser_data.fields[field], + response.schema.fields[field] + ); + } + + for( var field in app.schema_browser_data.fields ) + { + app.schema_browser_data.fields[field].copySourcesRaw = null; + + if( app.schema_browser_data.fields[field].copySources && + 0 !== app.schema_browser_data.fields[field].copySources.length ) + { + app.schema_browser_data.fields[field].copySourcesRaw = + app.schema_browser_data.fields[field].copySources; + } + + app.schema_browser_data.fields[field].copyDests = []; + app.schema_browser_data.fields[field].copySources = []; + } + + for( var field in app.schema_browser_data.fields ) + { + if( app.schema_browser_data.fields[field].copySourcesRaw ) + { + var copy_sources = app.schema_browser_data.fields[field].copySourcesRaw; + for( var i in copy_sources ) + { + var target = copy_sources[i].replace( /^.+:(.+)\{.+$/, '$1' ); + + app.schema_browser_data.fields[field].copySources.push( target ); + app.schema_browser_data.fields[target].copyDests.push( field ); + } + } + + app.schema_browser_data.relations.f_t[field] = app.schema_browser_data.fields[field].type; + + if( !app.schema_browser_data.relations.t_f[app.schema_browser_data.fields[field].type] ) + { + app.schema_browser_data.relations.t_f[app.schema_browser_data.fields[field].type] = []; + } + app.schema_browser_data.relations.t_f[app.schema_browser_data.fields[field].type].push( field ); + + if( app.schema_browser_data.fields[field].dynamicBase ) + { + app.schema_browser_data.relations.f_df[field] = app.schema_browser_data.fields[field].dynamicBase; + + if( !app.schema_browser_data.relations.df_f[app.schema_browser_data.fields[field].dynamicBase] ) + { + app.schema_browser_data.relations.df_f[app.schema_browser_data.fields[field].dynamicBase] = []; + } + app.schema_browser_data.relations.df_f[app.schema_browser_data.fields[field].dynamicBase].push( field ); + } + } + + for( var dynamic_field in app.schema_browser_data.dynamic_fields ) + { + app.schema_browser_data.relations.df_t[dynamic_field] = app.schema_browser_data.dynamic_fields[dynamic_field].type; + + if( !app.schema_browser_data.relations.t_df[app.schema_browser_data.dynamic_fields[dynamic_field].type] ) + { + app.schema_browser_data.relations.t_df[app.schema_browser_data.dynamic_fields[dynamic_field].type] = []; + } + app.schema_browser_data.relations.t_df[app.schema_browser_data.dynamic_fields[dynamic_field].type].push( dynamic_field ); + } + + $.get + ( + 'tpl/schema-browser.html', + function( template ) + { + content_element + .html( template ); + + var schema_browser_element = $( '#schema-browser', content_element ); + var related_element = $( '#related', schema_browser_element ); + var related_select_element = $( 'select', related_element ); + var data_element = $( '#data', schema_browser_element ); + + var related_options = ''; + + var fields = []; + for( var field_name in app.schema_browser_data.fields ) + { + fields.push + ( + '' + ); + } + if( 0 !== fields.length ) + { + fields.sort(); + related_options += '' + "\n"; + related_options += fields.sort().join( "\n" ) + "\n"; + related_options += '' + "\n"; + } + + var dynamic_fields = []; + for( var type_name in app.schema_browser_data.dynamic_fields ) + { + dynamic_fields.push + ( + '' + ); + } + if( 0 !== dynamic_fields.length ) + { + dynamic_fields.sort(); + related_options += '' + "\n"; + related_options += dynamic_fields.sort().join( "\n" ) + "\n"; + related_options += '' + "\n"; + } + + var types = []; + for( var type_name in app.schema_browser_data.types ) + { + types.push + ( + '' + ); + } + if( 0 !== types.length ) + { + types.sort(); + related_options += '' + "\n"; + related_options += types.sort().join( "\n" ) + "\n"; + related_options += '' + "\n"; + } + + related_select_element + .attr( 'rel', '#/' + $( 'p a', params.active_core ).html() + '/schema-browser' ) + .append( related_options ); + + related_select_element + .die( 'change' ) + .live + ( + 'change', + function( event ) + { + var select_element = $( this ); + var option_element = $( 'option:selected', select_element ); + + location.href = select_element.attr( 'rel' ) + option_element.val(); + return false; + } + ); + + params.schema_browser_element = schema_browser_element; + sammy.trigger + ( + 'schema_browser_navi', + params + ); + } + ); + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + } + } +); + +// #/:core/schema-browser +sammy.get +( + /^#\/([\w\d-]+)\/(schema-browser)$/, + function( context ) + { + var callback = function( schema_browser_data, data_element ) + { + data_element + .hide(); + }; + + delete app.schema_browser_data; + + sammy.trigger + ( + 'schema_browser_load', + { + callback : callback, + active_core : this.active_core + } + ); + } +); + +// #/:core/schema-browser/field|dynamic-field|type/$field +sammy.get +( + /^#\/([\w\d-]+)\/(schema-browser)(\/(field|dynamic-field|type)\/(.+))$/, + function( context ) + { + var core_basepath = this.active_core.attr( 'data-basepath' ); + + var callback = function( schema_browser_data, data_element ) + { + var field = context.params.splat[4]; + + var type = context.params.splat[3]; + var is_f = 'field' === type; + var is_df = 'dynamic-field' === type; + var is_t = 'type' === type; + + var options_element = $( '.options', data_element ); + var sammy_basepath = context.path.indexOf( '/', context.path.indexOf( '/', 2 ) + 1 ); + + data_element + .show(); + + var keystring_to_list = function( keystring, element_class ) + { + var key_list = keystring.replace( /-/g, '' ).split( '' ); + var list = []; + + for( var i in key_list ) + { + var option_key = schema_browser_data.key[key_list[i]]; + + if( !option_key ) + { + option_key = schema_browser_data.key[key_list[i].toLowerCase()]; + } + + if( !option_key ) + { + option_key = schema_browser_data.key[key_list[i].toUpperCase()]; + } + + if( option_key ) + { + list.push + ( + '
      ' + + option_key + + ',
      ' + ); + } + } + + list[list.length-1] = list[key_list.length-1].replace( /,/, '' ); + + return list; + } + + var flags = null; + + if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].flags ) + { + flags = schema_browser_data.fields[field].flags; + } + else if( is_df && schema_browser_data.dynamic_fields[field] && schema_browser_data.dynamic_fields[field].flags ) + { + flags = schema_browser_data.dynamic_fields[field].flags; + } + + // -- properties + var properties_element = $( 'dt.properties', options_element ); + if( flags ) + { + var properties_keys = keystring_to_list( flags, 'properties' ); + + $( 'dd.properties', options_element ) + .remove(); + + properties_element + .show() + .after( properties_keys.join( "\n" ) ); + } + else + { + $( '.properties', options_element ) + .hide(); + } + + // -- schema + var schema_element = $( 'dt.schema', options_element ); + if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].schema ) + { + var schema_keys = keystring_to_list( schema_browser_data.fields[field].schema, 'schema' ); + + $( 'dd.schema', options_element ) + .remove(); + + schema_element + .show() + .after( schema_keys.join( "\n" ) ); + } + else + { + $( '.schema', options_element ) + .hide(); + } + + // -- index + var index_element = $( 'dt.index', options_element ); + if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].index ) + { + var index_keys = []; + + if( 0 === schema_browser_data.fields[field].index.indexOf( '(' ) ) + { + index_keys.push( '
      ' + schema_browser_data.fields[field].index + '
      ' ); + } + else + { + index_keys = keystring_to_list( schema_browser_data.fields[field].index, 'index' ); + } + + $( 'dd.index', options_element ) + .remove(); + + index_element + .show() + .after( index_keys.join( "\n" ) ); + } + else + { + $( '.index', options_element ) + .hide(); + } + + // -- docs + var docs_element = $( 'dt.docs', options_element ); + if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].docs ) + { + $( 'dd.docs', options_element ) + .remove(); + + docs_element + .show() + .after( '
      ' + schema_browser_data.fields[field].docs + '
      ' ); + } + else + { + $( '.docs', options_element ) + .hide(); + } + + // -- distinct + var distinct_element = $( 'dt.distinct', options_element ); + if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].distinct ) + { + $( 'dd.distinct', options_element ) + .remove(); + + distinct_element + .show() + .after( '
      ' + schema_browser_data.fields[field].distinct + '
      ' ); + } + else + { + $( '.distinct', options_element ) + .hide(); + } + + // -- position-increment-gap + var pig_element = $( 'dt.position-increment-gap', options_element ); + if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].positionIncrementGap ) + { + $( 'dt.position-increment-gap', options_element ) + .remove(); + + pig_element + .show() + .after( '
      ' + schema_browser_data.fields[field].positionIncrementGap + '
      ' ); + } + else + { + $( '.position-increment-gap', options_element ) + .hide(); + } + + var analyzer_element = $( '.analyzer', data_element ); + var analyzer_data = null; + + if( is_f ) + { + analyzer_data = schema_browser_data.types[schema_browser_data.relations.f_t[field]]; + } + else if( is_df ) + { + analyzer_data = schema_browser_data.types[schema_browser_data.relations.df_t[field]]; + } + else if( is_t ) + { + analyzer_data = schema_browser_data.types[field]; + } + + if( analyzer_data ) + { + var transform_analyzer_data_into_list = function( analyzer_data ) + { + var args = []; + for( var key in analyzer_data.args ) + { + var arg_class = ''; + var arg_content = ''; + + if( 'true' === analyzer_data.args[key] || '1' === analyzer_data.args[key] ) + { + arg_class = 'ico-1'; + arg_content = key; + } + else if( 'false' === analyzer_data.args[key] || '0' === analyzer_data.args[key] ) + { + arg_class = 'ico-0'; + arg_content = key; + } + else + { + arg_content = key + ': '; + + if( 'synonyms' === key || 'words' === key ) + { + // @TODO: set link target for file + arg_content += '' + analyzer_data.args[key] + ''; + } + else + { + arg_content += analyzer_data.args[key]; + } + } + + args.push( '
      ' + arg_content + '
      ' ); + } + + var list_content = '
      ' + analyzer_data.className + '
      '; + if( 0 !== args.length ) + { + args.sort(); + list_content += args.join( "\n" ); + } + + return list_content; + } + + // -- field-type + var field_type_element = $( 'dt.field-type', options_element ); + + $( 'dd.field-type', options_element ) + .remove(); + + field_type_element + .show() + .after( '
      ' + analyzer_data.className + '
      ' ); + + + for( var key in analyzer_data ) + { + var key_match = key.match( /^(.+)Analyzer$/ ); + if( !key_match ) + { + continue; + } + + var analyzer_key_element = $( '.' + key_match[1], analyzer_element ); + var analyzer_key_data = analyzer_data[key]; + + analyzer_element.show(); + analyzer_key_element.show(); + + if( analyzer_key_data.className ) + { + $( 'dl:first dt', analyzer_key_element ) + .html( analyzer_key_data.className ); + } + + $( 'ul li', analyzer_key_element ) + .hide(); + + for( var type in analyzer_key_data ) + { + if( 'object' !== typeof analyzer_key_data[type] ) + { + continue; + } + + var type_element = $( '.' + type, analyzer_key_element ); + var type_content = []; + + type_element.show(); + + if( analyzer_key_data[type].className ) + { + type_content.push( transform_analyzer_data_into_list( analyzer_key_data[type] ) ); + } + else + { + for( var entry in analyzer_key_data[type] ) + { + type_content.push( transform_analyzer_data_into_list( analyzer_key_data[type][entry] ) ); + } + } + + $( 'dl', type_element ) + .empty() + .append( type_content.join( "\n" ) ); + } + } + } + + var terminfo_element = $( '.terminfo-holder', data_element ); + + if( !is_f ) + { + terminfo_element + .hide(); + } + else + { + terminfo_element + .show(); + + var status_element = $( '.status', terminfo_element ); + + $.ajax + ( + { + url : core_basepath + '/admin/luke?numTerms=50&wt=json&fl=' + field, + dataType : 'json', + context : terminfo_element, + beforeSend : function( xhr, settings ) + { + }, + success : function( response, text_status, xhr ) + { + status_element + .hide(); + + var field_data = response.fields[field]; + + var topterms_holder_element = $( '.topterms-holder', data_element ); + var histogram_holder_element = $( '.histogram-holder', data_element ); + + var luke_array_to_struct = function( array ) + { + var struct = { + keys : [], + values : [] + }; + for( var i = 0; i < array.length; i += 2 ) + { + struct.keys.push( array[i] ); + struct.values.push( array[i+1] ); + } + return struct; + } + + var luke_array_to_hash = function( array ) + { + var hash = {}; + for( var i = 0; i < array.length; i += 2 ) + { + hash[ array[i] ] = array[i+1]; + } + return hash; + } + + if( !field_data.topTerms ) + { + topterms_holder_element + .hide(); + } + else + { + topterms_holder_element + .show(); + + var topterms_table_element = $( 'table', topterms_holder_element ); + + var topterms_navi_less = $( 'p.navi .less', topterms_holder_element ); + var topterms_navi_more = $( 'p.navi .more', topterms_holder_element ); + + var topterms_count = luke_array_to_struct( field_data.topTerms ).keys.length; + var topterms_hash = luke_array_to_hash( field_data.topTerms ); + var topterms_content = ''; + + var i = 1; + for( var term in topterms_hash ) + { + topterms_content += '' + "\n" + + '' + i + '' + "\n" + + '' + term + '' + "\n" + + '' + topterms_hash[term] + '' + "\n" + + '' + "\n"; + + if( i !== topterms_count && 0 === i % 10 ) + { + topterms_content += ''; + } + + i++; + } + + topterms_content += ''; + + topterms_table_element + .empty() + .append( topterms_content ); + + $( 'tbody', topterms_table_element ) + .die( 'change' ) + .live + ( + 'change', + function() + { + var blocks = $( 'tbody', topterms_table_element ); + var visible_blocks = blocks.filter( ':visible' ); + var hidden_blocks = blocks.filter( ':hidden' ); + + $( 'p.head .shown', topterms_holder_element ) + .html( $( 'tr', visible_blocks ).size() ); + + 0 < hidden_blocks.size() + ? topterms_navi_more.show() + : topterms_navi_more.hide(); + + 1 < visible_blocks.size() + ? topterms_navi_less.show() + : topterms_navi_less.hide(); + } + ); + + $( 'tbody tr:odd', topterms_table_element ) + .addClass( 'odd' ); + + $( 'tbody:first', topterms_table_element ) + .show() + .trigger( 'change' ); + + $( 'p.head .max', topterms_holder_element ) + .html( field_data.distinct ); + + topterms_navi_less + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( 'tbody:visible', topterms_table_element ).last() + .hide() + .trigger( 'change' ); + } + ); + + topterms_navi_more + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( 'tbody:hidden', topterms_table_element ).first() + .show() + .trigger( 'change' ); + } + ); + } + + if( !field_data.histogram ) + { + histogram_holder_element + .hide(); + } + else + { + histogram_holder_element + .show(); + + var histogram_element = $( '.histogram', histogram_holder_element ); + + var histogram_values = luke_array_to_hash( field_data.histogram ); + var histogram_legend = ''; + + histogram_holder_element + .show(); + + for( var key in histogram_values ) + { + histogram_legend += '
      ' + key + '
      ' + "\n" + + '
      ' + + '' + histogram_values[key] + '' + + '
      ' + "\n"; + } + + $( 'dl', histogram_holder_element ) + .html( histogram_legend ); + + histogram_element + .sparkline + ( + luke_array_to_struct( field_data.histogram ).values, + { + type : 'bar', + barColor : '#c0c0c0', + zeroColor : '#ffffff', + height : histogram_element.height(), + barWidth : 46, + barSpacing : 3 + } + ); + } + + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + + } + } + + sammy.trigger + ( + 'schema_browser_load', + { + callback : callback, + active_core : this.active_core, + route_params : this.params + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/threads.js b/solr/webapp/web/js/scripts/threads.js new file mode 100644 index 00000000000..0b5feec62b1 --- /dev/null +++ b/solr/webapp/web/js/scripts/threads.js @@ -0,0 +1,144 @@ +// #/threads +sammy.get +( + /^#\/(threads)$/, + function( context ) + { + var core_basepath = $( 'li[data-basepath]', app.menu_element ).attr( 'data-basepath' ); + var content_element = $( '#content' ); + + $.get + ( + 'tpl/threads.html', + function( template ) + { + content_element + .html( template ); + + $.ajax + ( + { + url : core_basepath + '/admin/threads?wt=json', + dataType : 'json', + context : $( '#threads', content_element ), + beforeSend : function( xhr, settings ) + { + }, + success : function( response, text_status, xhr ) + { + var self = this; + + var threadDumpData = response.system.threadDump; + var threadDumpContent = []; + var c = 0; + for( var i = 1; i < threadDumpData.length; i += 2 ) + { + var state = threadDumpData[i].state.esc(); + var name = '' + threadDumpData[i].name.esc() + ' (' + threadDumpData[i].id.esc() + ')'; + + var classes = [state]; + var details = ''; + + if( 0 !== c % 2 ) + { + classes.push( 'odd' ); + } + + if( threadDumpData[i].lock ) + { + classes.push( 'lock' ); + name += "\n" + '

      ' + threadDumpData[i].lock.esc() + '

      '; + } + + if( threadDumpData[i].stackTrace && 0 !== threadDumpData[i].stackTrace.length ) + { + classes.push( 'stacktrace' ); + + var stack_trace = threadDumpData[i].stackTrace + .join( '###' ) + .esc() + .replace( /\(/g, '​(' ) + .replace( /###/g, '
    • ' ); + + name += '
      ' + "\n" + + '
        ' + "\n" + + '
      • ' + stack_trace + '
      • ' + + '
      ' + "\n" + + '
      '; + } + + var item = '' + "\n" + + + '' + name + '' + "\n" + + '' + threadDumpData[i].cpuTime.esc() + '
      ' + threadDumpData[i].userTime.esc() + '' + "\n" + + + ''; + + threadDumpContent.push( item ); + c++; + } + + var threadDumpBody = $( '#thread-dump tbody', this ); + + threadDumpBody + .html( threadDumpContent.join( "\n" ) ); + + $( '.name a', threadDumpBody ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( this ).closest( 'tr' ) + .toggleClass( 'open' ); + } + ); + + $( '.controls a', this ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + var threads_element = $( self ); + var is_collapsed = threads_element.hasClass( 'collapsed' ); + var thread_rows = $( 'tr', threads_element ); + + thread_rows + .each + ( + function( index, element ) + { + if( is_collapsed ) + { + $( element ) + .addClass( 'open' ); + } + else + { + $( element ) + .removeClass( 'open' ); + } + } + ); + + threads_element + .toggleClass( 'collapsed' ) + .toggleClass( 'expanded' ); + } + ); + }, + error : function( xhr, text_status, error_thrown) + { + }, + complete : function( xhr, text_status ) + { + } + } + ); + } + ); + } +); \ No newline at end of file diff --git a/solr/webapp/web/tpl/analysis.html b/solr/webapp/web/tpl/analysis.html index 738d1cbf309..f31d1f56e68 100644 --- a/solr/webapp/web/tpl/analysis.html +++ b/solr/webapp/web/tpl/analysis.html @@ -14,12 +14,18 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -
      -
      +
      - This Functionality requires the /analysis/field Handler to be registered and active! +
      This Functionality requires the /analysis/field Handler to be registered and active!
      + +
      + +
      + +
      +
      diff --git a/solr/webapp/web/tpl/cloud.html b/solr/webapp/web/tpl/cloud.html index ab707a9c993..32d53cb806c 100644 --- a/solr/webapp/web/tpl/cloud.html +++ b/solr/webapp/web/tpl/cloud.html @@ -16,7 +16,7 @@ limitations under the License. -->
      -
      +

      Zookeeper-Data

      @@ -24,9 +24,21 @@ limitations under the License.
      -
      +
      - Fetch Zookeeper Data +
      #tree
      + +
      + +
      +
        +
        + +
        + + [x] + +
        diff --git a/solr/webapp/web/tpl/query.html b/solr/webapp/web/tpl/query.html index 9d0160956d3..c602419b22e 100644 --- a/solr/webapp/web/tpl/query.html +++ b/solr/webapp/web/tpl/query.html @@ -56,6 +56,23 @@ limitations under the License. + + + + +
      • -

        Query Analyzer:

        +

        Query Analyzer:

        @@ -74,11 +74,13 @@ limitations under the License.
        • Tokenizer:

          -
          +
          +
        • Filters:

          -
          +
          +
        @@ -86,50 +88,52 @@ limitations under the License.
      - -
      -
      Load Term Info
      - + +
      + +
      Loading Term Info ...
      +
      - +

      Top / Terms:

      - + - + - + - + - + - +
        Term Frq
      - + - +
      - +
      - +

      Histogram:

      - +
      - +
      - +
      +
      - +
      diff --git a/solr/webapp/web/tpl/schema-browser_dynamic-field.html b/solr/webapp/web/tpl/schema-browser_dynamic-field.html deleted file mode 100644 index 449e8a88cfe..00000000000 --- a/solr/webapp/web/tpl/schema-browser_dynamic-field.html +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/solr/webapp/web/tpl/schema-browser_type.html b/solr/webapp/web/tpl/schema-browser_type.html deleted file mode 100644 index 449e8a88cfe..00000000000 --- a/solr/webapp/web/tpl/schema-browser_type.html +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/solr/webapp/web/tpl/threads.html b/solr/webapp/web/tpl/threads.html index 2d4c2f762a5..4591f69be63 100644 --- a/solr/webapp/web/tpl/threads.html +++ b/solr/webapp/web/tpl/threads.html @@ -31,11 +31,8 @@ limitations under the License. -   - id - name - cpuTime - userTime + name + cpuTime / userTime