From fcc254e5a8ab5cace58b3382a5e8cbf073f11c0f Mon Sep 17 00:00:00 2001 From: Brian Burns Date: Sun, 31 Mar 2019 22:04:51 -0500 Subject: [PATCH 01/16] added versioning and CRAN testing to contribution guide --- CONTRIBUTING.md | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b70093aa..8b9b7fa4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,8 +7,10 @@ The goal of this guide is to help you contribute to `pkgnet` as quickly and as e 2. [Submitting a Pull Request](#prs) 3. [Code Style](#style) 4. [Running Tests Locally](#testing) -5. [Releasing to CRAN (for maintainer)](#cran) +5. [Package Versioning](#version) +6. [Releasing to CRAN (for maintainer)](#cran) +*** ## Creating an Issue To report bugs, request features, or ask questions about the structure of the code, please [open an issue](https://github.com/UptakeOpenSource/pkgnet/issues). @@ -39,6 +41,7 @@ Good feature requests will note all of the following: If you're interested in submitting a pull request to address the bug you're reporting, please indicate that in the issue. +*** ## Submitting a Pull Request We welcome [pull requests](https://help.github.com/articles/about-pull-requests/) from anyone interested in contributing to `pkgnet`. This section describes best practices for submitting PRs to this project. @@ -61,6 +64,7 @@ To submit a PR, please follow these steps: We will try to review PRs promptly and get back to you within a few days. +*** ## Code Style The code in this project should follow a standard set of conventions for style in R code. @@ -80,7 +84,7 @@ some_function <- function(n){ } ``` -You do not need to namespace special operators in the case where doing so would hurt readablility. For example, `%>%` from `magrittr` and `:=` from `data.table` do not need `::` namespacing. +You do not need to namespace special operators in the case where doing so would hurt readability. For example, `%>%` from `magrittr` and `:=` from `data.table` do not need `::` namespacing. If you are adding new dependencies to the package (i.e. using an entirely new package), you need to also add that dependency to the `Imports` section of the [DESCRIPTION file](https://github.com/UptakeOpenSource/pkgnet/blob/master/DESCRIPTION). @@ -237,6 +241,7 @@ RandomNumberPlotter <- R6::R6Class( All comments should be above code, not beside it. +*** ## Running Tests Locally We use Travis CI to automatically run unit tests and a serious of other automated checks on every PR commit and merge to `master`. Every `pkgnet` release also goes through a battery of automated tests run on CRAN before becoming officially available through CRAN. @@ -246,7 +251,20 @@ However, these options can lengthen your testing cycle and make the process of c ```{bash} ./test.sh ``` +*** +## Package Versioning +We follow semantic versioning for `pkgnet` releases, `MAJOR`.`MINOR`.`PATCH`: + +* the `MAJOR` version will be updated when incompatible API changes are made, +* the `MINOR` version will be updated when functionality is added in a backwards-compatible manner, and +* the `PATCH` version will be updated when backwards-compatible bug fixes are made. + +In addition, the latest development version will have a .9999 appended to the end of the `MAJOR`.`MINOR`.`PATCH`. + +For more details, see https://semver.org/ + +*** ## Releasing to CRAN (for maintainer) Once substantial time has passed or significant changes have been made to `pkgnet`, a new release should be pushed to [CRAN](https://cran.r-project.org). @@ -259,7 +277,7 @@ This is a manual process, with the following steps. Open a PR with a branch name `release/v0.0.0` (replacing 0.0.0 with the actual version number). -Add a section for this release to `NEWS.md`. This file details the new features, changes, and bug fixes that occured since the last version. +Add a section for this release to `NEWS.md`. This file details the new features, changes, and bug fixes that occurred since the last version. Add a section for this release to `cran-comments.md`. This file holds details of our submission comments to CRAN and their responses to our submissions. @@ -277,6 +295,10 @@ Rscript -e "pkgdown::build_site()" Check in whichever of the files generated by `pkgdown` seem relevant to you. Anything that shows up as "modified" when you run `git status` should be checked in to the PR branch. New files ("not tracked by git") should be considered on a case-by-case basis. +### Test on latest development version of R (i.e. "R-Devel") + +This is a CRAN requirement. [This docker based process](https://alexandereckert.com/post/testing-r-packages-with-latest-r-devel/) from Alexander Eckert is very useful. + ### Submit to CRAN Build the package tarball by running the following @@ -301,7 +323,7 @@ Once the submission is accepted, great! Update `cran-comments.md` and merge the We use [the releases section](https://github.com/UptakeOpenSource/pkgnet/releases) in the repo to categorize certain important commits as release checkpoints. This makes it easier for developers to associate changes in the source code with the release history on CRAN, and enables features like `devtools::install_github()` for old versions. -Navigate to https://github.com/UptakeOpenSource/pkgnet/releases/new. Click the dropdown in the "target" section, then click "recent commits". Choose the latest commit for the release PR you just merged. This will automatically create a [git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) on that commit and tell Github which revision to build when people ask for a given release. +Navigate to https://github.com/UptakeOpenSource/pkgnet/releases/new. Click the drop down in the "target" section, then click "recent commits". Choose the latest commit for the release PR you just merged. This will automatically create a [git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) on that commit and tell Github which revision to build when people ask for a given release. Add some notes explaining what has changed since the previous release. From 04855e5cb6cff8bdab813fe3e9d20f7636140c6b Mon Sep 17 00:00:00 2001 From: Brian Burns Date: Sun, 31 Mar 2019 22:05:09 -0500 Subject: [PATCH 02/16] upgrade MINOR version --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bf70884f..6e4a2d0b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: pkgnet Type: Package Title: Get Network Representation of an R Package -Version: 0.3.2.9999 +Version: 0.4.0 Authors@R: c( person("Brian", "Burns", email = "brian.burns@uptake.com", role = c("aut", "cre")), person("James", "Lamb", email = "james.lamb@uptake.com", role = c("aut")), diff --git a/NEWS.md b/NEWS.md index 0ecd19d5..2cdf35f3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# pkgnet 0.3.2.9999 (current dev) +# pkgnet 0.4.0 ## NEW FEATURES From 7f0de4a24917b1b01aa35958a5d442d00e2f6546 Mon Sep 17 00:00:00 2001 From: Brian Burns Date: Sun, 31 Mar 2019 22:19:51 -0500 Subject: [PATCH 03/16] align dev versioning --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8b9b7fa4..97905172 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -281,7 +281,7 @@ Add a section for this release to `NEWS.md`. This file details the new features Add a section for this release to `cran-comments.md`. This file holds details of our submission comments to CRAN and their responses to our submissions. -Change the `Version:` field in `DESCRIPTION` to the official version you want on CRAN (should not have a trailing `.9000`). +Change the `Version:` field in `DESCRIPTION` to the official version you want on CRAN (should not have a trailing `.9999`). Rebuild the documentation by running: From e37ae1d1b2a45d2e7e1e8e729b0008b30513ab58 Mon Sep 17 00:00:00 2001 From: Brian Burns Date: Sun, 31 Mar 2019 23:15:49 -0500 Subject: [PATCH 04/16] Added release planning milestones note. --- CONTRIBUTING.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 97905172..fc0ed5af 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -254,6 +254,7 @@ However, these options can lengthen your testing cycle and make the process of c *** ## Package Versioning +### Version Format We follow semantic versioning for `pkgnet` releases, `MAJOR`.`MINOR`.`PATCH`: * the `MAJOR` version will be updated when incompatible API changes are made, @@ -264,6 +265,12 @@ In addition, the latest development version will have a .9999 appended to the en For more details, see https://semver.org/ +### Release Planning +The authors of this package have adopted [milestones on github](https://help.github.com/en/articles/about-milestones) as a vehile to scope and schedule upcoming releases. The main goal for a release is written in the milestone description. Then, any ideas, specific functionality, bugs, etcs submitted as [issues](https://help.github.com/en/articles/about-issues) pertinent to that goal are tagged for that milestone. Goals for milestone are dicsused openly via a github issue. + +Past and upcoming releases can be seen on the [pkgnet milestones page](https://github.com/UptakeOpenSource/pkgnet/milestones). + + *** ## Releasing to CRAN (for maintainer) From 488f68e30572ef11b7644cdc6d9e7e1eef1458ff Mon Sep 17 00:00:00 2001 From: Brian Burns Date: Mon, 1 Apr 2019 09:18:59 -0500 Subject: [PATCH 05/16] remove CreatePackageVigette example from package articles --- vignettes/pkgnet-report.Rmd | 61 ------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 vignettes/pkgnet-report.Rmd diff --git a/vignettes/pkgnet-report.Rmd b/vignettes/pkgnet-report.Rmd deleted file mode 100644 index d388432f..00000000 --- a/vignettes/pkgnet-report.Rmd +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: "pkgnet Package Report, by pkgnet" -output: - rmarkdown::html_vignette: - toc: true -vignette: > - %\VignetteIndexEntry{Package Report, by pkgnet} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - -This report on **pkgnet** is generated by [**pkgnet**](https://uptakeopensource.github.io/pkgnet/), an R package for analyzing other R packages through the lens of [network theory](https://en.wikipedia.org/wiki/Network_theory). - -```{r setup, include=FALSE} -library(pkgnet) - -knitr::opts_chunk$set( - echo = FALSE - , warning=FALSE - , out.width='100%' -) -pkgnet:::silence_logger() - -reporters <- list(DependencyReporter$new(), FunctionReporter$new(), InheritanceReporter$new()) - -reporters <- lapply( - X = reporters - , FUN = function(reporter){ - reporter$set_package(pkg_name = "pkgnet") - return(reporter) - } - ) - -``` - -```{r warning=FALSE} -reportSections <- lapply(reporters, function(reporter) { - report_env <- list2env(list(reporter = reporter)) - knitr::knit_child( - reporter$report_markdown_path - , envir = report_env - ) -}) - -``` - -```{r results="asis"} -cat(paste0(paste(reportSections, collapse = '\n'))) -``` - ---- - -```{r results="asis"} -cat(sprintf("This report built with **pkgnet v%s**.", packageVersion('pkgnet'))) -``` - -[**pkgnet**](https://uptakeopensource.github.io/pkgnet/) is an open-source R package, copyright © 2017-2019 Uptake, made available under the 3-Clause BSD License. - -```{r echo = FALSE} -pkgnet:::unsilence_logger() -``` From fb9c188bbf97dd9e3cb5d24c8ede43f67b3f3943 Mon Sep 17 00:00:00 2001 From: Brian Burns Date: Mon, 1 Apr 2019 09:28:20 -0500 Subject: [PATCH 06/16] draft cran comments --- cran-comments.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cran-comments.md b/cran-comments.md index a85dc22a..6091b719 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,5 +1,12 @@ # CRAN Submission History +## v 0.4.0 + +### Submission on April 1st, 2019 (Planned) +This is a minor release that adds viggette creation functionality and makes a number of other minor changes and bug fixes. Please see `NEWS.md` for details. + +As always, issues are tracked and source code is maintained at https://github.com/UptakeOpenSource/pkgnet. + ## v 0.3.2 ### Submission on January 25th, 2019 @@ -39,7 +46,7 @@ BUG FIXES ## v 0.3.0 ### Submission on December 19th, 2018 -> This is a major release with several improvements to +> This is a major[sic] release with several improvements to > R package diagnostics, report layout, and testing > strategy. New features and changes are now being > tracked in NEWS.md. From bde56ee3a6be7deae71e9ef3db8bccfbb50ad9cd Mon Sep 17 00:00:00 2001 From: Brian Burns Date: Mon, 1 Apr 2019 09:29:34 -0500 Subject: [PATCH 07/16] website update --- docs/CONDUCT.html | 41 +- docs/CONTRIBUTING.html | 86 +- docs/LICENSE-text.html | 41 +- docs/articles/index.html | 42 +- docs/articles/pkgnet-intro.html | 73 +- .../visNetwork-binding-2.0.6/visNetwork.js | 4204 +++++++++++++++++ docs/articles/pkgnet-report.html | 217 + .../crosstalk-1.0.0/css/crosstalk.css | 27 + .../crosstalk-1.0.0/js/crosstalk.js | 1471 ++++++ .../crosstalk-1.0.0/js/crosstalk.js.map | 37 + .../crosstalk-1.0.0/js/crosstalk.min.js | 2 + .../crosstalk-1.0.0/js/crosstalk.min.js.map | 1 + .../datatables-binding-0.5/datatables.js | 1191 +++++ .../datatables-crosstalk.css | 7 + .../css/jquery.dataTables.extra.css | 8 + .../css/jquery.dataTables.min.css | 1 + .../js/jquery.dataTables.min.js | 164 + .../htmlwidgets-1.3/htmlwidgets.js | 839 ++++ .../jquery-1.12.4/LICENSE.txt | 37 + .../jquery-1.12.4/jquery.min.js | 5 + .../img/network/acceptDeleteIcon.png | Bin 0 -> 20675 bytes .../vis-4.20.1/img/network/addNodeIcon.png | Bin 0 -> 20998 bytes .../vis-4.20.1/img/network/backIcon.png | Bin 0 -> 20802 bytes .../vis-4.20.1/img/network/connectIcon.png | Bin 0 -> 20764 bytes .../vis-4.20.1/img/network/cross.png | Bin 0 -> 18303 bytes .../vis-4.20.1/img/network/cross2.png | Bin 0 -> 17768 bytes .../vis-4.20.1/img/network/deleteIcon.png | Bin 0 -> 20981 bytes .../vis-4.20.1/img/network/downArrow.png | Bin 0 -> 4460 bytes .../vis-4.20.1/img/network/editIcon.png | Bin 0 -> 21016 bytes .../vis-4.20.1/img/network/leftArrow.png | Bin 0 -> 4531 bytes .../vis-4.20.1/img/network/minus.png | Bin 0 -> 4147 bytes .../vis-4.20.1/img/network/plus.png | Bin 0 -> 4341 bytes .../vis-4.20.1/img/network/rightArrow.png | Bin 0 -> 4514 bytes .../vis-4.20.1/img/network/upArrow.png | Bin 0 -> 4461 bytes .../vis-4.20.1/img/network/zoomExtends.png | Bin 0 -> 4464 bytes .../pkgnet-report_files/vis-4.20.1/vis.css | 1464 ++++++ .../pkgnet-report_files/vis-4.20.1/vis.min.js | 46 + .../visNetwork-binding-2.0.6/visNetwork.js | 4204 +++++++++++++++++ docs/articles/publishing-reports.html | 163 + docs/authors.html | 41 +- docs/docsearch.json | 94 + docs/index.html | 38 +- docs/news/index.html | 118 +- docs/pkgdown.yml | 4 + docs/reference/CreatePackageReport.html | 59 +- docs/reference/CreatePackageVignette.html | 225 + docs/reference/DefaultReporters.html | 55 +- docs/reference/DependencyReporter.html | 193 +- docs/reference/DirectedGraph.html | 339 ++ docs/reference/DirectedGraphMeasures.html | 264 ++ docs/reference/FunctionReporter.html | 244 +- docs/reference/GraphClasses.html | 299 ++ docs/reference/InheritanceReporter.html | 205 +- docs/reference/NetworkReporters.html | 239 + docs/reference/PackageReporters.html | 278 ++ docs/reference/SummaryReporter.html | 143 +- docs/reference/index.html | 67 +- docs/reference/pkgnet-package.html | 261 + docs/sitemap.xml | 51 + 59 files changed, 17368 insertions(+), 220 deletions(-) create mode 100644 docs/articles/pkgnet-intro_files/visNetwork-binding-2.0.6/visNetwork.js create mode 100644 docs/articles/pkgnet-report.html create mode 100644 docs/articles/pkgnet-report_files/crosstalk-1.0.0/css/crosstalk.css create mode 100644 docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.js create mode 100644 docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.js.map create mode 100644 docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.min.js create mode 100644 docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.min.js.map create mode 100644 docs/articles/pkgnet-report_files/datatables-binding-0.5/datatables.js create mode 100644 docs/articles/pkgnet-report_files/datatables-css-0.0.0/datatables-crosstalk.css create mode 100644 docs/articles/pkgnet-report_files/dt-core-1.10.16/css/jquery.dataTables.extra.css create mode 100644 docs/articles/pkgnet-report_files/dt-core-1.10.16/css/jquery.dataTables.min.css create mode 100644 docs/articles/pkgnet-report_files/dt-core-1.10.16/js/jquery.dataTables.min.js create mode 100644 docs/articles/pkgnet-report_files/htmlwidgets-1.3/htmlwidgets.js create mode 100644 docs/articles/pkgnet-report_files/jquery-1.12.4/LICENSE.txt create mode 100644 docs/articles/pkgnet-report_files/jquery-1.12.4/jquery.min.js create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/acceptDeleteIcon.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/addNodeIcon.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/backIcon.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/connectIcon.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/cross.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/cross2.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/deleteIcon.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/downArrow.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/editIcon.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/leftArrow.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/minus.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/plus.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/rightArrow.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/upArrow.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/img/network/zoomExtends.png create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/vis.css create mode 100644 docs/articles/pkgnet-report_files/vis-4.20.1/vis.min.js create mode 100644 docs/articles/pkgnet-report_files/visNetwork-binding-2.0.6/visNetwork.js create mode 100644 docs/articles/publishing-reports.html create mode 100644 docs/docsearch.json create mode 100644 docs/reference/CreatePackageVignette.html create mode 100644 docs/reference/DirectedGraph.html create mode 100644 docs/reference/DirectedGraphMeasures.html create mode 100644 docs/reference/GraphClasses.html create mode 100644 docs/reference/NetworkReporters.html create mode 100644 docs/reference/PackageReporters.html create mode 100644 docs/reference/pkgnet-package.html create mode 100644 docs/sitemap.xml diff --git a/docs/CONDUCT.html b/docs/CONDUCT.html index d8787e78..3a5d6590 100644 --- a/docs/CONDUCT.html +++ b/docs/CONDUCT.html @@ -29,6 +29,12 @@ + + + + + + @@ -44,6 +50,16 @@ + + + + @@ -60,7 +76,7 @@ pkgnet - 0.3.2 + 0.4.0 @@ -92,6 +108,12 @@ + + @@ -173,6 +195,23 @@

+ + + diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html index 6b45cb4e..8382253c 100644 --- a/docs/CONTRIBUTING.html +++ b/docs/CONTRIBUTING.html @@ -29,6 +29,12 @@ + + + + + + @@ -44,6 +50,16 @@ + + + + @@ -60,7 +76,7 @@ pkgnet - 0.3.2 + 0.4.0 @@ -92,6 +108,12 @@ + + @@ -118,8 +140,10 @@

  • Submitting a Pull Request
  • Code Style
  • Running Tests Locally
  • +
  • Package Versioning
  • Releasing to CRAN (for maintainer)
  • +

    Creating an Issue @@ -151,6 +175,7 @@

  • sample code showing how you would use this feature if it was added
  • If you’re interested in submitting a pull request to address the bug you’re reporting, please indicate that in the issue.

    +

    @@ -176,6 +201,7 @@

    We will try to review PRs promptly and get back to you within a few days.

    +

    @@ -193,7 +219,7 @@

    samples = rnorm(n) ) } -

    You do not need to namespace special operators in the case where doing so would hurt readablility. For example, %>% from magrittr and := from data.table do not need :: namespacing.

    +

    You do not need to namespace special operators in the case where doing so would hurt readability. For example, %>% from magrittr and := from data.table do not need :: namespacing.

    If you are adding new dependencies to the package (i.e. using an entirely new package), you need to also add that dependency to the Imports section of the DESCRIPTION file.

    @@ -354,6 +380,7 @@

    Inline comments

    All comments should be above code, not beside it.

    +
    @@ -363,6 +390,33 @@

    We use Travis CI to automatically run unit tests and a serious of other automated checks on every PR commit and merge to master. Every pkgnet release also goes through a battery of automated tests run on CRAN before becoming officially available through CRAN.

    However, these options can lengthen your testing cycle and make the process of contributing tedious. If you wish to run tests locally on whatever machine you are developing pkgnet code on, run the following from the repo root:

    ./test.sh
    +
    +

    +
    +

    +Package Versioning +

    +
    +

    +Version Format

    +

    We follow semantic versioning for pkgnet releases, MAJOR.MINOR.PATCH:

    +
      +
    • the MAJOR version will be updated when incompatible API changes are made,
      +
    • +
    • the MINOR version will be updated when functionality is added in a backwards-compatible manner, and
      +
    • +
    • the PATCH version will be updated when backwards-compatible bug fixes are made.
    • +
    +

    In addition, the latest development version will have a .9999 appended to the end of the MAJOR.MINOR.PATCH.

    +

    For more details, see https://semver.org/

    +
    +
    +

    +Release Planning

    +

    The authors of this package have adopted milestones on github as a vehile to scope and schedule upcoming releases. The main goal for a release is written in the milestone description. Then, any ideas, specific functionality, bugs, etcs submitted as issues pertinent to that goal are tagged for that milestone. Goals for milestone are dicsused openly via a github issue.

    +

    Past and upcoming releases can be seen on the pkgnet milestones page.

    +
    +

    @@ -375,9 +429,9 @@

    Open a PR

    Open a PR with a branch name release/v0.0.0 (replacing 0.0.0 with the actual version number).

    -

    Add a section for this release to NEWS.md. This file details the new features, changes, and bug fixes that occured since the last version.

    +

    Add a section for this release to NEWS.md. This file details the new features, changes, and bug fixes that occurred since the last version.

    Add a section for this release to cran-comments.md. This file holds details of our submission comments to CRAN and their responses to our submissions.

    -

    Change the Version: field in DESCRIPTION to the official version you want on CRAN (should not have a trailing .9000).

    +

    Change the Version: field in DESCRIPTION to the official version you want on CRAN (should not have a trailing .9999).

    Rebuild the documentation by running:

    Rscript -e "devtools::document()"
     Rscript -e "install.packages('pkgdown', repos = 'cran.rstudio.com')"
    @@ -385,6 +439,11 @@ 

    pkgdown is changing pretty rapidly, so it’s important to pull the latest from CRAN before building the site.

    Check in whichever of the files generated by pkgdown seem relevant to you. Anything that shows up as “modified” when you run git status should be checked in to the PR branch. New files (“not tracked by git”) should be considered on a case-by-case basis.

    +
    +

    +Test on latest development version of R (i.e. “R-Devel”)

    +

    This is a CRAN requirement. This docker based process from Alexander Eckert is very useful.

    +

    Submit to CRAN

    @@ -407,7 +466,7 @@

    Create a Release on GitHub

    We use the releases section in the repo to categorize certain important commits as release checkpoints. This makes it easier for developers to associate changes in the source code with the release history on CRAN, and enables features like devtools::install_github() for old versions.

    -

    Navigate to https://github.com/UptakeOpenSource/pkgnet/releases/new. Click the dropdown in the “target” section, then click “recent commits”. Choose the latest commit for the release PR you just merged. This will automatically create a git tag on that commit and tell Github which revision to build when people ask for a given release.

    +

    Navigate to https://github.com/UptakeOpenSource/pkgnet/releases/new. Click the drop down in the “target” section, then click “recent commits”. Choose the latest commit for the release PR you just merged. This will automatically create a git tag on that commit and tell Github which revision to build when people ask for a given release.

    Add some notes explaining what has changed since the previous release.

    @@ -437,6 +496,23 @@

    + + + diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index f71844d2..421f5b65 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -29,6 +29,12 @@ + + + + + + @@ -44,6 +50,16 @@ + + + + @@ -60,7 +76,7 @@ pkgnet - 0.3.2 + 0.4.0 @@ -92,6 +108,12 @@ + + @@ -127,6 +149,23 @@

    License

    + + + diff --git a/docs/articles/index.html b/docs/articles/index.html index fb73700f..a2d6972b 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -29,6 +29,12 @@ + + + + + + @@ -44,6 +50,16 @@ + + + + @@ -60,7 +76,7 @@ pkgnet - 0.3.2 + 0.4.0 @@ -92,6 +108,12 @@ + + @@ -111,6 +133,7 @@

    All vignettes

    @@ -128,6 +151,23 @@

    All vignettes

    + + + diff --git a/docs/articles/pkgnet-intro.html b/docs/articles/pkgnet-intro.html index 036fb417..51ba6d68 100644 --- a/docs/articles/pkgnet-intro.html +++ b/docs/articles/pkgnet-intro.html @@ -9,13 +9,21 @@ - + + + +
    @@ -30,7 +38,7 @@ pkgnet - 0.3.2 + 0.4.0
    @@ -60,7 +68,13 @@ + + + @@ -69,7 +83,7 @@ -
    +

    -Network Object

    -

    Both the DependencyReporter and the FunctionReporter are available as igraph objects named pkg_graph

    - -
    #> IGRAPH 949f68b DN-- 5 4 -- 
    +Network Graph Model Object

    +

    Both the DependencyReporter and the FunctionReporter have an object called pkg_graph that contains the graph model of their respective networks. This object has methods to calculate additional node-level and graph-level measures. It is powered by igraph, and the igraph object itself is directly accessible with pkg_graph$igraph.

    + +
    #>            node hubScore authorityScore
    +#> 1:          OPS        1              0
    +#> 2:      at_bats        0              1
    +#> 3:  batting_avg        1              1
    +#> 4:  on_base_pct        0              0
    +#> 5: slugging_avg        1              1
    + +
    #> IGRAPH a7f8a58 DN-- 5 4 -- 
     #> + attr: name (v/c)
    -#> + edges from 949f68b (vertex names):
    -#> [1] OPS         ->slugging_avg OPS         ->batting_avg 
    -#> [3] slugging_avg->at_bats      batting_avg ->at_bats
    +#> + edges from a7f8a58 (vertex names): +#> [1] slugging_avg->at_bats batting_avg ->at_bats +#> [3] OPS ->slugging_avg OPS ->batting_avg

    @@ -411,6 +432,20 @@

    - - + + diff --git a/docs/articles/pkgnet-intro_files/visNetwork-binding-2.0.6/visNetwork.js b/docs/articles/pkgnet-intro_files/visNetwork-binding-2.0.6/visNetwork.js new file mode 100644 index 00000000..a14189e6 --- /dev/null +++ b/docs/articles/pkgnet-intro_files/visNetwork-binding-2.0.6/visNetwork.js @@ -0,0 +1,4204 @@ +// Production steps of ECMA-262, Edition 6, 22.1.2.1 +// Référence : https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from +if (!Array.from) { + Array.from = (function () { + var toStr = Object.prototype.toString; + var isCallable = function (fn) { + return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; + }; + var toInteger = function (value) { + var number = Number(value); + if (isNaN(number)) { return 0; } + if (number === 0 || !isFinite(number)) { return number; } + return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); + }; + var maxSafeInteger = Math.pow(2, 53) - 1; + var toLength = function (value) { + var len = toInteger(value); + return Math.min(Math.max(len, 0), maxSafeInteger); + }; + + // La propriété length de la méthode vaut 1. + return function from(arrayLike/*, mapFn, thisArg */) { + // 1. Soit C, la valeur this + var C = this; + + // 2. Soit items le ToObject(arrayLike). + var items = Object(arrayLike); + + // 3. ReturnIfAbrupt(items). + if (arrayLike == null) { + throw new TypeError("Array.from doit utiliser un objet semblable à un tableau - null ou undefined ne peuvent pas être utilisés"); + } + + // 4. Si mapfn est undefined, le mapping sera false. + var mapFn = arguments.length > 1 ? arguments[1] : void undefined; + var T; + if (typeof mapFn !== 'undefined') { + // 5. sinon + // 5. a. si IsCallable(mapfn) est false, on lève une TypeError. + if (!isCallable(mapFn)) { + throw new TypeError('Array.from: lorsqu il est utilisé le deuxième argument doit être une fonction'); + } + + // 5. b. si thisArg a été fourni, T sera thisArg ; sinon T sera undefined. + if (arguments.length > 2) { + T = arguments[2]; + } + } + + // 10. Soit lenValue pour Get(items, "length"). + // 11. Soit len pour ToLength(lenValue). + var len = toLength(items.length); + + // 13. Si IsConstructor(C) vaut true, alors + // 13. a. Soit A le résultat de l'appel à la méthode interne [[Construct]] avec une liste en argument qui contient l'élément len. + // 14. a. Sinon, soit A le résultat de ArrayCreate(len). + var A = isCallable(C) ? Object(new C(len)) : new Array(len); + + // 16. Soit k égal à 0. + var k = 0; // 17. On répète tant que k < len… + var kValue; + while (k < len) { + kValue = items[k]; + if (mapFn) { + A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); + } else { + A[k] = kValue; + } + k += 1; + } + // 18. Soit putStatus égal à Put(A, "length", len, true). + A.length = len; // 20. On renvoie A. + return A; + }; + }()); +}; + + +// https://tc39.github.io/ecma262/#sec-array.prototype.includes +if (!Array.prototype.includes) { + Object.defineProperty(Array.prototype, 'includes', { + value: function(searchElement, fromIndex) { + + if (this == null) { + throw new TypeError('"this" est nul ou non défini'); + } + + // 1. Soit o égal à ? Object(cette valeur). + var o = Object(this); + + // 2. Soit len égal à ? Length(? Get(o, "length")). + var len = o.length >>> 0; + + // 3. Si len = 0, renvoyer "false". + if (len === 0) { + return false; + } + + // 4. Soit n = ? ToInteger(fromIndex). + // Pour la cohérence du code, on gardera le nom anglais "fromIndex" pour la variable auparavant appelée "indiceDépart" + // (Si fromIndex n'est pas défini, cette étape produit la valeur 0.) + var n = fromIndex | 0; + + // 5. Si n ≥ 0, + // a. Alors k = n. + // 6. Sinon, si n < 0, + // a. Alors k = len + n. + // b. Si k < 0, alors k = 0. + var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); + + function sameValueZero(x, y) { + return x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y)); + } + + // 7. Répéter tant que k < len + while (k < len) { + // a. Soit elementK le résultat de ? Get(O, ! ToString(k)). + // b. Si SameValueZero(searchElement, elementK) est vrai, renvoyer "true". + if (sameValueZero(o[k], searchElement)) { + return true; + } + // c. Augmenter la valeur de k de 1. + k++; + } + + // 8. Renvoyer "false" + return false; + } + }); +} + +// Add shim for Function.prototype.bind() from: +// https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind#Compatibility +// for fix some RStudio viewer bug (Desktop / windows) +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} + +//-------------------------------------------- +// functions to reset edges after hard to read +//-------------------------------------------- + +// for edges +function edgeAsHardToRead(edge, hideColor1, hideColor2, network, type){ + //console.info("edgeAsHardToRead") + + if(type === "edge"){ + //console.info("edge") + //console.info(edge.id) + + // saving color information (if we have) + if (edge.hiddenColor === undefined && edge.color !== hideColor1 && edge.color !== hideColor2) { + edge.hiddenColor = edge.color; + } + // set "hard to read" color + edge.color = hideColor1; + + // reset and save label + if (edge.hiddenLabel === undefined) { + edge.hiddenLabel = edge.label; + edge.label = undefined; + } + edge.isHardToRead = true; + } else { + //console.info("cluster") + //console.info(edge.id) + //console.info(edge) + // saving color information (if we have) + if (edge.hiddenColor === undefined && edge.color !== hideColor1 && edge.color !== hideColor2) { + //network.clustering.updateEdge(edge.id, {hiddenColor : edge.color}); + edge.hiddenColor = edge.color; + } + // set "hard to read" color + edge.color = hideColor1; + //network.clustering.updateEdge(edge.id, {color : hideColor1}); + //edge.color = hideColor1; + // reset and save label + if (edge.hiddenLabel === undefined) { + edge.hiddenLabel = edge.label; + edge.label = undefined; + } + edge.isHardToRead = true; + } + +} + +function resetOneEdge(edge, hideColor1, hideColor2, type){ + + /*console.info("resetOneEdge") + console.info(type) + console.info(edge.id) + console.info(edge) + console.info("edge.hiddenColor") + console.info(edge.hiddenColor)*/ + + var treat_egde = false; + if(type === "cluster"){ + if(edge.isHardToRead !== undefined){ // we have to reset this node + if(edge.isHardToRead){ + treat_egde = true; + } else if(edge.isHardToRead === false && (edge.color.color === hideColor1 || edge.color.color === hideColor2)){ + treat_egde = true; + } + } else if(edge.color.color === hideColor1 || edge.color.color === hideColor2){ + treat_egde = true; + } + + if(treat_egde){ + // get back color + if (edge.hiddenColor !== undefined) { + edge.color = edge.hiddenColor; + edge.hiddenColor = undefined; + }else{ + delete edge.color; + } + + // finally, get back label + if (edge.hiddenLabel !== undefined) { + edge.label = edge.hiddenLabel; + edge.hiddenLabel = undefined; + } + edge.isHardToRead = false; + } + } else { + // get back color + if (edge.hiddenColor !== undefined) { + edge.color = edge.hiddenColor; + edge.hiddenColor = undefined; + }else{ + edge.color = null; + } + + // finally, get back label + if (edge.hiddenLabel !== undefined) { + edge.label = edge.hiddenLabel; + edge.hiddenLabel = undefined; + } + edge.isHardToRead = false; + } +} + +function resetAllEdges(edges, hideColor1, hideColor2, network){ + + var edgesToReset = edges.get({ + fields: ['id', 'color', 'hiddenColor', 'label', 'hiddenLabel'], + filter: function (item) { + return item.isHardToRead === true; + }, + returnType :'Array' + }); + + var is_cluster_edges = false; + var edges_in_clusters; + if(network !== undefined){ + edges_in_clusters = network.body.modules.clustering.clusteredEdges; + if(Object.keys(edges_in_clusters).length > 0){ + is_cluster_edges = true; + edges_in_clusters = Object.keys(edges_in_clusters); + } else { + edges_in_clusters = []; + } + } + + var treat_edges_in_clusters = []; + // all edges get their own color and their label back + for (var i = 0; i < edgesToReset.length; i++) { + resetOneEdge(edgesToReset[i], hideColor1, hideColor2,type = "edge"); + if(is_cluster_edges){ + if(indexOf.call(edges_in_clusters, edgesToReset[i].id, true) > -1){ + var tmp_cluster_id = network.clustering.getClusteredEdges(edgesToReset[i].id); + if(tmp_cluster_id.length > 1){ + tmp_cluster_id = tmp_cluster_id[0]; + treat_edges_in_clusters.push(tmp_cluster_id); + resetOneEdge(network.body.edges[tmp_cluster_id].options, hideColor1, hideColor2, type = "cluster"); + } + } + } + } + + // some misunderstood bug on some cluster edges... so have a (bad) fix... + var edges_in_clusters_ctrl = edges_in_clusters.filter(function(word,index){ + if(word.match(/^clusterEdge/i)){ + if(indexOf.call(treat_edges_in_clusters, word, true) === -1){ + return true; + } else { + return false; + } + + }else{ + return false; + } + }); + + if(is_cluster_edges){ + if(edges_in_clusters_ctrl.length > 0){ + for (var j = 0; j < edges_in_clusters_ctrl.length; j++) { + if(network.body.edges[edges_in_clusters_ctrl[j]] !== undefined){ + resetOneEdge(network.body.edges[edges_in_clusters_ctrl[j]].options, hideColor1, hideColor2, type = "cluster"); + } + } + } + } + + edges.update(edgesToReset); +} + +//-------------------------------------------- +// functions to reset nodes after hard to read +//-------------------------------------------- + +// for classic node +function simpleResetNode(node, type){ + if(type === "node"){ + // get back color + if (node.hiddenColor !== undefined) { + node.color = node.hiddenColor; + node.hiddenColor = undefined; + }else{ + if(node.group !== undefined){ + node.color = undefined; + } else { + node.color = null; + } + } + } else { + if (Object.keys(node.options.hiddenColor).length > 2){ + node.setOptions({color : node.options.hiddenColor, hiddenColor : undefined}); + }else{ + if(node.options.group !== undefined){ + node.setOptions({color : undefined}); + } else { + node.setOptions({color : null}); + } + } + } +} + +// for icon node +function simpleIconResetNode(node, type){ + if(type === "node"){ + // icon color + node.icon.color = node.hiddenColor; + node.hiddenColor = undefined; + // get back color + if (node.hiddenColorForLabel !== undefined) { + node.color = node.hiddenColorForLabel; + node.hiddenColorForLabel = undefined; + }else{ + if(node.group !== undefined){ + node.color = undefined; + } else { + node.color = null; + } + } + } else { + node.setOptions({icon : { color : node.options.hiddenColor}, hiddenColor : undefined}); + if (node.options.hiddenColorForLabel !== undefined) { + node.setOptions({color : node.options.hiddenColorForLabel, hiddenColorForLabel : undefined}); + }else{ + if(node.options.group !== undefined){ + node.setOptions({color : undefined}); + } else { + node.setOptions({color : null}); + } + } + } +} + +// for image node +function simpleImageResetNode(node, imageType, type){ + if(type === "node"){ + // get back color + if (node.hiddenColor !== undefined) { + node.color = node.hiddenColor; + node.hiddenColor = undefined; + }else{ + if(node.group !== undefined){ + node.color = undefined; + } else { + node.color = null; + } + } + // and set shape as image/circularImage + node.shape = imageType; + } else { + if (Object.keys(node.options.hiddenColor).length > 2) { + node.setOptions({color : node.options.hiddenColor, hiddenColor : undefined}); + }else{ + if(node.options.group !== undefined){ + node.setOptions({color : undefined}); + } else { + node.setOptions({color : null}); + } + } + node.setOptions({shape : imageType}); + } +} + +// Global function to reset one cluster +function resetOneCluster(node, groups, options, network){ + if(node !== undefined){ + if(node.options.isHardToRead !== undefined){ // we have to reset this node + if(node.options.isHardToRead){ + var final_shape; + var shape_group = false; + var is_group = false; + // have a group information & a shape defined in group ? + if(node.options.group !== undefined){ + if(groups.groups[node.options.group] !== undefined){ + is_group = true; + if(groups.groups[node.options.group].shape !== undefined){ + shape_group = true; + } + } + } + // have a global shape in nodes options ? + var shape_options = false; + if(options.nodes !== undefined){ + if(options.nodes.shape !== undefined){ + shape_options = true; + } + } + // set final shape (individual > group > global) + if(node.options.hiddenImage !== undefined){ + final_shape = node.options.hiddenImage; + } else if(node.options.shape !== undefined){ + final_shape = node.options.shape; + } else if(shape_group){ + final_shape = groups.groups[node.options.group].shape; + } else if(shape_options){ + final_shape = options.nodes.shape; + } + + node.setOptions({bodyHiddenColor : network.body.nodes[node.id].options.color}); + // and call good reset function + if(final_shape === "icon"){ + simpleIconResetNode(node, "cluster"); + } else if(final_shape === "image"){ + simpleImageResetNode(node, "image", "cluster"); + } else if(final_shape === "circularImage"){ + simpleImageResetNode(node, "circularImage", "cluster"); + } else { + simpleResetNode(node, "cluster"); + } + // finally, get back label + if (node.options.hiddenLabel !== undefined) { + node.setOptions({label : node.options.hiddenLabel, hiddenLabel : undefined}); + } + node.options.isHardToRead = false; + } + } + } +} + +// Global function to reset one node +function resetOneNode(node, groups, options, network){ + if(node !== undefined){ + if(node.isHardToRead !== undefined){ // we have to reset this node + if(node.isHardToRead){ + var final_shape; + var shape_group = false; + var is_group = false; + // have a group information & a shape defined in group ? + if(node.group !== undefined){ + if(groups.groups[node.group] !== undefined){ + is_group = true; + if(groups.groups[node.group].shape !== undefined){ + shape_group = true; + } + } + } + // have a global shape in nodes options ? + var shape_options = false; + if(options.nodes !== undefined){ + if(options.nodes.shape !== undefined){ + shape_options = true; + } + } + // set final shape (individual > group > global) + if(node.hiddenImage !== undefined){ + final_shape = node.hiddenImage; + } else if(node.shape !== undefined){ + final_shape = node.shape; + } else if(shape_group){ + final_shape = groups.groups[node.group].shape; + } else if(shape_options){ + final_shape = options.nodes.shape; + } + + // reset body information + network.body.nodes[node.id].options.color = node.bodyHiddenColor; + + // and call good reset function + if(final_shape === "icon"){ + simpleIconResetNode(node, "node"); + } else if(final_shape === "image"){ + simpleImageResetNode(node, "image", "node"); + } else if(final_shape === "circularImage"){ + simpleImageResetNode(node, "circularImage", "node"); + } else { + simpleResetNode(node, "node"); + } + // finally, get back label + if (node.hiddenLabel !== undefined) { + node.label = node.hiddenLabel; + node.hiddenLabel = undefined; + } + node.isHardToRead = false; + } + } + } +} + +// Global function to reset all node +function resetAllNodes(nodes, update, groups, options, network){ + var nodesToReset = nodes.get({ + filter: function (item) { + return item.isHardToRead === true; + }, + returnType :'Array' + }); + + var have_cluster_nodes = false; + var nodes_in_clusters; + if(network !== undefined){ + nodes_in_clusters = network.body.modules.clustering.clusteredNodes; + if(Object.keys(nodes_in_clusters).length > 0){ + have_cluster_nodes = true; + nodes_in_clusters = Object.keys(nodes_in_clusters); + } else { + nodes_in_clusters = []; + } + } + + for (var i = 0; i < nodesToReset.length; i++) { + resetOneNode(nodesToReset[i], groups, options, network, type = "node"); + // reset coordinates + nodesToReset[i].x = undefined; + nodesToReset[i].y = undefined; + if(have_cluster_nodes){ + if(indexOf.call(nodes_in_clusters, nodesToReset[i].id, true) > -1){ + var tmp_cluster_id = network.clustering.findNode(nodesToReset[i].id); + // in case of multiple cluster... + for(var j = 0; j < (tmp_cluster_id.length-1); j++) { + resetOneCluster(network.body.nodes[tmp_cluster_id[j]], groups, options, network); + } + } + } + } + if(update){ + nodes.update(nodesToReset); + } +} + +//-------------------------------------------- +// functions to set nodes as hard to read +//-------------------------------------------- + +// for classic node +function simpleNodeAsHardToRead(node, hideColor1, hideColor2, type){ + + + // classic nodes + if(type === "node"){ + // saving color information (if we have) + if (node.hiddenColor === undefined && node.color !== hideColor1 && node.color !== hideColor2) { + node.hiddenColor = node.color; + } + + // set "hard to read" color + node.color = hideColor1; + // reset and save label + if (node.hiddenLabel === undefined) { + node.hiddenLabel = node.label; + node.label = undefined; + } + // cluster + } else { + // saving color information (if we have) + if (node.options.hiddenColor === undefined && node.options.color !== hideColor1 && node.options.color !== hideColor2) { + node.setOptions({hiddenColor : node.options.color}); + } + // set "hard to read" color + node.setOptions({color : hideColor1}); + // reset and save label + if (node.options.hiddenLabel === undefined) { + node.setOptions({hiddenLabel : node.options.label}); + node.setOptions({label : undefined}); + } + } +} + +// for icon node +function iconsNodeAsHardToRead(node, hideColor1, hideColor2, icon_color, type){ + // classic nodes + if(type === "node"){ + // individual information + if(node.icon !== undefined && node.icon !== null && node.icon !== {}){ + node.iconDefined = true; + } else { // information in group : have to as individual + node.icon = {}; + node.iconDefined = false; + } + // set "hard to read" color + node.icon.color = hideColor1; + node.hiddenColor = icon_color; + // for edges....saving color information (if we have) + if (node.hiddenColorForLabel === undefined && node.color !== hideColor1 && node.color !== hideColor2) { + node.hiddenColorForLabel = node.color; + } + // set "hard to read" color + node.color = hideColor1; + // reset and save label + if (node.hiddenLabel === undefined) { + node.hiddenLabel = node.label; + node.label = undefined; + } + } else { + // individual information + if(node.options.icon !== undefined && node.options.icon !== null && node.options.icon !== {}){ + node.setOptions({iconDefined : true}); + } else { // information in group : have to as individual + node.setOptions({iconDefined : false, icon:{}}); + } + // set "hard to read" color + node.setOptions({hiddenColor : icon_color, icon:{color : hideColor1}}); + // for edges....saving color information (if we have) + if (node.options.hiddenColorForLabel === undefined && node.options.color !== hideColor1 && node.options.color !== hideColor2) { + node.setOptions({hiddenColorForLabel : node.options.color}); + } + // set "hard to read" color + node.setOptions({color : hideColor1}); + // reset and save label + if (node.options.hiddenLabel === undefined) { + node.setOptions({hiddenLabel : node.options.label, label : undefined}); + } + } +} + +// for image node +function imageNodeAsHardToRead(node, imageType, hideColor1, hideColor2, type){ + // classic nodes + if(type === "node"){ + // saving color information (if we have) + if (node.hiddenColor === undefined && node.color !== hideColor1 && node.color !== hideColor2) { + node.hiddenColor = node.color; + } + // set "hard to read" color + node.color = hideColor1; + // reset and save label + if (node.hiddenLabel === undefined) { + node.hiddenLabel = node.label; + node.label = undefined; + } + // keep shape information, and set a new + if(imageType === "image"){ + node.hiddenImage = imageType; + node.shape = "square"; + }else if(imageType === "circularImage"){ + node.hiddenImage = imageType; + node.shape = "dot"; + } + } else { + // saving color information (if we have) + if (node.options.hiddenColor === undefined && node.options.color !== hideColor1 && node.options.color !== hideColor2) { + node.setOptions({hiddenColor : node.options.color}); + } + // set "hard to read" color + node.setOptions({color : hideColor1}); + // reset and save label + if (node.options.hiddenLabel === undefined) { + node.setOptions({hiddenLabel : node.options.label, label : undefined}); + } + if(imageType === "image"){ + node.setOptions({hiddenImage : "image", shape : "square"}); + } else if(imageType === "circularImage"){ + node.setOptions({hiddenImage : "circularImage", shape : "dot"}); + } + node.hiddenImage = imageType; + } +} + +// Global function to set one node as hard to read +function nodeAsHardToRead(node, groups, options, hideColor1, hideColor2, network, type){ + var final_shape; + var shape_group = false; + var is_group = false; + + if(node.isHardToRead === false || node.isHardToRead === undefined){ + + // have a group information & a shape defined in group ? + if(node.group !== undefined){ + if(groups.groups[node.group] !== undefined){ + is_group = true; + if(groups.groups[node.group].shape !== undefined){ + shape_group = true; + } + } + } + // have a group information & a shape defined in group ? + var shape_options = false; + if(options.nodes !== undefined){ + if(options.nodes.shape !== undefined){ + shape_options = true; + } + } + // set final shape (individual > group > global) + if(node.shape !== undefined){ + final_shape = node.shape; + } else if(shape_group){ + final_shape = groups.groups[node.group].shape; + } else if(shape_options){ + final_shape = options.nodes.shape; + } + + // information save in body nodes + if(type === "node"){ + node.bodyHiddenColor = clone(network.body.nodes[node.id].options.color); + } else { + node.setOptions({bodyHiddenColor : clone(network.body.nodes[node.id].options.color)}); + } + + // and call good function + if(final_shape === "icon"){ + // find color for icon + var icon_color = "#2B7CE9"; + var find_color = false; + // in nodes ? + if(node.icon !== undefined){ + if(node.icon.color !== undefined){ + icon_color = node.icon.color; + find_color = true; + } + } + // or in group ? + if(find_color === false && is_group && groups.groups[node.group].icon !== undefined){ + if(groups.groups[node.group].icon.color !== undefined){ + icon_color = groups.groups[node.group].icon.color; + find_color = true; + } + } + // in global node ? + if(find_color === false && options.nodes.icon !== undefined){ + if(options.nodes.icon.color !== undefined){ + icon_color = options.nodes.icon.color; + } + } + iconsNodeAsHardToRead(node, hideColor1, hideColor2, icon_color, type); + } else if(final_shape === "image"){ + imageNodeAsHardToRead(node, "image", hideColor1, hideColor2, type); + } else if(final_shape === "circularImage"){ + imageNodeAsHardToRead(node, "circularImage", hideColor1, hideColor2, type); + } else { + simpleNodeAsHardToRead(node, hideColor1, hideColor2, type); + } + + // finally set isHardToRead + if(type === "node"){ + node.isHardToRead = true; + } else { + node.setOptions({isHardToRead : true}); + } + // special case of just to label + } else if(node.isHardToRead === true && node.label !== undefined){ + if(type === "node"){ + node.hiddenLabel = node.label; + node.label = undefined; + } else { + node.setOptions({hiddenLabel : node.options.label, label : undefined}) + } + } +} + +//---------------------------------------------------------------- +// Revrite HTMLWidgets.dataframeToD3() for passing custom +// properties directly in data.frame (color.background) for example +//---------------------------------------------------------------- +function visNetworkdataframeToD3(df, type) { + + // variables we have specially to control + var nodesctrl = ["color", "fixed", "font", "icon", "shadow", "scaling", "shapeProperties", "chosen", "heightConstraint", "image", "margin", "widthConstraint"]; + var edgesctrl = ["color", "font", "arrows", "shadow", "smooth", "scaling", "chosen", "widthConstraint"]; + + var names = []; + var colnames = []; + var length; + var toctrl; + var ctrlname; + + for (var name in df) { + if (df.hasOwnProperty(name)) + colnames.push(name); + ctrlname = name.split("."); + if(ctrlname.length === 1){ + names.push( new Array(name)); + } else { + if(type === "nodes"){ + toctrl = indexOf.call(nodesctrl, ctrlname[0], true); + } else if(type === "edges"){ + toctrl = indexOf.call(edgesctrl, ctrlname[0], true); + } + if(toctrl > -1){ + names.push(ctrlname); + } else { + names.push(new Array(name)); + } + } + if (typeof(df[name]) !== "object" || typeof(df[name].length) === "undefined") { + throw new Error("All fields must be arrays"); + } else if (typeof(length) !== "undefined" && length !== df[name].length) { + throw new Error("All fields must be arrays of the same length"); + } + length = df[name].length; + } + + var results = []; + var item; + for (var row = 0; row < length; row++) { + item = {}; + for (var col = 0; col < names.length; col++) { + if(df[colnames[col]][row] !== null){ + if(names[col].length === 1){ + if(names[col][0] === "dashes"){ + item[names[col]] = eval(df[colnames[col]][row]); + } else { + item[names[col]] = df[colnames[col]][row]; + } + } else if(names[col].length === 2){ + if(item[names[col][0]] === undefined){ + item[names[col][0]] = {}; + } + if(names[col][0] === "icon" && names[col][1] === "code"){ + item[names[col][0]][names[col][1]] = JSON.parse( '"'+'\\u' + df[colnames[col]][row] + '"'); + } else if(names[col][0] === "icon" && names[col][1] === "color"){ + item.color = df[colnames[col]][row]; + item[names[col][0]][names[col][1]] = df[colnames[col]][row]; + } else{ + item[names[col][0]][names[col][1]] = df[colnames[col]][row]; + } + } else if(names[col].length === 3){ + if(item[names[col][0]] === undefined){ + item[names[col][0]] = {}; + } + if(item[names[col][0]][names[col][1]] === undefined){ + item[names[col][0]][names[col][1]] = {}; + } + item[names[col][0]][names[col][1]][names[col][2]] = df[colnames[col]][row]; + } else if(names[col].length === 4){ + if(item[names[col][0]] === undefined){ + item[names[col][0]] = {}; + } + if(item[names[col][0]][names[col][1]] === undefined){ + item[names[col][0]][names[col][1]] = {}; + } + if(item[names[col][0]][names[col][1]][names[col][2]] === undefined){ + item[names[col][0]][names[col][1]][names[col][2]] = {}; + } + item[names[col][0]][names[col][1]][names[col][2]][names[col][3]] = df[colnames[col]][row]; + } + } + } + results.push(item); + } + return results; +} + +//---------------------------------------------------------------- +// Some utils functions +//---------------------------------------------------------------- + +//unique element in array +function uniqueArray(arr, exclude_cluster, network) { + var a = []; + for (var i=0, l=arr.length; i -1; + }, + returnType :'Array' + }); + + currentConnectedToNodes = []; + var currentlength = otherLevelNodes.length; + for (j = 0; j < connectedToNodes.length; j++) { + otherLevelNodes = uniqueArray(otherLevelNodes.concat(connectedToNodes[j].to), false, network); + currentConnectedToNodes = uniqueArray(currentConnectedToNodes.concat(connectedToNodes[j].to), false, network); + } + if (otherLevelNodes.length === currentlength) { break; } + } + + var finalFirstLevelNodes = []; + for (j = 0; j < firstLevelNodes.length; j++) { + var findnode = network.clustering.findNode(firstLevelNodes[j]) + if(findnode.length === 1){ + finalFirstLevelNodes = finalFirstLevelNodes.concat(firstLevelNodes[j]); + } else { + finalFirstLevelNodes = finalFirstLevelNodes.concat(findnode[0]); + } + } + + var finalClusterNodes = []; + for (j = 0; j < otherLevelNodes.length; j++) { + var findnode = network.clustering.findNode(otherLevelNodes[j]) + if(findnode.length === 1){ + finalClusterNodes = finalClusterNodes.concat(otherLevelNodes[j]); + } else { + finalClusterNodes = finalClusterNodes.concat(findnode[0]); + } + } + + if(set_position){ + network.storePositions(); + } + + var clusterOptions = { + joinCondition: function (nodesOptions) { + return nodesOptions.id === selectedNode || indexOf.call(finalFirstLevelNodes, nodesOptions.id, true) > -1 || + indexOf.call(finalClusterNodes, nodesOptions.id, true) > -1; + }, + processProperties: function(clusterOptions, childNodes) { + var click_node = network.body.data.nodes.get({ + filter: function (item) { + return item.id == selectedNode; + }, + returnType :'Array' + }); + + var is_hard_to_read = false; + if(click_node[0].isHardToRead !== undefined){ + is_hard_to_read = click_node[0].isHardToRead; + } + + for (var i in click_node[0]) { + if(i !== "id" && i !== "isHardToRead"){ + if(i === "label" && is_hard_to_read){ + clusterOptions[i]= click_node[0]["hiddenLabel"]; + } else if(i === "color" && is_hard_to_read) { + clusterOptions[i]= click_node[0]["hiddenColor"]; + } else { + clusterOptions[i]= click_node[0][i]; + } + } + } + + // gestion des tree + if(treeParams !== undefined){ + if(treeParams.updateShape){ + clusterOptions.label = clusterOptions.labelClust + clusterOptions.color = clusterOptions.colorClust + clusterOptions.shape = treeParams.shapeY + } + } + + if(clusterOptions.label !== undefined){ + clusterOptions.label = clusterOptions.label + " " + labelSuffix; + } else { + clusterOptions.label = labelSuffix; + } + + if(clusterOptions.borderWidth !== undefined){ + clusterOptions.borderWidth = clusterOptions.borderWidth * 3; + } else { + clusterOptions.borderWidth = 3; + } + + if(set_position){ + if(click_node[0].x !== undefined){ + clusterOptions.x = click_node[0].x; + } + if(click_node[0].y !== undefined){ + clusterOptions.y = click_node[0].y; + } + } + + if(clusterParams !== undefined){ + for (var j in clusterParams) { + clusterOptions[j]= clusterParams[j]; + } + } + + return clusterOptions; + }, + clusterNodeProperties: { + allowSingleNodeCluster: false + } + } + network.cluster(clusterOptions); + } + } + + } + if(resetHighlight){ + document.getElementById("nodeSelect"+elid).value = ""; + document.getElementById("nodeSelect"+elid).onchange(); + } + if(fit){ + network.fit(); + } + } +}; + +function uncollapsedNetwork(nodes, fit, resetHighlight, keepCoord, network, elid) { + var selectedNode; + var j; + var arr_nodes = []; + var cluster_node; + + var nodes_in_clusters = network.body.modules.clustering.clusteredNodes; + if(Object.keys(nodes_in_clusters).length > 0){ + nodes_in_clusters = Object.keys(nodes_in_clusters); + } else { + nodes_in_clusters = [] + } + + if(nodes !== undefined && nodes !== null){ + arr_nodes = nodes + } else { + arr_nodes = nodes_in_clusters; + } + + for (var inodes = 0; inodes < arr_nodes.length; inodes++) { + selectedNode = '' + arr_nodes[inodes]; + if(selectedNode !== undefined){ + if(network.isCluster(selectedNode)){ + if(keepCoord){ + network.openCluster(selectedNode, + {releaseFunction : function(clusterPosition, containedNodesPositions) { + return containedNodesPositions; + } + }); + } else { + network.openCluster(selectedNode) + } + } else { + if(indexOf.call(nodes_in_clusters, selectedNode, true) > -1){ + // not a cluster into a cluster... + if(selectedNode.search(/^cluster/i) === -1){ + cluster_node = network.clustering.findNode(selectedNode)[0]; + if(network.isCluster(cluster_node)){ + if(keepCoord){ + network.openCluster(cluster_node, + {releaseFunction : function(clusterPosition, containedNodesPositions) { + return containedNodesPositions; + } + }); + } else { + network.openCluster(cluster_node) + } + } + } + } + } + } + } + if(resetHighlight){ + document.getElementById("nodeSelect"+elid).value = ""; + document.getElementById("nodeSelect"+elid).onchange(); + } + if(fit){ + network.fit(); + } +}; + +//---------------------------------------------------------------- +// All available functions/methods with visNetworkProxy +//--------------------------------------------------------------- +if (HTMLWidgets.shinyMode){ + + // collapsed method + Shiny.addCustomMessageHandler('visShinyCollapse', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + collapsedNetwork(data.nodes, data.fit, data.resetHighlight, data.clusterOptions, data.labelSuffix, undefined, el.chart, data.id) + } + }); + + // uncollapsed method + Shiny.addCustomMessageHandler('visShinyUncollapse', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + uncollapsedNetwork(data.nodes, data.fit, data.resetHighlight, data.keepCoord, el.chart, data.id) + } + }); + + // event method + Shiny.addCustomMessageHandler('visShinyEvents', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + + if(data.type === "once"){ + for (var key in data.events) { + eval('network.once("' + key + '",' + data.events[key] + ')'); + } + } else if(data.type === "on"){ + for (var key in data.events) { + eval('network.on("' + key + '",' + data.events[key] + ')'); + } + } else if(data.type === "off"){ + for (var key in data.events) { + eval('network.off("' + key + '",' + data.events[key] + ')'); + } + } + } + }); + + // moveNode method + Shiny.addCustomMessageHandler('visShinyMoveNode', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + network.moveNode(data.nodeId, data.x, data.y); + } + }); + + // unselectAll method + Shiny.addCustomMessageHandler('visShinyUnselectAll', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + + // reset selection + document.getElementById("nodeSelect"+data.id).value = ""; + document.getElementById("nodeSelect"+data.id).onchange(); + + if(document.getElementById(data.id).selectActive === true){ + document.getElementById("selectedBy"+data.id).value = ""; + document.getElementById("selectedBy"+data.id).onchange(); + } + + network.unselectAll(); + } + }); + + // updateOptions in the network + Shiny.addCustomMessageHandler('visShinyOptions', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + + if(el){ + var network = el.chart; + var options = el.options; + // configure + if(data.options.configure !== undefined){ + if(data.options.configure.container !== undefined){ + var dom_conf = document.getElementById(data.options.configure.container); + if(dom_conf !== null){ + data.options.configure.container = dom_conf; + } else { + data.options.configure.container = undefined; + } + } + } + + //************************* + // pre-treatment for icons (unicode) + //************************* + if(data.options.groups){ + for (var gr in data.options.groups){ + if(data.options.groups[gr].icon){ + if(data.options.groups[gr].icon.code){ + data.options.groups[gr].icon.code = JSON.parse( '"'+'\\u' + data.options.groups[gr].icon.code + '"'); + } + if(data.options.groups[gr].icon.color){ + data.options.groups[gr].color = data.options.groups[gr].icon.color; + } + } + } + } + + if(data.options.nodes){ + if(data.options.nodes.icon){ + if(data.options.nodes.icon.code){ + data.options.nodes.icon.code = JSON.parse( '"'+'\\u' + data.options.nodes.icon.code + '"'); + } + if(data.options.nodes.icon.color){ + data.options.nodes.color = data.options.nodes.icon.color; + } + } + } + + + update(options, data.options); + network.setOptions(options); + } + }); + + // setData the network + Shiny.addCustomMessageHandler('visShinySetData', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + var newnodes = new vis.DataSet(); + var newedges = new vis.DataSet(); + + newnodes.add(visNetworkdataframeToD3(data.nodes, "nodes")); + newedges.add(visNetworkdataframeToD3(data.edges, "edges")); + var newdata = { + nodes: newnodes, + edges: newedges + }; + network.setData(newdata); + } + }); + + // fit to a specific node + Shiny.addCustomMessageHandler('visShinyFit', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + network.fit(data.options); + } + }); + + // focus on a node in the network + Shiny.addCustomMessageHandler('visShinyFocus', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + network.focus(data.focusId, data.options); + } + }); + + // stabilize the network + Shiny.addCustomMessageHandler('visShinyStabilize', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + network.stabilize(data.options); + } + }); + + // startSimulation on network + Shiny.addCustomMessageHandler('visShinyStartSimulation', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + network.startSimulation(); + } + }); + + // stopSimulation on network + Shiny.addCustomMessageHandler('visShinyStopSimulation', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + network.stopSimulation(); + } + }); + + // get positions of the network + Shiny.addCustomMessageHandler('visShinyGetPositions', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + var pos; + + if(data.nodes !== undefined){ + pos = network.getPositions(data.nodes); + }else{ + pos = network.getPositions(); + } + // return positions in shiny + Shiny.onInputChange(data.input, pos); + } + }); + + // get edges data + Shiny.addCustomMessageHandler('visShinyGetEdges', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var current_edges = el.edges.getDataSet(); + // return data in shiny + Shiny.onInputChange(data.input, current_edges._data); + } + }); + + // get nodes data + Shiny.addCustomMessageHandler('visShinyGetNodes', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + if(data.addCoordinates){ + el.chart.storePositions(); + } + var current_nodes = el.nodes.getDataSet(); + // return data in shiny + Shiny.onInputChange(data.input, current_nodes._data); + } + }); + + // get selected edges + Shiny.addCustomMessageHandler('visShinyGetSelectedEdges', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + var pos = network.getSelectedEdges(); + // return in shiny + Shiny.onInputChange(data.input, pos); + } + }); + + // get selected nodes + Shiny.addCustomMessageHandler('visShinyGetSelectedNodes', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + var pos = network.getSelectedNodes(); + // return in shiny + Shiny.onInputChange(data.input, pos); + } + }); + + // getConnectedEdges + Shiny.addCustomMessageHandler('visShinyGetConnectedEdges', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + var pos = network.getConnectedEdges(data.nodeId); + // return in shiny + Shiny.onInputChange(data.input, pos); + } + }); + + // getConnectedNodes + Shiny.addCustomMessageHandler('visShinyGetConnectedNodes', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + var pos = network.getConnectedNodes(data.nodeId); + // return in shiny + Shiny.onInputChange(data.input, pos); + } + }); + + // getBoundingBox + Shiny.addCustomMessageHandler('visShinyGetBoundingBox', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + var pos = network.getBoundingBox(data.nodeId); + // return in shiny + Shiny.onInputChange(data.input, pos); + } + }); + + // get selection + Shiny.addCustomMessageHandler('visShinyGetSelection', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + var pos; + + pos = network.getSelection(); + + // return in shiny + Shiny.onInputChange(data.input, pos); + } + }); + + // get scale + Shiny.addCustomMessageHandler('visShinyGetScale', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + var pos; + + pos = network.getScale(); + + // return in shiny + Shiny.onInputChange(data.input, pos); + } + }); + + // store positions + Shiny.addCustomMessageHandler('visShinyStorePositions', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + network.storePositions(); + } + }); + + // get view position + Shiny.addCustomMessageHandler('visShinyGetViewPosition', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + var pos; + + pos = network.getViewPosition(); + + // return in shiny + Shiny.onInputChange(data.input, pos); + } + }); + + // get view position + Shiny.addCustomMessageHandler('visShinyGetOptionsFromConfigurator', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + // return in shiny + Shiny.onInputChange(data.input, network.getOptionsFromConfigurator()); + } + }); + + // Redraw the network + Shiny.addCustomMessageHandler('visShinyRedraw', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + el.chart.redraw(); + } + }); + + // select nodes + Shiny.addCustomMessageHandler('visShinySelectNodes', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + if(data.selid !== null){ + network.selectNodes(data.selid, data.highlightEdges); + if(data.clickEvent){ + el.myclick({nodes : data.selid}); + } + }else{ + if(data.clickEvent){ + el.myclick({nodes : []}); + } + } + } + }); + + // select edges + Shiny.addCustomMessageHandler('visShinySelectEdges', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + if(data.selid !== null){ + network.selectEdges(data.selid); + } + } + }); + + // set selection + Shiny.addCustomMessageHandler('visShinySetSelection', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(el){ + var network = el.chart; + if(data.selection.nodes !== null || data.selection.edges !== null){ + network.setSelection(data.selection, data.options); + } + if(data.clickEvent){ + if(data.selection.nodes !== null){ + el.myclick({nodes : data.selection.nodes}); + } else { + el.myclick({nodes : []}); + } + } + } + }); + + function updateVisOptions(data){ + // get container id + var graph = document.getElementById("graph"+data.id); + var el = document.getElementById(data.id); + var do_loop_by = false; + var option2; + var selectList2; + var selectList; + var reset = false; + + if(graph){ + // reset nodes before ? + if(document.getElementById(el.id).highlight){ + // need reset nodes + if(document.getElementById(el.id).highlightActive === true){ + reset = true; + } + } + if(reset){ + document.getElementById("nodeSelect"+data.id).value = ""; + document.getElementById("nodeSelect"+data.id).onchange(); + } + + // collapse init + if(data.options.collapse !== undefined){ + el.collapse = data.options.collapse.enabled; + el.collapseFit = data.options.collapse.fit; + el.collapseResetHighlight = data.options.collapse.resetHighlight; + el.collapseKeepCoord = data.options.collapse.keepCoord; + el.collapseLabelSuffix = data.options.collapse.labelSuffix; + el.clusterOptions = data.options.collapse.clusterOptions; + } + + // highlight init + if(data.options.highlight !== undefined){ + el.highlight = data.options.highlight.enabled; + el.degree = data.options.highlight.degree; + el.hoverNearest = data.options.highlight.hoverNearest; + el.highlightColor = data.options.highlight.hideColor; + el.highlightAlgorithm = data.options.highlight.algorithm; + el.highlightLabelOnly = data.options.labelOnly; + } + + // byselection init + if(data.options.byselection !== undefined){ + if(data.options.byselection.selected !== undefined){ + document.getElementById("selectedBy"+data.id).value = data.options.byselection.selected; + document.getElementById("selectedBy"+data.id).onchange(); + } + if(data.options.byselection.hideColor){ + el.byselectionColor = data.options.byselection.hideColor; + } + } + + if(data.options.byselection !== undefined){ + selectList2 = document.getElementById("selectedBy"+data.id) + selectList2.options.length = 0; + if(data.options.byselection.enabled === true){ + option2 = document.createElement("option"); + option2.value = ""; + if(data.options.byselection.main === undefined){ + option2.text = "Select by " + data.options.byselection.variable; + } else { + option2.text = data.options.byselection.main; + } + + selectList2.appendChild(option2); + + if(data.options.byselection.values !== undefined){ + for (var i = 0; i < data.options.byselection.values.length; i++) { + option2 = document.createElement("option"); + option2.value = data.options.byselection.values[i]; + option2.text = data.options.byselection.values[i]; + selectList2.appendChild(option2); + } + }else{ + do_loop_by = true; + } + + el.byselection_variable = data.options.byselection.variable; + el.byselection_multiple = data.options.byselection.multiple; + selectList2.style.display = 'inline'; + if(data.options.byselection.style !== undefined){ + selectList2.setAttribute('style', data.options.byselection.style); + } + el.byselection = true; + } else { + selectList2.style.display = 'none'; + el.byselection = false; + // reset selection + if(el.selectActive === true){ + document.getElementById("selectedBy"+data.id).value = ""; + document.getElementById("selectedBy"+data.id).onchange(); + } + } + }else{ + // reset selection + if(el.selectActive === true){ + document.getElementById("selectedBy"+data.id).value = ""; + document.getElementById("selectedBy"+data.id).onchange(); + } + } + + if(do_loop_by){ + var allNodes = graph.nodes.get({returnType:"Object"}); + var byselection_values = []; + for (var nodeId in allNodes) { + if(do_loop_by){ + var current_sel_value = allNodes[nodeId][data.options.byselection.variable]; + if(data.options.byselection.multiple){ + current_sel_value = current_sel_value.split(",").map(Function.prototype.call, String.prototype.trim); + }else{ + current_sel_value = [current_sel_value]; + } + for(var ind_c in current_sel_value){ + if(indexOf.call(byselection_values, current_sel_value[ind_c], false) === -1){ + option2 = document.createElement("option"); + option2.value = current_sel_value[ind_c]; + option2.text = current_sel_value[ind_c]; + selectList2.appendChild(option2); + byselection_values.push(current_sel_value[ind_c]); + } + } + } + } + } + + // node id selection init + if(data.options.idselection !== undefined){ + selectList = document.getElementById("nodeSelect"+data.id) + selectList.options.length = 0; + if(data.options.idselection.enabled === true){ + setNodeIdList(selectList, data.options.idselection, graph.nodes) + el.idselection = true; + } else { + selectList.style.display = 'none'; + el.idselection = false; + } + if(data.options.idselection.useLabels !== undefined){ + el.idselection_useLabels = data.options.idselection.useLabels + } + } + + if(data.options.idselection !== undefined){ + if(data.options.idselection.enabled === true && data.options.idselection.selected !== undefined){ + document.getElementById("nodeSelect"+data.id).value = data.options.idselection.selected; + document.getElementById("nodeSelect"+data.id).onchange(); + } + } + } + }; + + Shiny.addCustomMessageHandler('visShinyCustomOptions', updateVisOptions); + + // udpate nodes data + Shiny.addCustomMessageHandler('visShinyUpdateNodes', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + var main_el = document.getElementById(data.id); + + if(data.legend === false){ + if(el){ + // get & transform nodes object + var tmpnodes = visNetworkdataframeToD3(data.nodes, "nodes"); + + // reset some parameters / data before + if (main_el.selectActive === true | main_el.highlightActive === true) { + + //reset nodes + resetAllEdges(el.edges, el.highlightColor, el.byselectionColor, el.chart); + resetAllNodes(el.nodes, true, el.chart.groups, el.options, el.chart); + + if (main_el.selectActive === true){ + main_el.selectActive = false; + resetList('selectedBy', data.id, 'selectedBy'); + } + if (main_el.highlightActive === true){ + main_el.highlightActive = false; + resetList('nodeSelect', data.id, 'selected'); + } + } + // update nodes + el.nodes.update(tmpnodes); + + // update options ? + if(data.updateOptions){ + var dataOptions = {}; + dataOptions.options = {}; + + var updateOpts = false; + if(document.getElementById("nodeSelect"+data.id).style.display === 'inline'){ + updateOpts = true; + dataOptions.id = data.id; + dataOptions.options.idselection = {enabled : true, useLabels : main_el.idselection_useLabels}; + } + + if(document.getElementById("selectedBy"+data.id).style.display === 'inline'){ + updateOpts = true; + dataOptions.id = data.id; + dataOptions.options.byselection = {enabled : true, variable : main_el.byselection_variable, multiple : main_el.byselection_multiple}; + } + + if(updateOpts){ + updateVisOptions(dataOptions); + } + } + } + } else if(data.legend === true){ + var legend_network = document.getElementById("legend"+data.id); + if(legend_network){ + // get & transform nodes object + var tmpnodes = visNetworkdataframeToD3(data.nodes, "nodes"); + // update nodes + legend_network.network.body.data.nodes.update(tmpnodes); + // fit + legend_network.network.fit(); + } + } + }); + + // udpate edges data + Shiny.addCustomMessageHandler('visShinyUpdateEdges', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(data.legend === false){ + if(el){ + // get edges object + var tmpedges = visNetworkdataframeToD3(data.edges, "edges"); + // reset edges + resetAllEdges(el.edges, el.highlightColor, el.byselectionColor, el.chart) + el.edges.update(tmpedges); + } + } else if(data.legend === true){ + var legend_network = document.getElementById("legend"+data.id); + if(legend_network){ + // get & transform nodes object + var tmpedges = visNetworkdataframeToD3(data.edges, "edges"); + // update edges + legend_network.network.body.data.edges.update(tmpedges); + // fit + legend_network.network.fit(); + } + } + }); + + // remove nodes + Shiny.addCustomMessageHandler('visShinyRemoveNodes', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + var main_el = document.getElementById(data.id); + if(data.legend === false){ + if(el){ + // reset some parameters / date before + if (main_el.selectActive === true | main_el.highlightActive === true) { + //reset nodes + resetAllNodes(el.nodes, true, el.chart.groups, el.options, el.chart); + + if (main_el.selectActive === true){ + main_el.selectActive = false; + resetList('selectedBy', data.id, 'selectedBy'); + } + if (main_el.highlightActive === true){ + main_el.highlightActive = false; + resetList('nodeSelect', data.id, 'selected'); + } + } + // remove nodes + el.nodes.remove(data.rmid); + + // update options ? + if(data.updateOptions){ + var dataOptions = {}; + dataOptions.options = {}; + + var updateOpts = false; + if(document.getElementById("nodeSelect"+data.id).style.display === 'inline'){ + updateOpts = true; + dataOptions.id = data.id; + dataOptions.options.idselection = {enabled : true, useLabels : main_el.idselection_useLabels}; + } + + if(document.getElementById("selectedBy"+data.id).style.display === 'inline'){ + updateOpts = true; + dataOptions.id = data.id; + dataOptions.options.byselection = {enabled : true, variable : main_el.byselection_variable, multiple : main_el.byselection_multiple}; + } + + if(updateOpts){ + updateVisOptions(dataOptions); + } + } + } + } else if(data.legend === true){ + var legend_network = document.getElementById("legend"+data.id); + if(legend_network){ + // remove nodes + legend_network.network.body.data.nodes.remove(data.rmid); + // fit + legend_network.network.fit(); + } + } + }); + + // remove edges + Shiny.addCustomMessageHandler('visShinyRemoveEdges', function(data){ + // get container id + var el = document.getElementById("graph"+data.id); + if(data.legend === false){ + if(el){ + // reset edges + resetAllEdges(el.edges, el.highlightColor, el.byselectionColor, el.chart) + el.edges.remove(data.rmid); + } + } else if(data.legend === true){ + var legend_network = document.getElementById("legend"+data.id); + if(legend_network){ + // remove edges + legend_network.network.body.data.edges.remove(data.rmid); + // fit + legend_network.network.fit(); + } + } + }); + + // remove edges + Shiny.addCustomMessageHandler('visShinySetTitle', function(data){ + if(data.main !== null){ + var div_title = document.getElementById("title" + data.id); + if(div_title !== null){ + if(data.main.hidden === true){ + div_title.style.display = 'none'; + } else { + if(data.main.text !== undefined){ + if(data.main.text !== null){ + if(data.main.text.length > 0){ + div_title.innerHTML = data.main.text; + } else { + div_title.innerHTML = ""; + } + } + } + if(data.main.style !== undefined){ + if(data.main.style !== null){ + if(data.main.style.length > 0){ + div_title.setAttribute('style', data.main.style); + } + } + } + div_title.style.display = 'block'; + } + } + } + if(data.submain !== null){ + var div_subtitle = document.getElementById("subtitle" + data.id); + if(div_subtitle !== null){ + if(data.submain.hidden === true){ + div_subtitle.style.display = 'none'; + } else { + if(data.submain.text !== undefined){ + if(data.submain.text !== null){ + if(data.submain.text.length > 0){ + div_subtitle.innerHTML = data.submain.text; + } else { + div_subtitle.innerHTML = ""; + } + } + } + if(data.submain.style !== undefined){ + if(data.submain.style !== null){ + if(data.submain.style.length > 0){ + div_subtitle.setAttribute('style', data.submain.style); + } + } + } + div_subtitle.style.display = 'block'; + } + } + } + if(data.footer !== null){ + var div_footer = document.getElementById("footer" + data.id); + if(div_footer !== null){ + if(data.footer.hidden === true){ + div_footer.style.display = 'none'; + } else { + if(data.footer.text !== undefined){ + if(data.footer.text !== null){ + if(data.footer.text.length > 0){ + div_footer.innerHTML = data.footer.text; + } else { + div_footer.innerHTML = ""; + } + } + } + if(data.footer.style !== undefined){ + if(data.footer.style !== null){ + if(data.footer.style.length > 0){ + div_footer.setAttribute('style', data.footer.style); + } + } + } + div_footer.style.display = 'block'; + } + } + } + }); + + // updateTree + Shiny.addCustomMessageHandler('visShinyUpdateTree', function(data){ + // get container id + var el = document.getElementById(data.id); + if(el){ + if(el.tree){ + if(data.tree.updateShape != undefined){ + el.tree.updateShape = data.tree.updateShape + } + if(data.tree.shapeVar != undefined){ + el.tree.shapeVar = data.tree.shapeVar + } + if(data.tree.shapeY != undefined){ + el.tree.shapeY = data.tree.shapeY + } + } + } + }); +} + +//---------------------------------------------------------------- +// HTMLWidgets.widget Definition +//--------------------------------------------------------------- +HTMLWidgets.widget({ + + name: 'visNetwork', + + type: 'output', + + initialize: function(el, width, height) { + return { + }; + }, + + renderValue: function(el, x, instance) { + var data; + var nodes; + var edges; + + + // clustergin by zoom variables + var clusterIndex = 0; + var clusters = []; + var lastClusterZoomLevel = 0; + var clusterFactor; + var ctrlwait = 0; + + // legend control + var addlegend = false; + + // main div el.id + var el_id = document.getElementById(el.id); + + // test background + el_id.style.background = x.background; + + // clear el.id (for shiny...) + el_id.innerHTML = ""; + + // shared control with proxy function (is there a better way ?) + el_id.highlightActive = false; + el_id.selectActive = false; + el_id.idselection = x.idselection.enabled; + el_id.byselection = x.byselection.enabled; + + if(x.highlight !== undefined){ + el_id.highlight = x.highlight.enabled; + el_id.highlightColor = x.highlight.hideColor; + el_id.hoverNearest = x.highlight.hoverNearest; + el_id.degree = x.highlight.degree; + el_id.highlightAlgorithm = x.highlight.algorithm; + el_id.highlightLabelOnly = x.highlight.labelOnly; + } else { + el_id.highlight = false; + el_id.hoverNearest = false; + el_id.highlightColor = 'rgba(200,200,200,0.5)'; + el_id.degree = 1; + el_id.highlightAlgorithm = "all"; + el_id.highlightLabelOnly = true; + } + + if(x.byselection.enabled){ + el_id.byselectionColor = x.byselection.hideColor; + } else { + el_id.byselectionColor = 'rgba(200,200,200,0.5)'; + } + + if(x.idselection.enabled){ + el_id.idselection_useLabels = true; + } else { + el_id.idselection_useLabels = false; + } + + if(x.collapse !== undefined){ + if(x.collapse.enabled){ + el_id.collapse = true; + el_id.collapseFit = x.collapse.fit; + el_id.collapseResetHighlight = x.collapse.resetHighlight; + el_id.collapseKeepCoord = x.collapse.keepCoord; + el_id.collapseLabelSuffix = x.collapse.labelSuffix; + el_id.clusterOptions = x.collapse.clusterOptions; + } + } else { + el_id.collapse = false; + el_id.collapseFit = false; + el_id.collapseResetHighlight = false; + el_id.collapseKeepCoord = true; + el_id.collapseLabelSuffix = " (cluster)"; + el_id.clusterOptions = undefined; + } + + if(x.tree !== undefined){ + el_id.tree = x.tree; + } + + // configure + if(x.options.configure !== undefined){ + if(x.options.configure.container !== undefined){ + var dom_conf = document.getElementById(x.options.configure.container); + if(dom_conf !== null){ + x.options.configure.container = dom_conf; + } else { + x.options.configure.container = undefined; + } + } + } + + var changeInput = function(id, data) { + Shiny.onInputChange(el.id + '_' + id, data); + }; + + //************************* + //title + //************************* + var div_title = document.createElement('div'); + div_title.id = "title"+el.id; + div_title.setAttribute('style','font-family:Georgia, Times New Roman, Times, serif;font-weight:bold;font-size:20px;text-align:center;'); + div_title.style.display = 'none'; + el_id.appendChild(div_title); + if(x.main !== null){ + div_title.innerHTML = x.main.text; + div_title.setAttribute('style', x.main.style + ";background-color: inherit;"); + div_title.style.display = 'block'; + } + + //************************* + //subtitle + //************************* + var div_subtitle = document.createElement('div'); + div_subtitle.id = "subtitle"+el.id; + div_subtitle.setAttribute('style', 'font-family:Georgia, Times New Roman, Times, serif;font-size:12px;text-align:center;'); + div_subtitle.style.display = 'none'; + el_id.appendChild(div_subtitle); + if(x.submain !== null){ + div_subtitle.innerHTML = x.submain.text; + div_subtitle.setAttribute('style', x.submain.style + ";background-color: inherit;"); + div_title.style.display = 'block'; + } + + //************************* + //init idselection + //************************* + function onIdChange(id, init) { + if(id === ""){ + instance.network.selectNodes([]); + }else{ + instance.network.selectNodes([id]); + } + if(el_id.highlight){ + neighbourhoodHighlight(instance.network.getSelection().nodes, "click", el_id.highlightAlgorithm); + }else{ + if(init){ + selectNode = document.getElementById('nodeSelect'+el.id); + if(x.idselection.values !== undefined){ + if(indexOf.call(x.idselection.values, id, true) > -1){ + selectNode.value = id; + }else{ + selectNode.value = ""; + } + }else{ + selectNode.value = id; + } + } + } + if (window.Shiny){ + changeInput('selected', document.getElementById("nodeSelect"+el.id).value); + } + if(el_id.byselection){ + resetList('selectedBy', el.id, 'selectedBy'); + } + } + + // id nodes selection : add a list on top left + // actually only with nodes + edges data (not dot and gephi) + var idList = document.createElement("select"); + idList.setAttribute('class', 'dropdown'); + idList.style.display = 'none'; + idList.id = "nodeSelect"+el.id; + el_id.appendChild(idList); + + idList.onchange = function(){ + if(instance.network){ + onIdChange(document.getElementById("nodeSelect"+el.id).value, false); + } + }; + + var hr = document.createElement("hr"); + hr.setAttribute('style', 'height:0px; visibility:hidden; margin-bottom:-1px;'); + el_id.appendChild(hr); + + //************************* + //selectedBy + //************************* + function onByChange(value) { + if(instance.network){ + selectedHighlight(value); + } + if (window.Shiny){ + changeInput('selectedBy', value); + } + if(el_id.idselection){ + resetList('nodeSelect', el.id, 'selected'); + } + } + + // selectedBy : add a list on top left + // actually only with nodes + edges data (not dot and gephi) + //Create and append select list + var byList = document.createElement("select"); + byList.setAttribute('class', 'dropdown'); + byList.style.display = 'none'; + byList.id = "selectedBy"+el.id; + el_id.appendChild(byList); + + byList.onchange = function(){ + onByChange(document.getElementById("selectedBy"+el.id).value); + }; + + if(el_id.byselection){ + + el_id.byselection_values = x.byselection.values; + el_id.byselection_variable = x.byselection.variable; + el_id.byselection_multiple = x.byselection.multiple; + var option2; + + //Create and append select list + var selectList2 = document.getElementById("selectedBy"+el.id); + selectList2.setAttribute('style', x.byselection.style); + selectList2.style.display = 'inline'; + + option2 = document.createElement("option"); + option2.value = ""; + if(x.byselection.main === undefined){ + option2.text = "Select by " + x.byselection.variable; + } else { + option2.text = x.byselection.main; + } + + selectList2.appendChild(option2); + + //Create and append the options + for (var i2 = 0; i2 < x.byselection.values.length; i2++) { + option2 = document.createElement("option"); + option2.value = x.byselection.values[i2]; + option2.text = x.byselection.values[i2]; + selectList2.appendChild(option2); + } + + if (window.Shiny){ + changeInput('selectedBy', document.getElementById("selectedBy"+el.id).value); + } + } + + //************************* + // pre-treatment for icons (unicode) + //************************* + if(x.options.groups){ + for (var gr in x.options.groups){ + if(x.options.groups[gr].icon){ + if(x.options.groups[gr].icon.code){ + x.options.groups[gr].icon.code = JSON.parse( '"'+'\\u' + x.options.groups[gr].icon.code + '"'); + } + if(x.options.groups[gr].icon.color){ + x.options.groups[gr].color = x.options.groups[gr].icon.color; + } + } + } + } + + if(x.options.nodes.icon){ + if(x.options.nodes.icon.code){ + x.options.nodes.icon.code = JSON.parse( '"'+'\\u' + x.options.nodes.icon.code + '"'); + } + if(x.options.nodes.icon.color){ + x.options.nodes.color = x.options.nodes.icon.color; + } + } + + //************************* + //page structure + //************************* + + // divide page + var maindiv = document.createElement('div'); + maindiv.id = "maindiv"+el.id; + maindiv.setAttribute('style', 'height:95%;background-color: inherit;'); + el_id.appendChild(maindiv); + + var graph = document.createElement('div'); + graph.id = "graph"+el.id; + + if(x.legend !== undefined){ + if((x.groups && x.legend.useGroups) || (x.legend.nodes !== undefined) || (x.legend.edges !== undefined)){ + addlegend = true; + } + } + + //legend + if(addlegend){ + var legendwidth = x.legend.width*100; + var legend = document.createElement('div'); + + var pos = x.legend.position; + var pos2 = "right"; + if(pos == "right"){ + pos2 = "left"; + } + + legend.id = "legend"+el.id; + legend.setAttribute('style', 'float:' + pos + '; width:'+legendwidth+'%;height:100%'); + + //legend title + if(x.legend.main !== undefined){ + var legend_title = document.createElement('div'); + legend_title.innerHTML = x.legend.main.text; + legend_title.setAttribute('style', x.legend.main.style); + legend.appendChild(legend_title); + + legend.id = "legend_main"+el.id; + var legend_network = document.createElement('div'); + legend_network.id = "legend"+el.id; + legend_network.setAttribute('style', 'height:100%'); + legend.appendChild(legend_network); + } + + document.getElementById("maindiv"+el.id).appendChild(legend); + graph.setAttribute('style', 'float:' + pos2 + '; width:'+(100-legendwidth)+'%;height:100%;background-color: inherit;'); + }else{ + graph.setAttribute('style', 'float:right; width:100%;height:100%;background-color: inherit;'); + } + + document.getElementById("maindiv"+el.id).appendChild(graph); + + //************************* + //legend definition + //************************* + if(addlegend){ + + var legendnodes = new vis.DataSet(); + var legendedges = null; + var datalegend; + var tmpnodes; + + // set some options + var optionslegend = { + interaction:{ + dragNodes: false, + dragView: false, + selectable: false, + zoomView: x.legend.zoom + }, + physics:{ + stabilization: false + } + }; + + function range(start, length, step, rep){ + var a=[], b=start; + while(a.length < length){ + for (var i = 0; i < rep; i++){ + a.push(b); + if(a.length === length){ + break; + } + } + b+=step; + } + return a; + }; + + var mynetwork = document.getElementById('legend'+el.id); + var lx = mynetwork.clientWidth / 2 + 50; + var ly = mynetwork.clientHeight / 2 + 50; + var edge_ly = ly; + var ncol = x.legend.ncol; + var step_x = x.legend.stepX; + var step_y = x.legend.stepY; + var tmp_ly; + var tmp_lx = lx; + var tmp_lx2; + var all_tmp_y = []; + if(tmp_lx === 0){ + tmp_lx = 1 + } + + // construct nodes data if needed + if(x.legend.nodes !== undefined){ + if(x.legend.nodesToDataframe){ // data in data.frame + tmpnodes = visNetworkdataframeToD3(x.legend.nodes, "nodes") + } else { // data in list + tmpnodes = x.legend.nodes; + } + // only one element + if(tmpnodes.length === undefined){ + tmpnodes = new Array(tmpnodes); + } + } + + // array of y position + if(x.groups && x.legend.useGroups && x.legend.nodes !== undefined){ + all_tmp_y = range(ly, x.groups.length + tmpnodes.length, step_y, ncol); + } else if(x.groups && x.legend.useGroups && x.legend.nodes === undefined){ + all_tmp_y = range(ly, x.groups.length, step_y, ncol); + } else if(x.legend.useGroups === false && x.legend.nodes !== undefined){ + all_tmp_y = range(ly, tmpnodes.length, step_y, ncol); + } + + // want to view groups in legend + if(x.groups && x.legend.useGroups){ + // create data + for (var g1 = 0; g1 < x.groups.length; g1++){ + + if(g1 === 0){ + tmp_lx = lx; + } else { + tmp_lx = lx + g1%ncol * step_x; + } + + tmp_ly = all_tmp_y[g1]; + if(tmp_ly === 0){ + tmp_ly = 1 + } + + legendnodes.add({id: null, x : tmp_lx, y : tmp_ly, label: x.groups[g1], group: x.groups[g1], value: 1, mass:1}); + edge_ly = tmp_ly; + } + // control icon size + if(x.options.groups){ + optionslegend.groups = clone(x.options.groups); + for (var grp in optionslegend.groups) { + if(optionslegend.groups[grp].shape === "icon"){ + optionslegend.groups[grp].icon.size = 50; + } + } + } + } + // want to add custom nodes + if(x.legend.nodes !== undefined){ + + // control icon + for (var nd in tmpnodes){ + if(tmpnodes[nd].icon && !x.legend.nodesToDataframe){ + tmpnodes[nd].icon.code = JSON.parse( '"'+'\\u' + tmpnodes[nd].icon.code + '"'); + } + } + // group control for y + var add_gr_y = 0; + if(x.groups && x.legend.useGroups){ + add_gr_y = x.groups.length; + } + // set coordinates + for (var g = 0; g < tmpnodes.length; g++){ + if((g+legendnodes.length) === 0){ + tmp_lx = lx; + } else { + tmp_lx = lx + (g+legendnodes.length)%ncol * step_x; + } + + tmp_ly = all_tmp_y[add_gr_y + g]; + if(tmp_lx === 0){ + tmp_lx = 1 + } + if(tmp_ly === 0){ + tmp_ly = 1 + } + tmpnodes[g].x = tmp_lx; + tmpnodes[g].y = tmp_ly; + + if(tmpnodes[g].value === undefined && tmpnodes[g].size === undefined){ + tmpnodes[g].value = 1; + } + /*if(tmpnodes[g].id !== undefined){ + tmpnodes[g].id = null; + }*/ + tmpnodes[g].mass = 1; + edge_ly = tmp_ly; + } + legendnodes.add(tmpnodes); + } + // want to add custom edges + if(x.legend.edges !== undefined){ + if(x.legend.edgesToDataframe){ // data in data.frame + legendedges = visNetworkdataframeToD3(x.legend.edges, "edges") + } else { // data in list + legendedges = x.legend.edges; + } + // only one element + if(legendedges.length === undefined){ + legendedges = new Array(legendedges); + } + + // set coordinates and options + for (var edg = 0; edg < (legendedges.length); edg++){ + + var tmp_int = Math.floor(Math.random() * 1001); + legendedges[edg].from = edg + "tmp_leg_edges_" + tmp_int + "_1"; + legendedges[edg].to = edg + "tmp_leg_edges_" + tmp_int + "_2"; + legendedges[edg].physics = false; + legendedges[edg].smooth = false; + legendedges[edg].value = undefined; + + if(legendedges[edg].arrows === undefined){ + legendedges[edg].arrows = 'to'; + } + + if(legendedges[edg].width === undefined){ + legendedges[edg].width = 1; + } + + tmp_ly = edge_ly + (edg+1)*step_y; + if(tmp_ly === 0){ + tmp_ly = 1 + } + + if(ncol === 1){ + tmp_lx = lx - mynetwork.clientWidth/3; + tmp_lx2 = lx + mynetwork.clientWidth/3; + } else { + tmp_lx = lx; + tmp_lx2 = lx + (ncol-1) * step_x; + } + + if(tmp_lx === 0){ + tmp_lx = 1 + } + + if(tmp_lx2 === 0){ + tmp_lx2 = 1 + } + + legendnodes.add({id: edg + "tmp_leg_edges_" + tmp_int + "_1", x : tmp_lx, y : tmp_ly, size : 0.0001, hidden : false, shape : "square", mass:1}); + legendnodes.add({id: edg + "tmp_leg_edges_" + tmp_int + "_2", x : tmp_lx2, y : tmp_ly, size : 0.0001, hidden : false, shape : "square", mass:1}); + } + } + + // render legend network + datalegend = { + nodes: legendnodes, + edges: legendedges + }; + + + instance.legend = new vis.Network(document.getElementById("legend"+el.id), datalegend, optionslegend); + //link network for update for re-use and update + document.getElementById("legend"+el.id).network = instance.legend; + } + + //************************* + // Main Network rendering + //************************* + if(x.nodes){ + + // network + nodes = new vis.DataSet(); + edges = new vis.DataSet(); + + var tmpnodes; + if(x.nodesToDataframe){ // data in data.frame + tmpnodes = visNetworkdataframeToD3(x.nodes, "nodes") + } else { // data in list + tmpnodes = x.nodes; + } + // only one element + if(tmpnodes.length === undefined){ + tmpnodes = new Array(tmpnodes); + } + + // update coordinates if igraph + if(x.igraphlayout !== undefined){ + // to improved + var zoomLevel = -232.622349 / (tmpnodes.length + 91.165919) +2.516861; + var igclientWidth = document.getElementById("graph"+el.id).clientWidth; + var scalex = 100; + var scaley = 100; + + // current div visibled + if(igclientWidth !== 0){ + var factor = igclientWidth / 1890; + zoomLevel = zoomLevel/factor; + var scalex = (igclientWidth / 2) * zoomLevel; + var scaley = scalex; + if(x.igraphlayout.type !== "square"){ + scaley = (document.getElementById("graph"+el.id).clientHeight / 2) * zoomLevel; + } + } else { + // current div not visibled.... + igclientWidth = parseInt(el_id.style.width); + if(igclientWidth !== 0){ + var factor = igclientWidth / 1890; + zoomLevel = zoomLevel/factor; + var scalex = (igclientWidth / 2) * zoomLevel; + var scaley = scalex; + if(x.igraphlayout.type !== "square"){ + scaley = (parseInt(el_id.style.height) / 2) * zoomLevel; + } + } + } + + for (var nd in tmpnodes) { + tmpnodes[nd].x = tmpnodes[nd].x * scalex; + tmpnodes[nd].y = tmpnodes[nd].y * scaley; + } + } + + nodes.add(tmpnodes); + + var tmpedges; + if(x.edgesToDataframe){ // data in data.frame + tmpedges = visNetworkdataframeToD3(x.edges, "edges") + } else { // data in list + tmpedges = x.edges; + } + // only one element + if(tmpedges !== null){ + if(tmpedges.length === undefined){ + tmpedges = new Array(tmpedges); + } + edges.add(tmpedges); + } + + // reset tmpnodes + tmpnodes = null; + + data = { + nodes: nodes, + edges: edges + }; + + //save data for re-use and update + document.getElementById("graph"+el.id).nodes = nodes; + document.getElementById("graph"+el.id).edges = edges; + + }else if(x.dot){ + data = { + dot: x.dot + }; + }else if(x.gephi){ + data = { + gephi: x.gephi + }; + } + + var options = x.options; + + //************************* + //manipulation + //************************* + if(x.options.manipulation.enabled){ + + var style = document.createElement('style'); + style.type = 'text/css'; + style.appendChild(document.createTextNode(x.datacss)); + document.getElementsByTagName("head")[0].appendChild(style); + + var div = document.createElement('div'); + div.id = 'network-popUp'; + + div.innerHTML = 'node
    \ + \ + \ + \ + \ + \ +
    id
    label
    \ + \ + '; + + el_id.appendChild(div); + + if(x.options.manipulation.addNode === undefined){ + options.manipulation.addNode = function(data, callback) { + document.getElementById('operation').innerHTML = "Add Node"; + document.getElementById('node-id').value = data.id; + document.getElementById('node-label').value = data.label; + document.getElementById('saveButton').onclick = saveNode.bind(this, data, callback, "addNode"); + document.getElementById('cancelButton').onclick = clearPopUp.bind(); + document.getElementById('network-popUp').style.display = 'block'; + }; + } else if(typeof(x.options.manipulation.addNode) === typeof(true)){ + if(x.options.manipulation.addNode){ + options.manipulation.addNode = function(data, callback) { + document.getElementById('operation').innerHTML = "Add Node"; + document.getElementById('node-id').value = data.id; + document.getElementById('node-label').value = data.label; + document.getElementById('saveButton').onclick = saveNode.bind(this, data, callback, "addNode"); + document.getElementById('cancelButton').onclick = clearPopUp.bind(); + document.getElementById('network-popUp').style.display = 'block'; + }; + } else { + options.manipulation.addNode = false; + } + } else { + options.manipulation.addNode = x.options.manipulation.addNode; + } + + if(x.options.manipulation.editNode === undefined){ + options.manipulation.editNode = function(data, callback) { + document.getElementById('operation').innerHTML = "Edit Node"; + document.getElementById('node-id').value = data.id; + document.getElementById('node-label').value = data.label; + document.getElementById('saveButton').onclick = saveNode.bind(this, data, callback, "editNode"); + document.getElementById('cancelButton').onclick = cancelEdit.bind(this,callback); + document.getElementById('network-popUp').style.display = 'block'; + }; + } else if(typeof(x.options.manipulation.editNode) === typeof(true)){ + if(x.options.manipulation.editNode){ + options.manipulation.editNode = function(data, callback) { + document.getElementById('operation').innerHTML = "Edit Node"; + document.getElementById('node-id').value = data.id; + document.getElementById('node-label').value = data.label; + document.getElementById('saveButton').onclick = saveNode.bind(this, data, callback, "editNode"); + document.getElementById('cancelButton').onclick = cancelEdit.bind(this,callback); + document.getElementById('network-popUp').style.display = 'block'; + }; + } else { + options.manipulation.editNode = false; + } + } else { + options.manipulation.editNode = x.options.manipulation.editNode; + } + + if(x.options.manipulation.deleteNode === undefined){ + options.manipulation.deleteNode = function(data, callback) { + var r = confirm("Do you want to delete " + data.nodes.length + " node(s) and " + data.edges.length + " edges ?"); + if (r === true) { + deleteSubGraph(data, callback); + } + }; + } else if(typeof(x.options.manipulation.deleteNode) === typeof(true)){ + if(x.options.manipulation.deleteNode){ + options.manipulation.deleteNode = function(data, callback) { + var r = confirm("Do you want to delete " + data.nodes.length + " node(s) and " + data.edges.length + " edges ?"); + if (r === true) { + deleteSubGraph(data, callback); + } + }; + } else { + options.manipulation.deleteNode = false; + } + } else { + options.manipulation.deleteNode = x.options.manipulation.deleteNode; + } + + if(x.options.manipulation.deleteEdge === undefined){ + options.manipulation.deleteEdge = function(data, callback) { + var r = confirm("Do you want to delete " + data.edges.length + " edges ?"); + if (r === true) { + deleteSubGraph(data, callback); + } + }; + } else if(typeof(x.options.manipulation.deleteEdge) === typeof(true)){ + if(x.options.manipulation.deleteEdge){ + options.manipulation.deleteEdge = function(data, callback) { + var r = confirm("Do you want to delete " + data.edges.length + " edges ?"); + if (r === true) { + deleteSubGraph(data, callback); + } + }; + } else { + options.manipulation.deleteEdge = false; + } + } else { + options.manipulation.deleteEdge = x.options.manipulation.deleteEdge; + } + + if(x.options.manipulation.addEdge === undefined){ + options.manipulation.addEdge = function(data, callback) { + if (data.from == data.to) { + var r = confirm("Do you want to connect the node to itself?"); + if (r === true) { + saveEdge(data, callback, "addEdge"); + } + } + else { + saveEdge(data, callback, "addEdge"); + } + }; + } else if(typeof(x.options.manipulation.addEdge) === typeof(true)){ + if(x.options.manipulation.addEdge){ + options.manipulation.addEdge = function(data, callback) { + if (data.from == data.to) { + var r = confirm("Do you want to connect the node to itself?"); + if (r === true) { + saveEdge(data, callback, "addEdge"); + } + } + else { + saveEdge(data, callback, "addEdge"); + } + }; + } else { + options.manipulation.addEdge = false; + } + } else { + options.manipulation.addEdge = x.options.manipulation.addEdge; + } + + if(x.options.manipulation.editEdge === undefined){ + options.manipulation.editEdge = function(data, callback) { + if (data.from == data.to) { + var r = confirm("Do you want to connect the node to itself?"); + if (r === true) { + saveEdge(data, callback, "editEdge"); + } + } + else { + saveEdge(data, callback, "editEdge"); + } + }; + } else if(typeof(x.options.manipulation.editEdge) === typeof(true)){ + if(x.options.manipulation.editEdge){ + options.manipulation.editEdge = function(data, callback) { + if (data.from == data.to) { + var r = confirm("Do you want to connect the node to itself?"); + if (r === true) { + saveEdge(data, callback, "editEdge"); + } + } + else { + saveEdge(data, callback, "editEdge"); + } + }; + } else { + options.manipulation.editEdge = false; + } + } else { + options.manipulation.editEdge = x.options.manipulation.editEdge; + } + } + + // create network + instance.network = new vis.Network(document.getElementById("graph"+el.id), data, options); + if (window.Shiny){ + Shiny.onInputChange(el.id + '_initialized', true); + } + + //************************* + //add values to idselection + //************************* + + if(el_id.idselection){ + var selectList = document.getElementById("nodeSelect"+el.id) + setNodeIdList(selectList, x.idselection, nodes) + + if (window.Shiny){ + changeInput('selected', document.getElementById("nodeSelect"+el.id).value); + } + } + + //save data for re-use and update + document.getElementById("graph"+el.id).chart = instance.network; + document.getElementById("graph"+el.id).options = options; + + ///////// + // popup + ///////// + + // Temporary variables to hold mouse x-y pos.s + var tempX = 0 + var tempY = 0 + + // Main function to retrieve mouse x-y pos.s + function getMouseXY(e) { + tempX = e.clientX + tempY = e.clientY + // catch possible negative values in NS + if (tempX < 0){tempX = 0} + if (tempY < 0){tempY = 0} + } + + document.addEventListener('mousemove', getMouseXY); + + //this.body.emitter.emit("showPopup",{id:this.popupObj.id,x:t.x+3,y:t.y-5})) + + // popup for title + var popupState = false; + var popupTimeout = null; + var vispopup = document.createElement("div"); + + // disable vis.js tooltip + var style = document.createElement('style'); + style.type = 'text/css'; + style.innerHTML = 'div.vis-tooltip {display : none}'; + document.getElementsByTagName('head')[0].appendChild(style); + + var popupStyle = 'position: fixed;visibility:hidden;padding: 5px;font-family: verdana;font-size:14px;font-color:#000000;background-color: #f5f4ed;-moz-border-radius: 3px;-webkit-border-radius: 3px;border-radius: 3px;border: 1px solid #808074;box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);max-width:400px;word-break: break-all' + + if(x.tooltipStyle !== undefined){ + popupStyle = x.tooltipStyle + } + var popupStay = 300; + if(x.tooltipStay !== undefined){ + popupStay = x.tooltipStay + } + vispopup.setAttribute('style', popupStyle) + + document.getElementById("graph"+el.id).appendChild(vispopup); + + // add some event listeners to avoid it disappearing when the mouse if over it. + vispopup.addEventListener('mouseover',function () { + if (popupTimeout !== null) { + clearTimeout(popupTimeout); + popupTimeout = null; + } + }); + + // set the timeout when the mouse leaves it. + vispopup.addEventListener('mouseout',function () { + if (popupTimeout === null) { + myHidePopup(100); + } + }); + + // use the popup event to show + instance.network.on("showPopup", function(params) { + popupState = true; + myShowPopup(params); + }) + + // use the hide event to hide it + instance.network.on("hidePopup", function(params) { + // avoid double firing of this event, bug in 4.2.0 + if (popupState === true) { + popupState = false; + myHidePopup(popupStay); + } + }) + + // hiding the popup through css and a timeout + function myHidePopup(delay) { + popupTimeout = setTimeout(function() {vispopup.style.visibility = 'hidden';}, delay); + } + + // showing the popup + function myShowPopup(id) { + // get the data from the vis.DataSet + var nodeData = nodes.get([id]); + var edgeData = edges.get([id]); + + // a node ? + if(nodeData[0] !== null && nodeData[0] !== undefined){ + vispopup.innerHTML = nodeData[0].title; + // show and place the tooltip. + vispopup.style.visibility = 'visible'; + vispopup.style.top = tempY - 20 + "px"; + vispopup.style.left = tempX + 5 + "px"; + + } else if(edgeData[0] !== null && edgeData[0] !== undefined){ + // so it's perhaps a edge ? + vispopup.innerHTML = edgeData[0].title; + // show and place the tooltip. + vispopup.style.visibility = 'visible'; + vispopup.style.top = tempY - 20 + "px"; + vispopup.style.left = tempX + 5 + "px"; + } else { + // or a cluster ? + var node_cluster = instance.network.body.nodes[id] + if(node_cluster !== undefined){ + vispopup.innerHTML = node_cluster.options.title; + // show and place the tooltip. + vispopup.style.visibility = 'visible'; + vispopup.style.top = tempY - 20 + "px"; + vispopup.style.left = tempX + 5 + "px"; + } + } + + // for sparkline. Eval script... + var any_script= vispopup.getElementsByTagName('script') + for (var n = 0; n < any_script.length; n++){ + if(any_script[n].getAttribute("type") === "text/javascript"){ + eval(any_script[n].innerHTML); + } + } + } + + //************************* + // Events + //************************* + if(x.events !== undefined){ + for (var key in x.events) { + instance.network.on(key, x.events[key]); + } + } + + if(x.OnceEvents !== undefined){ + for (var key in x.OnceEvents) { + instance.network.once(key, x.OnceEvents[key]); + } + } + + if(x.ResetEvents !== undefined){ + for (var key in x.ResetEvents) { + instance.network.off(key); + } + } + //************************* + // Selected Highlight + //************************* + + function selectedHighlight(value) { + // get current nodes + var allNodes = nodes.get({returnType:"Object"}); + + // first resetEdges + resetAllEdges(edges, el_id.byselectionColor, el_id.highlightColor, instance.network); + var connectedNodes = []; + + // get variable + var sel = el_id.byselection_variable; + // need to make an update? + var update = !(el_id.selectActive === false && value === ""); + + if (value !== "") { + var updateArray = []; + el_id.selectActive = true; + + // mark all nodes as hard to read. + for (var nodeId in allNodes) { + var value_in = false; + // unique selection + if(el_id.byselection_multiple === false){ + if(sel == "label"){ + value_in = ((allNodes[nodeId]["label"] + "") === value) || ((allNodes[nodeId]["hiddenLabel"] + "") === value); + }else if(sel == "color"){ + value_in = ((allNodes[nodeId]["color"] + "") === value) || ((allNodes[nodeId]["hiddenColor"] + "") === value); + }else { + value_in = (allNodes[nodeId][sel] + "") === value; + } + }else{ // multiple selection + if(sel == "label"){ + var current_value = allNodes[nodeId]["label"] + ""; + var value_split = current_value.split(",").map(Function.prototype.call, String.prototype.trim); + var current_value2 = allNodes[nodeId]["hiddenLabel"] + ""; + var value_split2 = current_value.split(",").map(Function.prototype.call, String.prototype.trim); + value_in = (value_split.indexOf(value) !== -1) || (value_split2.indexOf(value) !== -1); + }else if(sel == "color"){ + var current_value = allNodes[nodeId]["color"] + ""; + var value_split = current_value.split(",").map(Function.prototype.call, String.prototype.trim); + var current_value2 = allNodes[nodeId]["hiddenColor"] + ""; + var value_split2 = current_value.split(",").map(Function.prototype.call, String.prototype.trim); + value_in = (value_split.indexOf(value) !== -1) || (value_split2.indexOf(value) !== -1); + }else { + var current_value = allNodes[nodeId][sel] + ""; + var value_split = current_value.split(",").map(Function.prototype.call, String.prototype.trim); + value_in = value_split.indexOf(value) !== -1; + } + } + if(value_in === false){ // not in selection, so as hard to read + nodeAsHardToRead(allNodes[nodeId], instance.network.groups, options, el_id.byselectionColor, el_id.highlightColor, instance.network, "node"); + } else { // in selection, so reset if needed + connectedNodes = connectedNodes.concat(allNodes[nodeId].id); + resetOneNode(allNodes[nodeId], instance.network.groups, options, instance.network); + } + allNodes[nodeId].x = undefined; + allNodes[nodeId].y = undefined; + // update data + if (allNodes.hasOwnProperty(nodeId) && update) { + updateArray.push(allNodes[nodeId]); + } + } + if(update){ + // set some edges as hard to read + var edgesHardToRead = edges.get({ + fields: ['id', 'color', 'hiddenColor', 'hiddenLabel', 'label'], + filter: function (item) { + return (indexOf.call(connectedNodes, item.from, true) === -1) ; + }, + returnType :'Array' + }); + + // all in degree nodes get their own color and their label back + for (i = 0; i < edgesHardToRead.length; i++) { + edgeAsHardToRead(edgesHardToRead[i], el_id.byselectionColor, el_id.highlightColor, instance.network, type = "edge") + } + edges.update(edgesHardToRead); + + nodes.update(updateArray); + } + } + else if (el_id.selectActive === true) { + //reset nodes + resetAllNodes(nodes, update, instance.network.groups, options, instance.network) + el_id.selectActive = false + } + } + + //************************* + //Highlight + //************************* + var is_hovered = false; + var is_clicked = false; + + function neighbourhoodHighlight(params, action_type, algorithm) { + + var nodes_in_clusters = instance.network.body.modules.clustering.clusteredNodes; + var have_cluster_nodes = false; + if(Object.keys(nodes_in_clusters).length > 0){ + have_cluster_nodes = true; + nodes_in_clusters = Object.keys(nodes_in_clusters); + edges_in_clusters = Object.keys(instance.network.body.modules.clustering.clusteredEdges); + } else { + nodes_in_clusters = []; + edges_in_clusters = []; + } + + var selectNode; + // get nodes data + var allNodes = nodes.get({returnType:"Object"}); + + // cluster + var array_cluster_id; + + // update + var update = !(el_id.highlightActive === false && params.length === 0) | (el_id.selectActive === true && params.length === 0); + + if(!(action_type == "hover" && is_clicked)){ + + // first resetEdges + resetAllEdges(edges, el_id.highlightColor, el_id.byselectionColor, instance.network); + + if (params.length > 0) { + var is_cluster = instance.network.isCluster(params[0]); + var selectedNode; + + if(is_cluster){ + selectedNode = instance.network.getNodesInCluster(params[0]); + } else { + selectedNode = params; + } + + var updateArray = []; + if(el_id.idselection){ + selectNode = document.getElementById('nodeSelect'+el.id); + if(is_cluster === false){ + if(x.idselection.values !== undefined){ + if(indexOf.call(x.idselection.values, selectedNode[0], true) > -1){ + selectNode.value = selectedNode[0]; + }else{ + selectNode.value = ""; + } + }else{ + selectNode.value = selectedNode[0]; + } + if (window.Shiny){ + changeInput('selected', selectNode.value); + } + } + } + + el_id.highlightActive = true; + var i,j; + var degrees = el_id.degree; + + // mark all nodes as hard to read. + for (var nodeId in instance.network.body.nodes) { + if(instance.network.isCluster(nodeId)){ + nodeAsHardToRead(instance.network.body.nodes[nodeId], instance.network.groups, options, el_id.highlightColor, el_id.byselectionColor, instance.network, "cluster"); + }else { + var tmp_node = allNodes[nodeId]; + if(tmp_node !== undefined){ + nodeAsHardToRead(tmp_node, instance.network.groups, options, el_id.highlightColor, el_id.byselectionColor, instance.network, "node"); + tmp_node.x = undefined; + tmp_node.y = undefined; + } + } + } + + if(algorithm === "all"){ + var connectedNodes; + if(degrees > 0){ + connectedNodes = []; + for (j = 0; j < selectedNode.length; j++) { + connectedNodes = connectedNodes.concat(instance.network.getConnectedNodes(selectedNode[j], true)); + } + connectedNodes = uniqueArray(connectedNodes, true, instance.network); + }else{ + connectedNodes = selectedNode; + } + + var allConnectedNodes = []; + // get the nodes to color + if(degrees >= 2){ + for (i = 2; i <= degrees; i++) { + var previous_connectedNodes = connectedNodes; + var currentlength = connectedNodes.length; + for (j = 0; j < currentlength; j++) { + connectedNodes = uniqueArray(connectedNodes.concat(instance.network.getConnectedNodes(connectedNodes[j])), true, instance.network); + } + if (connectedNodes.length === previous_connectedNodes.length) { break; } + } + } + // nodes to just label + for (j = 0; j < connectedNodes.length; j++) { + allConnectedNodes = allConnectedNodes.concat(instance.network.getConnectedNodes(connectedNodes[j])); + } + allConnectedNodes = uniqueArray(allConnectedNodes, true, instance.network); + + if(el_id.highlightLabelOnly === true){ + // all higher degree nodes get a different color and their label back + array_cluster_id = []; + for (i = 0; i < allConnectedNodes.length; i++) { + if (allNodes[allConnectedNodes[i]].hiddenLabel !== undefined) { + allNodes[allConnectedNodes[i]].label = allNodes[allConnectedNodes[i]].hiddenLabel; + allNodes[allConnectedNodes[i]].hiddenLabel = undefined; + if(have_cluster_nodes){ + if(indexOf.call(nodes_in_clusters, allConnectedNodes[i], true) > -1){ + + array_cluster_id = array_cluster_id.concat(instance.network.clustering.findNode(allConnectedNodes[i])[0]); + } + } + } + } + + if(array_cluster_id.length > 0){ + array_cluster_id = uniqueArray(array_cluster_id, false, instance.network); + for (i = 0; i < array_cluster_id.length; i++) { + instance.network.body.nodes[array_cluster_id[i]].setOptions({label : instance.network.body.nodes[array_cluster_id[i]].options.hiddenLabel, hiddenLabel:undefined}) + } + } + } + + // all in degree nodes get their own color and their label back + main nodes + connectedNodes = connectedNodes.concat(selectedNode); + + if (window.Shiny){ + Shiny.onInputChange(el.id + '_highlight_color_id', uniqueShiny(connectedNodes)); + } + if(el_id.highlightLabelOnly === true){ + if (window.Shiny){ + Shiny.onInputChange(el.id + '_highlight_label_id', allConnectedNodes.filter(function(x){ return !connectedNodes.includes(x)})); + } + } + + array_cluster_id = []; + for (i = 0; i < connectedNodes.length; i++) { + resetOneNode(allNodes[connectedNodes[i]], instance.network.groups, options, instance.network); + if(have_cluster_nodes){ + if(indexOf.call(nodes_in_clusters, connectedNodes[i], true) > -1){ + array_cluster_id = array_cluster_id.concat(instance.network.clustering.findNode(connectedNodes[i])[0]); + } + } + } + + if(array_cluster_id.length > 0){ + array_cluster_id = uniqueArray(array_cluster_id, false, instance.network); + for (i = 0; i < array_cluster_id.length; i++) { + resetOneCluster(instance.network.body.nodes[array_cluster_id[i]], instance.network.groups, options, instance.network); + } + } + + // set some edges as hard to read + var edgesHardToRead = edges.get({ + fields: ['id', 'color', 'hiddenColor', 'hiddenLabel', 'label'], + filter: function (item) { + return ((indexOf.call(connectedNodes, item.from, true) === -1)) ; + }, + returnType :'Array' + }); + + // all in degree nodes get their own color and their label back + array_cluster_id = []; + var tmp_cluster_id; + for (i = 0; i < edgesHardToRead.length; i++) { + edgeAsHardToRead(edgesHardToRead[i], el_id.highlightColor, el_id.byselectionColor, instance.network, type = "edge") + if(have_cluster_nodes){ + if(indexOf.call(edges_in_clusters, edgesHardToRead[i].id, true) > -1){ + tmp_cluster_id = instance.network.clustering.getClusteredEdges(edgesHardToRead[i].id); + if(tmp_cluster_id.length > 1){ + array_cluster_id = array_cluster_id.concat(tmp_cluster_id[0]); + } + } + } + } + + if(array_cluster_id.length > 0){ + array_cluster_id = uniqueArray(array_cluster_id, false, instance.network); + for (i = 0; i < array_cluster_id.length; i++) { + edgeAsHardToRead(instance.network.body.edges[array_cluster_id[i]].options, el_id.highlightColor, el_id.byselectionColor, instance.network, type = "cluster") + } + } + edges.update(edgesHardToRead); + } else if(algorithm === "hierarchical"){ + + var degree_from = degrees.from; + var degree_to = degrees.to; + degrees = Math.max(degree_from, degree_to); + + var allConnectedNodes = []; + var currentConnectedFromNodes = []; + var currentConnectedToNodes = []; + var connectedFromNodes = []; + var connectedToNodes = []; + + if(degree_from > 0){ + connectedFromNodes = edges.get({ + fields: ['from'], + filter: function (item) { + return ((indexOf.call(selectedNode, item.to, true) !== -1)) ; + }, + returnType :'Array' + }); + } + + if(degree_to > 0){ + connectedToNodes = edges.get({ + fields: ['to'], + filter: function (item) { + return ((indexOf.call(selectedNode, item.from, true) !== -1)) ; + }, + returnType :'Array' + }); + } + for (j = 0; j < connectedFromNodes.length; j++) { + allConnectedNodes = allConnectedNodes.concat(connectedFromNodes[j].from); + currentConnectedFromNodes = currentConnectedFromNodes.concat(connectedFromNodes[j].from); + } + + for (j = 0; j < connectedToNodes.length; j++) { + allConnectedNodes = allConnectedNodes.concat(connectedToNodes[j].to); + currentConnectedToNodes = currentConnectedToNodes.concat(connectedToNodes[j].to); + } + + var go_from; + var go_to; + + if(degrees > 1){ + for (i = 2; i <= degrees; i++) { + go_from = false; + go_to = false; + if(currentConnectedFromNodes.length > 0 && i <= degree_from){ + connectedFromNodes = edges.get({ + fields: ['from'], + filter: function (item) { + return indexOf.call(currentConnectedFromNodes, item.to, true) > -1; + }, + returnType :'Array' + }); + go_from = true; + } + + if(currentConnectedToNodes.length > 0 && i <= degree_to){ + connectedToNodes = edges.get({ + fields: ['to'], + filter: function (item) { + return indexOf.call(currentConnectedToNodes, item.from, true) > -1; + }, + returnType :'Array' + }); + go_to = true; + } + + if(go_from === true){ + currentConnectedFromNodes = []; + for (j = 0; j < connectedFromNodes.length; j++) { + allConnectedNodes = allConnectedNodes.concat(connectedFromNodes[j].from); + currentConnectedFromNodes = currentConnectedFromNodes.concat(connectedFromNodes[j].from); + } + } + + if(go_to === true){ + currentConnectedToNodes = []; + for (j = 0; j < connectedToNodes.length; j++) { + allConnectedNodes = allConnectedNodes.concat(connectedToNodes[j].to); + currentConnectedToNodes = currentConnectedToNodes.concat(connectedToNodes[j].to); + } + } + + if (go_from === false && go_to === false) { break;} + } + } + + allConnectedNodes = uniqueArray(allConnectedNodes, true, instance.network).concat(selectedNode); + + var nodesWithLabel = []; + if(el_id.highlightLabelOnly === true){ + if(degrees > 0){ + // nodes to just label + for (j = 0; j < currentConnectedToNodes.length; j++) { + nodesWithLabel = nodesWithLabel.concat(instance.network.getConnectedNodes(currentConnectedToNodes[j])); + } + + for (j = 0; j < currentConnectedFromNodes.length; j++) { + nodesWithLabel = nodesWithLabel.concat(instance.network.getConnectedNodes(currentConnectedFromNodes[j])); + } + nodesWithLabel = uniqueArray(nodesWithLabel, true, instance.network); + } else{ + nodesWithLabel = currentConnectedToNodes; + nodesWithLabel = nodesWithLabel.concat(currentConnectedFromNodes); + nodesWithLabel = uniqueArray(nodesWithLabel, true, instance.network); + } + } + // all higher degree nodes get a different color and their label back + array_cluster_id = []; + for (i = 0; i < nodesWithLabel.length; i++) { + if (allNodes[nodesWithLabel[i]].hiddenLabel !== undefined) { + allNodes[nodesWithLabel[i]].label = allNodes[nodesWithLabel[i]].hiddenLabel; + allNodes[nodesWithLabel[i]].hiddenLabel = undefined; + if(have_cluster_nodes){ + if(indexOf.call(nodes_in_clusters, nodesWithLabel[i], true) > -1){ + array_cluster_id = array_cluster_id.concat(instance.network.clustering.findNode(nodesWithLabel[i])[0]); + } + } + } + } + + if(array_cluster_id.length > 0){ + array_cluster_id = uniqueArray(array_cluster_id, false, instance.network); + for (i = 0; i < array_cluster_id.length; i++) { + instance.network.body.nodes[array_cluster_id[i]].setOptions({label : instance.network.body.nodes[array_cluster_id[i]].options.hiddenLabel, hiddenLabel:undefined}) + } + } + + // all in degree nodes get their own color and their label back + array_cluster_id = []; + for (i = 0; i < allConnectedNodes.length; i++) { + resetOneNode(allNodes[allConnectedNodes[i]], instance.network.groups, options, instance.network); + if(have_cluster_nodes){ + if(indexOf.call(nodes_in_clusters, allConnectedNodes[i], true) > -1){ + array_cluster_id = array_cluster_id.concat(instance.network.clustering.findNode(allConnectedNodes[i])[0]); + } + } + } + + if(array_cluster_id.length > 0){ + array_cluster_id = uniqueArray(array_cluster_id, false, instance.network); + for (i = 0; i < array_cluster_id.length; i++) { + resetOneCluster(instance.network.body.nodes[array_cluster_id[i]], instance.network.groups, options, instance.network); + } + } + + if (window.Shiny){ + Shiny.onInputChange(el.id + '_highlight_color_id', uniqueShiny(allConnectedNodes)); + } + if(el_id.highlightLabelOnly === true){ + if (window.Shiny){ + Shiny.onInputChange(el.id + '_highlight_label_id', nodesWithLabel.filter(function(x) {return !allConnectedNodes.includes(x)})); + } + } + + // set some edges as hard to read + var edgesHardToRead = edges.get({ + fields: ['id', 'color', 'hiddenColor', 'hiddenLabel', 'label'], + filter: function (item) { + return ((indexOf.call(allConnectedNodes, item.from, true) === -1) || (indexOf.call(allConnectedNodes, item.to, true) === -1)) ; + }, + returnType :'Array' + }); + + array_cluster_id = []; + for (i = 0; i < edgesHardToRead.length; i++) { + edgeAsHardToRead(edgesHardToRead[i], el_id.highlightColor, el_id.byselectionColor, instance.network, type = "edge") + if(have_cluster_nodes){ + if(indexOf.call(edges_in_clusters, edgesHardToRead[i].id, true) > -1){ + var tmp_cluster_id = instance.network.clustering.getClusteredEdges(edgesHardToRead[i].id); + if(tmp_cluster_id.length > 1){ + array_cluster_id = array_cluster_id.concat(tmp_cluster_id[0]); + } + } + } + } + + if(array_cluster_id.length > 0){ + array_cluster_id = uniqueArray(array_cluster_id, false, instance.network); + for (i = 0; i < array_cluster_id.length; i++) { + edgeAsHardToRead(instance.network.body.edges[array_cluster_id[i]].options, el_id.highlightColor, el_id.byselectionColor, instance.network, type = "cluster"); + } + } + + edges.update(edgesHardToRead); + + } + + if(update){ + if(!(action_type == "hover")){ + is_clicked = true; + } + // transform the object into an array + var updateArray = []; + for (nodeId in allNodes) { + if (allNodes.hasOwnProperty(nodeId)) { + updateArray.push(allNodes[nodeId]); + } + } + nodes.update(updateArray); + }else{ + is_clicked = false; + } + + } + else if (el_id.highlightActive === true | el_id.selectActive === true) { + // reset nodeSelect list if actived + if(el_id.idselection){ + resetList("nodeSelect", el.id, 'selected'); + } + //reset nodes + resetAllNodes(nodes, update, instance.network.groups, options, instance.network) + el_id.highlightActive = false; + is_clicked = false; + + if (window.Shiny){ + Shiny.onInputChange(el.id + '_highlight_label_id', null) + Shiny.onInputChange(el.id + '_highlight_color_id', null) + } + } + } + // reset selectedBy list if actived + if(el_id.byselection){ + resetList("selectedBy", el.id, 'selectedBy'); + } + } + + function onClickIDSelection(selectedItems) { + var selectNode; + if(el_id.idselection){ + if (selectedItems.nodes.length !== 0) { + selectNode = document.getElementById('nodeSelect'+el.id); + if(x.idselection.values !== undefined){ + if(indexOf.call(x.idselection.values, selectedItems.nodes[0], true) > -1){ + selectNode.value = selectedItems.nodes; + }else{ + selectNode.value = ""; + } + }else{ + selectNode.value = selectedItems.nodes; + } + if (window.Shiny){ + changeInput('selected', selectNode.value); + } + }else{ + resetList("nodeSelect", el.id, 'selected'); + } + } + if(el_id.byselection){ + // reset selectedBy list if actived + if (selectedItems.nodes.length === 0) { + resetList("selectedBy", el.id, 'selectedBy'); + selectedHighlight(""); + } + } + } + + // shared click function (selectedNodes) + document.getElementById("graph"+el.id).myclick = function(params){ + if(el_id.highlight && x.nodes){ + neighbourhoodHighlight(params.nodes, "click", el_id.highlightAlgorithm); + }else if((el_id.idselection || el_id.byselection) && x.nodes){ + onClickIDSelection(params) + } + }; + + // Set event in relation with highlightNearest + instance.network.on("click", function(params){ + if(el_id.highlight && x.nodes){ + neighbourhoodHighlight(params.nodes, "click", el_id.highlightAlgorithm); + }else if((el_id.idselection || el_id.byselection) && x.nodes){ + onClickIDSelection(params) + } + }); + + instance.network.on("hoverNode", function(params){ + if(el_id.hoverNearest && x.nodes){ + neighbourhoodHighlight([params.node], "hover", el_id.highlightAlgorithm); + } + }); + + instance.network.on("blurNode", function(params){ + if(el_id.hoverNearest && x.nodes){ + neighbourhoodHighlight([], "hover", el_id.highlightAlgorithm); + } + }); + + //************************* + //collapse + //************************* + instance.network.on("doubleClick", function(params){ + if(el_id.collapse){ + collapsedNetwork(params.nodes, el_id.collapseFit, el_id.collapseResetHighlight, + el_id.clusterOptions, el_id.collapseLabelSuffix, + el_id.tree, instance.network, el.id) + } + }); + + if(el_id.collapse){ + instance.network.on("doubleClick", networkOpenCluster); + } + + //************************* + //footer + //************************* + var div_footer = document.createElement('div'); + div_footer.id = "footer"+el.id; + div_footer.setAttribute('style', 'font-family:Georgia, Times New Roman, Times, serif;font-size:12px;text-align:center;background-color: inherit;'); + div_footer.style.display = 'none'; + + document.getElementById("graph" + el.id).appendChild(div_footer); + if(x.footer !== null){ + div_footer.innerHTML = x.footer.text; + div_footer.setAttribute('style', x.footer.style + ';background-color: inherit;'); + div_footer.style.display = 'block'; + } + + //************************* + // export + //************************* + if(x.export !== undefined){ + + var downloaddiv = document.createElement('div'); + downloaddiv.setAttribute('style', 'float:right; width:100%;background-color: inherit;'); + + var downloadbutton = document.createElement("button"); + downloadbutton.setAttribute('style', x.export.css); + downloadbutton.style.position = "relative"; + downloadbutton.id = "download"+el.id; + downloadbutton.appendChild(document.createTextNode(x.export.label)); + downloaddiv.appendChild(downloadbutton); + + var hr = document.createElement("hr"); + hr.setAttribute('style', 'height:5px; visibility:hidden; margin-bottom:-1px;'); + downloaddiv.appendChild(hr); + + document.getElementById("maindiv"+el.id).appendChild(downloaddiv); + + document.getElementById("download"+el.id).onclick = function() { + + // height control for export + var addHeightExport = document.getElementById("graph" + el.id).offsetHeight + idList.offsetHeight + byList.offsetHeight + downloaddiv.offsetHeight; + if(div_title.style.display !== 'none'){ + addHeightExport = addHeightExport + div_title.offsetHeight; + } + if(div_subtitle.style.display !== 'none'){ + addHeightExport = addHeightExport + div_subtitle.offsetHeight; + } + if(div_footer.style.display !== 'none'){ + addHeightExport = addHeightExport + div_footer.offsetHeight; + } else { + addHeightExport = addHeightExport + 15; + } + + downloadbutton.style.display = 'none'; + var export_background = x.export.background; + if(x.background !== "transparent" && x.background !== "rgba(0, 0, 0, 0)"){ + export_background = x.background + } + + if(x.export.type !== "pdf"){ + html2canvas(el_id, { + background: export_background, + height : addHeightExport, + onrendered: function(canvas) { + canvas.toBlobHD(function(blob) { + saveAs(blob, x.export.name); + }, "image/"+x.export.type); + } + }); + } else { + html2canvas(el_id, { + background: export_background, + height : addHeightExport, + onrendered: function(canvas) { + var myImage = canvas.toDataURL("image/png", 1.0); + //var imgWidth = (canvas.width * 25.4) / 24; + //var imgHeight = (canvas.height * 25.4) / 24; + var table = new jsPDF('l', 'pt', [canvas.width, canvas.height]); + table.addImage(myImage, 'JPEG', 0, 0, canvas.width, canvas.height); + table.save(x.export.name); + } + }); + } + + downloadbutton.style.display = 'block'; + }; + } + + //************************* + // dataManipulation + //************************* + function clearPopUp() { + document.getElementById('saveButton').onclick = null; + document.getElementById('cancelButton').onclick = null; + document.getElementById('network-popUp').style.display = 'none'; + } + + function saveNode(data, callback, cmd) { + data.id = document.getElementById('node-id').value; + data.label = document.getElementById('node-label').value; + if (window.Shiny){ + var obj = {cmd: cmd, id: data.id, label: data.label} + Shiny.onInputChange(el.id + '_graphChange', obj); + } + clearPopUp(); + callback(data); + } + + function saveEdge(data, callback, cmd) { + callback(data); //must be first called for egde id ! + if (window.Shiny){ + var obj = {cmd: cmd, id: data.id, from: data.from, to: data.to}; + Shiny.onInputChange(el.id + '_graphChange', obj); + } + + } + + function deleteSubGraph(data, callback) { + if (window.Shiny){ + var obj = {cmd: "deleteElements", nodes: data.nodes, edges: data.edges} + Shiny.onInputChange(el.id + '_graphChange', obj); + } + callback(data); + } + + function cancelEdit(callback) { + clearPopUp(); + callback(null); + } + + //************************* + // CLUSTERING + //************************* + if(x.clusteringGroup || x.clusteringColor || x.clusteringHubsize || x.clusteringConnection){ + + var clusterbutton = document.createElement("input"); + clusterbutton.id = "backbtn"+el.id; + clusterbutton.setAttribute('type', 'button'); + clusterbutton.setAttribute('value', 'Reinitialize clustering'); + clusterbutton.setAttribute('style', 'background-color:#FFFFFF;border: none'); + el_id.appendChild(clusterbutton); + + clusterbutton.onclick = function(){ + // reset some parameters / data before + if (el_id.selectActive === true | el_id.highlightActive === true) { + //reset nodes + neighbourhoodHighlight([], "click", el_id.highlightAlgorithm); + if (el_id.selectActive === true){ + el_id.selectActive = false; + resetList('selectedBy',el.id, 'selectedBy'); + } + if (el_id.highlightActive === true){ + el_id.highlightActive = false; + resetList('nodeSelect', el.id, 'selected'); + } + } + //instance.network.setData(data); + if(x.clusteringColor){ + clusterByColor(); + } + if(x.clusteringGroup){ + clusterByGroup(); + } + if(x.clusteringHubsize){ + clusterByHubsize(); + } + if(x.clusteringConnection){ + clusterByConnection(); + } + instance.network.fit(); + } + } + + if(x.clusteringGroup || x.clusteringColor || x.clusteringOutliers || x.clusteringHubsize || x.clusteringConnection){ + // if we click on a node, we want to open it up! + instance.network.on("doubleClick", function (params){ + + if (params.nodes.length === 1) { + if (instance.network.isCluster(params.nodes[0]) === true) { + is_clicked = false; + instance.network.openCluster(params.nodes[0], {releaseFunction : function(clusterPosition, containedNodesPositions) { + return containedNodesPositions; + }}); + } + } + }); + } + //************************* + //clustering Connection + //************************* + if(x.clusteringConnection){ + + function clusterByConnection() { + for (var i = 0; i < x.clusteringConnection.nodes.length; i++) { + instance.network.clusterByConnection(x.clusteringConnection.nodes[i]) + } + } + clusterByConnection(); + } + + //************************* + //clustering hubsize + //************************* + if(x.clusteringHubsize){ + + function clusterByHubsize() { + var clusterOptionsByData = { + processProperties: function(clusterOptions, childNodes) { + var cluster_level = 9999999 + for (var i = 0; i < childNodes.length; i++) { + //totalMass += childNodes[i].mass; + if(childNodes[i].level){ + cluster_level = Math.min(cluster_level, childNodes[i].level) + } + if(i === 0){ + //clusterOptions.shape = childNodes[i].shape; + clusterOptions.color = childNodes[i].color.background; + }else{ + //if(childNodes[i].shape !== clusterOptions.shape){ + //clusterOptions.shape = 'database'; + //} + if(childNodes[i].color.background !== clusterOptions.color){ + clusterOptions.color = 'grey'; + } + } + } + clusterOptions.label = "[" + childNodes.length + "]"; + if(cluster_level !== 9999999){ + clusterOptions.level = cluster_level + } + return clusterOptions; + }, + clusterNodeProperties: {borderWidth:3, shape:'box', font:{size:30}} + } + if(x.clusteringHubsize.size > 0){ + instance.network.clusterByHubsize(x.clusteringHubsize.size, clusterOptionsByData); + }else{ + instance.network.clusterByHubsize(undefined, clusterOptionsByData); + } + } + + clusterByHubsize(); + } + + if(x.clusteringColor){ + + //************************* + //clustering color + //************************* + function clusterByColor() { + var colors = x.clusteringColor.colors + var clusterOptionsByData; + for (var i = 0; i < colors.length; i++) { + var color = colors[i]; + var sh = x.clusteringColor.shape[i]; + var force = x.clusteringColor.force[i]; + clusterOptionsByData = { + joinCondition: function (childOptions) { + return childOptions.color.background == color; // the color is fully defined in the node. + }, + processProperties: function (clusterOptions, childNodes, childEdges) { + var totalMass = 0; + var cluster_level = 9999999; + for (var i = 0; i < childNodes.length; i++) { + totalMass += childNodes[i].mass; + if(childNodes[i].level){ + cluster_level = Math.min(cluster_level, childNodes[i].level) + } + if(force === false){ + if(i === 0){ + clusterOptions.shape = childNodes[i].shape; + }else{ + if(childNodes[i].shape !== clusterOptions.shape){ + clusterOptions.shape = sh; + } + } + } else { + clusterOptions.shape = sh; + } + + } + clusterOptions.value = totalMass; + if(cluster_level !== 9999999){ + clusterOptions.level = cluster_level + } + return clusterOptions; + }, + clusterNodeProperties: {id: 'cluster:' + color, borderWidth: 3, color:color, label: x.clusteringColor.label + color} + } + instance.network.cluster(clusterOptionsByData); + } + } + + clusterByColor(); + } + + //************************* + //clustering groups + //************************* + if(x.clusteringGroup){ + + function clusterByGroup() { + var groups = x.clusteringGroup.groups; + var clusterOptionsByData; + for (var i = 0; i < groups.length; i++) { + var group = groups[i]; + var col = x.clusteringGroup.color[i]; + var sh = x.clusteringGroup.shape[i]; + var force = x.clusteringGroup.force[i]; + var sc_size = x.clusteringGroup.scale_size[i]; + + clusterOptionsByData = { + joinCondition: function (childOptions) { + return childOptions.group == group; // + }, + processProperties: function (clusterOptions, childNodes, childEdges) { + var totalMass = 0; + var cluster_level = 9999999; + for (var i = 0; i < childNodes.length; i++) { + totalMass += childNodes[i].mass; + if(childNodes[i].level){ + cluster_level = Math.min(cluster_level, childNodes[i].level) + } + if(force === false){ + if(i === 0){ + clusterOptions.shape = childNodes[i].shape; + clusterOptions.color = childNodes[i].color.background; + }else{ + if(childNodes[i].shape !== clusterOptions.shape){ + clusterOptions.shape = sh; + } + if(childNodes[i].color.background !== clusterOptions.color){ + clusterOptions.color = col; + } + } + } else { + clusterOptions.shape = sh; + clusterOptions.color = col; + } + } + if(sc_size){ + clusterOptions.value = totalMass; + } + if(cluster_level !== 9999999){ + clusterOptions.level = cluster_level + } + return clusterOptions; + }, + clusterNodeProperties: {id: 'cluster:' + group, borderWidth: 3, label:x.clusteringGroup.label + group} + } + instance.network.cluster(clusterOptionsByData); + } + } + clusterByGroup(); + } + + //************************* + //clustering by zoom + //************************* + if(x.clusteringOutliers){ + + clusterFactor = x.clusteringOutliers.clusterFactor; + + // set the first initial zoom level + instance.network.on('initRedraw', function() { + if (lastClusterZoomLevel === 0) { + lastClusterZoomLevel = instance.network.getScale(); + } + }); + + // we use the zoom event for our clustering + instance.network.on('zoom', function (params) { + if(ctrlwait === 0){ + if (params.direction == '-') { + if (params.scale < lastClusterZoomLevel*clusterFactor) { + makeClusters(params.scale); + lastClusterZoomLevel = params.scale; + } + } + else { + openClusters(params.scale); + } + } + }); + } + + // make the clusters + function makeClusters(scale) { + ctrlwait = 1; + var clusterOptionsByData = { + processProperties: function (clusterOptions, childNodes) { + clusterIndex = clusterIndex + 1; + var childrenCount = 0; + var cluster_level = 9999999; + for (var i = 0; i < childNodes.length; i++) { + childrenCount += childNodes[i].childrenCount || 1; + if(childNodes[i].level){ + cluster_level = Math.min(cluster_level, childNodes[i].level) + } + } + clusterOptions.childrenCount = childrenCount; + clusterOptions.label = "# " + childrenCount + ""; + clusterOptions.font = {size: childrenCount*5+30} + clusterOptions.id = 'cluster:' + clusterIndex; + clusters.push({id:'cluster:' + clusterIndex, scale:scale}); + + if(cluster_level !== 9999999){ + clusterOptions.level = cluster_level + } + return clusterOptions; + }, + clusterNodeProperties: {borderWidth: 3, shape: 'database', font: {size: 30}} + } + instance.network.clusterOutliers(clusterOptionsByData); + if (x.clusteringOutliers.stabilize) { + instance.network.stabilize(); + }; + ctrlwait = 0; + } + + // open them back up! + function openClusters(scale) { + ctrlwait = 1; + var newClusters = []; + var declustered = false; + for (var i = 0; i < clusters.length; i++) { + if (clusters[i].scale < scale) { + instance.network.openCluster(clusters[i].id); + lastClusterZoomLevel = scale; + declustered = true; + } + else { + newClusters.push(clusters[i]) + } + } + clusters = newClusters; + if (x.clusteringOutliers.stabilize) { + instance.network.stabilize(); + }; + ctrlwait = 0; + } + + //****************** + // init selection + //****************** + if(el_id.idselection && x.nodes && x.idselection.selected !== undefined){ + onIdChange(''+ x.idselection.selected, true); + } + + if(el_id.byselection && x.nodes && x.byselection.selected !== undefined){ + onByChange(x.byselection.selected); + selectNode = document.getElementById('selectedBy'+el.id); + selectNode.value = x.byselection.selected; + } + + // try to fix icons loading css bug... + function iconsRedraw() { + setTimeout(function(){ + if(instance.network) + instance.network.redraw(); + if(instance.legend) + instance.legend.redraw(); + }, 250); + }; + + if(x.iconsRedraw !== undefined){ + if(x.iconsRedraw){ + iconsRedraw(); + instance.network.once("stabilized", function(){iconsRedraw();}) + } + } + }, + + resize: function(el, width, height, instance) { + if(instance.network) + instance.network.fit(); + if(instance.legend) + instance.legend.fit(); + } + +}); diff --git a/docs/articles/pkgnet-report.html b/docs/articles/pkgnet-report.html new file mode 100644 index 00000000..a6c0082b --- /dev/null +++ b/docs/articles/pkgnet-report.html @@ -0,0 +1,217 @@ + + + + + + + +pkgnet Package Report, by pkgnet • pkgnet + + + + + + + + + + + +
    +
    + + + +
    + + + + +
    +
    + + + + +

    This report on pkgnet is generated by pkgnet, an R package for analyzing other R packages through the lens of network theory.

    +
    +

    +Dependency Network

    +

    Here’s an overview of of the packages pkgnet relies upon.

    +
    +

    +Visualization

    +
    + +
    +
    +

    +Table

    +
    + +
    +
    +
    +

    +Function Network

    +

    Here’s an overview of the functions defined in pkgnet.

    +
    +

    +Visualization

    +
    + +
    +
    +

    +Table

    +
    + +
    +
    +
    +

    +Class Inheritance

    +

    Here’s an overview of the classes defined in pkgnet. The following class types are supported:

    +
      +
    • S4 Classes
    • +
    • Reference Classes (sometimes informally called “R5”)
    • +
    • R6 Classes
    • +
    +

    S3 classes are not supported. For more information about object-oriented programming in R, see the section at the bottom.

    +
    +

    +Visualization

    +
    + +
    +
    +

    +Table

    +
    + +
    +
    +

    +About Classes, Inheritance, and R’s Object-Oriented Systems

    +

    In object-oriented programming, code is oriented around “objects”. “Classes” are definitions of types of objects that share the same attributes and functionality. For more information, see the Wikipedia article.

    +

    In the concept of inheritance, children classes are extensions of their parent class in that they—generally speaking—are a superset of their parent class. Children classes “inherit” attributes and functionality from their parent classes. This reporter graphs the inheritance between the classes of a package, with inheritance as a directed edge from a child class to its parent class.

    +

    R has four main object-oriented systems: S3, S4, and Reference Classes are part of base R; the R6 package provides another commonly used system.

    +

    This reporter supports the S4, Reference Class, and R6 systems. S3 classes are not supported because their inheritance is defined on an ad hoc per-object basis, rather than formally by class definitions.

    +

    For more info about R’s built-in object-oriented systems, check out the relevant chapter in Hadley Wickham’s Advanced R. For more info about R6, check out their documentation website or the chapter in Advanced R’s second edition.

    +
    +

    This report built with pkgnet v0.3.2.9999.

    +

    pkgnet is an open-source R package, copyright © 2017-2019 Uptake, made available under the 3-Clause BSD License.

    +
    +
    +
    + + + +
    + + +
    + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + diff --git a/docs/articles/pkgnet-report_files/crosstalk-1.0.0/css/crosstalk.css b/docs/articles/pkgnet-report_files/crosstalk-1.0.0/css/crosstalk.css new file mode 100644 index 00000000..46befd2e --- /dev/null +++ b/docs/articles/pkgnet-report_files/crosstalk-1.0.0/css/crosstalk.css @@ -0,0 +1,27 @@ +/* Adjust margins outwards, so column contents line up with the edges of the + parent of container-fluid. */ +.container-fluid.crosstalk-bscols { + margin-left: -30px; + margin-right: -30px; + white-space: normal; +} + +/* But don't adjust the margins outwards if we're directly under the body, + i.e. we were the top-level of something at the console. */ +body > .container-fluid.crosstalk-bscols { + margin-left: auto; + margin-right: auto; +} + +.crosstalk-input-checkboxgroup .crosstalk-options-group .crosstalk-options-column { + display: inline-block; + padding-right: 12px; + vertical-align: top; +} + +@media only screen and (max-width:480px) { + .crosstalk-input-checkboxgroup .crosstalk-options-group .crosstalk-options-column { + display: block; + padding-right: inherit; + } +} diff --git a/docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.js b/docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.js new file mode 100644 index 00000000..8e6ee305 --- /dev/null +++ b/docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.js @@ -0,0 +1,1471 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o b) { + return 1; + } +} + +/** + * @private + */ + +var FilterSet = function () { + function FilterSet() { + _classCallCheck(this, FilterSet); + + this.reset(); + } + + _createClass(FilterSet, [{ + key: "reset", + value: function reset() { + // Key: handle ID, Value: array of selected keys, or null + this._handles = {}; + // Key: key string, Value: count of handles that include it + this._keys = {}; + this._value = null; + this._activeHandles = 0; + } + }, { + key: "update", + value: function update(handleId, keys) { + if (keys !== null) { + keys = keys.slice(0); // clone before sorting + keys.sort(naturalComparator); + } + + var _diffSortedLists = (0, _util.diffSortedLists)(this._handles[handleId], keys), + added = _diffSortedLists.added, + removed = _diffSortedLists.removed; + + this._handles[handleId] = keys; + + for (var i = 0; i < added.length; i++) { + this._keys[added[i]] = (this._keys[added[i]] || 0) + 1; + } + for (var _i = 0; _i < removed.length; _i++) { + this._keys[removed[_i]]--; + } + + this._updateValue(keys); + } + + /** + * @param {string[]} keys Sorted array of strings that indicate + * a superset of possible keys. + * @private + */ + + }, { + key: "_updateValue", + value: function _updateValue() { + var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._allKeys; + + var handleCount = Object.keys(this._handles).length; + if (handleCount === 0) { + this._value = null; + } else { + this._value = []; + for (var i = 0; i < keys.length; i++) { + var count = this._keys[keys[i]]; + if (count === handleCount) { + this._value.push(keys[i]); + } + } + } + } + }, { + key: "clear", + value: function clear(handleId) { + if (typeof this._handles[handleId] === "undefined") { + return; + } + + var keys = this._handles[handleId]; + if (!keys) { + keys = []; + } + + for (var i = 0; i < keys.length; i++) { + this._keys[keys[i]]--; + } + delete this._handles[handleId]; + + this._updateValue(); + } + }, { + key: "value", + get: function get() { + return this._value; + } + }, { + key: "_allKeys", + get: function get() { + var allKeys = Object.keys(this._keys); + allKeys.sort(naturalComparator); + return allKeys; + } + }]); + + return FilterSet; +}(); + +exports.default = FilterSet; + +},{"./util":11}],4:[function(require,module,exports){ +(function (global){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +exports.default = group; + +var _var2 = require("./var"); + +var _var3 = _interopRequireDefault(_var2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +// Use a global so that multiple copies of crosstalk.js can be loaded and still +// have groups behave as singletons across all copies. +global.__crosstalk_groups = global.__crosstalk_groups || {}; +var groups = global.__crosstalk_groups; + +function group(groupName) { + if (groupName && typeof groupName === "string") { + if (!groups.hasOwnProperty(groupName)) { + groups[groupName] = new Group(groupName); + } + return groups[groupName]; + } else if ((typeof groupName === "undefined" ? "undefined" : _typeof(groupName)) === "object" && groupName._vars && groupName.var) { + // Appears to already be a group object + return groupName; + } else if (Array.isArray(groupName) && groupName.length == 1 && typeof groupName[0] === "string") { + return group(groupName[0]); + } else { + throw new Error("Invalid groupName argument"); + } +} + +var Group = function () { + function Group(name) { + _classCallCheck(this, Group); + + this.name = name; + this._vars = {}; + } + + _createClass(Group, [{ + key: "var", + value: function _var(name) { + if (!name || typeof name !== "string") { + throw new Error("Invalid var name"); + } + + if (!this._vars.hasOwnProperty(name)) this._vars[name] = new _var3.default(this, name); + return this._vars[name]; + } + }, { + key: "has", + value: function has(name) { + if (!name || typeof name !== "string") { + throw new Error("Invalid var name"); + } + + return this._vars.hasOwnProperty(name); + } + }]); + + return Group; +}(); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./var":12}],5:[function(require,module,exports){ +(function (global){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _group = require("./group"); + +var _group2 = _interopRequireDefault(_group); + +var _selection = require("./selection"); + +var _filter = require("./filter"); + +require("./input"); + +require("./input_selectize"); + +require("./input_checkboxgroup"); + +require("./input_slider"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var defaultGroup = (0, _group2.default)("default"); + +function var_(name) { + return defaultGroup.var(name); +} + +function has(name) { + return defaultGroup.has(name); +} + +if (global.Shiny) { + global.Shiny.addCustomMessageHandler("update-client-value", function (message) { + if (typeof message.group === "string") { + (0, _group2.default)(message.group).var(message.name).set(message.value); + } else { + var_(message.name).set(message.value); + } + }); +} + +var crosstalk = { + group: _group2.default, + var: var_, + has: has, + SelectionHandle: _selection.SelectionHandle, + FilterHandle: _filter.FilterHandle +}; + +/** + * @namespace crosstalk + */ +exports.default = crosstalk; + +global.crosstalk = crosstalk; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./filter":2,"./group":4,"./input":6,"./input_checkboxgroup":7,"./input_selectize":8,"./input_slider":9,"./selection":10}],6:[function(require,module,exports){ +(function (global){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.register = register; +var $ = global.jQuery; + +var bindings = {}; + +function register(reg) { + bindings[reg.className] = reg; + if (global.document && global.document.readyState !== "complete") { + $(function () { + bind(); + }); + } else if (global.document) { + setTimeout(bind, 100); + } +} + +function bind() { + Object.keys(bindings).forEach(function (className) { + var binding = bindings[className]; + $("." + binding.className).not(".crosstalk-input-bound").each(function (i, el) { + bindInstance(binding, el); + }); + }); +} + +// Escape jQuery identifier +function $escape(val) { + return val.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g, "\\$1"); +} + +function bindEl(el) { + var $el = $(el); + Object.keys(bindings).forEach(function (className) { + if ($el.hasClass(className) && !$el.hasClass("crosstalk-input-bound")) { + var binding = bindings[className]; + bindInstance(binding, el); + } + }); +} + +function bindInstance(binding, el) { + var jsonEl = $(el).find("script[type='application/json'][data-for='" + $escape(el.id) + "']"); + var data = JSON.parse(jsonEl[0].innerText); + + var instance = binding.factory(el, data); + $(el).data("crosstalk-instance", instance); + $(el).addClass("crosstalk-input-bound"); +} + +if (global.Shiny) { + (function () { + var inputBinding = new global.Shiny.InputBinding(); + var $ = global.jQuery; + $.extend(inputBinding, { + find: function find(scope) { + return $(scope).find(".crosstalk-input"); + }, + initialize: function initialize(el) { + if (!$(el).hasClass("crosstalk-input-bound")) { + bindEl(el); + } + }, + getId: function getId(el) { + return el.id; + }, + getValue: function getValue(el) {}, + setValue: function setValue(el, value) {}, + receiveMessage: function receiveMessage(el, data) {}, + subscribe: function subscribe(el, callback) { + $(el).data("crosstalk-instance").resume(); + }, + unsubscribe: function unsubscribe(el) { + $(el).data("crosstalk-instance").suspend(); + } + }); + global.Shiny.inputBindings.register(inputBinding, "crosstalk.inputBinding"); + })(); +} + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{}],7:[function(require,module,exports){ +(function (global){ +"use strict"; + +var _input = require("./input"); + +var input = _interopRequireWildcard(_input); + +var _filter = require("./filter"); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +var $ = global.jQuery; + +input.register({ + className: "crosstalk-input-checkboxgroup", + + factory: function factory(el, data) { + /* + * map: {"groupA": ["keyA", "keyB", ...], ...} + * group: "ct-groupname" + */ + var ctHandle = new _filter.FilterHandle(data.group); + + var lastKnownKeys = void 0; + var $el = $(el); + $el.on("change", "input[type='checkbox']", function () { + var checked = $el.find("input[type='checkbox']:checked"); + if (checked.length === 0) { + lastKnownKeys = null; + ctHandle.clear(); + } else { + (function () { + var keys = {}; + checked.each(function () { + data.map[this.value].forEach(function (key) { + keys[key] = true; + }); + }); + var keyArray = Object.keys(keys); + keyArray.sort(); + lastKnownKeys = keyArray; + ctHandle.set(keyArray); + })(); + } + }); + + return { + suspend: function suspend() { + ctHandle.clear(); + }, + resume: function resume() { + if (lastKnownKeys) ctHandle.set(lastKnownKeys); + } + }; + } +}); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./filter":2,"./input":6}],8:[function(require,module,exports){ +(function (global){ +"use strict"; + +var _input = require("./input"); + +var input = _interopRequireWildcard(_input); + +var _util = require("./util"); + +var util = _interopRequireWildcard(_util); + +var _filter = require("./filter"); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +var $ = global.jQuery; + +input.register({ + className: "crosstalk-input-select", + + factory: function factory(el, data) { + /* + * items: {value: [...], label: [...]} + * map: {"groupA": ["keyA", "keyB", ...], ...} + * group: "ct-groupname" + */ + + var first = [{ value: "", label: "(All)" }]; + var items = util.dataframeToD3(data.items); + var opts = { + options: first.concat(items), + valueField: "value", + labelField: "label", + searchField: "label" + }; + + var select = $(el).find("select")[0]; + + var selectize = $(select).selectize(opts)[0].selectize; + + var ctHandle = new _filter.FilterHandle(data.group); + + var lastKnownKeys = void 0; + selectize.on("change", function () { + if (selectize.items.length === 0) { + lastKnownKeys = null; + ctHandle.clear(); + } else { + (function () { + var keys = {}; + selectize.items.forEach(function (group) { + data.map[group].forEach(function (key) { + keys[key] = true; + }); + }); + var keyArray = Object.keys(keys); + keyArray.sort(); + lastKnownKeys = keyArray; + ctHandle.set(keyArray); + })(); + } + }); + + return { + suspend: function suspend() { + ctHandle.clear(); + }, + resume: function resume() { + if (lastKnownKeys) ctHandle.set(lastKnownKeys); + } + }; + } +}); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./filter":2,"./input":6,"./util":11}],9:[function(require,module,exports){ +(function (global){ +"use strict"; + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +var _input = require("./input"); + +var input = _interopRequireWildcard(_input); + +var _filter = require("./filter"); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +var $ = global.jQuery; +var strftime = global.strftime; + +input.register({ + className: "crosstalk-input-slider", + + factory: function factory(el, data) { + /* + * map: {"groupA": ["keyA", "keyB", ...], ...} + * group: "ct-groupname" + */ + var ctHandle = new _filter.FilterHandle(data.group); + + var opts = {}; + var $el = $(el).find("input"); + var dataType = $el.data("data-type"); + var timeFormat = $el.data("time-format"); + var timeFormatter = void 0; + + // Set up formatting functions + if (dataType === "date") { + timeFormatter = strftime.utc(); + opts.prettify = function (num) { + return timeFormatter(timeFormat, new Date(num)); + }; + } else if (dataType === "datetime") { + var timezone = $el.data("timezone"); + if (timezone) timeFormatter = strftime.timezone(timezone);else timeFormatter = strftime; + + opts.prettify = function (num) { + return timeFormatter(timeFormat, new Date(num)); + }; + } + + $el.ionRangeSlider(opts); + + function getValue() { + var result = $el.data("ionRangeSlider").result; + + // Function for converting numeric value from slider to appropriate type. + var convert = void 0; + var dataType = $el.data("data-type"); + if (dataType === "date") { + convert = function convert(val) { + return formatDateUTC(new Date(+val)); + }; + } else if (dataType === "datetime") { + convert = function convert(val) { + // Convert ms to s + return +val / 1000; + }; + } else { + convert = function convert(val) { + return +val; + }; + } + + if ($el.data("ionRangeSlider").options.type === "double") { + return [convert(result.from), convert(result.to)]; + } else { + return convert(result.from); + } + } + + var lastKnownKeys = null; + + $el.on("change.crosstalkSliderInput", function (event) { + if (!$el.data("updating") && !$el.data("animating")) { + var _getValue = getValue(), + _getValue2 = _slicedToArray(_getValue, 2), + from = _getValue2[0], + to = _getValue2[1]; + + var keys = []; + for (var i = 0; i < data.values.length; i++) { + var val = data.values[i]; + if (val >= from && val <= to) { + keys.push(data.keys[i]); + } + } + keys.sort(); + ctHandle.set(keys); + lastKnownKeys = keys; + } + }); + + // let $el = $(el); + // $el.on("change", "input[type="checkbox"]", function() { + // let checked = $el.find("input[type="checkbox"]:checked"); + // if (checked.length === 0) { + // ctHandle.clear(); + // } else { + // let keys = {}; + // checked.each(function() { + // data.map[this.value].forEach(function(key) { + // keys[key] = true; + // }); + // }); + // let keyArray = Object.keys(keys); + // keyArray.sort(); + // ctHandle.set(keyArray); + // } + // }); + + return { + suspend: function suspend() { + ctHandle.clear(); + }, + resume: function resume() { + if (lastKnownKeys) ctHandle.set(lastKnownKeys); + } + }; + } +}); + +// Convert a number to a string with leading zeros +function padZeros(n, digits) { + var str = n.toString(); + while (str.length < digits) { + str = "0" + str; + }return str; +} + +// Given a Date object, return a string in yyyy-mm-dd format, using the +// UTC date. This may be a day off from the date in the local time zone. +function formatDateUTC(date) { + if (date instanceof Date) { + return date.getUTCFullYear() + "-" + padZeros(date.getUTCMonth() + 1, 2) + "-" + padZeros(date.getUTCDate(), 2); + } else { + return null; + } +} + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./filter":2,"./input":6}],10:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.SelectionHandle = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _events = require("./events"); + +var _events2 = _interopRequireDefault(_events); + +var _group = require("./group"); + +var _group2 = _interopRequireDefault(_group); + +var _util = require("./util"); + +var util = _interopRequireWildcard(_util); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var SelectionHandle = exports.SelectionHandle = function () { + + /** + * @classdesc + * Use this class to read and write (and listen for changes to) the selection + * for a Crosstalk group. This is intended to be used for linked brushing. + * + * If two (or more) `SelectionHandle` instances in the same webpage share the + * same group name, they will share the same state. Setting the selection using + * one `SelectionHandle` instance will result in the `value` property instantly + * changing across the others, and `"change"` event listeners on all instances + * (including the one that initiated the sending) will fire. + * + * @param {string} [group] - The name of the Crosstalk group, or if none, + * null or undefined (or any other falsy value). This can be changed later + * via the [SelectionHandle#setGroup](#setGroup) method. + * @param {Object} [extraInfo] - An object whose properties will be copied to + * the event object whenever an event is emitted. + */ + function SelectionHandle() { + var group = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + var extraInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + + _classCallCheck(this, SelectionHandle); + + this._eventRelay = new _events2.default(); + this._emitter = new util.SubscriptionTracker(this._eventRelay); + + // Name of the group we're currently tracking, if any. Can change over time. + this._group = null; + // The Var we're currently tracking, if any. Can change over time. + this._var = null; + // The event handler subscription we currently have on var.on("change"). + this._varOnChangeSub = null; + + this._extraInfo = util.extend({ sender: this }, extraInfo); + + this.setGroup(group); + } + + /** + * Changes the Crosstalk group membership of this SelectionHandle. The group + * being switched away from (if any) will not have its selection value + * modified as a result of calling `setGroup`, even if this handle was the + * most recent handle to set the selection of the group. + * + * The group being switched to (if any) will also not have its selection value + * modified as a result of calling `setGroup`. If you want to set the + * selection value of the new group, call `set` explicitly. + * + * @param {string} group - The name of the Crosstalk group, or null (or + * undefined) to clear the group. + */ + + + _createClass(SelectionHandle, [{ + key: "setGroup", + value: function setGroup(group) { + var _this = this; + + // If group is unchanged, do nothing + if (this._group === group) return; + // Treat null, undefined, and other falsy values the same + if (!this._group && !group) return; + + if (this._var) { + this._var.off("change", this._varOnChangeSub); + this._var = null; + this._varOnChangeSub = null; + } + + this._group = group; + + if (group) { + this._var = (0, _group2.default)(group).var("selection"); + var sub = this._var.on("change", function (e) { + _this._eventRelay.trigger("change", e, _this); + }); + this._varOnChangeSub = sub; + } + } + + /** + * Retrieves the current selection for the group represented by this + * `SelectionHandle`. + * + * - If no selection is active, then this value will be falsy. + * - If a selection is active, but no data points are selected, then this + * value will be an empty array. + * - If a selection is active, and data points are selected, then the keys + * of the selected data points will be present in the array. + */ + + }, { + key: "_mergeExtraInfo", + + + /** + * Combines the given `extraInfo` (if any) with the handle's default + * `_extraInfo` (if any). + * @private + */ + value: function _mergeExtraInfo(extraInfo) { + // Important incidental effect: shallow clone is returned + return util.extend({}, this._extraInfo ? this._extraInfo : null, extraInfo ? extraInfo : null); + } + + /** + * Overwrites the current selection for the group, and raises the `"change"` + * event among all of the group's '`SelectionHandle` instances (including + * this one). + * + * @fires SelectionHandle#change + * @param {string[]} selectedKeys - Falsy, empty array, or array of keys (see + * {@link SelectionHandle#value}). + * @param {Object} [extraInfo] - Extra properties to be included on the event + * object that's passed to listeners (in addition to any options that were + * passed into the `SelectionHandle` constructor). + */ + + }, { + key: "set", + value: function set(selectedKeys, extraInfo) { + if (this._var) this._var.set(selectedKeys, this._mergeExtraInfo(extraInfo)); + } + + /** + * Overwrites the current selection for the group, and raises the `"change"` + * event among all of the group's '`SelectionHandle` instances (including + * this one). + * + * @fires SelectionHandle#change + * @param {Object} [extraInfo] - Extra properties to be included on the event + * object that's passed to listeners (in addition to any that were passed + * into the `SelectionHandle` constructor). + */ + + }, { + key: "clear", + value: function clear(extraInfo) { + if (this._var) this.set(void 0, this._mergeExtraInfo(extraInfo)); + } + + /** + * Subscribes to events on this `SelectionHandle`. + * + * @param {string} eventType - Indicates the type of events to listen to. + * Currently, only `"change"` is supported. + * @param {SelectionHandle~listener} listener - The callback function that + * will be invoked when the event occurs. + * @return {string} - A token to pass to {@link SelectionHandle#off} to cancel + * this subscription. + */ + + }, { + key: "on", + value: function on(eventType, listener) { + return this._emitter.on(eventType, listener); + } + + /** + * Cancels event subscriptions created by {@link SelectionHandle#on}. + * + * @param {string} eventType - The type of event to unsubscribe. + * @param {string|SelectionHandle~listener} listener - Either the callback + * function previously passed into {@link SelectionHandle#on}, or the + * string that was returned from {@link SelectionHandle#on}. + */ + + }, { + key: "off", + value: function off(eventType, listener) { + return this._emitter.off(eventType, listener); + } + + /** + * Shuts down the `SelectionHandle` object. + * + * Removes all event listeners that were added through this handle. + */ + + }, { + key: "close", + value: function close() { + this._emitter.removeAllListeners(); + this.setGroup(null); + } + + /** + * @callback SelectionHandle~listener + * @param {Object} event - An object containing details of the event. For + * `"change"` events, this includes the properties `value` (the new + * value of the selection, or `undefined` if no selection is active), + * `oldValue` (the previous value of the selection), and `sender` (the + * `SelectionHandle` instance that made the change). + */ + + /** + * @event SelectionHandle#change + * @type {object} + * @property {object} value - The new value of the selection, or `undefined` + * if no selection is active. + * @property {object} oldValue - The previous value of the selection. + * @property {SelectionHandle} sender - The `SelectionHandle` instance that + * changed the value. + */ + + }, { + key: "value", + get: function get() { + return this._var ? this._var.get() : null; + } + }]); + + return SelectionHandle; +}(); + +},{"./events":1,"./group":4,"./util":11}],11:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +exports.extend = extend; +exports.checkSorted = checkSorted; +exports.diffSortedLists = diffSortedLists; +exports.dataframeToD3 = dataframeToD3; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function extend(target) { + for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + sources[_key - 1] = arguments[_key]; + } + + for (var i = 0; i < sources.length; i++) { + var src = sources[i]; + if (typeof src === "undefined" || src === null) continue; + + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + } + return target; +} + +function checkSorted(list) { + for (var i = 1; i < list.length; i++) { + if (list[i] <= list[i - 1]) { + throw new Error("List is not sorted or contains duplicate"); + } + } +} + +function diffSortedLists(a, b) { + var i_a = 0; + var i_b = 0; + + if (!a) a = []; + if (!b) b = []; + + var a_only = []; + var b_only = []; + + checkSorted(a); + checkSorted(b); + + while (i_a < a.length && i_b < b.length) { + if (a[i_a] === b[i_b]) { + i_a++; + i_b++; + } else if (a[i_a] < b[i_b]) { + a_only.push(a[i_a++]); + } else { + b_only.push(b[i_b++]); + } + } + + if (i_a < a.length) a_only = a_only.concat(a.slice(i_a)); + if (i_b < b.length) b_only = b_only.concat(b.slice(i_b)); + return { + removed: a_only, + added: b_only + }; +} + +// Convert from wide: { colA: [1,2,3], colB: [4,5,6], ... } +// to long: [ {colA: 1, colB: 4}, {colA: 2, colB: 5}, ... ] +function dataframeToD3(df) { + var names = []; + var length = void 0; + for (var name in df) { + if (df.hasOwnProperty(name)) names.push(name); + if (_typeof(df[name]) !== "object" || typeof df[name].length === "undefined") { + throw new Error("All fields must be arrays"); + } else if (typeof length !== "undefined" && length !== df[name].length) { + throw new Error("All fields must be arrays of the same length"); + } + length = df[name].length; + } + var results = []; + var item = void 0; + for (var row = 0; row < length; row++) { + item = {}; + for (var col = 0; col < names.length; col++) { + item[names[col]] = df[names[col]][row]; + } + results.push(item); + } + return results; +} + +/** + * Keeps track of all event listener additions/removals and lets all active + * listeners be removed with a single operation. + * + * @private + */ + +var SubscriptionTracker = exports.SubscriptionTracker = function () { + function SubscriptionTracker(emitter) { + _classCallCheck(this, SubscriptionTracker); + + this._emitter = emitter; + this._subs = {}; + } + + _createClass(SubscriptionTracker, [{ + key: "on", + value: function on(eventType, listener) { + var sub = this._emitter.on(eventType, listener); + this._subs[sub] = eventType; + return sub; + } + }, { + key: "off", + value: function off(eventType, listener) { + var sub = this._emitter.off(eventType, listener); + if (sub) { + delete this._subs[sub]; + } + return sub; + } + }, { + key: "removeAllListeners", + value: function removeAllListeners() { + var _this = this; + + var current_subs = this._subs; + this._subs = {}; + Object.keys(current_subs).forEach(function (sub) { + _this._emitter.off(current_subs[sub], sub); + }); + } + }]); + + return SubscriptionTracker; +}(); + +},{}],12:[function(require,module,exports){ +(function (global){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _events = require("./events"); + +var _events2 = _interopRequireDefault(_events); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Var = function () { + function Var(group, name, /*optional*/value) { + _classCallCheck(this, Var); + + this._group = group; + this._name = name; + this._value = value; + this._events = new _events2.default(); + } + + _createClass(Var, [{ + key: "get", + value: function get() { + return this._value; + } + }, { + key: "set", + value: function set(value, /*optional*/event) { + if (this._value === value) { + // Do nothing; the value hasn't changed + return; + } + var oldValue = this._value; + this._value = value; + // Alert JavaScript listeners that the value has changed + var evt = {}; + if (event && (typeof event === "undefined" ? "undefined" : _typeof(event)) === "object") { + for (var k in event) { + if (event.hasOwnProperty(k)) evt[k] = event[k]; + } + } + evt.oldValue = oldValue; + evt.value = value; + this._events.trigger("change", evt, this); + + // TODO: Make this extensible, to let arbitrary back-ends know that + // something has changed + if (global.Shiny && global.Shiny.onInputChange) { + global.Shiny.onInputChange(".clientValue-" + (this._group.name !== null ? this._group.name + "-" : "") + this._name, typeof value === "undefined" ? null : value); + } + } + }, { + key: "on", + value: function on(eventType, listener) { + return this._events.on(eventType, listener); + } + }, { + key: "off", + value: function off(eventType, listener) { + return this._events.off(eventType, listener); + } + }]); + + return Var; +}(); + +exports.default = Var; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./events":1}]},{},[5]) +//# sourceMappingURL=crosstalk.js.map diff --git a/docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.js.map b/docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.js.map new file mode 100644 index 00000000..508b24fa --- /dev/null +++ b/docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.js.map @@ -0,0 +1,37 @@ +{ + "version": 3, + "sources": [ + "node_modules/browser-pack/_prelude.js", + "javascript/src/events.js", + "javascript/src/filter.js", + "javascript/src/filterset.js", + "javascript/src/group.js", + "javascript/src/index.js", + "javascript/src/input.js", + "javascript/src/input_checkboxgroup.js", + "javascript/src/input_selectize.js", + "javascript/src/input_slider.js", + "javascript/src/selection.js", + "javascript/src/util.js", + "javascript/src/var.js" + ], + "names": [], + "mappings": "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", + "file": "generated.js", + "sourceRoot": "", + "sourcesContent": [ + "(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o {\n this._eventRelay.trigger(\"change\", e, this);\n });\n this._varOnChangeSub = sub;\n }\n }\n\n /**\n * Combine the given `extraInfo` (if any) with the handle's default\n * `_extraInfo` (if any).\n * @private\n */\n _mergeExtraInfo(extraInfo) {\n return util.extend({},\n this._extraInfo ? this._extraInfo : null,\n extraInfo ? extraInfo : null);\n }\n\n /**\n * Close the handle. This clears this handle's contribution to the filter set,\n * and unsubscribes all event listeners.\n */\n close() {\n this._emitter.removeAllListeners();\n this.clear();\n this.setGroup(null);\n }\n\n /**\n * Clear this handle's contribution to the filter set.\n *\n * @param {Object} [extraInfo] - Extra properties to be included on the event\n * object that's passed to listeners (in addition to any options that were\n * passed into the `FilterHandle` constructor).\n */\n clear(extraInfo) {\n if (!this._filterSet)\n return;\n this._filterSet.clear(this._id);\n this._onChange(extraInfo);\n }\n\n /**\n * Set this handle's contribution to the filter set. This array should consist\n * of the keys of the rows that _should_ be displayed; any keys that are not\n * present in the array will be considered _filtered out_. Note that multiple\n * `FilterHandle` instances in the group may each contribute an array of keys,\n * and only those keys that appear in _all_ of the arrays make it through the\n * filter.\n *\n * @param {string[]} keys - Empty array, or array of keys. To clear the\n * filter, don't pass an empty array; instead, use the\n * {@link FilterHandle#clear} method.\n * @param {Object} [extraInfo] - Extra properties to be included on the event\n * object that's passed to listeners (in addition to any options that were\n * passed into the `FilterHandle` constructor).\n */\n set(keys, extraInfo) {\n if (!this._filterSet)\n return;\n this._filterSet.update(this._id, keys);\n this._onChange(extraInfo);\n }\n\n /**\n * @return {string[]|null} - Either: 1) an array of keys that made it through\n * all of the `FilterHandle` instances, or, 2) `null`, which means no filter\n * is being applied (all data should be displayed).\n */\n get filteredKeys() {\n return this._filterSet ? this._filterSet.value : null;\n }\n\n /**\n * Subscribe to events on this `FilterHandle`.\n *\n * @param {string} eventType - Indicates the type of events to listen to.\n * Currently, only `\"change\"` is supported.\n * @param {FilterHandle~listener} listener - The callback function that\n * will be invoked when the event occurs.\n * @return {string} - A token to pass to {@link FilterHandle#off} to cancel\n * this subscription.\n */\n on(eventType, listener) {\n return this._emitter.on(eventType, listener);\n }\n\n /**\n * Cancel event subscriptions created by {@link FilterHandle#on}.\n *\n * @param {string} eventType - The type of event to unsubscribe.\n * @param {string|FilterHandle~listener} listener - Either the callback\n * function previously passed into {@link FilterHandle#on}, or the\n * string that was returned from {@link FilterHandle#on}.\n */\n off(eventType, listener) {\n return this._emitter.off(eventType, listener);\n }\n\n _onChange(extraInfo) {\n if (!this._filterSet)\n return;\n this._filterVar.set(this._filterSet.value, this._mergeExtraInfo(extraInfo));\n }\n\n /**\n * @callback FilterHandle~listener\n * @param {Object} event - An object containing details of the event. For\n * `\"change\"` events, this includes the properties `value` (the new\n * value of the filter set, or `null` if no filter set is active),\n * `oldValue` (the previous value of the filter set), and `sender` (the\n * `FilterHandle` instance that made the change).\n */\n\n /**\n * @event FilterHandle#change\n * @type {object}\n * @property {object} value - The new value of the filter set, or `null`\n * if no filter set is active.\n * @property {object} oldValue - The previous value of the filter set.\n * @property {FilterHandle} sender - The `FilterHandle` instance that\n * changed the value.\n */\n}\n", + "import { diffSortedLists } from \"./util\";\n\nfunction naturalComparator(a, b) {\n if (a === b) {\n return 0;\n } else if (a < b) {\n return -1;\n } else if (a > b) {\n return 1;\n }\n}\n\n/**\n * @private\n */\nexport default class FilterSet {\n constructor() {\n this.reset();\n }\n\n reset() {\n // Key: handle ID, Value: array of selected keys, or null\n this._handles = {};\n // Key: key string, Value: count of handles that include it\n this._keys = {};\n this._value = null;\n this._activeHandles = 0;\n }\n\n get value() {\n return this._value;\n }\n\n update(handleId, keys) {\n if (keys !== null) {\n keys = keys.slice(0); // clone before sorting\n keys.sort(naturalComparator);\n }\n\n let {added, removed} = diffSortedLists(this._handles[handleId], keys);\n this._handles[handleId] = keys;\n\n for (let i = 0; i < added.length; i++) {\n this._keys[added[i]] = (this._keys[added[i]] || 0) + 1;\n }\n for (let i = 0; i < removed.length; i++) {\n this._keys[removed[i]]--;\n }\n\n this._updateValue(keys);\n }\n\n /**\n * @param {string[]} keys Sorted array of strings that indicate\n * a superset of possible keys.\n * @private\n */\n _updateValue(keys = this._allKeys) {\n let handleCount = Object.keys(this._handles).length;\n if (handleCount === 0) {\n this._value = null;\n } else {\n this._value = [];\n for (let i = 0; i < keys.length; i++) {\n let count = this._keys[keys[i]];\n if (count === handleCount) {\n this._value.push(keys[i]);\n }\n }\n }\n }\n\n clear(handleId) {\n if (typeof(this._handles[handleId]) === \"undefined\") {\n return;\n }\n\n let keys = this._handles[handleId];\n if (!keys) {\n keys = [];\n }\n\n for (let i = 0; i < keys.length; i++) {\n this._keys[keys[i]]--;\n }\n delete this._handles[handleId];\n\n this._updateValue();\n }\n\n get _allKeys() {\n let allKeys = Object.keys(this._keys);\n allKeys.sort(naturalComparator);\n return allKeys;\n }\n}\n", + "import Var from \"./var\";\n\n// Use a global so that multiple copies of crosstalk.js can be loaded and still\n// have groups behave as singletons across all copies.\nglobal.__crosstalk_groups = global.__crosstalk_groups || {};\nlet groups = global.__crosstalk_groups;\n\nexport default function group(groupName) {\n if (groupName && typeof(groupName) === \"string\") {\n if (!groups.hasOwnProperty(groupName)) {\n groups[groupName] = new Group(groupName);\n }\n return groups[groupName];\n } else if (typeof(groupName) === \"object\" && groupName._vars && groupName.var) {\n // Appears to already be a group object\n return groupName;\n } else if (Array.isArray(groupName) &&\n groupName.length == 1 &&\n typeof(groupName[0]) === \"string\") {\n return group(groupName[0]);\n } else {\n throw new Error(\"Invalid groupName argument\");\n }\n}\n\nclass Group {\n constructor(name) {\n this.name = name;\n this._vars = {};\n }\n\n var(name) {\n if (!name || typeof(name) !== \"string\") {\n throw new Error(\"Invalid var name\");\n }\n\n if (!this._vars.hasOwnProperty(name))\n this._vars[name] = new Var(this, name);\n return this._vars[name];\n }\n\n has(name) {\n if (!name || typeof(name) !== \"string\") {\n throw new Error(\"Invalid var name\");\n }\n\n return this._vars.hasOwnProperty(name);\n }\n}\n", + "import group from \"./group\";\nimport { SelectionHandle } from \"./selection\";\nimport { FilterHandle } from \"./filter\";\nimport \"./input\";\nimport \"./input_selectize\";\nimport \"./input_checkboxgroup\";\nimport \"./input_slider\";\n\nconst defaultGroup = group(\"default\");\n\nfunction var_(name) {\n return defaultGroup.var(name);\n}\n\nfunction has(name) {\n return defaultGroup.has(name);\n}\n\nif (global.Shiny) {\n global.Shiny.addCustomMessageHandler(\"update-client-value\", function(message) {\n if (typeof(message.group) === \"string\") {\n group(message.group).var(message.name).set(message.value);\n } else {\n var_(message.name).set(message.value);\n }\n });\n}\n\nconst crosstalk = {\n group: group,\n var: var_,\n has: has,\n SelectionHandle: SelectionHandle,\n FilterHandle: FilterHandle\n};\n\n/**\n * @namespace crosstalk\n */\nexport default crosstalk;\nglobal.crosstalk = crosstalk;\n", + "let $ = global.jQuery;\n\nlet bindings = {};\n\nexport function register(reg) {\n bindings[reg.className] = reg;\n if (global.document && global.document.readyState !== \"complete\") {\n $(() => {\n bind();\n });\n } else if (global.document) {\n setTimeout(bind, 100);\n }\n}\n\nfunction bind() {\n Object.keys(bindings).forEach(function(className) {\n let binding = bindings[className];\n $(\".\" + binding.className).not(\".crosstalk-input-bound\").each(function(i, el) {\n bindInstance(binding, el);\n });\n });\n}\n\n// Escape jQuery identifier\nfunction $escape(val) {\n return val.replace(/([!\"#$%&'()*+,.\\/:;<=>?@\\[\\\\\\]^`{|}~])/g, \"\\\\$1\");\n}\n\nfunction bindEl(el) {\n let $el = $(el);\n Object.keys(bindings).forEach(function(className) {\n if ($el.hasClass(className) && !$el.hasClass(\"crosstalk-input-bound\")) {\n let binding = bindings[className];\n bindInstance(binding, el);\n }\n });\n}\n\nfunction bindInstance(binding, el) {\n let jsonEl = $(el).find(\"script[type='application/json'][data-for='\" + $escape(el.id) + \"']\");\n let data = JSON.parse(jsonEl[0].innerText);\n\n let instance = binding.factory(el, data);\n $(el).data(\"crosstalk-instance\", instance);\n $(el).addClass(\"crosstalk-input-bound\");\n}\n\nif (global.Shiny) {\n let inputBinding = new global.Shiny.InputBinding();\n let $ = global.jQuery;\n $.extend(inputBinding, {\n find: function(scope) {\n return $(scope).find(\".crosstalk-input\");\n },\n initialize: function(el) {\n if (!$(el).hasClass(\"crosstalk-input-bound\")) {\n bindEl(el);\n }\n },\n getId: function(el) {\n return el.id;\n },\n getValue: function(el) {\n\n },\n setValue: function(el, value) {\n\n },\n receiveMessage: function(el, data) {\n\n },\n subscribe: function(el, callback) {\n $(el).data(\"crosstalk-instance\").resume();\n },\n unsubscribe: function(el) {\n $(el).data(\"crosstalk-instance\").suspend();\n }\n });\n global.Shiny.inputBindings.register(inputBinding, \"crosstalk.inputBinding\");\n}\n", + "import * as input from \"./input\";\nimport { FilterHandle } from \"./filter\";\n\nlet $ = global.jQuery;\n\ninput.register({\n className: \"crosstalk-input-checkboxgroup\",\n\n factory: function(el, data) {\n /*\n * map: {\"groupA\": [\"keyA\", \"keyB\", ...], ...}\n * group: \"ct-groupname\"\n */\n let ctHandle = new FilterHandle(data.group);\n\n let lastKnownKeys;\n let $el = $(el);\n $el.on(\"change\", \"input[type='checkbox']\", function() {\n let checked = $el.find(\"input[type='checkbox']:checked\");\n if (checked.length === 0) {\n lastKnownKeys = null;\n ctHandle.clear();\n } else {\n let keys = {};\n checked.each(function() {\n data.map[this.value].forEach(function(key) {\n keys[key] = true;\n });\n });\n let keyArray = Object.keys(keys);\n keyArray.sort();\n lastKnownKeys = keyArray;\n ctHandle.set(keyArray);\n }\n });\n\n return {\n suspend: function() {\n ctHandle.clear();\n },\n resume: function() {\n if (lastKnownKeys)\n ctHandle.set(lastKnownKeys);\n }\n };\n }\n});\n", + "import * as input from \"./input\";\nimport * as util from \"./util\";\nimport { FilterHandle } from \"./filter\";\n\nlet $ = global.jQuery;\n\ninput.register({\n className: \"crosstalk-input-select\",\n\n factory: function(el, data) {\n /*\n * items: {value: [...], label: [...]}\n * map: {\"groupA\": [\"keyA\", \"keyB\", ...], ...}\n * group: \"ct-groupname\"\n */\n\n let first = [{value: \"\", label: \"(All)\"}];\n let items = util.dataframeToD3(data.items);\n let opts = {\n options: first.concat(items),\n valueField: \"value\",\n labelField: \"label\",\n searchField: \"label\"\n };\n\n let select = $(el).find(\"select\")[0];\n\n let selectize = $(select).selectize(opts)[0].selectize;\n\n let ctHandle = new FilterHandle(data.group);\n\n let lastKnownKeys;\n selectize.on(\"change\", function() {\n if (selectize.items.length === 0) {\n lastKnownKeys = null;\n ctHandle.clear();\n } else {\n let keys = {};\n selectize.items.forEach(function(group) {\n data.map[group].forEach(function(key) {\n keys[key] = true;\n });\n });\n let keyArray = Object.keys(keys);\n keyArray.sort();\n lastKnownKeys = keyArray;\n ctHandle.set(keyArray);\n }\n });\n\n return {\n suspend: function() {\n ctHandle.clear();\n },\n resume: function() {\n if (lastKnownKeys)\n ctHandle.set(lastKnownKeys);\n }\n };\n }\n});\n", + "import * as input from \"./input\";\nimport { FilterHandle } from \"./filter\";\n\nlet $ = global.jQuery;\nlet strftime = global.strftime;\n\ninput.register({\n className: \"crosstalk-input-slider\",\n\n factory: function(el, data) {\n /*\n * map: {\"groupA\": [\"keyA\", \"keyB\", ...], ...}\n * group: \"ct-groupname\"\n */\n let ctHandle = new FilterHandle(data.group);\n\n let opts = {};\n let $el = $(el).find(\"input\");\n let dataType = $el.data(\"data-type\");\n let timeFormat = $el.data(\"time-format\");\n let timeFormatter;\n\n // Set up formatting functions\n if (dataType === \"date\") {\n timeFormatter = strftime.utc();\n opts.prettify = function(num) {\n return timeFormatter(timeFormat, new Date(num));\n };\n\n } else if (dataType === \"datetime\") {\n let timezone = $el.data(\"timezone\");\n if (timezone)\n timeFormatter = strftime.timezone(timezone);\n else\n timeFormatter = strftime;\n\n opts.prettify = function(num) {\n return timeFormatter(timeFormat, new Date(num));\n };\n }\n\n $el.ionRangeSlider(opts);\n\n function getValue() {\n let result = $el.data(\"ionRangeSlider\").result;\n\n // Function for converting numeric value from slider to appropriate type.\n let convert;\n let dataType = $el.data(\"data-type\");\n if (dataType === \"date\") {\n convert = function(val) {\n return formatDateUTC(new Date(+val));\n };\n } else if (dataType === \"datetime\") {\n convert = function(val) {\n // Convert ms to s\n return +val / 1000;\n };\n } else {\n convert = function(val) { return +val; };\n }\n\n if ($el.data(\"ionRangeSlider\").options.type === \"double\") {\n return [convert(result.from), convert(result.to)];\n } else {\n return convert(result.from);\n }\n }\n\n let lastKnownKeys = null;\n\n $el.on(\"change.crosstalkSliderInput\", function(event) {\n if (!$el.data(\"updating\") && !$el.data(\"animating\")) {\n let [from, to] = getValue();\n let keys = [];\n for (let i = 0; i < data.values.length; i++) {\n let val = data.values[i];\n if (val >= from && val <= to) {\n keys.push(data.keys[i]);\n }\n }\n keys.sort();\n ctHandle.set(keys);\n lastKnownKeys = keys;\n }\n });\n\n\n // let $el = $(el);\n // $el.on(\"change\", \"input[type=\"checkbox\"]\", function() {\n // let checked = $el.find(\"input[type=\"checkbox\"]:checked\");\n // if (checked.length === 0) {\n // ctHandle.clear();\n // } else {\n // let keys = {};\n // checked.each(function() {\n // data.map[this.value].forEach(function(key) {\n // keys[key] = true;\n // });\n // });\n // let keyArray = Object.keys(keys);\n // keyArray.sort();\n // ctHandle.set(keyArray);\n // }\n // });\n\n return {\n suspend: function() {\n ctHandle.clear();\n },\n resume: function() {\n if (lastKnownKeys)\n ctHandle.set(lastKnownKeys);\n }\n };\n }\n});\n\n\n// Convert a number to a string with leading zeros\nfunction padZeros(n, digits) {\n let str = n.toString();\n while (str.length < digits)\n str = \"0\" + str;\n return str;\n}\n\n// Given a Date object, return a string in yyyy-mm-dd format, using the\n// UTC date. This may be a day off from the date in the local time zone.\nfunction formatDateUTC(date) {\n if (date instanceof Date) {\n return date.getUTCFullYear() + \"-\" +\n padZeros(date.getUTCMonth()+1, 2) + \"-\" +\n padZeros(date.getUTCDate(), 2);\n\n } else {\n return null;\n }\n}\n", + "import Events from \"./events\";\nimport grp from \"./group\";\nimport * as util from \"./util\";\n\nexport class SelectionHandle {\n\n /**\n * @classdesc\n * Use this class to read and write (and listen for changes to) the selection\n * for a Crosstalk group. This is intended to be used for linked brushing.\n *\n * If two (or more) `SelectionHandle` instances in the same webpage share the\n * same group name, they will share the same state. Setting the selection using\n * one `SelectionHandle` instance will result in the `value` property instantly\n * changing across the others, and `\"change\"` event listeners on all instances\n * (including the one that initiated the sending) will fire.\n *\n * @param {string} [group] - The name of the Crosstalk group, or if none,\n * null or undefined (or any other falsy value). This can be changed later\n * via the [SelectionHandle#setGroup](#setGroup) method.\n * @param {Object} [extraInfo] - An object whose properties will be copied to\n * the event object whenever an event is emitted.\n */\n constructor(group = null, extraInfo = null) {\n this._eventRelay = new Events();\n this._emitter = new util.SubscriptionTracker(this._eventRelay);\n\n // Name of the group we're currently tracking, if any. Can change over time.\n this._group = null;\n // The Var we're currently tracking, if any. Can change over time.\n this._var = null;\n // The event handler subscription we currently have on var.on(\"change\").\n this._varOnChangeSub = null;\n\n this._extraInfo = util.extend({ sender: this }, extraInfo);\n\n this.setGroup(group);\n }\n\n /**\n * Changes the Crosstalk group membership of this SelectionHandle. The group\n * being switched away from (if any) will not have its selection value\n * modified as a result of calling `setGroup`, even if this handle was the\n * most recent handle to set the selection of the group.\n *\n * The group being switched to (if any) will also not have its selection value\n * modified as a result of calling `setGroup`. If you want to set the\n * selection value of the new group, call `set` explicitly.\n *\n * @param {string} group - The name of the Crosstalk group, or null (or\n * undefined) to clear the group.\n */\n setGroup(group) {\n // If group is unchanged, do nothing\n if (this._group === group)\n return;\n // Treat null, undefined, and other falsy values the same\n if (!this._group && !group)\n return;\n\n if (this._var) {\n this._var.off(\"change\", this._varOnChangeSub);\n this._var = null;\n this._varOnChangeSub = null;\n }\n\n this._group = group;\n\n if (group) {\n this._var = grp(group).var(\"selection\");\n let sub = this._var.on(\"change\", (e) => {\n this._eventRelay.trigger(\"change\", e, this);\n });\n this._varOnChangeSub = sub;\n }\n }\n\n /**\n * Retrieves the current selection for the group represented by this\n * `SelectionHandle`.\n *\n * - If no selection is active, then this value will be falsy.\n * - If a selection is active, but no data points are selected, then this\n * value will be an empty array.\n * - If a selection is active, and data points are selected, then the keys\n * of the selected data points will be present in the array.\n */\n get value() {\n return this._var ? this._var.get() : null;\n }\n\n /**\n * Combines the given `extraInfo` (if any) with the handle's default\n * `_extraInfo` (if any).\n * @private\n */\n _mergeExtraInfo(extraInfo) {\n // Important incidental effect: shallow clone is returned\n return util.extend({},\n this._extraInfo ? this._extraInfo : null,\n extraInfo ? extraInfo : null);\n }\n\n /**\n * Overwrites the current selection for the group, and raises the `\"change\"`\n * event among all of the group's '`SelectionHandle` instances (including\n * this one).\n *\n * @fires SelectionHandle#change\n * @param {string[]} selectedKeys - Falsy, empty array, or array of keys (see\n * {@link SelectionHandle#value}).\n * @param {Object} [extraInfo] - Extra properties to be included on the event\n * object that's passed to listeners (in addition to any options that were\n * passed into the `SelectionHandle` constructor).\n */\n set(selectedKeys, extraInfo) {\n if (this._var)\n this._var.set(selectedKeys, this._mergeExtraInfo(extraInfo));\n }\n\n /**\n * Overwrites the current selection for the group, and raises the `\"change\"`\n * event among all of the group's '`SelectionHandle` instances (including\n * this one).\n *\n * @fires SelectionHandle#change\n * @param {Object} [extraInfo] - Extra properties to be included on the event\n * object that's passed to listeners (in addition to any that were passed\n * into the `SelectionHandle` constructor).\n */\n clear(extraInfo) {\n if (this._var)\n this.set(void 0, this._mergeExtraInfo(extraInfo));\n }\n\n /**\n * Subscribes to events on this `SelectionHandle`.\n *\n * @param {string} eventType - Indicates the type of events to listen to.\n * Currently, only `\"change\"` is supported.\n * @param {SelectionHandle~listener} listener - The callback function that\n * will be invoked when the event occurs.\n * @return {string} - A token to pass to {@link SelectionHandle#off} to cancel\n * this subscription.\n */\n on(eventType, listener) {\n return this._emitter.on(eventType, listener);\n }\n\n /**\n * Cancels event subscriptions created by {@link SelectionHandle#on}.\n *\n * @param {string} eventType - The type of event to unsubscribe.\n * @param {string|SelectionHandle~listener} listener - Either the callback\n * function previously passed into {@link SelectionHandle#on}, or the\n * string that was returned from {@link SelectionHandle#on}.\n */\n off(eventType, listener) {\n return this._emitter.off(eventType, listener);\n }\n\n /**\n * Shuts down the `SelectionHandle` object.\n *\n * Removes all event listeners that were added through this handle.\n */\n close() {\n this._emitter.removeAllListeners();\n this.setGroup(null);\n }\n\n /**\n * @callback SelectionHandle~listener\n * @param {Object} event - An object containing details of the event. For\n * `\"change\"` events, this includes the properties `value` (the new\n * value of the selection, or `undefined` if no selection is active),\n * `oldValue` (the previous value of the selection), and `sender` (the\n * `SelectionHandle` instance that made the change).\n */\n\n /**\n * @event SelectionHandle#change\n * @type {object}\n * @property {object} value - The new value of the selection, or `undefined`\n * if no selection is active.\n * @property {object} oldValue - The previous value of the selection.\n * @property {SelectionHandle} sender - The `SelectionHandle` instance that\n * changed the value.\n */\n}\n", + "export function extend(target, ...sources) {\n for (let i = 0; i < sources.length; i++) {\n let src = sources[i];\n if (typeof(src) === \"undefined\" || src === null)\n continue;\n\n for (let key in src) {\n if (src.hasOwnProperty(key)) {\n target[key] = src[key];\n }\n }\n }\n return target;\n}\n\nexport function checkSorted(list) {\n for (let i = 1; i < list.length; i++) {\n if (list[i] <= list[i-1]) {\n throw new Error(\"List is not sorted or contains duplicate\");\n }\n }\n}\n\nexport function diffSortedLists(a, b) {\n let i_a = 0;\n let i_b = 0;\n\n if (!a) a = [];\n if (!b) b = [];\n\n let a_only = [];\n let b_only = [];\n\n checkSorted(a);\n checkSorted(b);\n\n while (i_a < a.length && i_b < b.length) {\n if (a[i_a] === b[i_b]) {\n i_a++;\n i_b++;\n } else if (a[i_a] < b[i_b]) {\n a_only.push(a[i_a++]);\n } else {\n b_only.push(b[i_b++]);\n }\n }\n\n if (i_a < a.length)\n a_only = a_only.concat(a.slice(i_a));\n if (i_b < b.length)\n b_only = b_only.concat(b.slice(i_b));\n return {\n removed: a_only,\n added: b_only\n };\n}\n\n// Convert from wide: { colA: [1,2,3], colB: [4,5,6], ... }\n// to long: [ {colA: 1, colB: 4}, {colA: 2, colB: 5}, ... ]\nexport function dataframeToD3(df) {\n let names = [];\n let length;\n for (let name in df) {\n if (df.hasOwnProperty(name))\n names.push(name);\n if (typeof(df[name]) !== \"object\" || typeof(df[name].length) === \"undefined\") {\n throw new Error(\"All fields must be arrays\");\n } else if (typeof(length) !== \"undefined\" && length !== df[name].length) {\n throw new Error(\"All fields must be arrays of the same length\");\n }\n length = df[name].length;\n }\n let results = [];\n let item;\n for (let row = 0; row < length; row++) {\n item = {};\n for (let col = 0; col < names.length; col++) {\n item[names[col]] = df[names[col]][row];\n }\n results.push(item);\n }\n return results;\n}\n\n/**\n * Keeps track of all event listener additions/removals and lets all active\n * listeners be removed with a single operation.\n *\n * @private\n */\nexport class SubscriptionTracker {\n constructor(emitter) {\n this._emitter = emitter;\n this._subs = {};\n }\n\n on(eventType, listener) {\n let sub = this._emitter.on(eventType, listener);\n this._subs[sub] = eventType;\n return sub;\n }\n\n off(eventType, listener) {\n let sub = this._emitter.off(eventType, listener);\n if (sub) {\n delete this._subs[sub];\n }\n return sub;\n }\n\n removeAllListeners() {\n let current_subs = this._subs;\n this._subs = {};\n Object.keys(current_subs).forEach((sub) => {\n this._emitter.off(current_subs[sub], sub);\n });\n }\n}\n", + "import Events from \"./events\";\n\nexport default class Var {\n constructor(group, name, /*optional*/ value) {\n this._group = group;\n this._name = name;\n this._value = value;\n this._events = new Events();\n }\n\n get() {\n return this._value;\n }\n\n set(value, /*optional*/ event) {\n if (this._value === value) {\n // Do nothing; the value hasn't changed\n return;\n }\n let oldValue = this._value;\n this._value = value;\n // Alert JavaScript listeners that the value has changed\n let evt = {};\n if (event && typeof(event) === \"object\") {\n for (let k in event) {\n if (event.hasOwnProperty(k))\n evt[k] = event[k];\n }\n }\n evt.oldValue = oldValue;\n evt.value = value;\n this._events.trigger(\"change\", evt, this);\n\n // TODO: Make this extensible, to let arbitrary back-ends know that\n // something has changed\n if (global.Shiny && global.Shiny.onInputChange) {\n global.Shiny.onInputChange(\n \".clientValue-\" +\n (this._group.name !== null ? this._group.name + \"-\" : \"\") +\n this._name,\n typeof(value) === \"undefined\" ? null : value\n );\n }\n }\n\n on(eventType, listener) {\n return this._events.on(eventType, listener);\n }\n\n off(eventType, listener) {\n return this._events.off(eventType, listener);\n }\n}\n" + ] +} \ No newline at end of file diff --git a/docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.min.js b/docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.min.js new file mode 100644 index 00000000..55262e87 --- /dev/null +++ b/docs/articles/pkgnet-report_files/crosstalk-1.0.0/js/crosstalk.min.js @@ -0,0 +1,2 @@ +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gb?1:void 0}Object.defineProperty(c,"__esModule",{value:!0});var f=function(){function a(a,b){for(var c=0;c0&&void 0!==arguments[0]?arguments[0]:this._allKeys,b=Object.keys(this._handles).length;if(0===b)this._value=null;else{this._value=[];for(var c=0;c?@\[\\\]^`{|}~])/g,"\\$1")}function f(a){var b=h(a);Object.keys(i).forEach(function(c){if(b.hasClass(c)&&!b.hasClass("crosstalk-input-bound")){var d=i[c];g(d,a)}})}function g(a,b){var c=h(b).find("script[type='application/json'][data-for='"+e(b.id)+"']"),d=JSON.parse(c[0].innerText),f=a.factory(b,d);h(b).data("crosstalk-instance",f),h(b).addClass("crosstalk-input-bound")}Object.defineProperty(c,"__esModule",{value:!0}),c.register=b;var h=a.jQuery,i={};a.Shiny&&!function(){var b=new a.Shiny.InputBinding,c=a.jQuery;c.extend(b,{find:function(a){return c(a).find(".crosstalk-input")},initialize:function(a){c(a).hasClass("crosstalk-input-bound")||f(a)},getId:function(a){return a.id},getValue:function(a){},setValue:function(a,b){},receiveMessage:function(a,b){},subscribe:function(a,b){c(a).data("crosstalk-instance").resume()},unsubscribe:function(a){c(a).data("crosstalk-instance").suspend()}}),a.Shiny.inputBindings.register(b,"crosstalk.inputBinding")}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],7:[function(a,b,c){(function(b){"use strict";function c(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b.default=a,b}var d=a("./input"),e=c(d),f=a("./filter"),g=b.jQuery;e.register({className:"crosstalk-input-checkboxgroup",factory:function(a,b){var c=new f.FilterHandle(b.group),d=void 0,e=g(a);return e.on("change","input[type='checkbox']",function(){var a=e.find("input[type='checkbox']:checked");0===a.length?(d=null,c.clear()):!function(){var e={};a.each(function(){b.map[this.value].forEach(function(a){e[a]=!0})});var f=Object.keys(e);f.sort(),d=f,c.set(f)}()}),{suspend:function(){c.clear()},resume:function(){d&&c.set(d)}}}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./filter":2,"./input":6}],8:[function(a,b,c){(function(b){"use strict";function c(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b.default=a,b}var d=a("./input"),e=c(d),f=a("./util"),g=c(f),h=a("./filter"),i=b.jQuery;e.register({className:"crosstalk-input-select",factory:function(a,b){var c=[{value:"",label:"(All)"}],d=g.dataframeToD3(b.items),e={options:c.concat(d),valueField:"value",labelField:"label",searchField:"label"},f=i(a).find("select")[0],j=i(f).selectize(e)[0].selectize,k=new h.FilterHandle(b.group),l=void 0;return j.on("change",function(){0===j.items.length?(l=null,k.clear()):!function(){var a={};j.items.forEach(function(c){b.map[c].forEach(function(b){a[b]=!0})});var c=Object.keys(a);c.sort(),l=c,k.set(c)}()}),{suspend:function(){k.clear()},resume:function(){l&&k.set(l)}}}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./filter":2,"./input":6,"./util":11}],9:[function(a,b,c){(function(b){"use strict";function c(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b.default=a,b}function d(a,b){for(var c=a.toString();c.length=i&&m<=j&&k.push(b.keys[l])}k.sort(),d.set(k),p=k}}),{suspend:function(){d.clear()},resume:function(){p&&d.set(p)}}}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./filter":2,"./input":6}],10:[function(a,b,c){"use strict";function d(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b.default=a,b}function e(a){return a&&a.__esModule?a:{default:a}}function f(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionHandle=void 0;var g=function(){function a(a,b){for(var c=0;c0&&void 0!==arguments[0]?arguments[0]:null,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;f(this,a),this._eventRelay=new i.default,this._emitter=new m.SubscriptionTracker(this._eventRelay),this._group=null,this._var=null,this._varOnChangeSub=null,this._extraInfo=m.extend({sender:this},c),this.setGroup(b)}return g(a,[{key:"setGroup",value:function(a){var b=this;if(this._group!==a&&(this._group||a)&&(this._var&&(this._var.off("change",this._varOnChangeSub),this._var=null,this._varOnChangeSub=null),this._group=a,a)){this._var=(0,k.default)(a).var("selection");var c=this._var.on("change",function(a){b._eventRelay.trigger("change",a,b)});this._varOnChangeSub=c}}},{key:"_mergeExtraInfo",value:function(a){return m.extend({},this._extraInfo?this._extraInfo:null,a?a:null)}},{key:"set",value:function(a,b){this._var&&this._var.set(a,this._mergeExtraInfo(b))}},{key:"clear",value:function(a){this._var&&this.set(void 0,this._mergeExtraInfo(a))}},{key:"on",value:function(a,b){return this._emitter.on(a,b)}},{key:"off",value:function(a,b){return this._emitter.off(a,b)}},{key:"close",value:function(){this._emitter.removeAllListeners(),this.setGroup(null)}},{key:"value",get:function(){return this._var?this._var.get():null}}]),a}()},{"./events":1,"./group":4,"./util":11}],11:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a){for(var b=arguments.length,c=Array(b>1?b-1:0),d=1;d {\n this._eventRelay.trigger(\"change\", e, this);\n });\n this._varOnChangeSub = sub;\n }\n }\n\n /**\n * Combine the given `extraInfo` (if any) with the handle's default\n * `_extraInfo` (if any).\n * @private\n */\n _mergeExtraInfo(extraInfo) {\n return util.extend({},\n this._extraInfo ? this._extraInfo : null,\n extraInfo ? extraInfo : null);\n }\n\n /**\n * Close the handle. This clears this handle's contribution to the filter set,\n * and unsubscribes all event listeners.\n */\n close() {\n this._emitter.removeAllListeners();\n this.clear();\n this.setGroup(null);\n }\n\n /**\n * Clear this handle's contribution to the filter set.\n *\n * @param {Object} [extraInfo] - Extra properties to be included on the event\n * object that's passed to listeners (in addition to any options that were\n * passed into the `FilterHandle` constructor).\n */\n clear(extraInfo) {\n if (!this._filterSet)\n return;\n this._filterSet.clear(this._id);\n this._onChange(extraInfo);\n }\n\n /**\n * Set this handle's contribution to the filter set. This array should consist\n * of the keys of the rows that _should_ be displayed; any keys that are not\n * present in the array will be considered _filtered out_. Note that multiple\n * `FilterHandle` instances in the group may each contribute an array of keys,\n * and only those keys that appear in _all_ of the arrays make it through the\n * filter.\n *\n * @param {string[]} keys - Empty array, or array of keys. To clear the\n * filter, don't pass an empty array; instead, use the\n * {@link FilterHandle#clear} method.\n * @param {Object} [extraInfo] - Extra properties to be included on the event\n * object that's passed to listeners (in addition to any options that were\n * passed into the `FilterHandle` constructor).\n */\n set(keys, extraInfo) {\n if (!this._filterSet)\n return;\n this._filterSet.update(this._id, keys);\n this._onChange(extraInfo);\n }\n\n /**\n * @return {string[]|null} - Either: 1) an array of keys that made it through\n * all of the `FilterHandle` instances, or, 2) `null`, which means no filter\n * is being applied (all data should be displayed).\n */\n get filteredKeys() {\n return this._filterSet ? this._filterSet.value : null;\n }\n\n /**\n * Subscribe to events on this `FilterHandle`.\n *\n * @param {string} eventType - Indicates the type of events to listen to.\n * Currently, only `\"change\"` is supported.\n * @param {FilterHandle~listener} listener - The callback function that\n * will be invoked when the event occurs.\n * @return {string} - A token to pass to {@link FilterHandle#off} to cancel\n * this subscription.\n */\n on(eventType, listener) {\n return this._emitter.on(eventType, listener);\n }\n\n /**\n * Cancel event subscriptions created by {@link FilterHandle#on}.\n *\n * @param {string} eventType - The type of event to unsubscribe.\n * @param {string|FilterHandle~listener} listener - Either the callback\n * function previously passed into {@link FilterHandle#on}, or the\n * string that was returned from {@link FilterHandle#on}.\n */\n off(eventType, listener) {\n return this._emitter.off(eventType, listener);\n }\n\n _onChange(extraInfo) {\n if (!this._filterSet)\n return;\n this._filterVar.set(this._filterSet.value, this._mergeExtraInfo(extraInfo));\n }\n\n /**\n * @callback FilterHandle~listener\n * @param {Object} event - An object containing details of the event. For\n * `\"change\"` events, this includes the properties `value` (the new\n * value of the filter set, or `null` if no filter set is active),\n * `oldValue` (the previous value of the filter set), and `sender` (the\n * `FilterHandle` instance that made the change).\n */\n\n /**\n * @event FilterHandle#change\n * @type {object}\n * @property {object} value - The new value of the filter set, or `null`\n * if no filter set is active.\n * @property {object} oldValue - The previous value of the filter set.\n * @property {FilterHandle} sender - The `FilterHandle` instance that\n * changed the value.\n */\n}\n","import { diffSortedLists } from \"./util\";\n\nfunction naturalComparator(a, b) {\n if (a === b) {\n return 0;\n } else if (a < b) {\n return -1;\n } else if (a > b) {\n return 1;\n }\n}\n\n/**\n * @private\n */\nexport default class FilterSet {\n constructor() {\n this.reset();\n }\n\n reset() {\n // Key: handle ID, Value: array of selected keys, or null\n this._handles = {};\n // Key: key string, Value: count of handles that include it\n this._keys = {};\n this._value = null;\n this._activeHandles = 0;\n }\n\n get value() {\n return this._value;\n }\n\n update(handleId, keys) {\n if (keys !== null) {\n keys = keys.slice(0); // clone before sorting\n keys.sort(naturalComparator);\n }\n\n let {added, removed} = diffSortedLists(this._handles[handleId], keys);\n this._handles[handleId] = keys;\n\n for (let i = 0; i < added.length; i++) {\n this._keys[added[i]] = (this._keys[added[i]] || 0) + 1;\n }\n for (let i = 0; i < removed.length; i++) {\n this._keys[removed[i]]--;\n }\n\n this._updateValue(keys);\n }\n\n /**\n * @param {string[]} keys Sorted array of strings that indicate\n * a superset of possible keys.\n * @private\n */\n _updateValue(keys = this._allKeys) {\n let handleCount = Object.keys(this._handles).length;\n if (handleCount === 0) {\n this._value = null;\n } else {\n this._value = [];\n for (let i = 0; i < keys.length; i++) {\n let count = this._keys[keys[i]];\n if (count === handleCount) {\n this._value.push(keys[i]);\n }\n }\n }\n }\n\n clear(handleId) {\n if (typeof(this._handles[handleId]) === \"undefined\") {\n return;\n }\n\n let keys = this._handles[handleId];\n if (!keys) {\n keys = [];\n }\n\n for (let i = 0; i < keys.length; i++) {\n this._keys[keys[i]]--;\n }\n delete this._handles[handleId];\n\n this._updateValue();\n }\n\n get _allKeys() {\n let allKeys = Object.keys(this._keys);\n allKeys.sort(naturalComparator);\n return allKeys;\n }\n}\n","import Var from \"./var\";\n\n// Use a global so that multiple copies of crosstalk.js can be loaded and still\n// have groups behave as singletons across all copies.\nglobal.__crosstalk_groups = global.__crosstalk_groups || {};\nlet groups = global.__crosstalk_groups;\n\nexport default function group(groupName) {\n if (groupName && typeof(groupName) === \"string\") {\n if (!groups.hasOwnProperty(groupName)) {\n groups[groupName] = new Group(groupName);\n }\n return groups[groupName];\n } else if (typeof(groupName) === \"object\" && groupName._vars && groupName.var) {\n // Appears to already be a group object\n return groupName;\n } else if (Array.isArray(groupName) &&\n groupName.length == 1 &&\n typeof(groupName[0]) === \"string\") {\n return group(groupName[0]);\n } else {\n throw new Error(\"Invalid groupName argument\");\n }\n}\n\nclass Group {\n constructor(name) {\n this.name = name;\n this._vars = {};\n }\n\n var(name) {\n if (!name || typeof(name) !== \"string\") {\n throw new Error(\"Invalid var name\");\n }\n\n if (!this._vars.hasOwnProperty(name))\n this._vars[name] = new Var(this, name);\n return this._vars[name];\n }\n\n has(name) {\n if (!name || typeof(name) !== \"string\") {\n throw new Error(\"Invalid var name\");\n }\n\n return this._vars.hasOwnProperty(name);\n }\n}\n","import group from \"./group\";\nimport { SelectionHandle } from \"./selection\";\nimport { FilterHandle } from \"./filter\";\nimport \"./input\";\nimport \"./input_selectize\";\nimport \"./input_checkboxgroup\";\nimport \"./input_slider\";\n\nconst defaultGroup = group(\"default\");\n\nfunction var_(name) {\n return defaultGroup.var(name);\n}\n\nfunction has(name) {\n return defaultGroup.has(name);\n}\n\nif (global.Shiny) {\n global.Shiny.addCustomMessageHandler(\"update-client-value\", function(message) {\n if (typeof(message.group) === \"string\") {\n group(message.group).var(message.name).set(message.value);\n } else {\n var_(message.name).set(message.value);\n }\n });\n}\n\nconst crosstalk = {\n group: group,\n var: var_,\n has: has,\n SelectionHandle: SelectionHandle,\n FilterHandle: FilterHandle\n};\n\n/**\n * @namespace crosstalk\n */\nexport default crosstalk;\nglobal.crosstalk = crosstalk;\n","let $ = global.jQuery;\n\nlet bindings = {};\n\nexport function register(reg) {\n bindings[reg.className] = reg;\n if (global.document && global.document.readyState !== \"complete\") {\n $(() => {\n bind();\n });\n } else if (global.document) {\n setTimeout(bind, 100);\n }\n}\n\nfunction bind() {\n Object.keys(bindings).forEach(function(className) {\n let binding = bindings[className];\n $(\".\" + binding.className).not(\".crosstalk-input-bound\").each(function(i, el) {\n bindInstance(binding, el);\n });\n });\n}\n\n// Escape jQuery identifier\nfunction $escape(val) {\n return val.replace(/([!\"#$%&'()*+,.\\/:;<=>?@\\[\\\\\\]^`{|}~])/g, \"\\\\$1\");\n}\n\nfunction bindEl(el) {\n let $el = $(el);\n Object.keys(bindings).forEach(function(className) {\n if ($el.hasClass(className) && !$el.hasClass(\"crosstalk-input-bound\")) {\n let binding = bindings[className];\n bindInstance(binding, el);\n }\n });\n}\n\nfunction bindInstance(binding, el) {\n let jsonEl = $(el).find(\"script[type='application/json'][data-for='\" + $escape(el.id) + \"']\");\n let data = JSON.parse(jsonEl[0].innerText);\n\n let instance = binding.factory(el, data);\n $(el).data(\"crosstalk-instance\", instance);\n $(el).addClass(\"crosstalk-input-bound\");\n}\n\nif (global.Shiny) {\n let inputBinding = new global.Shiny.InputBinding();\n let $ = global.jQuery;\n $.extend(inputBinding, {\n find: function(scope) {\n return $(scope).find(\".crosstalk-input\");\n },\n initialize: function(el) {\n if (!$(el).hasClass(\"crosstalk-input-bound\")) {\n bindEl(el);\n }\n },\n getId: function(el) {\n return el.id;\n },\n getValue: function(el) {\n\n },\n setValue: function(el, value) {\n\n },\n receiveMessage: function(el, data) {\n\n },\n subscribe: function(el, callback) {\n $(el).data(\"crosstalk-instance\").resume();\n },\n unsubscribe: function(el) {\n $(el).data(\"crosstalk-instance\").suspend();\n }\n });\n global.Shiny.inputBindings.register(inputBinding, \"crosstalk.inputBinding\");\n}\n","import * as input from \"./input\";\nimport { FilterHandle } from \"./filter\";\n\nlet $ = global.jQuery;\n\ninput.register({\n className: \"crosstalk-input-checkboxgroup\",\n\n factory: function(el, data) {\n /*\n * map: {\"groupA\": [\"keyA\", \"keyB\", ...], ...}\n * group: \"ct-groupname\"\n */\n let ctHandle = new FilterHandle(data.group);\n\n let lastKnownKeys;\n let $el = $(el);\n $el.on(\"change\", \"input[type='checkbox']\", function() {\n let checked = $el.find(\"input[type='checkbox']:checked\");\n if (checked.length === 0) {\n lastKnownKeys = null;\n ctHandle.clear();\n } else {\n let keys = {};\n checked.each(function() {\n data.map[this.value].forEach(function(key) {\n keys[key] = true;\n });\n });\n let keyArray = Object.keys(keys);\n keyArray.sort();\n lastKnownKeys = keyArray;\n ctHandle.set(keyArray);\n }\n });\n\n return {\n suspend: function() {\n ctHandle.clear();\n },\n resume: function() {\n if (lastKnownKeys)\n ctHandle.set(lastKnownKeys);\n }\n };\n }\n});\n","import * as input from \"./input\";\nimport * as util from \"./util\";\nimport { FilterHandle } from \"./filter\";\n\nlet $ = global.jQuery;\n\ninput.register({\n className: \"crosstalk-input-select\",\n\n factory: function(el, data) {\n /*\n * items: {value: [...], label: [...]}\n * map: {\"groupA\": [\"keyA\", \"keyB\", ...], ...}\n * group: \"ct-groupname\"\n */\n\n let first = [{value: \"\", label: \"(All)\"}];\n let items = util.dataframeToD3(data.items);\n let opts = {\n options: first.concat(items),\n valueField: \"value\",\n labelField: \"label\",\n searchField: \"label\"\n };\n\n let select = $(el).find(\"select\")[0];\n\n let selectize = $(select).selectize(opts)[0].selectize;\n\n let ctHandle = new FilterHandle(data.group);\n\n let lastKnownKeys;\n selectize.on(\"change\", function() {\n if (selectize.items.length === 0) {\n lastKnownKeys = null;\n ctHandle.clear();\n } else {\n let keys = {};\n selectize.items.forEach(function(group) {\n data.map[group].forEach(function(key) {\n keys[key] = true;\n });\n });\n let keyArray = Object.keys(keys);\n keyArray.sort();\n lastKnownKeys = keyArray;\n ctHandle.set(keyArray);\n }\n });\n\n return {\n suspend: function() {\n ctHandle.clear();\n },\n resume: function() {\n if (lastKnownKeys)\n ctHandle.set(lastKnownKeys);\n }\n };\n }\n});\n","import * as input from \"./input\";\nimport { FilterHandle } from \"./filter\";\n\nlet $ = global.jQuery;\nlet strftime = global.strftime;\n\ninput.register({\n className: \"crosstalk-input-slider\",\n\n factory: function(el, data) {\n /*\n * map: {\"groupA\": [\"keyA\", \"keyB\", ...], ...}\n * group: \"ct-groupname\"\n */\n let ctHandle = new FilterHandle(data.group);\n\n let opts = {};\n let $el = $(el).find(\"input\");\n let dataType = $el.data(\"data-type\");\n let timeFormat = $el.data(\"time-format\");\n let timeFormatter;\n\n // Set up formatting functions\n if (dataType === \"date\") {\n timeFormatter = strftime.utc();\n opts.prettify = function(num) {\n return timeFormatter(timeFormat, new Date(num));\n };\n\n } else if (dataType === \"datetime\") {\n let timezone = $el.data(\"timezone\");\n if (timezone)\n timeFormatter = strftime.timezone(timezone);\n else\n timeFormatter = strftime;\n\n opts.prettify = function(num) {\n return timeFormatter(timeFormat, new Date(num));\n };\n }\n\n $el.ionRangeSlider(opts);\n\n function getValue() {\n let result = $el.data(\"ionRangeSlider\").result;\n\n // Function for converting numeric value from slider to appropriate type.\n let convert;\n let dataType = $el.data(\"data-type\");\n if (dataType === \"date\") {\n convert = function(val) {\n return formatDateUTC(new Date(+val));\n };\n } else if (dataType === \"datetime\") {\n convert = function(val) {\n // Convert ms to s\n return +val / 1000;\n };\n } else {\n convert = function(val) { return +val; };\n }\n\n if ($el.data(\"ionRangeSlider\").options.type === \"double\") {\n return [convert(result.from), convert(result.to)];\n } else {\n return convert(result.from);\n }\n }\n\n let lastKnownKeys = null;\n\n $el.on(\"change.crosstalkSliderInput\", function(event) {\n if (!$el.data(\"updating\") && !$el.data(\"animating\")) {\n let [from, to] = getValue();\n let keys = [];\n for (let i = 0; i < data.values.length; i++) {\n let val = data.values[i];\n if (val >= from && val <= to) {\n keys.push(data.keys[i]);\n }\n }\n keys.sort();\n ctHandle.set(keys);\n lastKnownKeys = keys;\n }\n });\n\n\n // let $el = $(el);\n // $el.on(\"change\", \"input[type=\"checkbox\"]\", function() {\n // let checked = $el.find(\"input[type=\"checkbox\"]:checked\");\n // if (checked.length === 0) {\n // ctHandle.clear();\n // } else {\n // let keys = {};\n // checked.each(function() {\n // data.map[this.value].forEach(function(key) {\n // keys[key] = true;\n // });\n // });\n // let keyArray = Object.keys(keys);\n // keyArray.sort();\n // ctHandle.set(keyArray);\n // }\n // });\n\n return {\n suspend: function() {\n ctHandle.clear();\n },\n resume: function() {\n if (lastKnownKeys)\n ctHandle.set(lastKnownKeys);\n }\n };\n }\n});\n\n\n// Convert a number to a string with leading zeros\nfunction padZeros(n, digits) {\n let str = n.toString();\n while (str.length < digits)\n str = \"0\" + str;\n return str;\n}\n\n// Given a Date object, return a string in yyyy-mm-dd format, using the\n// UTC date. This may be a day off from the date in the local time zone.\nfunction formatDateUTC(date) {\n if (date instanceof Date) {\n return date.getUTCFullYear() + \"-\" +\n padZeros(date.getUTCMonth()+1, 2) + \"-\" +\n padZeros(date.getUTCDate(), 2);\n\n } else {\n return null;\n }\n}\n","import Events from \"./events\";\nimport grp from \"./group\";\nimport * as util from \"./util\";\n\nexport class SelectionHandle {\n\n /**\n * @classdesc\n * Use this class to read and write (and listen for changes to) the selection\n * for a Crosstalk group. This is intended to be used for linked brushing.\n *\n * If two (or more) `SelectionHandle` instances in the same webpage share the\n * same group name, they will share the same state. Setting the selection using\n * one `SelectionHandle` instance will result in the `value` property instantly\n * changing across the others, and `\"change\"` event listeners on all instances\n * (including the one that initiated the sending) will fire.\n *\n * @param {string} [group] - The name of the Crosstalk group, or if none,\n * null or undefined (or any other falsy value). This can be changed later\n * via the [SelectionHandle#setGroup](#setGroup) method.\n * @param {Object} [extraInfo] - An object whose properties will be copied to\n * the event object whenever an event is emitted.\n */\n constructor(group = null, extraInfo = null) {\n this._eventRelay = new Events();\n this._emitter = new util.SubscriptionTracker(this._eventRelay);\n\n // Name of the group we're currently tracking, if any. Can change over time.\n this._group = null;\n // The Var we're currently tracking, if any. Can change over time.\n this._var = null;\n // The event handler subscription we currently have on var.on(\"change\").\n this._varOnChangeSub = null;\n\n this._extraInfo = util.extend({ sender: this }, extraInfo);\n\n this.setGroup(group);\n }\n\n /**\n * Changes the Crosstalk group membership of this SelectionHandle. The group\n * being switched away from (if any) will not have its selection value\n * modified as a result of calling `setGroup`, even if this handle was the\n * most recent handle to set the selection of the group.\n *\n * The group being switched to (if any) will also not have its selection value\n * modified as a result of calling `setGroup`. If you want to set the\n * selection value of the new group, call `set` explicitly.\n *\n * @param {string} group - The name of the Crosstalk group, or null (or\n * undefined) to clear the group.\n */\n setGroup(group) {\n // If group is unchanged, do nothing\n if (this._group === group)\n return;\n // Treat null, undefined, and other falsy values the same\n if (!this._group && !group)\n return;\n\n if (this._var) {\n this._var.off(\"change\", this._varOnChangeSub);\n this._var = null;\n this._varOnChangeSub = null;\n }\n\n this._group = group;\n\n if (group) {\n this._var = grp(group).var(\"selection\");\n let sub = this._var.on(\"change\", (e) => {\n this._eventRelay.trigger(\"change\", e, this);\n });\n this._varOnChangeSub = sub;\n }\n }\n\n /**\n * Retrieves the current selection for the group represented by this\n * `SelectionHandle`.\n *\n * - If no selection is active, then this value will be falsy.\n * - If a selection is active, but no data points are selected, then this\n * value will be an empty array.\n * - If a selection is active, and data points are selected, then the keys\n * of the selected data points will be present in the array.\n */\n get value() {\n return this._var ? this._var.get() : null;\n }\n\n /**\n * Combines the given `extraInfo` (if any) with the handle's default\n * `_extraInfo` (if any).\n * @private\n */\n _mergeExtraInfo(extraInfo) {\n // Important incidental effect: shallow clone is returned\n return util.extend({},\n this._extraInfo ? this._extraInfo : null,\n extraInfo ? extraInfo : null);\n }\n\n /**\n * Overwrites the current selection for the group, and raises the `\"change\"`\n * event among all of the group's '`SelectionHandle` instances (including\n * this one).\n *\n * @fires SelectionHandle#change\n * @param {string[]} selectedKeys - Falsy, empty array, or array of keys (see\n * {@link SelectionHandle#value}).\n * @param {Object} [extraInfo] - Extra properties to be included on the event\n * object that's passed to listeners (in addition to any options that were\n * passed into the `SelectionHandle` constructor).\n */\n set(selectedKeys, extraInfo) {\n if (this._var)\n this._var.set(selectedKeys, this._mergeExtraInfo(extraInfo));\n }\n\n /**\n * Overwrites the current selection for the group, and raises the `\"change\"`\n * event among all of the group's '`SelectionHandle` instances (including\n * this one).\n *\n * @fires SelectionHandle#change\n * @param {Object} [extraInfo] - Extra properties to be included on the event\n * object that's passed to listeners (in addition to any that were passed\n * into the `SelectionHandle` constructor).\n */\n clear(extraInfo) {\n if (this._var)\n this.set(void 0, this._mergeExtraInfo(extraInfo));\n }\n\n /**\n * Subscribes to events on this `SelectionHandle`.\n *\n * @param {string} eventType - Indicates the type of events to listen to.\n * Currently, only `\"change\"` is supported.\n * @param {SelectionHandle~listener} listener - The callback function that\n * will be invoked when the event occurs.\n * @return {string} - A token to pass to {@link SelectionHandle#off} to cancel\n * this subscription.\n */\n on(eventType, listener) {\n return this._emitter.on(eventType, listener);\n }\n\n /**\n * Cancels event subscriptions created by {@link SelectionHandle#on}.\n *\n * @param {string} eventType - The type of event to unsubscribe.\n * @param {string|SelectionHandle~listener} listener - Either the callback\n * function previously passed into {@link SelectionHandle#on}, or the\n * string that was returned from {@link SelectionHandle#on}.\n */\n off(eventType, listener) {\n return this._emitter.off(eventType, listener);\n }\n\n /**\n * Shuts down the `SelectionHandle` object.\n *\n * Removes all event listeners that were added through this handle.\n */\n close() {\n this._emitter.removeAllListeners();\n this.setGroup(null);\n }\n\n /**\n * @callback SelectionHandle~listener\n * @param {Object} event - An object containing details of the event. For\n * `\"change\"` events, this includes the properties `value` (the new\n * value of the selection, or `undefined` if no selection is active),\n * `oldValue` (the previous value of the selection), and `sender` (the\n * `SelectionHandle` instance that made the change).\n */\n\n /**\n * @event SelectionHandle#change\n * @type {object}\n * @property {object} value - The new value of the selection, or `undefined`\n * if no selection is active.\n * @property {object} oldValue - The previous value of the selection.\n * @property {SelectionHandle} sender - The `SelectionHandle` instance that\n * changed the value.\n */\n}\n","export function extend(target, ...sources) {\n for (let i = 0; i < sources.length; i++) {\n let src = sources[i];\n if (typeof(src) === \"undefined\" || src === null)\n continue;\n\n for (let key in src) {\n if (src.hasOwnProperty(key)) {\n target[key] = src[key];\n }\n }\n }\n return target;\n}\n\nexport function checkSorted(list) {\n for (let i = 1; i < list.length; i++) {\n if (list[i] <= list[i-1]) {\n throw new Error(\"List is not sorted or contains duplicate\");\n }\n }\n}\n\nexport function diffSortedLists(a, b) {\n let i_a = 0;\n let i_b = 0;\n\n if (!a) a = [];\n if (!b) b = [];\n\n let a_only = [];\n let b_only = [];\n\n checkSorted(a);\n checkSorted(b);\n\n while (i_a < a.length && i_b < b.length) {\n if (a[i_a] === b[i_b]) {\n i_a++;\n i_b++;\n } else if (a[i_a] < b[i_b]) {\n a_only.push(a[i_a++]);\n } else {\n b_only.push(b[i_b++]);\n }\n }\n\n if (i_a < a.length)\n a_only = a_only.concat(a.slice(i_a));\n if (i_b < b.length)\n b_only = b_only.concat(b.slice(i_b));\n return {\n removed: a_only,\n added: b_only\n };\n}\n\n// Convert from wide: { colA: [1,2,3], colB: [4,5,6], ... }\n// to long: [ {colA: 1, colB: 4}, {colA: 2, colB: 5}, ... ]\nexport function dataframeToD3(df) {\n let names = [];\n let length;\n for (let name in df) {\n if (df.hasOwnProperty(name))\n names.push(name);\n if (typeof(df[name]) !== \"object\" || typeof(df[name].length) === \"undefined\") {\n throw new Error(\"All fields must be arrays\");\n } else if (typeof(length) !== \"undefined\" && length !== df[name].length) {\n throw new Error(\"All fields must be arrays of the same length\");\n }\n length = df[name].length;\n }\n let results = [];\n let item;\n for (let row = 0; row < length; row++) {\n item = {};\n for (let col = 0; col < names.length; col++) {\n item[names[col]] = df[names[col]][row];\n }\n results.push(item);\n }\n return results;\n}\n\n/**\n * Keeps track of all event listener additions/removals and lets all active\n * listeners be removed with a single operation.\n *\n * @private\n */\nexport class SubscriptionTracker {\n constructor(emitter) {\n this._emitter = emitter;\n this._subs = {};\n }\n\n on(eventType, listener) {\n let sub = this._emitter.on(eventType, listener);\n this._subs[sub] = eventType;\n return sub;\n }\n\n off(eventType, listener) {\n let sub = this._emitter.off(eventType, listener);\n if (sub) {\n delete this._subs[sub];\n }\n return sub;\n }\n\n removeAllListeners() {\n let current_subs = this._subs;\n this._subs = {};\n Object.keys(current_subs).forEach((sub) => {\n this._emitter.off(current_subs[sub], sub);\n });\n }\n}\n","import Events from \"./events\";\n\nexport default class Var {\n constructor(group, name, /*optional*/ value) {\n this._group = group;\n this._name = name;\n this._value = value;\n this._events = new Events();\n }\n\n get() {\n return this._value;\n }\n\n set(value, /*optional*/ event) {\n if (this._value === value) {\n // Do nothing; the value hasn't changed\n return;\n }\n let oldValue = this._value;\n this._value = value;\n // Alert JavaScript listeners that the value has changed\n let evt = {};\n if (event && typeof(event) === \"object\") {\n for (let k in event) {\n if (event.hasOwnProperty(k))\n evt[k] = event[k];\n }\n }\n evt.oldValue = oldValue;\n evt.value = value;\n this._events.trigger(\"change\", evt, this);\n\n // TODO: Make this extensible, to let arbitrary back-ends know that\n // something has changed\n if (global.Shiny && global.Shiny.onInputChange) {\n global.Shiny.onInputChange(\n \".clientValue-\" +\n (this._group.name !== null ? this._group.name + \"-\" : \"\") +\n this._name,\n typeof(value) === \"undefined\" ? null : value\n );\n }\n }\n\n on(eventType, listener) {\n return this._events.on(eventType, listener);\n }\n\n off(eventType, listener) {\n return this._events.off(eventType, listener);\n }\n}\n"]} \ No newline at end of file diff --git a/docs/articles/pkgnet-report_files/datatables-binding-0.5/datatables.js b/docs/articles/pkgnet-report_files/datatables-binding-0.5/datatables.js new file mode 100644 index 00000000..4a16eee6 --- /dev/null +++ b/docs/articles/pkgnet-report_files/datatables-binding-0.5/datatables.js @@ -0,0 +1,1191 @@ +(function() { + +// some helper functions: using a global object DTWidget so that it can be used +// in JS() code, e.g. datatable(options = list(foo = JS('code'))); unlike R's +// dynamic scoping, when 'code' is eval()'ed, JavaScript does not know objects +// from the "parent frame", e.g. JS('DTWidget') will not work unless it was made +// a global object +var DTWidget = {}; + +// 123456666.7890 -> 123,456,666.7890 +var markInterval = function(d, digits, interval, mark, decMark, precision) { + x = precision ? d.toPrecision(digits) : d.toFixed(digits); + if (!/^-?[\d.]+$/.test(x)) return x; + var xv = x.split('.'); + if (xv.length > 2) return x; // should have at most one decimal point + xv[0] = xv[0].replace(new RegExp('\\B(?=(\\d{' + interval + '})+(?!\\d))', 'g'), mark); + return xv.join(decMark); +}; + +DTWidget.formatCurrency = function(thiz, row, data, col, currency, digits, interval, mark, decMark, before) { + var d = parseFloat(data[col]); + if (isNaN(d)) return; + var res = markInterval(d, digits, interval, mark, decMark); + res = before ? (/^-/.test(res) ? '-' + currency + res.replace(/^-/, '') : currency + res) : + res + currency; + $(thiz.api().cell(row, col).node()).html(res); +}; + +DTWidget.formatString = function(thiz, row, data, col, prefix, suffix) { + var d = data[col]; + if (d === null) return; + var cell = $(thiz.api().cell(row, col).node()); + cell.html(prefix + cell.html() + suffix); +}; + +DTWidget.formatPercentage = function(thiz, row, data, col, digits, interval, mark, decMark) { + var d = parseFloat(data[col]); + if (isNaN(d)) return; + $(thiz.api().cell(row, col).node()) + .html(markInterval(d * 100, digits, interval, mark, decMark) + '%'); +}; + +DTWidget.formatRound = function(thiz, row, data, col, digits, interval, mark, decMark) { + var d = parseFloat(data[col]); + if (isNaN(d)) return; + $(thiz.api().cell(row, col).node()).html(markInterval(d, digits, interval, mark, decMark)); +}; + +DTWidget.formatSignif = function(thiz, row, data, col, digits, interval, mark, decMark) { + var d = parseFloat(data[col]); + if (isNaN(d)) return; + $(thiz.api().cell(row, col).node()) + .html(markInterval(d, digits, interval, mark, decMark, true)); +}; + +DTWidget.formatDate = function(thiz, row, data, col, method, params) { + var d = data[col]; + if (d === null) return; + // (new Date('2015-10-28')).toDateString() may return 2015-10-27 because the + // actual time created could be like 'Tue Oct 27 2015 19:00:00 GMT-0500 (CDT)', + // i.e. the date-only string is treated as UTC time instead of local time + if ((method === 'toDateString' || method === 'toLocaleDateString') && /^\d{4,}\D\d{2}\D\d{2}$/.test(d)) { + d = d.split(/\D/); + d = new Date(d[0], d[1] - 1, d[2]); + } else { + d = new Date(d); + } + $(thiz.api().cell(row, col).node()).html(d[method].apply(d, params)); +}; + +window.DTWidget = DTWidget; + +var transposeArray2D = function(a) { + return a.length === 0 ? a : HTMLWidgets.transposeArray2D(a); +}; + +var crosstalkPluginsInstalled = false; + +function maybeInstallCrosstalkPlugins() { + if (crosstalkPluginsInstalled) + return; + crosstalkPluginsInstalled = true; + + $.fn.dataTable.ext.afnFiltering.push( + function(oSettings, aData, iDataIndex) { + var ctfilter = oSettings.nTable.ctfilter; + if (ctfilter && !ctfilter[iDataIndex]) + return false; + + var ctselect = oSettings.nTable.ctselect; + if (ctselect && !ctselect[iDataIndex]) + return false; + + return true; + } + ); +} + +HTMLWidgets.widget({ + name: "datatables", + type: "output", + renderOnNullValue: true, + initialize: function(el, width, height) { + $(el).html(' '); + return { + data: null, + ctfilterHandle: new crosstalk.FilterHandle(), + ctfilterSubscription: null, + ctselectHandle: new crosstalk.SelectionHandle(), + ctselectSubscription: null + }; + }, + renderValue: function(el, data, instance) { + if (el.offsetWidth === 0 || el.offsetHeight === 0) { + instance.data = data; + return; + } + instance.data = null; + var $el = $(el); + $el.empty(); + + if (data === null) { + $el.append(' '); + // clear previous Shiny inputs (if any) + for (var i in instance.clearInputs) instance.clearInputs[i](); + instance.clearInputs = {}; + return; + } + + var crosstalkOptions = data.crosstalkOptions; + if (!crosstalkOptions) crosstalkOptions = { + 'key': null, 'group': null + }; + if (crosstalkOptions.group) { + maybeInstallCrosstalkPlugins(); + instance.ctfilterHandle.setGroup(crosstalkOptions.group); + instance.ctselectHandle.setGroup(crosstalkOptions.group); + } + + // If we are in a flexdashboard scroll layout then we: + // (a) Always want to use pagination (otherwise we'll have + // a "double scroll bar" effect on the phone); and + // (b) Never want to fill the container (we want the pagination + // level to determine the size of the container) + if (window.FlexDashboard && !window.FlexDashboard.isFillPage()) { + data.options.bPaginate = true; + data.fillContainer = false; + } + + // if we are in the viewer then we always want to fillContainer and + // and autoHideNavigation (unless the user has explicitly set these) + if (window.HTMLWidgets.viewerMode) { + if (!data.hasOwnProperty("fillContainer")) + data.fillContainer = true; + if (!data.hasOwnProperty("autoHideNavigation")) + data.autoHideNavigation = true; + } + + // propagate fillContainer to instance (so we have it in resize) + instance.fillContainer = data.fillContainer; + + var cells = data.data; + + if (cells instanceof Array) cells = transposeArray2D(cells); + + $el.append(data.container); + var $table = $el.find('table'); + if (data.class) $table.addClass(data.class); + if (data.caption) $table.prepend(data.caption); + + if (!data.selection) data.selection = { + mode: 'none', selected: null, target: 'row' + }; + if (HTMLWidgets.shinyMode && data.selection.mode !== 'none' && + data.selection.target === 'row+column') { + if ($table.children('tfoot').length === 0) { + $table.append($('')); + $table.find('thead tr').clone().appendTo($table.find('tfoot')); + } + } + + // column filters + var filterRow; + switch (data.filter) { + case 'top': + $table.children('thead').append(data.filterHTML); + filterRow = $table.find('thead tr:last td'); + break; + case 'bottom': + if ($table.children('tfoot').length === 0) { + $table.append($('')); + } + $table.children('tfoot').prepend(data.filterHTML); + filterRow = $table.find('tfoot tr:first td'); + break; + } + + var options = { searchDelay: 1000 }; + if (cells !== null) $.extend(options, { + data: cells + }); + + // options for fillContainer + var bootstrapActive = typeof($.fn.popover) != 'undefined'; + if (instance.fillContainer) { + + // force scrollX/scrollY and turn off autoWidth + options.scrollX = true; + options.scrollY = "100px"; // can be any value, we'll adjust below + + // if we aren't paginating then move around the info/filter controls + // to save space at the bottom and rephrase the info callback + if (data.options.bPaginate === false) { + + // we know how to do this cleanly for bootstrap, not so much + // for other themes/layouts + if (bootstrapActive) { + options.dom = "<'row'<'col-sm-4'i><'col-sm-8'f>>" + + "<'row'<'col-sm-12'tr>>"; + } + + options.fnInfoCallback = function(oSettings, iStart, iEnd, + iMax, iTotal, sPre) { + return Number(iTotal).toLocaleString() + " records"; + }; + } + } + + // auto hide navigation if requested + if (data.autoHideNavigation === true) { + if (bootstrapActive && data.options.bPaginate !== false) { + // strip all nav if length >= cells + if ((cells instanceof Array) && data.options.iDisplayLength >= cells.length) + options.dom = "<'row'<'col-sm-12'tr>>"; + // alternatively lean things out for flexdashboard mobile portrait + else if (window.FlexDashboard && window.FlexDashboard.isMobilePhone()) + options.dom = "<'row'<'col-sm-12'f>>" + + "<'row'<'col-sm-12'tr>>" + + "<'row'<'col-sm-12'p>>"; + } + } + + $.extend(true, options, data.options || {}); + + var searchCols = options.searchCols; + if (searchCols) { + searchCols = searchCols.map(function(x) { + return x === null ? '' : x.search; + }); + // FIXME: this means I don't respect the escapeRegex setting + delete options.searchCols; + } + + // server-side processing? + var server = options.serverSide === true; + + // use the dataSrc function to pre-process JSON data returned from R + var DT_rows_all = [], DT_rows_current = []; + if (server && HTMLWidgets.shinyMode && typeof options.ajax === 'object' && + /^session\/[\da-z]+\/dataobj/.test(options.ajax.url) && !options.ajax.dataSrc) { + options.ajax.dataSrc = function(json) { + DT_rows_all = $.makeArray(json.DT_rows_all); + DT_rows_current = $.makeArray(json.DT_rows_current); + var data = json.data; + if (!colReorderEnabled()) return data; + var table = $table.DataTable(), order = table.colReorder.order(), flag = true, i, j, row; + for (i = 0; i < order.length; ++i) if (order[i] !== i) flag = false; + if (flag) return data; + for (i = 0; i < data.length; ++i) { + row = data[i].slice(); + for (j = 0; j < order.length; ++j) data[i][j] = row[order[j]]; + } + return data; + }; + } + + var thiz = this; + if (instance.fillContainer) $table.on('init.dt', function(e) { + thiz.fillAvailableHeight(el, $(el).innerHeight()); + }); + // If the page contains serveral datatables and one of which enables colReorder, + // the table.colReorder.order() function will exist but throws error when called. + // So it seems like the only way to know if colReorder is enabled or not is to + // check the options. + var colReorderEnabled = function() { return "colReorder" in options; }; + var table = $table.DataTable(options); + $el.data('datatable', table); + + // Unregister previous Crosstalk event subscriptions, if they exist + if (instance.ctfilterSubscription) { + instance.ctfilterHandle.off("change", instance.ctfilterSubscription); + instance.ctfilterSubscription = null; + } + if (instance.ctselectSubscription) { + instance.ctselectHandle.off("change", instance.ctselectSubscription); + instance.ctselectSubscription = null; + } + + if (!crosstalkOptions.group) { + $table[0].ctfilter = null; + $table[0].ctselect = null; + } else { + var key = crosstalkOptions.key; + function keysToMatches(keys) { + if (!keys) { + return null; + } else { + var selectedKeys = {}; + for (var i = 0; i < keys.length; i++) { + selectedKeys[keys[i]] = true; + } + var matches = {}; + for (var j = 0; j < key.length; j++) { + if (selectedKeys[key[j]]) + matches[j] = true; + } + return matches; + } + } + + function applyCrosstalkFilter(e) { + $table[0].ctfilter = keysToMatches(e.value); + table.draw(); + } + instance.ctfilterSubscription = instance.ctfilterHandle.on("change", applyCrosstalkFilter); + applyCrosstalkFilter({value: instance.ctfilterHandle.filteredKeys}); + + function applyCrosstalkSelection(e) { + if (e.sender !== instance.ctselectHandle) { + table + .rows('.' + selClass, {search: 'applied'}) + .nodes() + .to$() + .removeClass(selClass); + if (selectedRows) + changeInput('rows_selected', selectedRows(), void 0, true); + } + + if (e.sender !== instance.ctselectHandle && e.value && e.value.length) { + var matches = keysToMatches(e.value); + + // persistent selection with plotly (& leaflet) + var ctOpts = crosstalk.var("plotlyCrosstalkOpts").get() || {}; + if (ctOpts.persistent === true) { + var matches = $.extend(matches, $table[0].ctselect); + } + + $table[0].ctselect = matches; + table.draw(); + } else { + if ($table[0].ctselect) { + $table[0].ctselect = null; + table.draw(); + } + } + } + instance.ctselectSubscription = instance.ctselectHandle.on("change", applyCrosstalkSelection); + // TODO: This next line doesn't seem to work when renderDataTable is used + applyCrosstalkSelection({value: instance.ctselectHandle.value}); + } + + var inArray = function(val, array) { + return $.inArray(val, $.makeArray(array)) > -1; + }; + + // encode + to %2B when searching in the table on server side, because + // shiny::parseQueryString() treats + as spaces, and DataTables does not + // encode + to %2B (or % to %25) when sending the request + var encode_plus = function(x) { + return server ? x.replace(/%/g, '%25').replace(/\+/g, '%2B') : x; + }; + + // search the i-th column + var searchColumn = function(i, value) { + var regex = false, ci = true; + if (options.search) { + regex = options.search.regex, + ci = options.search.caseInsensitive !== false; + } + return table.column(i).search(encode_plus(value), regex, !regex, ci); + }; + + if (data.filter !== 'none') { + + filterRow.each(function(i, td) { + + var $td = $(td), type = $td.data('type'), filter; + var $input = $td.children('div').first().children('input'); + $input.prop('disabled', !table.settings()[0].aoColumns[i].bSearchable || type === 'disabled'); + $input.on('input blur', function() { + $input.next('span').toggle(Boolean($input.val())); + }); + // Bootstrap sets pointer-events to none and we won't be able to click + // the clear button + $input.next('span').css('pointer-events', 'auto').hide().click(function() { + $(this).hide().prev('input').val('').trigger('input').focus(); + }); + var searchCol; // search string for this column + if (searchCols && searchCols[i]) { + searchCol = searchCols[i]; + $input.val(searchCol).trigger('input'); + } + var $x = $td.children('div').last(); + + // remove the overflow: hidden attribute of the scrollHead + // (otherwise the scrolling table body obscures the filters) + var scrollHead = $(el).find('.dataTables_scrollHead,.dataTables_scrollFoot'); + var cssOverflow = scrollHead.css('overflow'); + if (cssOverflow === 'hidden') { + $x.on('show hide', function(e) { + scrollHead.css('overflow', e.type === 'show' ? '' : cssOverflow); + }); + $x.css('z-index', 25); + } + + if (inArray(type, ['factor', 'logical'])) { + $input.on({ + click: function() { + $input.parent().hide(); $x.show().trigger('show'); filter[0].selectize.focus(); + }, + input: function() { + if ($input.val() === '') filter[0].selectize.setValue([]); + } + }); + var $input2 = $x.children('select'); + filter = $input2.selectize({ + options: $input2.data('options').map(function(v, i) { + return ({text: v, value: v}); + }), + plugins: ['remove_button'], + hideSelected: true, + onChange: function(value) { + if (value === null) value = []; // compatibility with jQuery 3.0 + $input.val(value.length ? JSON.stringify(value) : ''); + if (value.length) $input.trigger('input'); + $input.attr('title', $input.val()); + if (server) { + table.column(i).search(value.length ? encode_plus(JSON.stringify(value)) : '').draw(); + return; + } + // turn off filter if nothing selected + $td.data('filter', value.length > 0); + table.draw(); // redraw table, and filters will be applied + } + }); + if (searchCol) filter[0].selectize.setValue(JSON.parse(searchCol)); + filter[0].selectize.on('blur', function() { + $x.hide().trigger('hide'); $input.parent().show(); $input.trigger('blur'); + }); + filter.next('div').css('margin-bottom', 'auto'); + } else if (type === 'character') { + var fun = function() { + searchColumn(i, $input.val()).draw(); + }; + if (server) { + fun = $.fn.dataTable.util.throttle(fun, options.searchDelay); + } + $input.on('input', fun); + } else if (inArray(type, ['number', 'integer', 'date', 'time'])) { + var $x0 = $x; + $x = $x0.children('div').first(); + $x0.css({ + 'background-color': '#fff', + 'border': '1px #ddd solid', + 'border-radius': '4px', + 'padding': '20px 20px 10px 20px' + }); + var $spans = $x0.children('span').css({ + 'margin-top': '10px', + 'white-space': 'nowrap' + }); + var $span1 = $spans.first(), $span2 = $spans.last(); + var r1 = +$x.data('min'), r2 = +$x.data('max'); + // when the numbers are too small or have many decimal places, the + // slider may have numeric precision problems (#150) + var scale = Math.pow(10, Math.max(0, +$x.data('scale') || 0)); + r1 = Math.round(r1 * scale); r2 = Math.round(r2 * scale); + var scaleBack = function(x, scale) { + if (scale === 1) return x; + var d = Math.round(Math.log(scale) / Math.log(10)); + // to avoid problems like 3.423/100 -> 0.034230000000000003 + return (x / scale).toFixed(d); + }; + $input.on({ + focus: function() { + $x0.show().trigger('show'); + // first, make sure the slider div leaves at least 20px between + // the two (slider value) span's + $x0.width(Math.max(160, $span1.outerWidth() + $span2.outerWidth() + 20)); + // then, if the input is really wide, make the slider the same + // width as the input + if ($x0.outerWidth() < $input.outerWidth()) { + $x0.outerWidth($input.outerWidth()); + } + // make sure the slider div does not reach beyond the right margin + if ($(window).width() < $x0.offset().left + $x0.width()) { + $x0.offset({ + 'left': $input.offset().left + $input.outerWidth() - $x0.outerWidth() + }); + } + }, + blur: function() { + $x0.hide().trigger('hide'); + }, + input: function() { + if ($input.val() === '') filter.val([r1, r2]); + }, + change: function() { + var v = $input.val().replace(/\s/g, ''); + if (v === '') return; + v = v.split('...'); + if (v.length !== 2) { + $input.parent().addClass('has-error'); + return; + } + if (v[0] === '') v[0] = r1; + if (v[1] === '') v[1] = r2; + $input.parent().removeClass('has-error'); + // treat date as UTC time at midnight + var strTime = function(x) { + var s = type === 'date' ? 'T00:00:00Z' : ''; + var t = new Date(x + s).getTime(); + // add 10 minutes to date since it does not hurt the date, and + // it helps avoid the tricky floating point arithmetic problems, + // e.g. sometimes the date may be a few milliseconds earlier + // than the midnight due to precision problems in noUiSlider + return type === 'date' ? t + 3600000 : t; + }; + if (inArray(type, ['date', 'time'])) { + v[0] = strTime(v[0]); + v[1] = strTime(v[1]); + } + if (v[0] != r1) v[0] *= scale; + if (v[1] != r2) v[1] *= scale; + filter.val(v); + } + }); + var formatDate = function(d, isoFmt) { + d = scaleBack(d, scale); + if (type === 'number') return d; + if (type === 'integer') return parseInt(d); + var x = new Date(+d); + var fmt = ('filterDateFmt' in data) ? data.filterDateFmt[i] : undefined; + if (fmt !== undefined && isoFmt === false) return x[fmt.method].apply(x, fmt.params); + if (type === 'date') { + var pad0 = function(x) { + return ('0' + x).substr(-2, 2); + }; + return x.getUTCFullYear() + '-' + pad0(1 + x.getUTCMonth()) + + '-' + pad0(x.getUTCDate()); + } else { + return x.toISOString(); + } + }; + var opts = type === 'date' ? { step: 60 * 60 * 1000 } : + type === 'integer' ? { step: 1 } : {}; + filter = $x.noUiSlider($.extend({ + start: [r1, r2], + range: {min: r1, max: r2}, + connect: true + }, opts)); + if (scale > 1) (function() { + var t1 = r1, t2 = r2; + var val = filter.val(); + while (val[0] > r1 || val[1] < r2) { + if (val[0] > r1) { + t1 -= val[0] - r1; + } + if (val[1] < r2) { + t2 += r2 - val[1]; + } + filter = $x.noUiSlider($.extend({ + start: [t1, t2], + range: {min: t1, max: t2}, + connect: true + }, opts), true); + val = filter.val(); + } + r1 = t1; r2 = t2; + })(); + var updateSliderText = function(v1, v2) { + $span1.text(formatDate(v1, false)); $span2.text(formatDate(v2, false)); + }; + updateSliderText(r1, r2); + var updateSlider = function(e) { + var val = filter.val(); + // turn off filter if in full range + $td.data('filter', val[0] > r1 || val[1] < r2); + var v1 = formatDate(val[0]), v2 = formatDate(val[1]), ival; + if ($td.data('filter')) { + ival = v1 + ' ... ' + v2; + $input.attr('title', ival).val(ival).trigger('input'); + } else { + $input.attr('title', '').val(''); + } + updateSliderText(val[0], val[1]); + if (e.type === 'slide') return; // no searching when sliding only + if (server) { + table.column(i).search($td.data('filter') ? ival : '').draw(); + return; + } + table.draw(); + }; + filter.on({ + set: updateSlider, + slide: updateSlider + }); + } + + // server-side processing will be handled by R (or whatever server + // language you use); the following code is only needed for client-side + // processing + if (server) { + // if a search string has been pre-set, search now + if (searchCol) searchColumn(i, searchCol).draw(); + return; + } + + var customFilter = function(settings, data, dataIndex) { + // there is no way to attach a search function to a specific table, + // and we need to make sure a global search function is not applied to + // all tables (i.e. a range filter in a previous table should not be + // applied to the current table); we use the settings object to + // determine if we want to perform searching on the current table, + // since settings.sTableId will be different to different tables + if (table.settings()[0] !== settings) return true; + // no filter on this column or no need to filter this column + if (typeof filter === 'undefined' || !$td.data('filter')) return true; + + var r = filter.val(), v, r0, r1; + var i_data = function(i) { + if (!colReorderEnabled()) return i; + var order = table.colReorder.order(), k; + for (k = 0; k < order.length; ++k) if (order[k] === i) return k; + return i; // in theory it will never be here... + } + v = data[i_data(i)]; + if (type === 'number' || type === 'integer') { + v = parseFloat(v); + // how to handle NaN? currently exclude these rows + if (isNaN(v)) return(false); + r0 = parseFloat(scaleBack(r[0], scale)) + r1 = parseFloat(scaleBack(r[1], scale)); + if (v >= r0 && v <= r1) return true; + } else if (type === 'date' || type === 'time') { + v = new Date(v); + r0 = new Date(r[0] / scale); r1 = new Date(r[1] / scale); + if (v >= r0 && v <= r1) return true; + } else if (type === 'factor') { + if (r.length === 0 || inArray(v, r)) return true; + } else if (type === 'logical') { + if (r.length === 0) return true; + if (inArray(v === '' ? 'na' : v, r)) return true; + } + return false; + }; + + $.fn.dataTable.ext.search.push(customFilter); + + // search for the preset search strings if it is non-empty + if (searchCol) { + if (inArray(type, ['factor', 'logical'])) { + filter[0].selectize.setValue(JSON.parse(searchCol)); + } else if (type === 'character') { + $input.trigger('input'); + } else if (inArray(type, ['number', 'integer', 'date', 'time'])) { + $input.trigger('change'); + } + } + + }); + + } + + // highlight search keywords + var highlight = function() { + var body = $(table.table().body()); + // removing the old highlighting first + body.unhighlight(); + + // don't highlight the "not found" row, so we get the rows using the api + if (table.rows({ filter: 'applied' }).data().length === 0) return; + // highlight gloal search keywords + body.highlight($.trim(table.search()).split(/\s+/)); + // then highlight keywords from individual column filters + if (filterRow) filterRow.each(function(i, td) { + var $td = $(td), type = $td.data('type'); + if (type !== 'character') return; + var $input = $td.children('div').first().children('input'); + var column = table.column(i).nodes().to$(), + val = $.trim($input.val()); + if (type !== 'character' || val === '') return; + column.highlight(val.split(/\s+/)); + }); + }; + + if (options.searchHighlight) { + table + .on('draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth', highlight) + .on('destroy', function() { + // remove event handler + table.off('draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth'); + }); + + // initial highlight for state saved conditions and initial states + highlight(); + } + + // run the callback function on the table instance + if (typeof data.callback === 'function') data.callback(table); + + // double click to edit the cell + if (data.editable) table.on('dblclick.dt', 'tbody td', function() { + var $input = $(''); + var $this = $(this), value = table.cell(this).data(), html = $this.html(); + var changed = false; + $input.val(value); + $this.empty().append($input); + $input.css('width', '100%').focus().on('change', function() { + changed = true; + var valueNew = $input.val(); + if (valueNew != value) { + table.cell($this).data(valueNew); + if (HTMLWidgets.shinyMode) changeInput('cell_edit', cellInfo($this)); + // for server-side processing, users have to call replaceData() to update the table + if (!server) table.draw(false); + } else { + $this.html(html); + } + $input.remove(); + }).on('blur', function() { + if (!changed) $input.trigger('change'); + }); + }); + + // interaction with shiny + if (!HTMLWidgets.shinyMode && !crosstalkOptions.group) return; + + var methods = {}; + var shinyData = {}; + + methods.updateCaption = function(caption) { + if (!caption) return; + $table.children('caption').replaceWith(caption); + } + + // register clear functions to remove input values when the table is removed + instance.clearInputs = {}; + + var changeInput = function(id, value, type, noCrosstalk) { + var event = id; + id = el.id + '_' + id; + if (type) id = id + ':' + type; + // do not update if the new value is the same as old value + if (shinyData.hasOwnProperty(id) && shinyData[id] === JSON.stringify(value)) + return; + shinyData[id] = JSON.stringify(value); + if (HTMLWidgets.shinyMode) { + Shiny.onInputChange(id, value); + if (!instance.clearInputs[id]) instance.clearInputs[id] = function() { + Shiny.onInputChange(id, null); + } + } + + // HACK + if (event === "rows_selected" && !noCrosstalk) { + if (crosstalkOptions.group) { + var keys = crosstalkOptions.key; + var selectedKeys = null; + if (value) { + selectedKeys = []; + for (var i = 0; i < value.length; i++) { + // The value array's contents use 1-based row numbers, so we must + // convert to 0-based before indexing into the keys array. + selectedKeys.push(keys[value[i] - 1]); + } + } + instance.ctselectHandle.set(selectedKeys); + } + } + }; + + var addOne = function(x) { + return x.map(function(i) { return 1 + i; }); + }; + + var unique = function(x) { + var ux = []; + $.each(x, function(i, el){ + if ($.inArray(el, ux) === -1) ux.push(el); + }); + return ux; + } + + // change the row index of a cell + var tweakCellIndex = function(cell) { + var info = cell.index(); + if (server) { + info.row = DT_rows_current[info.row]; + } else { + info.row += 1; + } + return {row: info.row, col: info.column}; + } + + var selMode = data.selection.mode, selTarget = data.selection.target; + if (inArray(selMode, ['single', 'multiple'])) { + var selClass = data.style === 'bootstrap' ? 'active' : 'selected'; + var selected = data.selection.selected, selected1, selected2; + // selected1: row indices; selected2: column indices + if (selected === null) { + selected1 = selected2 = []; + } else if (selTarget === 'row') { + selected1 = $.makeArray(selected); + } else if (selTarget === 'column') { + selected2 = $.makeArray(selected); + } else if (selTarget === 'row+column') { + selected1 = $.makeArray(selected.rows); + selected2 = $.makeArray(selected.cols); + } + + // After users reorder the rows or filter the table, we cannot use the table index + // directly. Instead, we need this function to find out the rows between the two clicks. + // If user filter the table again between the start click and the end click, the behavior + // would be undefined, but it should not be a problem. + var shiftSelRowsIndex = function(start, end) { + var indexes = server ? DT_rows_all : table.rows({ search: 'applied' }).indexes().toArray(); + start = indexes.indexOf(start); end = indexes.indexOf(end); + // if start is larger than end, we need to swap + if (start > end) { + var tmp = end; end = start; start = tmp; + } + return indexes.slice(start, end + 1); + } + + var serverRowIndex = function(clientRowIndex) { + return server ? DT_rows_current[clientRowIndex] : clientRowIndex + 1; + } + + // row, column, or cell selection + var lastClickedRow; + if (inArray(selTarget, ['row', 'row+column'])) { + var selectedRows = function() { + var rows = table.rows('.' + selClass); + var idx = rows.indexes().toArray(); + if (!server) return addOne(idx); + idx = idx.map(function(i) { + return DT_rows_current[i]; + }); + selected1 = selMode === 'multiple' ? unique(selected1.concat(idx)) : idx; + return selected1; + } + table.on('mousedown.dt', 'tbody tr', function(e) { + var $this = $(this), thisRow = table.row(this); + if (selMode === 'multiple') { + if (e.shiftKey && lastClickedRow !== undefined) { + // select or de-select depends on the last clicked row's status + var flagSel = !$this.hasClass(selClass); + var crtClickedRow = serverRowIndex(thisRow.index()); + if (server) { + var rowsIndex = shiftSelRowsIndex(lastClickedRow, crtClickedRow); + // update current page's selClass + rowsIndex.map(function(i) { + var rowIndex = DT_rows_current.indexOf(i); + if (rowIndex >= 0) { + var row = table.row(rowIndex).nodes().to$(); + var flagRowSel = !row.hasClass(selClass); + if (flagSel === flagRowSel) row.toggleClass(selClass); + } + }); + // update selected1 + if (flagSel) { + selected1 = unique(selected1.concat(rowsIndex)); + } else { + selected1 = selected1.filter(function(index) { + return !inArray(index, rowsIndex); + }); + } + } else { + // js starts from 0 + shiftSelRowsIndex(lastClickedRow - 1, crtClickedRow - 1).map(function(value) { + var row = table.row(value).nodes().to$(); + var flagRowSel = !row.hasClass(selClass); + if (flagSel === flagRowSel) row.toggleClass(selClass); + }); + } + e.preventDefault(); + } else { + $this.toggleClass(selClass); + } + } else { + if ($this.hasClass(selClass)) { + $this.removeClass(selClass); + } else { + table.$('tr.' + selClass).removeClass(selClass); + $this.addClass(selClass); + } + } + if (server && !$this.hasClass(selClass)) { + var id = DT_rows_current[thisRow.index()]; + // remove id from selected1 since its class .selected has been removed + if (inArray(id, selected1)) selected1.splice($.inArray(id, selected1), 1); + } + changeInput('rows_selected', selectedRows()); + changeInput('row_last_clicked', serverRowIndex(thisRow.index())); + lastClickedRow = serverRowIndex(thisRow.index()); + }); + changeInput('rows_selected', selected1); + var selectRows = function() { + table.$('tr.' + selClass).removeClass(selClass); + if (selected1.length === 0) return; + if (server) { + table.rows({page: 'current'}).every(function() { + if (inArray(DT_rows_current[this.index()], selected1)) { + $(this.node()).addClass(selClass); + } + }); + } else { + var selected0 = selected1.map(function(i) { return i - 1; }); + $(table.rows(selected0).nodes()).addClass(selClass); + } + } + selectRows(); // in case users have specified pre-selected rows + // restore selected rows after the table is redrawn (e.g. sort/search/page); + // client-side tables will preserve the selections automatically; for + // server-side tables, we have to *real* row indices are in `selected1` + if (server) table.on('draw.dt', selectRows); + methods.selectRows = function(selected) { + selected1 = $.makeArray(selected); + selectRows(); + changeInput('rows_selected', selected1); + } + } + + if (inArray(selTarget, ['column', 'row+column'])) { + if (selTarget === 'row+column') { + $(table.columns().footer()).css('cursor', 'pointer'); + } + table.on('click.dt', selTarget === 'column' ? 'tbody td' : 'tfoot tr th', function() { + var colIdx = selTarget === 'column' ? table.cell(this).index().column : + $.inArray(this, table.columns().footer()), + thisCol = $(table.column(colIdx).nodes()); + if (colIdx === -1) return; + if (thisCol.hasClass(selClass)) { + thisCol.removeClass(selClass); + selected2.splice($.inArray(colIdx, selected2), 1); + } else { + if (selMode === 'single') $(table.cells().nodes()).removeClass(selClass); + thisCol.addClass(selClass); + selected2 = selMode === 'single' ? [colIdx] : unique(selected2.concat([colIdx])); + } + changeInput('columns_selected', selected2); + }); + changeInput('columns_selected', selected2); + var selectCols = function() { + table.columns().nodes().flatten().to$().removeClass(selClass); + if (selected2.length > 0) + table.columns(selected2).nodes().flatten().to$().addClass(selClass); + } + selectCols(); // in case users have specified pre-selected columns + if (server) table.on('draw.dt', selectCols); + methods.selectColumns = function(selected) { + selected2 = $.makeArray(selected); + selectCols(); + changeInput('columns_selected', selected2); + } + } + + if (selTarget === 'cell') { + var selected3; + if (selected === null) { + selected3 = []; + } else { + selected3 = selected; + } + var findIndex = function(ij) { + for (var i = 0; i < selected3.length; i++) { + if (ij[0] === selected3[i][0] && ij[1] === selected3[i][1]) return i; + } + return -1; + } + table.on('click.dt', 'tbody td', function() { + var $this = $(this), info = tweakCellIndex(table.cell(this)); + if ($this.hasClass(selClass)) { + $this.removeClass(selClass); + selected3.splice(findIndex([info.row, info.col]), 1); + } else { + if (selMode === 'single') $(table.cells().nodes()).removeClass(selClass); + $this.addClass(selClass); + selected3 = selMode === 'single' ? [[info.row, info.col]] : + unique(selected3.concat([[info.row, info.col]])); + } + changeInput('cells_selected', transposeArray2D(selected3), 'shiny.matrix'); + }); + changeInput('cells_selected', transposeArray2D(selected3), 'shiny.matrix'); + var selectCells = function() { + table.$('td.' + selClass).removeClass(selClass); + if (selected3.length === 0) return; + if (server) { + table.cells({page: 'current'}).every(function() { + var info = tweakCellIndex(this); + if (findIndex([info.row, info.col], selected3) > -1) + $(this.node()).addClass(selClass); + }); + } else { + selected3.map(function(ij) { + $(table.cell(ij[0] - 1, ij[1]).node()).addClass(selClass); + }); + } + }; + selectCells(); // in case users have specified pre-selected columns + if (server) table.on('draw.dt', selectCells); + methods.selectCells = function(selected) { + selected3 = selected ? selected : []; + selectCells(); + changeInput('cells_selected', transposeArray2D(selected3), 'shiny.matrix'); + } + } + } + + // expose some table info to Shiny + var updateTableInfo = function(e, settings) { + // TODO: is anyone interested in the page info? + // changeInput('page_info', table.page.info()); + var updateRowInfo = function(id, modifier) { + var idx; + if (server) { + idx = modifier.page === 'current' ? DT_rows_current : DT_rows_all; + } else { + var rows = table.rows($.extend({ + search: 'applied', + page: 'all' + }, modifier)); + idx = addOne(rows.indexes().toArray()); + } + changeInput('rows' + '_' + id, idx); + }; + updateRowInfo('current', {page: 'current'}); + updateRowInfo('all', {}); + } + table.on('draw.dt', updateTableInfo); + updateTableInfo(); + + // state info + table.on('draw.dt column-visibility.dt', function() { + changeInput('state', table.state()); + }); + changeInput('state', table.state()); + + // search info + var updateSearchInfo = function() { + changeInput('search', table.search()); + if (filterRow) changeInput('search_columns', filterRow.toArray().map(function(td) { + return $(td).find('input').first().val(); + })); + } + table.on('draw.dt', updateSearchInfo); + updateSearchInfo(); + + var cellInfo = function(thiz) { + var info = tweakCellIndex(table.cell(thiz)); + info.value = table.cell(thiz).data(); + return info; + } + // the current cell clicked on + table.on('click.dt', 'tbody td', function() { + changeInput('cell_clicked', cellInfo(this)); + }) + changeInput('cell_clicked', {}); + + // do not trigger table selection when clicking on links unless they have classes + table.on('click.dt', 'tbody td a', function(e) { + if (this.className === '') e.stopPropagation(); + }); + + methods.addRow = function(data, rowname) { + var data0 = table.row(0).data(), n = data0.length, d = n - data.length; + if (d === 1) { + data = rowname.concat(data) + } else if (d !== 0) { + console.log(data); + console.log(data0); + throw 'New data must be of the same length as current data (' + n + ')'; + }; + table.row.add(data).draw(); + } + + methods.updateSearch = function(keywords) { + if (keywords.global !== null) + $(table.table().container()).find('input[type=search]').first() + .val(keywords.global).trigger('input'); + var columns = keywords.columns; + if (!filterRow || columns === null) return; + filterRow.toArray().map(function(td, i) { + var v = typeof columns === 'string' ? columns : columns[i]; + if (typeof v === 'undefined') { + console.log('The search keyword for column ' + i + ' is undefined') + return; + } + $(td).find('input').first().val(v); + searchColumn(i, v); + }); + table.draw(); + } + + methods.hideCols = function(hide, reset) { + if (reset) table.columns().visible(true, false); + table.columns(hide).visible(false); + } + + methods.showCols = function(show, reset) { + if (reset) table.columns().visible(false, false); + table.columns(show).visible(true); + } + + methods.colReorder = function(order, origOrder) { + table.colReorder.order(order, origOrder); + } + + methods.selectPage = function(page) { + if (table.page.info().pages < page || page < 1) { + throw 'Selected page is out of range'; + }; + table.page(page - 1).draw(false); + } + + methods.reloadData = function(resetPaging, clearSelection) { + // empty selections first if necessary + if (methods.selectRows && inArray('row', clearSelection)) methods.selectRows([]); + if (methods.selectColumns && inArray('column', clearSelection)) methods.selectColumns([]); + if (methods.selectCells && inArray('cell', clearSelection)) methods.selectCells([]); + table.ajax.reload(null, resetPaging); + } + + table.shinyMethods = methods; + }, + resize: function(el, width, height, instance) { + if (instance.data) this.renderValue(el, instance.data, instance); + + // dynamically adjust height if fillContainer = TRUE + if (instance.fillContainer) + this.fillAvailableHeight(el, height); + + this.adjustWidth(el); + }, + + // dynamically set the scroll body to fill available height + // (used with fillContainer = TRUE) + fillAvailableHeight: function(el, availableHeight) { + + // see how much of the table is occupied by header/footer elements + // and use that to compute a target scroll body height + var dtWrapper = $(el).find('div.dataTables_wrapper'); + var dtScrollBody = $(el).find($('div.dataTables_scrollBody')); + var framingHeight = dtWrapper.innerHeight() - dtScrollBody.innerHeight(); + var scrollBodyHeight = availableHeight - framingHeight; + + // set the height + dtScrollBody.height(scrollBodyHeight + 'px'); + }, + + // adjust the width of columns; remove the hard-coded widths on table and the + // scroll header when scrollX/Y are enabled + adjustWidth: function(el) { + var $el = $(el), table = $el.data('datatable'); + if (table) table.columns.adjust(); + $el.find('.dataTables_scrollHeadInner').css('width', '') + .children('table').css('margin-left', ''); + } +}); + + if (!HTMLWidgets.shinyMode) return; + + Shiny.addCustomMessageHandler('datatable-calls', function(data) { + var id = data.id; + var el = document.getElementById(id); + var table = el ? $(el).data('datatable') : null; + if (!table) { + console.log("Couldn't find table with id " + id); + return; + } + + var methods = table.shinyMethods, call = data.call; + if (methods[call.method]) { + methods[call.method].apply(table, call.args); + } else { + console.log("Unknown method " + call.method); + } + }); + +})(); diff --git a/docs/articles/pkgnet-report_files/datatables-css-0.0.0/datatables-crosstalk.css b/docs/articles/pkgnet-report_files/datatables-css-0.0.0/datatables-crosstalk.css new file mode 100644 index 00000000..43422d25 --- /dev/null +++ b/docs/articles/pkgnet-report_files/datatables-css-0.0.0/datatables-crosstalk.css @@ -0,0 +1,7 @@ +.dt-crosstalk-fade { + opacity: 0.2; +} + +html body div.DTS div.dataTables_scrollBody { + background: none; +} diff --git a/docs/articles/pkgnet-report_files/dt-core-1.10.16/css/jquery.dataTables.extra.css b/docs/articles/pkgnet-report_files/dt-core-1.10.16/css/jquery.dataTables.extra.css new file mode 100644 index 00000000..dbbac6dd --- /dev/null +++ b/docs/articles/pkgnet-report_files/dt-core-1.10.16/css/jquery.dataTables.extra.css @@ -0,0 +1,8 @@ +/* Selected rows/cells */ +table.dataTable tr.selected td, table.dataTable td.selected { + background-color: #b0bed9 !important; +} +/* In case of scrollX/Y or FixedHeader */ +.dataTables_scrollBody .dataTables_sizing { + visibility: hidden; +} diff --git a/docs/articles/pkgnet-report_files/dt-core-1.10.16/css/jquery.dataTables.min.css b/docs/articles/pkgnet-report_files/dt-core-1.10.16/css/jquery.dataTables.min.css new file mode 100644 index 00000000..71ae98a4 --- /dev/null +++ b/docs/articles/pkgnet-report_files/dt-core-1.10.16/css/jquery.dataTables.min.css @@ -0,0 +1 @@ +table.dataTable{width:100%;margin:0 auto;clear:both;border-collapse:separate;border-spacing:0}table.dataTable thead th,table.dataTable tfoot th{font-weight:bold}table.dataTable thead th,table.dataTable thead td{padding:10px 18px;border-bottom:1px solid #111}table.dataTable thead th:active,table.dataTable thead td:active{outline:none}table.dataTable tfoot th,table.dataTable tfoot td{padding:10px 18px 6px 18px;border-top:1px solid #111}table.dataTable thead .sorting,table.dataTable thead .sorting_asc,table.dataTable thead .sorting_desc,table.dataTable thead .sorting_asc_disabled,table.dataTable thead .sorting_desc_disabled{cursor:pointer;*cursor:hand;background-repeat:no-repeat;background-position:center right}table.dataTable thead .sorting{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7XQMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC)}table.dataTable thead .sorting_asc{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==)}table.dataTable thead .sorting_desc{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII=)}table.dataTable thead .sorting_asc_disabled{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAW0lEQVQoz2NgoCm4w3Vnwh02wspK7/y6k01Ikdadx3f+37l9RxmfIsY7c4GKQHDiHUbcyhzvvIMq+3THBpci3jv7oIpAcMcdduzKEu/8vPMdDn/eiWQYBYMKAAC3ykIEuYQJUgAAAABJRU5ErkJggg==)}table.dataTable thead .sorting_desc_disabled{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAWUlEQVQoz2NgGAWDCtyJvPPzznc4/HknEbsy9js77vyHw313eHGZZ3PnE1TRuzuOuK1lvDMRqmzuHUZ87lO+cxuo6PEdLUIeyb7z604pYf+y3Zlwh4u2YQoAc7ZCBHH4jigAAAAASUVORK5CYII=)}table.dataTable tbody tr{background-color:#ffffff}table.dataTable tbody tr.selected{background-color:#B0BED9}table.dataTable tbody th,table.dataTable tbody td{padding:8px 10px}table.dataTable.row-border tbody th,table.dataTable.row-border tbody td,table.dataTable.display tbody th,table.dataTable.display tbody td{border-top:1px solid #ddd}table.dataTable.row-border tbody tr:first-child th,table.dataTable.row-border tbody tr:first-child td,table.dataTable.display tbody tr:first-child th,table.dataTable.display tbody tr:first-child td{border-top:none}table.dataTable.cell-border tbody th,table.dataTable.cell-border tbody td{border-top:1px solid #ddd;border-right:1px solid #ddd}table.dataTable.cell-border tbody tr th:first-child,table.dataTable.cell-border tbody tr td:first-child{border-left:1px solid #ddd}table.dataTable.cell-border tbody tr:first-child th,table.dataTable.cell-border tbody tr:first-child td{border-top:none}table.dataTable.stripe tbody tr.odd,table.dataTable.display tbody tr.odd{background-color:#f9f9f9}table.dataTable.stripe tbody tr.odd.selected,table.dataTable.display tbody tr.odd.selected{background-color:#acbad4}table.dataTable.hover tbody tr:hover,table.dataTable.display tbody tr:hover{background-color:#f6f6f6}table.dataTable.hover tbody tr:hover.selected,table.dataTable.display tbody tr:hover.selected{background-color:#aab7d1}table.dataTable.order-column tbody tr>.sorting_1,table.dataTable.order-column tbody tr>.sorting_2,table.dataTable.order-column tbody tr>.sorting_3,table.dataTable.display tbody tr>.sorting_1,table.dataTable.display tbody tr>.sorting_2,table.dataTable.display tbody tr>.sorting_3{background-color:#fafafa}table.dataTable.order-column tbody tr.selected>.sorting_1,table.dataTable.order-column tbody tr.selected>.sorting_2,table.dataTable.order-column tbody tr.selected>.sorting_3,table.dataTable.display tbody tr.selected>.sorting_1,table.dataTable.display tbody tr.selected>.sorting_2,table.dataTable.display tbody tr.selected>.sorting_3{background-color:#acbad5}table.dataTable.display tbody tr.odd>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd>.sorting_1{background-color:#f1f1f1}table.dataTable.display tbody tr.odd>.sorting_2,table.dataTable.order-column.stripe tbody tr.odd>.sorting_2{background-color:#f3f3f3}table.dataTable.display tbody tr.odd>.sorting_3,table.dataTable.order-column.stripe tbody tr.odd>.sorting_3{background-color:whitesmoke}table.dataTable.display tbody tr.odd.selected>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_1{background-color:#a6b4cd}table.dataTable.display tbody tr.odd.selected>.sorting_2,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_2{background-color:#a8b5cf}table.dataTable.display tbody tr.odd.selected>.sorting_3,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_3{background-color:#a9b7d1}table.dataTable.display tbody tr.even>.sorting_1,table.dataTable.order-column.stripe tbody tr.even>.sorting_1{background-color:#fafafa}table.dataTable.display tbody tr.even>.sorting_2,table.dataTable.order-column.stripe tbody tr.even>.sorting_2{background-color:#fcfcfc}table.dataTable.display tbody tr.even>.sorting_3,table.dataTable.order-column.stripe tbody tr.even>.sorting_3{background-color:#fefefe}table.dataTable.display tbody tr.even.selected>.sorting_1,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_1{background-color:#acbad5}table.dataTable.display tbody tr.even.selected>.sorting_2,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_2{background-color:#aebcd6}table.dataTable.display tbody tr.even.selected>.sorting_3,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_3{background-color:#afbdd8}table.dataTable.display tbody tr:hover>.sorting_1,table.dataTable.order-column.hover tbody tr:hover>.sorting_1{background-color:#eaeaea}table.dataTable.display tbody tr:hover>.sorting_2,table.dataTable.order-column.hover tbody tr:hover>.sorting_2{background-color:#ececec}table.dataTable.display tbody tr:hover>.sorting_3,table.dataTable.order-column.hover tbody tr:hover>.sorting_3{background-color:#efefef}table.dataTable.display tbody tr:hover.selected>.sorting_1,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_1{background-color:#a2aec7}table.dataTable.display tbody tr:hover.selected>.sorting_2,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_2{background-color:#a3b0c9}table.dataTable.display tbody tr:hover.selected>.sorting_3,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_3{background-color:#a5b2cb}table.dataTable.no-footer{border-bottom:1px solid #111}table.dataTable.nowrap th,table.dataTable.nowrap td{white-space:nowrap}table.dataTable.compact thead th,table.dataTable.compact thead td{padding:4px 17px 4px 4px}table.dataTable.compact tfoot th,table.dataTable.compact tfoot td{padding:4px}table.dataTable.compact tbody th,table.dataTable.compact tbody td{padding:4px}table.dataTable th.dt-left,table.dataTable td.dt-left{text-align:left}table.dataTable th.dt-center,table.dataTable td.dt-center,table.dataTable td.dataTables_empty{text-align:center}table.dataTable th.dt-right,table.dataTable td.dt-right{text-align:right}table.dataTable th.dt-justify,table.dataTable td.dt-justify{text-align:justify}table.dataTable th.dt-nowrap,table.dataTable td.dt-nowrap{white-space:nowrap}table.dataTable thead th.dt-head-left,table.dataTable thead td.dt-head-left,table.dataTable tfoot th.dt-head-left,table.dataTable tfoot td.dt-head-left{text-align:left}table.dataTable thead th.dt-head-center,table.dataTable thead td.dt-head-center,table.dataTable tfoot th.dt-head-center,table.dataTable tfoot td.dt-head-center{text-align:center}table.dataTable thead th.dt-head-right,table.dataTable thead td.dt-head-right,table.dataTable tfoot th.dt-head-right,table.dataTable tfoot td.dt-head-right{text-align:right}table.dataTable thead th.dt-head-justify,table.dataTable thead td.dt-head-justify,table.dataTable tfoot th.dt-head-justify,table.dataTable tfoot td.dt-head-justify{text-align:justify}table.dataTable thead th.dt-head-nowrap,table.dataTable thead td.dt-head-nowrap,table.dataTable tfoot th.dt-head-nowrap,table.dataTable tfoot td.dt-head-nowrap{white-space:nowrap}table.dataTable tbody th.dt-body-left,table.dataTable tbody td.dt-body-left{text-align:left}table.dataTable tbody th.dt-body-center,table.dataTable tbody td.dt-body-center{text-align:center}table.dataTable tbody th.dt-body-right,table.dataTable tbody td.dt-body-right{text-align:right}table.dataTable tbody th.dt-body-justify,table.dataTable tbody td.dt-body-justify{text-align:justify}table.dataTable tbody th.dt-body-nowrap,table.dataTable tbody td.dt-body-nowrap{white-space:nowrap}table.dataTable,table.dataTable th,table.dataTable td{box-sizing:content-box}.dataTables_wrapper{position:relative;clear:both;*zoom:1;zoom:1}.dataTables_wrapper .dataTables_length{float:left}.dataTables_wrapper .dataTables_filter{float:right;text-align:right}.dataTables_wrapper .dataTables_filter input{margin-left:0.5em}.dataTables_wrapper .dataTables_info{clear:both;float:left;padding-top:0.755em}.dataTables_wrapper .dataTables_paginate{float:right;text-align:right;padding-top:0.25em}.dataTables_wrapper .dataTables_paginate .paginate_button{box-sizing:border-box;display:inline-block;min-width:1.5em;padding:0.5em 1em;margin-left:2px;text-align:center;text-decoration:none !important;cursor:pointer;*cursor:hand;color:#333 !important;border:1px solid transparent;border-radius:2px}.dataTables_wrapper .dataTables_paginate .paginate_button.current,.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover{color:#333 !important;border:1px solid #979797;background-color:white;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #fff), color-stop(100%, #dcdcdc));background:-webkit-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-moz-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-ms-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-o-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:linear-gradient(to bottom, #fff 0%, #dcdcdc 100%)}.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:active{cursor:default;color:#666 !important;border:1px solid transparent;background:transparent;box-shadow:none}.dataTables_wrapper .dataTables_paginate .paginate_button:hover{color:white !important;border:1px solid #111;background-color:#585858;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #585858), color-stop(100%, #111));background:-webkit-linear-gradient(top, #585858 0%, #111 100%);background:-moz-linear-gradient(top, #585858 0%, #111 100%);background:-ms-linear-gradient(top, #585858 0%, #111 100%);background:-o-linear-gradient(top, #585858 0%, #111 100%);background:linear-gradient(to bottom, #585858 0%, #111 100%)}.dataTables_wrapper .dataTables_paginate .paginate_button:active{outline:none;background-color:#2b2b2b;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #2b2b2b), color-stop(100%, #0c0c0c));background:-webkit-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-moz-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-ms-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-o-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:linear-gradient(to bottom, #2b2b2b 0%, #0c0c0c 100%);box-shadow:inset 0 0 3px #111}.dataTables_wrapper .dataTables_paginate .ellipsis{padding:0 1em}.dataTables_wrapper .dataTables_processing{position:absolute;top:50%;left:50%;width:100%;height:40px;margin-left:-50%;margin-top:-25px;padding-top:20px;text-align:center;font-size:1.2em;background-color:white;background:-webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255,255,255,0)), color-stop(25%, rgba(255,255,255,0.9)), color-stop(75%, rgba(255,255,255,0.9)), color-stop(100%, rgba(255,255,255,0)));background:-webkit-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-ms-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-o-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%)}.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter,.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_processing,.dataTables_wrapper .dataTables_paginate{color:#333}.dataTables_wrapper .dataTables_scroll{clear:both}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody{*margin-top:-1px;-webkit-overflow-scrolling:touch}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>th,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>td,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>th,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>td{vertical-align:middle}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>th>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>td>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>th>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>td>div.dataTables_sizing{height:0;overflow:hidden;margin:0 !important;padding:0 !important}.dataTables_wrapper.no-footer .dataTables_scrollBody{border-bottom:1px solid #111}.dataTables_wrapper.no-footer div.dataTables_scrollHead table.dataTable,.dataTables_wrapper.no-footer div.dataTables_scrollBody>table{border-bottom:none}.dataTables_wrapper:after{visibility:hidden;display:block;content:"";clear:both;height:0}@media screen and (max-width: 767px){.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_paginate{float:none;text-align:center}.dataTables_wrapper .dataTables_paginate{margin-top:0.5em}}@media screen and (max-width: 640px){.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter{float:none;text-align:center}.dataTables_wrapper .dataTables_filter{margin-top:0.5em}} diff --git a/docs/articles/pkgnet-report_files/dt-core-1.10.16/js/jquery.dataTables.min.js b/docs/articles/pkgnet-report_files/dt-core-1.10.16/js/jquery.dataTables.min.js new file mode 100644 index 00000000..162da347 --- /dev/null +++ b/docs/articles/pkgnet-report_files/dt-core-1.10.16/js/jquery.dataTables.min.js @@ -0,0 +1,164 @@ +/*! + DataTables 1.10.16 + ©2008-2017 SpryMedia Ltd - datatables.net/license +*/ +(function(h){"function"===typeof define&&define.amd?define(["jquery"],function(E){return h(E,window,document)}):"object"===typeof exports?module.exports=function(E,G){E||(E=window);G||(G="undefined"!==typeof window?require("jquery"):require("jquery")(E));return h(G,E,E.document)}:h(jQuery,window,document)})(function(h,E,G,k){function X(a){var b,c,d={};h.each(a,function(e){if((b=e.match(/^([^A-Z]+?)([A-Z])/))&&-1!=="a aa ai ao as b fn i m o s ".indexOf(b[1]+" "))c=e.replace(b[0],b[2].toLowerCase()), +d[c]=e,"o"===b[1]&&X(a[e])});a._hungarianMap=d}function I(a,b,c){a._hungarianMap||X(a);var d;h.each(b,function(e){d=a._hungarianMap[e];if(d!==k&&(c||b[d]===k))"o"===d.charAt(0)?(b[d]||(b[d]={}),h.extend(!0,b[d],b[e]),I(a[d],b[d],c)):b[d]=b[e]})}function Ca(a){var b=m.defaults.oLanguage,c=a.sZeroRecords;!a.sEmptyTable&&(c&&"No data available in table"===b.sEmptyTable)&&F(a,a,"sZeroRecords","sEmptyTable");!a.sLoadingRecords&&(c&&"Loading..."===b.sLoadingRecords)&&F(a,a,"sZeroRecords","sLoadingRecords"); +a.sInfoThousands&&(a.sThousands=a.sInfoThousands);(a=a.sDecimal)&&cb(a)}function db(a){A(a,"ordering","bSort");A(a,"orderMulti","bSortMulti");A(a,"orderClasses","bSortClasses");A(a,"orderCellsTop","bSortCellsTop");A(a,"order","aaSorting");A(a,"orderFixed","aaSortingFixed");A(a,"paging","bPaginate");A(a,"pagingType","sPaginationType");A(a,"pageLength","iDisplayLength");A(a,"searching","bFilter");"boolean"===typeof a.sScrollX&&(a.sScrollX=a.sScrollX?"100%":"");"boolean"===typeof a.scrollX&&(a.scrollX= +a.scrollX?"100%":"");if(a=a.aoSearchCols)for(var b=0,c=a.length;b").css({position:"fixed",top:0,left:-1*h(E).scrollLeft(),height:1,width:1,overflow:"hidden"}).append(h("
    ").css({position:"absolute", +top:1,left:1,width:100,overflow:"scroll"}).append(h("
    ").css({width:"100%",height:10}))).appendTo("body"),d=c.children(),e=d.children();b.barWidth=d[0].offsetWidth-d[0].clientWidth;b.bScrollOversize=100===e[0].offsetWidth&&100!==d[0].clientWidth;b.bScrollbarLeft=1!==Math.round(e.offset().left);b.bBounding=c[0].getBoundingClientRect().width?!0:!1;c.remove()}h.extend(a.oBrowser,m.__browser);a.oScroll.iBarWidth=m.__browser.barWidth}function gb(a,b,c,d,e,f){var g,j=!1;c!==k&&(g=c,j=!0);for(;d!== +e;)a.hasOwnProperty(d)&&(g=j?b(g,a[d],d,a):a[d],j=!0,d+=f);return g}function Da(a,b){var c=m.defaults.column,d=a.aoColumns.length,c=h.extend({},m.models.oColumn,c,{nTh:b?b:G.createElement("th"),sTitle:c.sTitle?c.sTitle:b?b.innerHTML:"",aDataSort:c.aDataSort?c.aDataSort:[d],mData:c.mData?c.mData:d,idx:d});a.aoColumns.push(c);c=a.aoPreSearchCols;c[d]=h.extend({},m.models.oSearch,c[d]);ja(a,d,h(b).data())}function ja(a,b,c){var b=a.aoColumns[b],d=a.oClasses,e=h(b.nTh);if(!b.sWidthOrig){b.sWidthOrig= +e.attr("width")||null;var f=(e.attr("style")||"").match(/width:\s*(\d+[pxem%]+)/);f&&(b.sWidthOrig=f[1])}c!==k&&null!==c&&(eb(c),I(m.defaults.column,c),c.mDataProp!==k&&!c.mData&&(c.mData=c.mDataProp),c.sType&&(b._sManualType=c.sType),c.className&&!c.sClass&&(c.sClass=c.className),c.sClass&&e.addClass(c.sClass),h.extend(b,c),F(b,c,"sWidth","sWidthOrig"),c.iDataSort!==k&&(b.aDataSort=[c.iDataSort]),F(b,c,"aDataSort"));var g=b.mData,j=Q(g),i=b.mRender?Q(b.mRender):null,c=function(a){return"string"=== +typeof a&&-1!==a.indexOf("@")};b._bAttrSrc=h.isPlainObject(g)&&(c(g.sort)||c(g.type)||c(g.filter));b._setter=null;b.fnGetData=function(a,b,c){var d=j(a,b,k,c);return i&&b?i(d,b,a,c):d};b.fnSetData=function(a,b,c){return R(g)(a,b,c)};"number"!==typeof g&&(a._rowReadObject=!0);a.oFeatures.bSort||(b.bSortable=!1,e.addClass(d.sSortableNone));a=-1!==h.inArray("asc",b.asSorting);c=-1!==h.inArray("desc",b.asSorting);!b.bSortable||!a&&!c?(b.sSortingClass=d.sSortableNone,b.sSortingClassJUI=""):a&&!c?(b.sSortingClass= +d.sSortableAsc,b.sSortingClassJUI=d.sSortJUIAscAllowed):!a&&c?(b.sSortingClass=d.sSortableDesc,b.sSortingClassJUI=d.sSortJUIDescAllowed):(b.sSortingClass=d.sSortable,b.sSortingClassJUI=d.sSortJUI)}function Y(a){if(!1!==a.oFeatures.bAutoWidth){var b=a.aoColumns;Ea(a);for(var c=0,d=b.length;cq[f])d(l.length+q[f],n);else if("string"===typeof q[f]){j=0;for(i=l.length;j< +i;j++)("_all"==q[f]||h(l[j].nTh).hasClass(q[f]))&&d(j,n)}}if(c){e=0;for(a=c.length;eb&&a[e]--; -1!=d&&c===k&&a.splice(d,1)}function ca(a,b,c,d){var e=a.aoData[b],f,g=function(c,d){for(;c.childNodes.length;)c.removeChild(c.firstChild); +c.innerHTML=B(a,b,d,"display")};if("dom"===c||(!c||"auto"===c)&&"dom"===e.src)e._aData=Ha(a,e,d,d===k?k:e._aData).data;else{var j=e.anCells;if(j)if(d!==k)g(j[d],d);else{c=0;for(f=j.length;c").appendTo(g));b=0;for(c=l.length;btr").attr("role","row");h(g).find(">tr>th, >tr>td").addClass(n.sHeaderTH);h(j).find(">tr>th, >tr>td").addClass(n.sFooterTH); +if(null!==j){a=a.aoFooter[0];b=0;for(c=a.length;b=a.fnRecordsDisplay()?0:g,a.iInitDisplayStart= +-1);var g=a._iDisplayStart,n=a.fnDisplayEnd();if(a.bDeferLoading)a.bDeferLoading=!1,a.iDraw++,C(a,!1);else if(j){if(!a.bDestroying&&!kb(a))return}else a.iDraw++;if(0!==i.length){f=j?a.aoData.length:n;for(j=j?0:g;j",{"class":e?d[0]:""}).append(h("",{valign:"top",colSpan:aa(a),"class":a.oClasses.sRowEmpty}).html(c))[0];r(a,"aoHeaderCallback","header",[h(a.nTHead).children("tr")[0],Ja(a),g,n,i]);r(a,"aoFooterCallback","footer",[h(a.nTFoot).children("tr")[0],Ja(a),g,n,i]);d=h(a.nTBody);d.children().detach();d.append(h(b));r(a,"aoDrawCallback","draw",[a]);a.bSorted=!1;a.bFiltered=!1;a.bDrawing=!1}}function S(a,b){var c=a.oFeatures,d=c.bFilter; +c.bSort&&lb(a);d?fa(a,a.oPreviousSearch):a.aiDisplay=a.aiDisplayMaster.slice();!0!==b&&(a._iDisplayStart=0);a._drawHold=b;N(a);a._drawHold=!1}function mb(a){var b=a.oClasses,c=h(a.nTable),c=h("
    ").insertBefore(c),d=a.oFeatures,e=h("
    ",{id:a.sTableId+"_wrapper","class":b.sWrapper+(a.nTFoot?"":" "+b.sNoFooter)});a.nHolding=c[0];a.nTableWrapper=e[0];a.nTableReinsertBefore=a.nTable.nextSibling;for(var f=a.sDom.split(""),g,j,i,n,l,q,k=0;k")[0]; +n=f[k+1];if("'"==n||'"'==n){l="";for(q=2;f[k+q]!=n;)l+=f[k+q],q++;"H"==l?l=b.sJUIHeader:"F"==l&&(l=b.sJUIFooter);-1!=l.indexOf(".")?(n=l.split("."),i.id=n[0].substr(1,n[0].length-1),i.className=n[1]):"#"==l.charAt(0)?i.id=l.substr(1,l.length-1):i.className=l;k+=q}e.append(i);e=h(i)}else if(">"==j)e=e.parent();else if("l"==j&&d.bPaginate&&d.bLengthChange)g=nb(a);else if("f"==j&&d.bFilter)g=ob(a);else if("r"==j&&d.bProcessing)g=pb(a);else if("t"==j)g=qb(a);else if("i"==j&&d.bInfo)g=rb(a);else if("p"== +j&&d.bPaginate)g=sb(a);else if(0!==m.ext.feature.length){i=m.ext.feature;q=0;for(n=i.length;q',j=d.sSearch,j=j.match(/_INPUT_/)?j.replace("_INPUT_",g):j+g,b=h("
    ",{id:!f.f?c+"_filter":null,"class":b.sFilter}).append(h("
    ").addClass(b.sLength);a.aanFeatures.l||(i[0].id=c+"_length");i.children().append(a.oLanguage.sLengthMenu.replace("_MENU_",e[0].outerHTML));h("select",i).val(a._iDisplayLength).on("change.DT",function(){Qa(a,h(this).val());N(a)});h(a.nTable).on("length.dt.DT",function(b,c,d){a===c&&h("select",i).val(d)});return i[0]}function sb(a){var b=a.sPaginationType,c=m.ext.pager[b],d="function"===typeof c,e=function(a){N(a)}, +b=h("
    ").addClass(a.oClasses.sPaging+b)[0],f=a.aanFeatures;d||c.fnInit(a,b,e);f.p||(b.id=a.sTableId+"_paginate",a.aoDrawCallback.push({fn:function(a){if(d){var b=a._iDisplayStart,i=a._iDisplayLength,h=a.fnRecordsDisplay(),l=-1===i,b=l?0:Math.ceil(b/i),i=l?1:Math.ceil(h/i),h=c(b,i),k,l=0;for(k=f.p.length;lf&&(d=0)):"first"==b?d=0:"previous"==b?(d=0<=e?d-e:0,0>d&&(d=0)):"next"==b?d+e",{id:!a.aanFeatures.r?a.sTableId+"_processing":null,"class":a.oClasses.sProcessing}).html(a.oLanguage.sProcessing).insertBefore(a.nTable)[0]}function C(a,b){a.oFeatures.bProcessing&&h(a.aanFeatures.r).css("display", +b?"block":"none");r(a,null,"processing",[a,b])}function qb(a){var b=h(a.nTable);b.attr("role","grid");var c=a.oScroll;if(""===c.sX&&""===c.sY)return a.nTable;var d=c.sX,e=c.sY,f=a.oClasses,g=b.children("caption"),j=g.length?g[0]._captionSide:null,i=h(b[0].cloneNode(!1)),n=h(b[0].cloneNode(!1)),l=b.children("tfoot");l.length||(l=null);i=h("
    ",{"class":f.sScrollWrapper}).append(h("
    ",{"class":f.sScrollHead}).css({overflow:"hidden",position:"relative",border:0,width:d?!d?null:v(d):"100%"}).append(h("
    ", +{"class":f.sScrollHeadInner}).css({"box-sizing":"content-box",width:c.sXInner||"100%"}).append(i.removeAttr("id").css("margin-left",0).append("top"===j?g:null).append(b.children("thead"))))).append(h("
    ",{"class":f.sScrollBody}).css({position:"relative",overflow:"auto",width:!d?null:v(d)}).append(b));l&&i.append(h("
    ",{"class":f.sScrollFoot}).css({overflow:"hidden",border:0,width:d?!d?null:v(d):"100%"}).append(h("
    ",{"class":f.sScrollFootInner}).append(n.removeAttr("id").css("margin-left", +0).append("bottom"===j?g:null).append(b.children("tfoot")))));var b=i.children(),k=b[0],f=b[1],t=l?b[2]:null;if(d)h(f).on("scroll.DT",function(){var a=this.scrollLeft;k.scrollLeft=a;l&&(t.scrollLeft=a)});h(f).css(e&&c.bCollapse?"max-height":"height",e);a.nScrollHead=k;a.nScrollBody=f;a.nScrollFoot=t;a.aoDrawCallback.push({fn:ka,sName:"scrolling"});return i[0]}function ka(a){var b=a.oScroll,c=b.sX,d=b.sXInner,e=b.sY,b=b.iBarWidth,f=h(a.nScrollHead),g=f[0].style,j=f.children("div"),i=j[0].style,n=j.children("table"), +j=a.nScrollBody,l=h(j),q=j.style,t=h(a.nScrollFoot).children("div"),m=t.children("table"),o=h(a.nTHead),p=h(a.nTable),s=p[0],r=s.style,u=a.nTFoot?h(a.nTFoot):null,x=a.oBrowser,T=x.bScrollOversize,Xb=D(a.aoColumns,"nTh"),O,K,P,w,Ta=[],y=[],z=[],A=[],B,C=function(a){a=a.style;a.paddingTop="0";a.paddingBottom="0";a.borderTopWidth="0";a.borderBottomWidth="0";a.height=0};K=j.scrollHeight>j.clientHeight;if(a.scrollBarVis!==K&&a.scrollBarVis!==k)a.scrollBarVis=K,Y(a);else{a.scrollBarVis=K;p.children("thead, tfoot").remove(); +u&&(P=u.clone().prependTo(p),O=u.find("tr"),P=P.find("tr"));w=o.clone().prependTo(p);o=o.find("tr");K=w.find("tr");w.find("th, td").removeAttr("tabindex");c||(q.width="100%",f[0].style.width="100%");h.each(ra(a,w),function(b,c){B=Z(a,b);c.style.width=a.aoColumns[B].sWidth});u&&H(function(a){a.style.width=""},P);f=p.outerWidth();if(""===c){r.width="100%";if(T&&(p.find("tbody").height()>j.offsetHeight||"scroll"==l.css("overflow-y")))r.width=v(p.outerWidth()-b);f=p.outerWidth()}else""!==d&&(r.width= +v(d),f=p.outerWidth());H(C,K);H(function(a){z.push(a.innerHTML);Ta.push(v(h(a).css("width")))},K);H(function(a,b){if(h.inArray(a,Xb)!==-1)a.style.width=Ta[b]},o);h(K).height(0);u&&(H(C,P),H(function(a){A.push(a.innerHTML);y.push(v(h(a).css("width")))},P),H(function(a,b){a.style.width=y[b]},O),h(P).height(0));H(function(a,b){a.innerHTML='
    '+z[b]+"
    ";a.style.width=Ta[b]},K);u&&H(function(a,b){a.innerHTML='
    '+ +A[b]+"
    ";a.style.width=y[b]},P);if(p.outerWidth()j.offsetHeight||"scroll"==l.css("overflow-y")?f+b:f;if(T&&(j.scrollHeight>j.offsetHeight||"scroll"==l.css("overflow-y")))r.width=v(O-b);(""===c||""!==d)&&J(a,1,"Possible column misalignment",6)}else O="100%";q.width=v(O);g.width=v(O);u&&(a.nScrollFoot.style.width=v(O));!e&&T&&(q.height=v(s.offsetHeight+b));c=p.outerWidth();n[0].style.width=v(c);i.width=v(c);d=p.height()>j.clientHeight||"scroll"==l.css("overflow-y");e="padding"+ +(x.bScrollbarLeft?"Left":"Right");i[e]=d?b+"px":"0px";u&&(m[0].style.width=v(c),t[0].style.width=v(c),t[0].style[e]=d?b+"px":"0px");p.children("colgroup").insertBefore(p.children("thead"));l.scroll();if((a.bSorted||a.bFiltered)&&!a._drawHold)j.scrollTop=0}}function H(a,b,c){for(var d=0,e=0,f=b.length,g,j;e").appendTo(j.find("tbody")); +j.find("thead, tfoot").remove();j.append(h(a.nTHead).clone()).append(h(a.nTFoot).clone());j.find("tfoot th, tfoot td").css("width","");n=ra(a,j.find("thead")[0]);for(m=0;m").css({width:o.sWidthOrig,margin:0,padding:0,border:0,height:1}));if(a.aoData.length)for(m=0;m").css(f||e?{position:"absolute",top:0,left:0,height:1,right:0,overflow:"hidden"}:{}).append(j).appendTo(k);f&&g?j.width(g):f?(j.css("width","auto"),j.removeAttr("width"),j.width()").css("width",v(a)).appendTo(b||G.body),d=c[0].offsetWidth;c.remove();return d}function Eb(a,b){var c=Fb(a,b);if(0>c)return null;var d=a.aoData[c];return!d.nTr?h("").html(B(a,c,b,"display"))[0]:d.anCells[b]}function Fb(a,b){for(var c,d=-1,e=-1,f=0,g=a.aoData.length;fd&&(d=c.length,e=f);return e}function v(a){return null===a?"0px":"number"==typeof a?0>a?"0px":a+"px":a.match(/\d$/)?a+"px":a}function V(a){var b,c,d=[],e=a.aoColumns,f,g,j,i;b=a.aaSortingFixed;c=h.isPlainObject(b);var n=[];f=function(a){a.length&&!h.isArray(a[0])?n.push(a):h.merge(n,a)};h.isArray(b)&&f(b);c&&b.pre&&f(b.pre);f(a.aaSorting);c&&b.post&&f(b.post);for(a=0;ae?1:0,0!==c)return"asc"===j.dir?c:-c;c=d[a];e=d[b];return ce?1:0}):i.sort(function(a,b){var c,g,j,i,k=h.length,m=f[a]._aSortData,o=f[b]._aSortData;for(j=0;jg?1:0})}a.bSorted=!0}function Hb(a){for(var b,c,d=a.aoColumns,e=V(a),a=a.oLanguage.oAria,f=0,g=d.length;f/g, +"");var i=c.nTh;i.removeAttribute("aria-sort");c.bSortable&&(0e?e+1:3));e=0;for(f=d.length;ee?e+1:3))}a.aLastSort=d}function Gb(a,b){var c=a.aoColumns[b],d=m.ext.order[c.sSortDataType],e;d&&(e=d.call(a.oInstance,a,b,$(a,b)));for(var f,g=m.ext.type.order[c.sType+"-pre"],j=0,i=a.aoData.length;j=f.length?[0,c[1]]:c)}));b.search!== +k&&h.extend(a.oPreviousSearch,Ab(b.search));if(b.columns){d=0;for(e=b.columns.length;d=c&&(b=c-d);b-=b%d;if(-1===d||0>b)b=0;a._iDisplayStart=b}function Ma(a,b){var c=a.renderer,d=m.ext.renderer[b];return h.isPlainObject(c)&&c[b]?d[c[b]]||d._:"string"===typeof c?d[c]||d._:d._}function y(a){return a.oFeatures.bServerSide?"ssp":a.ajax||a.sAjaxSource?"ajax":"dom"}function ha(a,b){var c=[],c=Kb.numbers_length,d=Math.floor(c/2);b<=c?c=W(0,b):a<=d?(c=W(0, +c-2),c.push("ellipsis"),c.push(b-1)):(a>=b-1-d?c=W(b-(c-2),b):(c=W(a-d+2,a+d-1),c.push("ellipsis"),c.push(b-1)),c.splice(0,0,"ellipsis"),c.splice(0,0,0));c.DT_el="span";return c}function cb(a){h.each({num:function(b){return za(b,a)},"num-fmt":function(b){return za(b,a,Wa)},"html-num":function(b){return za(b,a,Aa)},"html-num-fmt":function(b){return za(b,a,Aa,Wa)}},function(b,c){x.type.order[b+a+"-pre"]=c;b.match(/^html\-/)&&(x.type.search[b+a]=x.type.search.html)})}function Lb(a){return function(){var b= +[ya(this[m.ext.iApiIndex])].concat(Array.prototype.slice.call(arguments));return m.ext.internal[a].apply(this,b)}}var m=function(a){this.$=function(a,b){return this.api(!0).$(a,b)};this._=function(a,b){return this.api(!0).rows(a,b).data()};this.api=function(a){return a?new s(ya(this[x.iApiIndex])):new s(this)};this.fnAddData=function(a,b){var c=this.api(!0),d=h.isArray(a)&&(h.isArray(a[0])||h.isPlainObject(a[0]))?c.rows.add(a):c.row.add(a);(b===k||b)&&c.draw();return d.flatten().toArray()};this.fnAdjustColumnSizing= +function(a){var b=this.api(!0).columns.adjust(),c=b.settings()[0],d=c.oScroll;a===k||a?b.draw(!1):(""!==d.sX||""!==d.sY)&&ka(c)};this.fnClearTable=function(a){var b=this.api(!0).clear();(a===k||a)&&b.draw()};this.fnClose=function(a){this.api(!0).row(a).child.hide()};this.fnDeleteRow=function(a,b,c){var d=this.api(!0),a=d.rows(a),e=a.settings()[0],h=e.aoData[a[0][0]];a.remove();b&&b.call(this,e,h);(c===k||c)&&d.draw();return h};this.fnDestroy=function(a){this.api(!0).destroy(a)};this.fnDraw=function(a){this.api(!0).draw(a)}; +this.fnFilter=function(a,b,c,d,e,h){e=this.api(!0);null===b||b===k?e.search(a,c,d,h):e.column(b).search(a,c,d,h);e.draw()};this.fnGetData=function(a,b){var c=this.api(!0);if(a!==k){var d=a.nodeName?a.nodeName.toLowerCase():"";return b!==k||"td"==d||"th"==d?c.cell(a,b).data():c.row(a).data()||null}return c.data().toArray()};this.fnGetNodes=function(a){var b=this.api(!0);return a!==k?b.row(a).node():b.rows().nodes().flatten().toArray()};this.fnGetPosition=function(a){var b=this.api(!0),c=a.nodeName.toUpperCase(); +return"TR"==c?b.row(a).index():"TD"==c||"TH"==c?(a=b.cell(a).index(),[a.row,a.columnVisible,a.column]):null};this.fnIsOpen=function(a){return this.api(!0).row(a).child.isShown()};this.fnOpen=function(a,b,c){return this.api(!0).row(a).child(b,c).show().child()[0]};this.fnPageChange=function(a,b){var c=this.api(!0).page(a);(b===k||b)&&c.draw(!1)};this.fnSetColumnVis=function(a,b,c){a=this.api(!0).column(a).visible(b);(c===k||c)&&a.columns.adjust().draw()};this.fnSettings=function(){return ya(this[x.iApiIndex])}; +this.fnSort=function(a){this.api(!0).order(a).draw()};this.fnSortListener=function(a,b,c){this.api(!0).order.listener(a,b,c)};this.fnUpdate=function(a,b,c,d,e){var h=this.api(!0);c===k||null===c?h.row(b).data(a):h.cell(b,c).data(a);(e===k||e)&&h.columns.adjust();(d===k||d)&&h.draw();return 0};this.fnVersionCheck=x.fnVersionCheck;var b=this,c=a===k,d=this.length;c&&(a={});this.oApi=this.internal=x.internal;for(var e in m.ext.internal)e&&(this[e]=Lb(e));this.each(function(){var e={},g=1").appendTo(q));p.nTHead=b[0];b=q.children("tbody");b.length===0&&(b=h("").appendTo(q));p.nTBody=b[0];b=q.children("tfoot");if(b.length===0&&a.length>0&&(p.oScroll.sX!==""||p.oScroll.sY!==""))b=h("").appendTo(q);if(b.length===0||b.children().length===0)q.addClass(u.sNoFooter); +else if(b.length>0){p.nTFoot=b[0];da(p.aoFooter,p.nTFoot)}if(g.aaData)for(j=0;j/g,Zb=/^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/,$b=RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\|\\$|\\^|\\-)", +"g"),Wa=/[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi,L=function(a){return!a||!0===a||"-"===a?!0:!1},Nb=function(a){var b=parseInt(a,10);return!isNaN(b)&&isFinite(a)?b:null},Ob=function(a,b){Xa[b]||(Xa[b]=RegExp(Pa(b),"g"));return"string"===typeof a&&"."!==b?a.replace(/\./g,"").replace(Xa[b],"."):a},Ya=function(a,b,c){var d="string"===typeof a;if(L(a))return!0;b&&d&&(a=Ob(a,b));c&&d&&(a=a.replace(Wa,""));return!isNaN(parseFloat(a))&&isFinite(a)},Pb=function(a,b,c){return L(a)?!0:!(L(a)||"string"=== +typeof a)?null:Ya(a.replace(Aa,""),b,c)?!0:null},D=function(a,b,c){var d=[],e=0,f=a.length;if(c!==k)for(;ea.length)){b=a.slice().sort();for(var c=b[0],d=1,e=b.length;d")[0],Wb=va.textContent!==k,Yb=/<.*?>/g,Na=m.util.throttle,Rb=[],w=Array.prototype,ac=function(a){var b,c,d=m.settings,e=h.map(d,function(a){return a.nTable});if(a){if(a.nTable&&a.oApi)return[a];if(a.nodeName&&"table"===a.nodeName.toLowerCase())return b=h.inArray(a,e),-1!==b?[d[b]]:null;if(a&&"function"===typeof a.settings)return a.settings().toArray();"string"===typeof a?c=h(a):a instanceof +h&&(c=a)}else return[];if(c)return c.map(function(){b=h.inArray(this,e);return-1!==b?d[b]:null}).toArray()};s=function(a,b){if(!(this instanceof s))return new s(a,b);var c=[],d=function(a){(a=ac(a))&&(c=c.concat(a))};if(h.isArray(a))for(var e=0,f=a.length;ea?new s(b[a],this[a]):null},filter:function(a){var b=[];if(w.filter)b=w.filter.call(this,a,this);else for(var c=0,d=this.length;c").addClass(b),h("td",c).addClass(b).html(a)[0].colSpan=aa(d),e.push(c[0]))};f(a,b);c._details&&c._details.detach();c._details=h(e);c._detailsShow&& +c._details.insertAfter(c.nTr)}return this});o(["row().child.show()","row().child().show()"],function(){Tb(this,!0);return this});o(["row().child.hide()","row().child().hide()"],function(){Tb(this,!1);return this});o(["row().child.remove()","row().child().remove()"],function(){bb(this);return this});o("row().child.isShown()",function(){var a=this.context;return a.length&&this.length?a[0].aoData[this[0]]._detailsShow||!1:!1});var bc=/^([^:]+):(name|visIdx|visible)$/,Ub=function(a,b,c,d,e){for(var c= +[],d=0,f=e.length;d=0?b:g.length+b];if(typeof a==="function"){var e=Ba(c,f);return h.map(g,function(b,f){return a(f,Ub(c,f,0,0,e),i[f])?f:null})}var k=typeof a==="string"?a.match(bc):"";if(k)switch(k[2]){case "visIdx":case "visible":b= +parseInt(k[1],10);if(b<0){var m=h.map(g,function(a,b){return a.bVisible?b:null});return[m[m.length+b]]}return[Z(c,b)];case "name":return h.map(j,function(a,b){return a===k[1]?b:null});default:return[]}if(a.nodeName&&a._DT_CellIndex)return[a._DT_CellIndex.column];b=h(i).filter(a).map(function(){return h.inArray(this,i)}).toArray();if(b.length||!a.nodeName)return b;b=h(a).closest("*[data-dt-column]");return b.length?[b.data("dt-column")]:[]},c,f)},1);c.selector.cols=a;c.selector.opts=b;return c});u("columns().header()", +"column().header()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTh},1)});u("columns().footer()","column().footer()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTf},1)});u("columns().data()","column().data()",function(){return this.iterator("column-rows",Ub,1)});u("columns().dataSrc()","column().dataSrc()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].mData},1)});u("columns().cache()","column().cache()", +function(a){return this.iterator("column-rows",function(b,c,d,e,f){return ia(b.aoData,f,"search"===a?"_aFilterData":"_aSortData",c)},1)});u("columns().nodes()","column().nodes()",function(){return this.iterator("column-rows",function(a,b,c,d,e){return ia(a.aoData,e,"anCells",b)},1)});u("columns().visible()","column().visible()",function(a,b){var c=this.iterator("column",function(b,c){if(a===k)return b.aoColumns[c].bVisible;var f=b.aoColumns,g=f[c],j=b.aoData,i,n,l;if(a!==k&&g.bVisible!==a){if(a){var m= +h.inArray(!0,D(f,"bVisible"),c+1);i=0;for(n=j.length;id;return!0};m.isDataTable=m.fnIsDataTable=function(a){var b=h(a).get(0),c=!1;if(a instanceof m.Api)return!0;h.each(m.settings,function(a,e){var f=e.nScrollHead?h("table",e.nScrollHead)[0]:null,g=e.nScrollFoot? +h("table",e.nScrollFoot)[0]:null;if(e.nTable===b||f===b||g===b)c=!0});return c};m.tables=m.fnTables=function(a){var b=!1;h.isPlainObject(a)&&(b=a.api,a=a.visible);var c=h.map(m.settings,function(b){if(!a||a&&h(b.nTable).is(":visible"))return b.nTable});return b?new s(c):c};m.camelToHungarian=I;o("$()",function(a,b){var c=this.rows(b).nodes(),c=h(c);return h([].concat(c.filter(a).toArray(),c.find(a).toArray()))});h.each(["on","one","off"],function(a,b){o(b+"()",function(){var a=Array.prototype.slice.call(arguments); +a[0]=h.map(a[0].split(/\s/),function(a){return!a.match(/\.dt\b/)?a+".dt":a}).join(" ");var d=h(this.tables().nodes());d[b].apply(d,a);return this})});o("clear()",function(){return this.iterator("table",function(a){na(a)})});o("settings()",function(){return new s(this.context,this.context)});o("init()",function(){var a=this.context;return a.length?a[0].oInit:null});o("data()",function(){return this.iterator("table",function(a){return D(a.aoData,"_aData")}).flatten()});o("destroy()",function(a){a=a|| +!1;return this.iterator("table",function(b){var c=b.nTableWrapper.parentNode,d=b.oClasses,e=b.nTable,f=b.nTBody,g=b.nTHead,j=b.nTFoot,i=h(e),f=h(f),k=h(b.nTableWrapper),l=h.map(b.aoData,function(a){return a.nTr}),o;b.bDestroying=!0;r(b,"aoDestroyCallback","destroy",[b]);a||(new s(b)).columns().visible(!0);k.off(".DT").find(":not(tbody *)").off(".DT");h(E).off(".DT-"+b.sInstance);e!=g.parentNode&&(i.children("thead").detach(),i.append(g));j&&e!=j.parentNode&&(i.children("tfoot").detach(),i.append(j)); +b.aaSorting=[];b.aaSortingFixed=[];wa(b);h(l).removeClass(b.asStripeClasses.join(" "));h("th, td",g).removeClass(d.sSortable+" "+d.sSortableAsc+" "+d.sSortableDesc+" "+d.sSortableNone);f.children().detach();f.append(l);g=a?"remove":"detach";i[g]();k[g]();!a&&c&&(c.insertBefore(e,b.nTableReinsertBefore),i.css("width",b.sDestroyWidth).removeClass(d.sTable),(o=b.asDestroyStripes.length)&&f.children().each(function(a){h(this).addClass(b.asDestroyStripes[a%o])}));c=h.inArray(b,m.settings);-1!==c&&m.settings.splice(c, +1)})});h.each(["column","row","cell"],function(a,b){o(b+"s().every()",function(a){var d=this.selector.opts,e=this;return this.iterator(b,function(f,g,h,i,n){a.call(e[b](g,"cell"===b?h:d,"cell"===b?d:k),g,h,i,n)})})});o("i18n()",function(a,b,c){var d=this.context[0],a=Q(a)(d.oLanguage);a===k&&(a=b);c!==k&&h.isPlainObject(a)&&(a=a[c]!==k?a[c]:a._);return a.replace("%d",c)});m.version="1.10.16";m.settings=[];m.models={};m.models.oSearch={bCaseInsensitive:!0,sSearch:"",bRegex:!1,bSmart:!0};m.models.oRow= +{nTr:null,anCells:null,_aData:[],_aSortData:null,_aFilterData:null,_sFilterRow:null,_sRowStripe:"",src:null,idx:-1};m.models.oColumn={idx:null,aDataSort:null,asSorting:null,bSearchable:null,bSortable:null,bVisible:null,_sManualType:null,_bAttrSrc:!1,fnCreatedCell:null,fnGetData:null,fnSetData:null,mData:null,mRender:null,nTh:null,nTf:null,sClass:null,sContentPadding:null,sDefaultContent:null,sName:null,sSortDataType:"std",sSortingClass:null,sSortingClassJUI:null,sTitle:null,sType:null,sWidth:null, +sWidthOrig:null};m.defaults={aaData:null,aaSorting:[[0,"asc"]],aaSortingFixed:[],ajax:null,aLengthMenu:[10,25,50,100],aoColumns:null,aoColumnDefs:null,aoSearchCols:[],asStripeClasses:null,bAutoWidth:!0,bDeferRender:!1,bDestroy:!1,bFilter:!0,bInfo:!0,bLengthChange:!0,bPaginate:!0,bProcessing:!1,bRetrieve:!1,bScrollCollapse:!1,bServerSide:!1,bSort:!0,bSortMulti:!0,bSortCellsTop:!1,bSortClasses:!0,bStateSave:!1,fnCreatedRow:null,fnDrawCallback:null,fnFooterCallback:null,fnFormatNumber:function(a){return a.toString().replace(/\B(?=(\d{3})+(?!\d))/g, +this.oLanguage.sThousands)},fnHeaderCallback:null,fnInfoCallback:null,fnInitComplete:null,fnPreDrawCallback:null,fnRowCallback:null,fnServerData:null,fnServerParams:null,fnStateLoadCallback:function(a){try{return JSON.parse((-1===a.iStateDuration?sessionStorage:localStorage).getItem("DataTables_"+a.sInstance+"_"+location.pathname))}catch(b){}},fnStateLoadParams:null,fnStateLoaded:null,fnStateSaveCallback:function(a,b){try{(-1===a.iStateDuration?sessionStorage:localStorage).setItem("DataTables_"+a.sInstance+ +"_"+location.pathname,JSON.stringify(b))}catch(c){}},fnStateSaveParams:null,iStateDuration:7200,iDeferLoading:null,iDisplayLength:10,iDisplayStart:0,iTabIndex:0,oClasses:{},oLanguage:{oAria:{sSortAscending:": activate to sort column ascending",sSortDescending:": activate to sort column descending"},oPaginate:{sFirst:"First",sLast:"Last",sNext:"Next",sPrevious:"Previous"},sEmptyTable:"No data available in table",sInfo:"Showing _START_ to _END_ of _TOTAL_ entries",sInfoEmpty:"Showing 0 to 0 of 0 entries", +sInfoFiltered:"(filtered from _MAX_ total entries)",sInfoPostFix:"",sDecimal:"",sThousands:",",sLengthMenu:"Show _MENU_ entries",sLoadingRecords:"Loading...",sProcessing:"Processing...",sSearch:"Search:",sSearchPlaceholder:"",sUrl:"",sZeroRecords:"No matching records found"},oSearch:h.extend({},m.models.oSearch),sAjaxDataProp:"data",sAjaxSource:null,sDom:"lfrtip",searchDelay:null,sPaginationType:"simple_numbers",sScrollX:"",sScrollXInner:"",sScrollY:"",sServerMethod:"GET",renderer:null,rowId:"DT_RowId"}; +X(m.defaults);m.defaults.column={aDataSort:null,iDataSort:-1,asSorting:["asc","desc"],bSearchable:!0,bSortable:!0,bVisible:!0,fnCreatedCell:null,mData:null,mRender:null,sCellType:"td",sClass:"",sContentPadding:"",sDefaultContent:null,sName:"",sSortDataType:"std",sTitle:null,sType:null,sWidth:null};X(m.defaults.column);m.models.oSettings={oFeatures:{bAutoWidth:null,bDeferRender:null,bFilter:null,bInfo:null,bLengthChange:null,bPaginate:null,bProcessing:null,bServerSide:null,bSort:null,bSortMulti:null, +bSortClasses:null,bStateSave:null},oScroll:{bCollapse:null,iBarWidth:0,sX:null,sXInner:null,sY:null},oLanguage:{fnInfoCallback:null},oBrowser:{bScrollOversize:!1,bScrollbarLeft:!1,bBounding:!1,barWidth:0},ajax:null,aanFeatures:[],aoData:[],aiDisplay:[],aiDisplayMaster:[],aIds:{},aoColumns:[],aoHeader:[],aoFooter:[],oPreviousSearch:{},aoPreSearchCols:[],aaSorting:null,aaSortingFixed:[],asStripeClasses:null,asDestroyStripes:[],sDestroyWidth:0,aoRowCallback:[],aoHeaderCallback:[],aoFooterCallback:[], +aoDrawCallback:[],aoRowCreatedCallback:[],aoPreDrawCallback:[],aoInitComplete:[],aoStateSaveParams:[],aoStateLoadParams:[],aoStateLoaded:[],sTableId:"",nTable:null,nTHead:null,nTFoot:null,nTBody:null,nTableWrapper:null,bDeferLoading:!1,bInitialised:!1,aoOpenRows:[],sDom:null,searchDelay:null,sPaginationType:"two_button",iStateDuration:0,aoStateSave:[],aoStateLoad:[],oSavedState:null,oLoadedState:null,sAjaxSource:null,sAjaxDataProp:null,bAjaxDataGet:!0,jqXHR:null,json:k,oAjaxData:k,fnServerData:null, +aoServerParams:[],sServerMethod:null,fnFormatNumber:null,aLengthMenu:null,iDraw:0,bDrawing:!1,iDrawError:-1,_iDisplayLength:10,_iDisplayStart:0,_iRecordsTotal:0,_iRecordsDisplay:0,oClasses:{},bFiltered:!1,bSorted:!1,bSortCellsTop:null,oInit:null,aoDestroyCallback:[],fnRecordsTotal:function(){return"ssp"==y(this)?1*this._iRecordsTotal:this.aiDisplayMaster.length},fnRecordsDisplay:function(){return"ssp"==y(this)?1*this._iRecordsDisplay:this.aiDisplay.length},fnDisplayEnd:function(){var a=this._iDisplayLength, +b=this._iDisplayStart,c=b+a,d=this.aiDisplay.length,e=this.oFeatures,f=e.bPaginate;return e.bServerSide?!1===f||-1===a?b+d:Math.min(b+a,this._iRecordsDisplay):!f||c>d||-1===a?d:c},oInstance:null,sInstance:null,iTabIndex:0,nScrollHead:null,nScrollFoot:null,aLastSort:[],oPlugins:{},rowIdFn:null,rowId:null};m.ext=x={buttons:{},classes:{},builder:"-source-",errMode:"alert",feature:[],search:[],selector:{cell:[],column:[],row:[]},internal:{},legacy:{ajax:null},pager:{},renderer:{pageButton:{},header:{}}, +order:{},type:{detect:[],search:{},order:{}},_unique:0,fnVersionCheck:m.fnVersionCheck,iApiIndex:0,oJUIClasses:{},sVersion:m.version};h.extend(x,{afnFiltering:x.search,aTypes:x.type.detect,ofnSearch:x.type.search,oSort:x.type.order,afnSortData:x.order,aoFeatures:x.feature,oApi:x.internal,oStdClasses:x.classes,oPagination:x.pager});h.extend(m.ext.classes,{sTable:"dataTable",sNoFooter:"no-footer",sPageButton:"paginate_button",sPageButtonActive:"current",sPageButtonDisabled:"disabled",sStripeOdd:"odd", +sStripeEven:"even",sRowEmpty:"dataTables_empty",sWrapper:"dataTables_wrapper",sFilter:"dataTables_filter",sInfo:"dataTables_info",sPaging:"dataTables_paginate paging_",sLength:"dataTables_length",sProcessing:"dataTables_processing",sSortAsc:"sorting_asc",sSortDesc:"sorting_desc",sSortable:"sorting",sSortableAsc:"sorting_asc_disabled",sSortableDesc:"sorting_desc_disabled",sSortableNone:"sorting_disabled",sSortColumn:"sorting_",sFilterInput:"",sLengthSelect:"",sScrollWrapper:"dataTables_scroll",sScrollHead:"dataTables_scrollHead", +sScrollHeadInner:"dataTables_scrollHeadInner",sScrollBody:"dataTables_scrollBody",sScrollFoot:"dataTables_scrollFoot",sScrollFootInner:"dataTables_scrollFootInner",sHeaderTH:"",sFooterTH:"",sSortJUIAsc:"",sSortJUIDesc:"",sSortJUI:"",sSortJUIAscAllowed:"",sSortJUIDescAllowed:"",sSortJUIWrapper:"",sSortIcon:"",sJUIHeader:"",sJUIFooter:""});var Kb=m.ext.pager;h.extend(Kb,{simple:function(){return["previous","next"]},full:function(){return["first","previous","next","last"]},numbers:function(a,b){return[ha(a, +b)]},simple_numbers:function(a,b){return["previous",ha(a,b),"next"]},full_numbers:function(a,b){return["first","previous",ha(a,b),"next","last"]},first_last_numbers:function(a,b){return["first",ha(a,b),"last"]},_numbers:ha,numbers_length:7});h.extend(!0,m.ext.renderer,{pageButton:{_:function(a,b,c,d,e,f){var g=a.oClasses,j=a.oLanguage.oPaginate,i=a.oLanguage.oAria.paginate||{},n,l,m=0,o=function(b,d){var k,s,u,r,v=function(b){Sa(a,b.data.action,true)};k=0;for(s=d.length;k").appendTo(b);o(u,r)}else{n=null;l="";switch(r){case "ellipsis":b.append('');break;case "first":n=j.sFirst;l=r+(e>0?"":" "+g.sPageButtonDisabled);break;case "previous":n=j.sPrevious;l=r+(e>0?"":" "+g.sPageButtonDisabled);break;case "next":n=j.sNext;l=r+(e",{"class":g.sPageButton+ +" "+l,"aria-controls":a.sTableId,"aria-label":i[r],"data-dt-idx":m,tabindex:a.iTabIndex,id:c===0&&typeof r==="string"?a.sTableId+"_"+r:null}).html(n).appendTo(b);Va(u,{action:r},v);m++}}}},s;try{s=h(b).find(G.activeElement).data("dt-idx")}catch(u){}o(h(b).empty(),d);s!==k&&h(b).find("[data-dt-idx="+s+"]").focus()}}});h.extend(m.ext.type.detect,[function(a,b){var c=b.oLanguage.sDecimal;return Ya(a,c)?"num"+c:null},function(a){if(a&&!(a instanceof Date)&&!Zb.test(a))return null;var b=Date.parse(a); +return null!==b&&!isNaN(b)||L(a)?"date":null},function(a,b){var c=b.oLanguage.sDecimal;return Ya(a,c,!0)?"num-fmt"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Pb(a,c)?"html-num"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Pb(a,c,!0)?"html-num-fmt"+c:null},function(a){return L(a)||"string"===typeof a&&-1!==a.indexOf("<")?"html":null}]);h.extend(m.ext.type.search,{html:function(a){return L(a)?a:"string"===typeof a?a.replace(Mb," ").replace(Aa,""):""},string:function(a){return L(a)? +a:"string"===typeof a?a.replace(Mb," "):a}});var za=function(a,b,c,d){if(0!==a&&(!a||"-"===a))return-Infinity;b&&(a=Ob(a,b));a.replace&&(c&&(a=a.replace(c,"")),d&&(a=a.replace(d,"")));return 1*a};h.extend(x.type.order,{"date-pre":function(a){return Date.parse(a)||-Infinity},"html-pre":function(a){return L(a)?"":a.replace?a.replace(/<.*?>/g,"").toLowerCase():a+""},"string-pre":function(a){return L(a)?"":"string"===typeof a?a.toLowerCase():!a.toString?"":a.toString()},"string-asc":function(a,b){return a< +b?-1:a>b?1:0},"string-desc":function(a,b){return ab?-1:0}});cb("");h.extend(!0,m.ext.renderer,{header:{_:function(a,b,c,d){h(a.nTable).on("order.dt.DT",function(e,f,g,h){if(a===f){e=c.idx;b.removeClass(c.sSortingClass+" "+d.sSortAsc+" "+d.sSortDesc).addClass(h[e]=="asc"?d.sSortAsc:h[e]=="desc"?d.sSortDesc:c.sSortingClass)}})},jqueryui:function(a,b,c,d){h("
    ").addClass(d.sSortJUIWrapper).append(b.contents()).append(h("").addClass(d.sSortIcon+" "+c.sSortingClassJUI)).appendTo(b); +h(a.nTable).on("order.dt.DT",function(e,f,g,h){if(a===f){e=c.idx;b.removeClass(d.sSortAsc+" "+d.sSortDesc).addClass(h[e]=="asc"?d.sSortAsc:h[e]=="desc"?d.sSortDesc:c.sSortingClass);b.find("span."+d.sSortIcon).removeClass(d.sSortJUIAsc+" "+d.sSortJUIDesc+" "+d.sSortJUI+" "+d.sSortJUIAscAllowed+" "+d.sSortJUIDescAllowed).addClass(h[e]=="asc"?d.sSortJUIAsc:h[e]=="desc"?d.sSortJUIDesc:c.sSortingClassJUI)}})}}});var Vb=function(a){return"string"===typeof a?a.replace(//g,">").replace(/"/g, +"""):a};m.render={number:function(a,b,c,d,e){return{display:function(f){if("number"!==typeof f&&"string"!==typeof f)return f;var g=0>f?"-":"",h=parseFloat(f);if(isNaN(h))return Vb(f);h=h.toFixed(c);f=Math.abs(h);h=parseInt(f,10);f=c?b+(f-h).toFixed(c).substring(2):"";return g+(d||"")+h.toString().replace(/\B(?=(\d{3})+(?!\d))/g,a)+f+(e||"")}}},text:function(){return{display:Vb}}};h.extend(m.ext.internal,{_fnExternApiFunc:Lb,_fnBuildAjax:sa,_fnAjaxUpdate:kb,_fnAjaxParameters:tb,_fnAjaxUpdateDraw:ub, +_fnAjaxDataSrc:ta,_fnAddColumn:Da,_fnColumnOptions:ja,_fnAdjustColumnSizing:Y,_fnVisibleToColumnIndex:Z,_fnColumnIndexToVisible:$,_fnVisbleColumns:aa,_fnGetColumns:la,_fnColumnTypes:Fa,_fnApplyColumnDefs:hb,_fnHungarianMap:X,_fnCamelToHungarian:I,_fnLanguageCompat:Ca,_fnBrowserDetect:fb,_fnAddData:M,_fnAddTr:ma,_fnNodeToDataIndex:function(a,b){return b._DT_RowIndex!==k?b._DT_RowIndex:null},_fnNodeToColumnIndex:function(a,b,c){return h.inArray(c,a.aoData[b].anCells)},_fnGetCellData:B,_fnSetCellData:ib, +_fnSplitObjNotation:Ia,_fnGetObjectDataFn:Q,_fnSetObjectDataFn:R,_fnGetDataMaster:Ja,_fnClearTable:na,_fnDeleteIndex:oa,_fnInvalidate:ca,_fnGetRowElements:Ha,_fnCreateTr:Ga,_fnBuildHead:jb,_fnDrawHead:ea,_fnDraw:N,_fnReDraw:S,_fnAddOptionsHtml:mb,_fnDetectHeader:da,_fnGetUniqueThs:ra,_fnFeatureHtmlFilter:ob,_fnFilterComplete:fa,_fnFilterCustom:xb,_fnFilterColumn:wb,_fnFilter:vb,_fnFilterCreateSearch:Oa,_fnEscapeRegex:Pa,_fnFilterData:yb,_fnFeatureHtmlInfo:rb,_fnUpdateInfo:Bb,_fnInfoMacros:Cb,_fnInitialise:ga, +_fnInitComplete:ua,_fnLengthChange:Qa,_fnFeatureHtmlLength:nb,_fnFeatureHtmlPaginate:sb,_fnPageChange:Sa,_fnFeatureHtmlProcessing:pb,_fnProcessingDisplay:C,_fnFeatureHtmlTable:qb,_fnScrollDraw:ka,_fnApplyToChildren:H,_fnCalculateColumnWidths:Ea,_fnThrottle:Na,_fnConvertToWidth:Db,_fnGetWidestNode:Eb,_fnGetMaxLenString:Fb,_fnStringToCss:v,_fnSortFlatten:V,_fnSort:lb,_fnSortAria:Hb,_fnSortListener:Ua,_fnSortAttachListener:La,_fnSortingClasses:wa,_fnSortData:Gb,_fnSaveState:xa,_fnLoadState:Ib,_fnSettingsFromNode:ya, +_fnLog:J,_fnMap:F,_fnBindAction:Va,_fnCallbackReg:z,_fnCallbackFire:r,_fnLengthOverflow:Ra,_fnRenderer:Ma,_fnDataSource:y,_fnRowAttributes:Ka,_fnCalculateEnd:function(){}});h.fn.dataTable=m;m.$=h;h.fn.dataTableSettings=m.settings;h.fn.dataTableExt=m.ext;h.fn.DataTable=function(a){return h(this).dataTable(a).api()};h.each(m,function(a,b){h.fn.DataTable[a]=b});return h.fn.dataTable}); diff --git a/docs/articles/pkgnet-report_files/htmlwidgets-1.3/htmlwidgets.js b/docs/articles/pkgnet-report_files/htmlwidgets-1.3/htmlwidgets.js new file mode 100644 index 00000000..ed9837d9 --- /dev/null +++ b/docs/articles/pkgnet-report_files/htmlwidgets-1.3/htmlwidgets.js @@ -0,0 +1,839 @@ +(function() { + // If window.HTMLWidgets is already defined, then use it; otherwise create a + // new object. This allows preceding code to set options that affect the + // initialization process (though none currently exist). + window.HTMLWidgets = window.HTMLWidgets || {}; + + // See if we're running in a viewer pane. If not, we're in a web browser. + var viewerMode = window.HTMLWidgets.viewerMode = + /\bviewer_pane=1\b/.test(window.location); + + // See if we're running in Shiny mode. If not, it's a static document. + // Note that static widgets can appear in both Shiny and static modes, but + // obviously, Shiny widgets can only appear in Shiny apps/documents. + var shinyMode = window.HTMLWidgets.shinyMode = + typeof(window.Shiny) !== "undefined" && !!window.Shiny.outputBindings; + + // We can't count on jQuery being available, so we implement our own + // version if necessary. + function querySelectorAll(scope, selector) { + if (typeof(jQuery) !== "undefined" && scope instanceof jQuery) { + return scope.find(selector); + } + if (scope.querySelectorAll) { + return scope.querySelectorAll(selector); + } + } + + function asArray(value) { + if (value === null) + return []; + if ($.isArray(value)) + return value; + return [value]; + } + + // Implement jQuery's extend + function extend(target /*, ... */) { + if (arguments.length == 1) { + return target; + } + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + for (var prop in source) { + if (source.hasOwnProperty(prop)) { + target[prop] = source[prop]; + } + } + } + return target; + } + + // IE8 doesn't support Array.forEach. + function forEach(values, callback, thisArg) { + if (values.forEach) { + values.forEach(callback, thisArg); + } else { + for (var i = 0; i < values.length; i++) { + callback.call(thisArg, values[i], i, values); + } + } + } + + // Replaces the specified method with the return value of funcSource. + // + // Note that funcSource should not BE the new method, it should be a function + // that RETURNS the new method. funcSource receives a single argument that is + // the overridden method, it can be called from the new method. The overridden + // method can be called like a regular function, it has the target permanently + // bound to it so "this" will work correctly. + function overrideMethod(target, methodName, funcSource) { + var superFunc = target[methodName] || function() {}; + var superFuncBound = function() { + return superFunc.apply(target, arguments); + }; + target[methodName] = funcSource(superFuncBound); + } + + // Add a method to delegator that, when invoked, calls + // delegatee.methodName. If there is no such method on + // the delegatee, but there was one on delegator before + // delegateMethod was called, then the original version + // is invoked instead. + // For example: + // + // var a = { + // method1: function() { console.log('a1'); } + // method2: function() { console.log('a2'); } + // }; + // var b = { + // method1: function() { console.log('b1'); } + // }; + // delegateMethod(a, b, "method1"); + // delegateMethod(a, b, "method2"); + // a.method1(); + // a.method2(); + // + // The output would be "b1", "a2". + function delegateMethod(delegator, delegatee, methodName) { + var inherited = delegator[methodName]; + delegator[methodName] = function() { + var target = delegatee; + var method = delegatee[methodName]; + + // The method doesn't exist on the delegatee. Instead, + // call the method on the delegator, if it exists. + if (!method) { + target = delegator; + method = inherited; + } + + if (method) { + return method.apply(target, arguments); + } + }; + } + + // Implement a vague facsimilie of jQuery's data method + function elementData(el, name, value) { + if (arguments.length == 2) { + return el["htmlwidget_data_" + name]; + } else if (arguments.length == 3) { + el["htmlwidget_data_" + name] = value; + return el; + } else { + throw new Error("Wrong number of arguments for elementData: " + + arguments.length); + } + } + + // http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex + function escapeRegExp(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + } + + function hasClass(el, className) { + var re = new RegExp("\\b" + escapeRegExp(className) + "\\b"); + return re.test(el.className); + } + + // elements - array (or array-like object) of HTML elements + // className - class name to test for + // include - if true, only return elements with given className; + // if false, only return elements *without* given className + function filterByClass(elements, className, include) { + var results = []; + for (var i = 0; i < elements.length; i++) { + if (hasClass(elements[i], className) == include) + results.push(elements[i]); + } + return results; + } + + function on(obj, eventName, func) { + if (obj.addEventListener) { + obj.addEventListener(eventName, func, false); + } else if (obj.attachEvent) { + obj.attachEvent(eventName, func); + } + } + + function off(obj, eventName, func) { + if (obj.removeEventListener) + obj.removeEventListener(eventName, func, false); + else if (obj.detachEvent) { + obj.detachEvent(eventName, func); + } + } + + // Translate array of values to top/right/bottom/left, as usual with + // the "padding" CSS property + // https://developer.mozilla.org/en-US/docs/Web/CSS/padding + function unpackPadding(value) { + if (typeof(value) === "number") + value = [value]; + if (value.length === 1) { + return {top: value[0], right: value[0], bottom: value[0], left: value[0]}; + } + if (value.length === 2) { + return {top: value[0], right: value[1], bottom: value[0], left: value[1]}; + } + if (value.length === 3) { + return {top: value[0], right: value[1], bottom: value[2], left: value[1]}; + } + if (value.length === 4) { + return {top: value[0], right: value[1], bottom: value[2], left: value[3]}; + } + } + + // Convert an unpacked padding object to a CSS value + function paddingToCss(paddingObj) { + return paddingObj.top + "px " + paddingObj.right + "px " + paddingObj.bottom + "px " + paddingObj.left + "px"; + } + + // Makes a number suitable for CSS + function px(x) { + if (typeof(x) === "number") + return x + "px"; + else + return x; + } + + // Retrieves runtime widget sizing information for an element. + // The return value is either null, or an object with fill, padding, + // defaultWidth, defaultHeight fields. + function sizingPolicy(el) { + var sizingEl = document.querySelector("script[data-for='" + el.id + "'][type='application/htmlwidget-sizing']"); + if (!sizingEl) + return null; + var sp = JSON.parse(sizingEl.textContent || sizingEl.text || "{}"); + if (viewerMode) { + return sp.viewer; + } else { + return sp.browser; + } + } + + // @param tasks Array of strings (or falsy value, in which case no-op). + // Each element must be a valid JavaScript expression that yields a + // function. Or, can be an array of objects with "code" and "data" + // properties; in this case, the "code" property should be a string + // of JS that's an expr that yields a function, and "data" should be + // an object that will be added as an additional argument when that + // function is called. + // @param target The object that will be "this" for each function + // execution. + // @param args Array of arguments to be passed to the functions. (The + // same arguments will be passed to all functions.) + function evalAndRun(tasks, target, args) { + if (tasks) { + forEach(tasks, function(task) { + var theseArgs = args; + if (typeof(task) === "object") { + theseArgs = theseArgs.concat([task.data]); + task = task.code; + } + var taskFunc = eval("(" + task + ")"); + if (typeof(taskFunc) !== "function") { + throw new Error("Task must be a function! Source:\n" + task); + } + taskFunc.apply(target, theseArgs); + }); + } + } + + function initSizing(el) { + var sizing = sizingPolicy(el); + if (!sizing) + return; + + var cel = document.getElementById("htmlwidget_container"); + if (!cel) + return; + + if (typeof(sizing.padding) !== "undefined") { + document.body.style.margin = "0"; + document.body.style.padding = paddingToCss(unpackPadding(sizing.padding)); + } + + if (sizing.fill) { + document.body.style.overflow = "hidden"; + document.body.style.width = "100%"; + document.body.style.height = "100%"; + document.documentElement.style.width = "100%"; + document.documentElement.style.height = "100%"; + if (cel) { + cel.style.position = "absolute"; + var pad = unpackPadding(sizing.padding); + cel.style.top = pad.top + "px"; + cel.style.right = pad.right + "px"; + cel.style.bottom = pad.bottom + "px"; + cel.style.left = pad.left + "px"; + el.style.width = "100%"; + el.style.height = "100%"; + } + + return { + getWidth: function() { return cel.offsetWidth; }, + getHeight: function() { return cel.offsetHeight; } + }; + + } else { + el.style.width = px(sizing.width); + el.style.height = px(sizing.height); + + return { + getWidth: function() { return el.offsetWidth; }, + getHeight: function() { return el.offsetHeight; } + }; + } + } + + // Default implementations for methods + var defaults = { + find: function(scope) { + return querySelectorAll(scope, "." + this.name); + }, + renderError: function(el, err) { + var $el = $(el); + + this.clearError(el); + + // Add all these error classes, as Shiny does + var errClass = "shiny-output-error"; + if (err.type !== null) { + // use the classes of the error condition as CSS class names + errClass = errClass + " " + $.map(asArray(err.type), function(type) { + return errClass + "-" + type; + }).join(" "); + } + errClass = errClass + " htmlwidgets-error"; + + // Is el inline or block? If inline or inline-block, just display:none it + // and add an inline error. + var display = $el.css("display"); + $el.data("restore-display-mode", display); + + if (display === "inline" || display === "inline-block") { + $el.hide(); + if (err.message !== "") { + var errorSpan = $("").addClass(errClass); + errorSpan.text(err.message); + $el.after(errorSpan); + } + } else if (display === "block") { + // If block, add an error just after the el, set visibility:none on the + // el, and position the error to be on top of the el. + // Mark it with a unique ID and CSS class so we can remove it later. + $el.css("visibility", "hidden"); + if (err.message !== "") { + var errorDiv = $("
    ").addClass(errClass).css("position", "absolute") + .css("top", el.offsetTop) + .css("left", el.offsetLeft) + // setting width can push out the page size, forcing otherwise + // unnecessary scrollbars to appear and making it impossible for + // the element to shrink; so use max-width instead + .css("maxWidth", el.offsetWidth) + .css("height", el.offsetHeight); + errorDiv.text(err.message); + $el.after(errorDiv); + + // Really dumb way to keep the size/position of the error in sync with + // the parent element as the window is resized or whatever. + var intId = setInterval(function() { + if (!errorDiv[0].parentElement) { + clearInterval(intId); + return; + } + errorDiv + .css("top", el.offsetTop) + .css("left", el.offsetLeft) + .css("maxWidth", el.offsetWidth) + .css("height", el.offsetHeight); + }, 500); + } + } + }, + clearError: function(el) { + var $el = $(el); + var display = $el.data("restore-display-mode"); + $el.data("restore-display-mode", null); + + if (display === "inline" || display === "inline-block") { + if (display) + $el.css("display", display); + $(el.nextSibling).filter(".htmlwidgets-error").remove(); + } else if (display === "block"){ + $el.css("visibility", "inherit"); + $(el.nextSibling).filter(".htmlwidgets-error").remove(); + } + }, + sizing: {} + }; + + // Called by widget bindings to register a new type of widget. The definition + // object can contain the following properties: + // - name (required) - A string indicating the binding name, which will be + // used by default as the CSS classname to look for. + // - initialize (optional) - A function(el) that will be called once per + // widget element; if a value is returned, it will be passed as the third + // value to renderValue. + // - renderValue (required) - A function(el, data, initValue) that will be + // called with data. Static contexts will cause this to be called once per + // element; Shiny apps will cause this to be called multiple times per + // element, as the data changes. + window.HTMLWidgets.widget = function(definition) { + if (!definition.name) { + throw new Error("Widget must have a name"); + } + if (!definition.type) { + throw new Error("Widget must have a type"); + } + // Currently we only support output widgets + if (definition.type !== "output") { + throw new Error("Unrecognized widget type '" + definition.type + "'"); + } + // TODO: Verify that .name is a valid CSS classname + + // Support new-style instance-bound definitions. Old-style class-bound + // definitions have one widget "object" per widget per type/class of + // widget; the renderValue and resize methods on such widget objects + // take el and instance arguments, because the widget object can't + // store them. New-style instance-bound definitions have one widget + // object per widget instance; the definition that's passed in doesn't + // provide renderValue or resize methods at all, just the single method + // factory(el, width, height) + // which returns an object that has renderValue(x) and resize(w, h). + // This enables a far more natural programming style for the widget + // author, who can store per-instance state using either OO-style + // instance fields or functional-style closure variables (I guess this + // is in contrast to what can only be called C-style pseudo-OO which is + // what we required before). + if (definition.factory) { + definition = createLegacyDefinitionAdapter(definition); + } + + if (!definition.renderValue) { + throw new Error("Widget must have a renderValue function"); + } + + // For static rendering (non-Shiny), use a simple widget registration + // scheme. We also use this scheme for Shiny apps/documents that also + // contain static widgets. + window.HTMLWidgets.widgets = window.HTMLWidgets.widgets || []; + // Merge defaults into the definition; don't mutate the original definition. + var staticBinding = extend({}, defaults, definition); + overrideMethod(staticBinding, "find", function(superfunc) { + return function(scope) { + var results = superfunc(scope); + // Filter out Shiny outputs, we only want the static kind + return filterByClass(results, "html-widget-output", false); + }; + }); + window.HTMLWidgets.widgets.push(staticBinding); + + if (shinyMode) { + // Shiny is running. Register the definition with an output binding. + // The definition itself will not be the output binding, instead + // we will make an output binding object that delegates to the + // definition. This is because we foolishly used the same method + // name (renderValue) for htmlwidgets definition and Shiny bindings + // but they actually have quite different semantics (the Shiny + // bindings receive data that includes lots of metadata that it + // strips off before calling htmlwidgets renderValue). We can't + // just ignore the difference because in some widgets it's helpful + // to call this.renderValue() from inside of resize(), and if + // we're not delegating, then that call will go to the Shiny + // version instead of the htmlwidgets version. + + // Merge defaults with definition, without mutating either. + var bindingDef = extend({}, defaults, definition); + + // This object will be our actual Shiny binding. + var shinyBinding = new Shiny.OutputBinding(); + + // With a few exceptions, we'll want to simply use the bindingDef's + // version of methods if they are available, otherwise fall back to + // Shiny's defaults. NOTE: If Shiny's output bindings gain additional + // methods in the future, and we want them to be overrideable by + // HTMLWidget binding definitions, then we'll need to add them to this + // list. + delegateMethod(shinyBinding, bindingDef, "getId"); + delegateMethod(shinyBinding, bindingDef, "onValueChange"); + delegateMethod(shinyBinding, bindingDef, "onValueError"); + delegateMethod(shinyBinding, bindingDef, "renderError"); + delegateMethod(shinyBinding, bindingDef, "clearError"); + delegateMethod(shinyBinding, bindingDef, "showProgress"); + + // The find, renderValue, and resize are handled differently, because we + // want to actually decorate the behavior of the bindingDef methods. + + shinyBinding.find = function(scope) { + var results = bindingDef.find(scope); + + // Only return elements that are Shiny outputs, not static ones + var dynamicResults = results.filter(".html-widget-output"); + + // It's possible that whatever caused Shiny to think there might be + // new dynamic outputs, also caused there to be new static outputs. + // Since there might be lots of different htmlwidgets bindings, we + // schedule execution for later--no need to staticRender multiple + // times. + if (results.length !== dynamicResults.length) + scheduleStaticRender(); + + return dynamicResults; + }; + + // Wrap renderValue to handle initialization, which unfortunately isn't + // supported natively by Shiny at the time of this writing. + + shinyBinding.renderValue = function(el, data) { + Shiny.renderDependencies(data.deps); + // Resolve strings marked as javascript literals to objects + if (!(data.evals instanceof Array)) data.evals = [data.evals]; + for (var i = 0; data.evals && i < data.evals.length; i++) { + window.HTMLWidgets.evaluateStringMember(data.x, data.evals[i]); + } + if (!bindingDef.renderOnNullValue) { + if (data.x === null) { + el.style.visibility = "hidden"; + return; + } else { + el.style.visibility = "inherit"; + } + } + if (!elementData(el, "initialized")) { + initSizing(el); + + elementData(el, "initialized", true); + if (bindingDef.initialize) { + var result = bindingDef.initialize(el, el.offsetWidth, + el.offsetHeight); + elementData(el, "init_result", result); + } + } + bindingDef.renderValue(el, data.x, elementData(el, "init_result")); + evalAndRun(data.jsHooks.render, elementData(el, "init_result"), [el, data.x]); + }; + + // Only override resize if bindingDef implements it + if (bindingDef.resize) { + shinyBinding.resize = function(el, width, height) { + // Shiny can call resize before initialize/renderValue have been + // called, which doesn't make sense for widgets. + if (elementData(el, "initialized")) { + bindingDef.resize(el, width, height, elementData(el, "init_result")); + } + }; + } + + Shiny.outputBindings.register(shinyBinding, bindingDef.name); + } + }; + + var scheduleStaticRenderTimerId = null; + function scheduleStaticRender() { + if (!scheduleStaticRenderTimerId) { + scheduleStaticRenderTimerId = setTimeout(function() { + scheduleStaticRenderTimerId = null; + window.HTMLWidgets.staticRender(); + }, 1); + } + } + + // Render static widgets after the document finishes loading + // Statically render all elements that are of this widget's class + window.HTMLWidgets.staticRender = function() { + var bindings = window.HTMLWidgets.widgets || []; + forEach(bindings, function(binding) { + var matches = binding.find(document.documentElement); + forEach(matches, function(el) { + var sizeObj = initSizing(el, binding); + + if (hasClass(el, "html-widget-static-bound")) + return; + el.className = el.className + " html-widget-static-bound"; + + var initResult; + if (binding.initialize) { + initResult = binding.initialize(el, + sizeObj ? sizeObj.getWidth() : el.offsetWidth, + sizeObj ? sizeObj.getHeight() : el.offsetHeight + ); + elementData(el, "init_result", initResult); + } + + if (binding.resize) { + var lastSize = { + w: sizeObj ? sizeObj.getWidth() : el.offsetWidth, + h: sizeObj ? sizeObj.getHeight() : el.offsetHeight + }; + var resizeHandler = function(e) { + var size = { + w: sizeObj ? sizeObj.getWidth() : el.offsetWidth, + h: sizeObj ? sizeObj.getHeight() : el.offsetHeight + }; + if (size.w === 0 && size.h === 0) + return; + if (size.w === lastSize.w && size.h === lastSize.h) + return; + lastSize = size; + binding.resize(el, size.w, size.h, initResult); + }; + + on(window, "resize", resizeHandler); + + // This is needed for cases where we're running in a Shiny + // app, but the widget itself is not a Shiny output, but + // rather a simple static widget. One example of this is + // an rmarkdown document that has runtime:shiny and widget + // that isn't in a render function. Shiny only knows to + // call resize handlers for Shiny outputs, not for static + // widgets, so we do it ourselves. + if (window.jQuery) { + window.jQuery(document).on( + "shown.htmlwidgets shown.bs.tab.htmlwidgets shown.bs.collapse.htmlwidgets", + resizeHandler + ); + window.jQuery(document).on( + "hidden.htmlwidgets hidden.bs.tab.htmlwidgets hidden.bs.collapse.htmlwidgets", + resizeHandler + ); + } + + // This is needed for the specific case of ioslides, which + // flips slides between display:none and display:block. + // Ideally we would not have to have ioslide-specific code + // here, but rather have ioslides raise a generic event, + // but the rmarkdown package just went to CRAN so the + // window to getting that fixed may be long. + if (window.addEventListener) { + // It's OK to limit this to window.addEventListener + // browsers because ioslides itself only supports + // such browsers. + on(document, "slideenter", resizeHandler); + on(document, "slideleave", resizeHandler); + } + } + + var scriptData = document.querySelector("script[data-for='" + el.id + "'][type='application/json']"); + if (scriptData) { + var data = JSON.parse(scriptData.textContent || scriptData.text); + // Resolve strings marked as javascript literals to objects + if (!(data.evals instanceof Array)) data.evals = [data.evals]; + for (var k = 0; data.evals && k < data.evals.length; k++) { + window.HTMLWidgets.evaluateStringMember(data.x, data.evals[k]); + } + binding.renderValue(el, data.x, initResult); + evalAndRun(data.jsHooks.render, initResult, [el, data.x]); + } + }); + }); + + invokePostRenderHandlers(); + } + + // Wait until after the document has loaded to render the widgets. + if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", function() { + document.removeEventListener("DOMContentLoaded", arguments.callee, false); + window.HTMLWidgets.staticRender(); + }, false); + } else if (document.attachEvent) { + document.attachEvent("onreadystatechange", function() { + if (document.readyState === "complete") { + document.detachEvent("onreadystatechange", arguments.callee); + window.HTMLWidgets.staticRender(); + } + }); + } + + + window.HTMLWidgets.getAttachmentUrl = function(depname, key) { + // If no key, default to the first item + if (typeof(key) === "undefined") + key = 1; + + var link = document.getElementById(depname + "-" + key + "-attachment"); + if (!link) { + throw new Error("Attachment " + depname + "/" + key + " not found in document"); + } + return link.getAttribute("href"); + }; + + window.HTMLWidgets.dataframeToD3 = function(df) { + var names = []; + var length; + for (var name in df) { + if (df.hasOwnProperty(name)) + names.push(name); + if (typeof(df[name]) !== "object" || typeof(df[name].length) === "undefined") { + throw new Error("All fields must be arrays"); + } else if (typeof(length) !== "undefined" && length !== df[name].length) { + throw new Error("All fields must be arrays of the same length"); + } + length = df[name].length; + } + var results = []; + var item; + for (var row = 0; row < length; row++) { + item = {}; + for (var col = 0; col < names.length; col++) { + item[names[col]] = df[names[col]][row]; + } + results.push(item); + } + return results; + }; + + window.HTMLWidgets.transposeArray2D = function(array) { + if (array.length === 0) return array; + var newArray = array[0].map(function(col, i) { + return array.map(function(row) { + return row[i] + }) + }); + return newArray; + }; + // Split value at splitChar, but allow splitChar to be escaped + // using escapeChar. Any other characters escaped by escapeChar + // will be included as usual (including escapeChar itself). + function splitWithEscape(value, splitChar, escapeChar) { + var results = []; + var escapeMode = false; + var currentResult = ""; + for (var pos = 0; pos < value.length; pos++) { + if (!escapeMode) { + if (value[pos] === splitChar) { + results.push(currentResult); + currentResult = ""; + } else if (value[pos] === escapeChar) { + escapeMode = true; + } else { + currentResult += value[pos]; + } + } else { + currentResult += value[pos]; + escapeMode = false; + } + } + if (currentResult !== "") { + results.push(currentResult); + } + return results; + } + // Function authored by Yihui/JJ Allaire + window.HTMLWidgets.evaluateStringMember = function(o, member) { + var parts = splitWithEscape(member, '.', '\\'); + for (var i = 0, l = parts.length; i < l; i++) { + var part = parts[i]; + // part may be a character or 'numeric' member name + if (o !== null && typeof o === "object" && part in o) { + if (i == (l - 1)) { // if we are at the end of the line then evalulate + if (typeof o[part] === "string") + o[part] = eval("(" + o[part] + ")"); + } else { // otherwise continue to next embedded object + o = o[part]; + } + } + } + }; + + // Retrieve the HTMLWidget instance (i.e. the return value of an + // HTMLWidget binding's initialize() or factory() function) + // associated with an element, or null if none. + window.HTMLWidgets.getInstance = function(el) { + return elementData(el, "init_result"); + }; + + // Finds the first element in the scope that matches the selector, + // and returns the HTMLWidget instance (i.e. the return value of + // an HTMLWidget binding's initialize() or factory() function) + // associated with that element, if any. If no element matches the + // selector, or the first matching element has no HTMLWidget + // instance associated with it, then null is returned. + // + // The scope argument is optional, and defaults to window.document. + window.HTMLWidgets.find = function(scope, selector) { + if (arguments.length == 1) { + selector = scope; + scope = document; + } + + var el = scope.querySelector(selector); + if (el === null) { + return null; + } else { + return window.HTMLWidgets.getInstance(el); + } + }; + + // Finds all elements in the scope that match the selector, and + // returns the HTMLWidget instances (i.e. the return values of + // an HTMLWidget binding's initialize() or factory() function) + // associated with the elements, in an array. If elements that + // match the selector don't have an associated HTMLWidget + // instance, the returned array will contain nulls. + // + // The scope argument is optional, and defaults to window.document. + window.HTMLWidgets.findAll = function(scope, selector) { + if (arguments.length == 1) { + selector = scope; + scope = document; + } + + var nodes = scope.querySelectorAll(selector); + var results = []; + for (var i = 0; i < nodes.length; i++) { + results.push(window.HTMLWidgets.getInstance(nodes[i])); + } + return results; + }; + + var postRenderHandlers = []; + function invokePostRenderHandlers() { + while (postRenderHandlers.length) { + var handler = postRenderHandlers.shift(); + if (handler) { + handler(); + } + } + } + + // Register the given callback function to be invoked after the + // next time static widgets are rendered. + window.HTMLWidgets.addPostRenderHandler = function(callback) { + postRenderHandlers.push(callback); + }; + + // Takes a new-style instance-bound definition, and returns an + // old-style class-bound definition. This saves us from having + // to rewrite all the logic in this file to accomodate both + // types of definitions. + function createLegacyDefinitionAdapter(defn) { + var result = { + name: defn.name, + type: defn.type, + initialize: function(el, width, height) { + return defn.factory(el, width, height); + }, + renderValue: function(el, x, instance) { + return instance.renderValue(x); + }, + resize: function(el, width, height, instance) { + return instance.resize(width, height); + } + }; + + if (defn.find) + result.find = defn.find; + if (defn.renderError) + result.renderError = defn.renderError; + if (defn.clearError) + result.clearError = defn.clearError; + + return result; + } +})(); + diff --git a/docs/articles/pkgnet-report_files/jquery-1.12.4/LICENSE.txt b/docs/articles/pkgnet-report_files/jquery-1.12.4/LICENSE.txt new file mode 100644 index 00000000..5bf4f5e6 --- /dev/null +++ b/docs/articles/pkgnet-report_files/jquery-1.12.4/LICENSE.txt @@ -0,0 +1,37 @@ +Copyright 2005, 2014 jQuery Foundation and other contributors, +https://jquery.org/ + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/jquery/jquery + +The following license applies to all parts of this software except as +documented below: + +==== + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +==== + +All files located in the node_modules and external directories are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. diff --git a/docs/articles/pkgnet-report_files/jquery-1.12.4/jquery.min.js b/docs/articles/pkgnet-report_files/jquery-1.12.4/jquery.min.js new file mode 100644 index 00000000..e8364758 --- /dev/null +++ b/docs/articles/pkgnet-report_files/jquery-1.12.4/jquery.min.js @@ -0,0 +1,5 @@ +/*! jQuery v1.12.4 | (c) jQuery Foundation | jquery.org/license */ +!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.toString,k=i.hasOwnProperty,l={},m="1.12.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return e.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a){return n.each(this,a)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(e.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:g,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(n.isPlainObject(c)||(b=n.isArray(c)))?(b?(b=!1,f=a&&n.isArray(a)?a:[]):f=a&&n.isPlainObject(a)?a:{},g[d]=n.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray||function(a){return"array"===n.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){var b=a&&a.toString();return!n.isArray(a)&&b-parseFloat(b)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==n.type(a)||a.nodeType||n.isWindow(a))return!1;try{if(a.constructor&&!k.call(a,"constructor")&&!k.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(!l.ownFirst)for(b in a)return k.call(a,b);for(b in a);return void 0===b||k.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?i[j.call(a)]||"object":typeof a},globalEval:function(b){b&&n.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b){var c,d=0;if(s(a)){for(c=a.length;c>d;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):g.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(h)return h.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,g=0,h=[];if(s(a))for(d=a.length;d>g;g++)e=b(a[g],g,c),null!=e&&h.push(e);else for(g in a)e=b(a[g],g,c),null!=e&&h.push(e);return f.apply([],h)},guid:1,proxy:function(a,b){var c,d,f;return"string"==typeof b&&(f=a[b],b=a,a=f),n.isFunction(a)?(c=e.call(arguments,2),d=function(){return a.apply(b||this,c.concat(e.call(arguments)))},d.guid=a.guid=a.guid||n.guid++,d):void 0},now:function(){return+new Date},support:l}),"function"==typeof Symbol&&(n.fn[Symbol.iterator]=c[Symbol.iterator]),n.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){i["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=!!a&&"length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ga(),z=ga(),A=ga(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+M+"))|)"+L+"*\\]",O=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+N+")*)|.*)\\)|)",P=new RegExp(L+"+","g"),Q=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),R=new RegExp("^"+L+"*,"+L+"*"),S=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),T=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),U=new RegExp(O),V=new RegExp("^"+M+"$"),W={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M+"|[*])"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},X=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Z=/^[^{]+\{\s*\[native \w/,$=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,_=/[+~]/,aa=/'|\\/g,ba=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),ca=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},da=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(ea){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fa(a,b,d,e){var f,h,j,k,l,o,r,s,w=b&&b.ownerDocument,x=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==x&&9!==x&&11!==x)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==x&&(o=$.exec(a)))if(f=o[1]){if(9===x){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(w&&(j=w.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(o[2])return H.apply(d,b.getElementsByTagName(a)),d;if((f=o[3])&&c.getElementsByClassName&&b.getElementsByClassName)return H.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==x)w=b,s=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(aa,"\\$&"):b.setAttribute("id",k=u),r=g(a),h=r.length,l=V.test(k)?"#"+k:"[id='"+k+"']";while(h--)r[h]=l+" "+qa(r[h]);s=r.join(","),w=_.test(a)&&oa(b.parentNode)||b}if(s)try{return H.apply(d,w.querySelectorAll(s)),d}catch(y){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(Q,"$1"),b,d,e)}function ga(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ha(a){return a[u]=!0,a}function ia(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ja(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function ka(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function la(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function na(a){return ha(function(b){return b=+b,ha(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function oa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=fa.support={},f=fa.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fa.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ia(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ia(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Z.test(n.getElementsByClassName),c.getById=ia(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ba,ca);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ba,ca);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return"undefined"!=typeof b.getElementsByClassName&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=Z.test(n.querySelectorAll))&&(ia(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ia(function(a){var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Z.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ia(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",O)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Z.test(o.compareDocumentPosition),t=b||Z.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return ka(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?ka(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},fa.matches=function(a,b){return fa(a,null,null,b)},fa.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(T,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fa(b,n,null,[a]).length>0},fa.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fa.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fa.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fa.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fa.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fa.selectors={cacheLength:50,createPseudo:ha,match:W,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ba,ca),a[3]=(a[3]||a[4]||a[5]||"").replace(ba,ca),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fa.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fa.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return W.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&U.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ba,ca).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fa.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(P," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fa.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ha(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ha(function(a){var b=[],c=[],d=h(a.replace(Q,"$1"));return d[u]?ha(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ha(function(a){return function(b){return fa(a,b).length>0}}),contains:ha(function(a){return a=a.replace(ba,ca),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ha(function(a){return V.test(a||"")||fa.error("unsupported lang: "+a),a=a.replace(ba,ca).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Y.test(a.nodeName)},input:function(a){return X.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:na(function(){return[0]}),last:na(function(a,b){return[b-1]}),eq:na(function(a,b,c){return[0>c?c+b:c]}),even:na(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:na(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:na(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:na(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function ra(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j,k=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(j=b[u]||(b[u]={}),i=j[b.uniqueID]||(j[b.uniqueID]={}),(h=i[d])&&h[0]===w&&h[1]===f)return k[2]=h[2];if(i[d]=k,k[2]=a(b,c,g))return!0}}}function sa(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ta(a,b,c){for(var d=0,e=b.length;e>d;d++)fa(a,b[d],c);return c}function ua(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(c&&!c(f,d,e)||(g.push(f),j&&b.push(h)));return g}function va(a,b,c,d,e,f){return d&&!d[u]&&(d=va(d)),e&&!e[u]&&(e=va(e,f)),ha(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ta(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ua(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ua(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ua(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function wa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ra(function(a){return a===b},h,!0),l=ra(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[ra(sa(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return va(i>1&&sa(m),i>1&&qa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(Q,"$1"),c,e>i&&wa(a.slice(i,e)),f>e&&wa(a=a.slice(e)),f>e&&qa(a))}m.push(c)}return sa(m)}function xa(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=F.call(i));u=ua(u)}H.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&fa.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ha(f):f}return h=fa.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xa(e,d)),f.selector=a}return f},i=fa.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ba,ca),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=W.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ba,ca),_.test(j[0].type)&&oa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qa(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,!b||_.test(a)&&oa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ia(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ia(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ja("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ia(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ja("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ia(function(a){return null==a.getAttribute("disabled")})||ja(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fa}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.uniqueSort=n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},v=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},w=n.expr.match.needsContext,x=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,y=/^.[^:#\[\.,]*$/;function z(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(y.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return n.inArray(a,b)>-1!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;e>b;b++)if(n.contains(d[b],this))return!0}));for(b=0;e>b;b++)n.find(a,d[b],c);return c=this.pushStack(e>1?n.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(z(this,a||[],!1))},not:function(a){return this.pushStack(z(this,a||[],!0))},is:function(a){return!!z(this,"string"==typeof a&&w.test(a)?n(a):a||[],!1).length}});var A,B=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=n.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||A,"string"==typeof a){if(e="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:B.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),x.test(e[1])&&n.isPlainObject(b))for(e in b)n.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}if(f=d.getElementById(e[2]),f&&f.parentNode){if(f.id!==e[2])return A.find(a);this.length=1,this[0]=f}return this.context=d,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof c.ready?c.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};C.prototype=n.fn,A=n(d);var D=/^(?:parents|prev(?:Until|All))/,E={children:!0,contents:!0,next:!0,prev:!0};n.fn.extend({has:function(a){var b,c=n(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(n.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=w.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?n.inArray(this[0],n(a)):n.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.uniqueSort(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function F(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return u(a,"parentNode")},parentsUntil:function(a,b,c){return u(a,"parentNode",c)},next:function(a){return F(a,"nextSibling")},prev:function(a){return F(a,"previousSibling")},nextAll:function(a){return u(a,"nextSibling")},prevAll:function(a){return u(a,"previousSibling")},nextUntil:function(a,b,c){return u(a,"nextSibling",c)},prevUntil:function(a,b,c){return u(a,"previousSibling",c)},siblings:function(a){return v((a.parentNode||{}).firstChild,a)},children:function(a){return v(a.firstChild)},contents:function(a){return n.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(E[a]||(e=n.uniqueSort(e)),D.test(a)&&(e=e.reverse())),this.pushStack(e)}});var G=/\S+/g;function H(a){var b={};return n.each(a.match(G)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?H(a):n.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h-1)f.splice(c,1),h>=c&&h--}),this},has:function(a){return a?n.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=!0,c||j.disable(),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().progress(c.notify).done(c.resolve).fail(c.reject):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=e.call(arguments),d=c.length,f=1!==d||a&&n.isFunction(a.promise)?d:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?e.call(arguments):d,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(d>1)for(i=new Array(d),j=new Array(d),k=new Array(d);d>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().progress(h(b,j,i)).done(h(b,k,c)).fail(g.reject):--f;return f||g.resolveWith(k,c),g.promise()}});var I;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(I.resolveWith(d,[n]),n.fn.triggerHandler&&(n(d).triggerHandler("ready"),n(d).off("ready"))))}});function J(){d.addEventListener?(d.removeEventListener("DOMContentLoaded",K),a.removeEventListener("load",K)):(d.detachEvent("onreadystatechange",K),a.detachEvent("onload",K))}function K(){(d.addEventListener||"load"===a.event.type||"complete"===d.readyState)&&(J(),n.ready())}n.ready.promise=function(b){if(!I)if(I=n.Deferred(),"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll)a.setTimeout(n.ready);else if(d.addEventListener)d.addEventListener("DOMContentLoaded",K),a.addEventListener("load",K);else{d.attachEvent("onreadystatechange",K),a.attachEvent("onload",K);var c=!1;try{c=null==a.frameElement&&d.documentElement}catch(e){}c&&c.doScroll&&!function f(){if(!n.isReady){try{c.doScroll("left")}catch(b){return a.setTimeout(f,50)}J(),n.ready()}}()}return I.promise(b)},n.ready.promise();var L;for(L in n(l))break;l.ownFirst="0"===L,l.inlineBlockNeedsLayout=!1,n(function(){var a,b,c,e;c=d.getElementsByTagName("body")[0],c&&c.style&&(b=d.createElement("div"),e=d.createElement("div"),e.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(e).appendChild(b),"undefined"!=typeof b.style.zoom&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",l.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(e))}),function(){var a=d.createElement("div");l.deleteExpando=!0;try{delete a.test}catch(b){l.deleteExpando=!1}a=null}();var M=function(a){var b=n.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b},N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(O,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}n.data(a,b,c)}else c=void 0; +}return c}function Q(a){var b;for(b in a)if(("data"!==b||!n.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function R(a,b,d,e){if(M(a)){var f,g,h=n.expando,i=a.nodeType,j=i?n.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||n.guid++:h),j[k]||(j[k]=i?{}:{toJSON:n.noop}),"object"!=typeof b&&"function"!=typeof b||(e?j[k]=n.extend(j[k],b):j[k].data=n.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[n.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[n.camelCase(b)])):f=g,f}}function S(a,b,c){if(M(a)){var d,e,f=a.nodeType,g=f?n.cache:a,h=f?a[n.expando]:n.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){n.isArray(b)?b=b.concat(n.map(b,n.camelCase)):b in d?b=[b]:(b=n.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!Q(d):!n.isEmptyObject(d))return}(c||(delete g[h].data,Q(g[h])))&&(f?n.cleanData([a],!0):l.deleteExpando||g!=g.window?delete g[h]:g[h]=void 0)}}}n.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?n.cache[a[n.expando]]:a[n.expando],!!a&&!Q(a)},data:function(a,b,c){return R(a,b,c)},removeData:function(a,b){return S(a,b)},_data:function(a,b,c){return R(a,b,c,!0)},_removeData:function(a,b){return S(a,b,!0)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=n.data(f),1===f.nodeType&&!n._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));n._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){n.data(this,a)}):arguments.length>1?this.each(function(){n.data(this,a,b)}):f?P(f,a,n.data(f,a)):void 0},removeData:function(a){return this.each(function(){n.removeData(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=n._data(a,b),c&&(!d||n.isArray(c)?d=n._data(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return n._data(a,c)||n._data(a,c,{empty:n.Callbacks("once memory").add(function(){n._removeData(a,b+"queue"),n._removeData(a,c)})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},Z=/^(?:checkbox|radio)$/i,$=/<([\w:-]+)/,_=/^$|\/(?:java|ecma)script/i,aa=/^\s+/,ba="abbr|article|aside|audio|bdi|canvas|data|datalist|details|dialog|figcaption|figure|footer|header|hgroup|main|mark|meter|nav|output|picture|progress|section|summary|template|time|video";function ca(a){var b=ba.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}!function(){var a=d.createElement("div"),b=d.createDocumentFragment(),c=d.createElement("input");a.innerHTML="
    a",l.leadingWhitespace=3===a.firstChild.nodeType,l.tbody=!a.getElementsByTagName("tbody").length,l.htmlSerialize=!!a.getElementsByTagName("link").length,l.html5Clone="<:nav>"!==d.createElement("nav").cloneNode(!0).outerHTML,c.type="checkbox",c.checked=!0,b.appendChild(c),l.appendChecked=c.checked,a.innerHTML="",l.noCloneChecked=!!a.cloneNode(!0).lastChild.defaultValue,b.appendChild(a),c=d.createElement("input"),c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),a.appendChild(c),l.checkClone=a.cloneNode(!0).cloneNode(!0).lastChild.checked,l.noCloneEvent=!!a.addEventListener,a[n.expando]=1,l.attributes=!a.getAttribute(n.expando)}();var da={option:[1,""],legend:[1,"
    ","
    "],area:[1,"",""],param:[1,"",""],thead:[1,"","
    "],tr:[2,"","
    "],col:[2,"","
    "],td:[3,"","
    "],_default:l.htmlSerialize?[0,"",""]:[1,"X
    ","
    "]};da.optgroup=da.option,da.tbody=da.tfoot=da.colgroup=da.caption=da.thead,da.th=da.td;function ea(a,b){var c,d,e=0,f="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||n.nodeName(d,b)?f.push(d):n.merge(f,ea(d,b));return void 0===b||b&&n.nodeName(a,b)?n.merge([a],f):f}function fa(a,b){for(var c,d=0;null!=(c=a[d]);d++)n._data(c,"globalEval",!b||n._data(b[d],"globalEval"))}var ga=/<|&#?\w+;/,ha=/r;r++)if(g=a[r],g||0===g)if("object"===n.type(g))n.merge(q,g.nodeType?[g]:g);else if(ga.test(g)){i=i||p.appendChild(b.createElement("div")),j=($.exec(g)||["",""])[1].toLowerCase(),m=da[j]||da._default,i.innerHTML=m[1]+n.htmlPrefilter(g)+m[2],f=m[0];while(f--)i=i.lastChild;if(!l.leadingWhitespace&&aa.test(g)&&q.push(b.createTextNode(aa.exec(g)[0])),!l.tbody){g="table"!==j||ha.test(g)?""!==m[1]||ha.test(g)?0:i:i.firstChild,f=g&&g.childNodes.length;while(f--)n.nodeName(k=g.childNodes[f],"tbody")&&!k.childNodes.length&&g.removeChild(k)}n.merge(q,i.childNodes),i.textContent="";while(i.firstChild)i.removeChild(i.firstChild);i=p.lastChild}else q.push(b.createTextNode(g));i&&p.removeChild(i),l.appendChecked||n.grep(ea(q,"input"),ia),r=0;while(g=q[r++])if(d&&n.inArray(g,d)>-1)e&&e.push(g);else if(h=n.contains(g.ownerDocument,g),i=ea(p.appendChild(g),"script"),h&&fa(i),c){f=0;while(g=i[f++])_.test(g.type||"")&&c.push(g)}return i=null,p}!function(){var b,c,e=d.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(l[b]=c in a)||(e.setAttribute(c,"t"),l[b]=e.attributes[c].expando===!1);e=null}();var ka=/^(?:input|select|textarea)$/i,la=/^key/,ma=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,na=/^(?:focusinfocus|focusoutblur)$/,oa=/^([^.]*)(?:\.(.+)|)/;function pa(){return!0}function qa(){return!1}function ra(){try{return d.activeElement}catch(a){}}function sa(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)sa(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=qa;else if(!e)return a;return 1===f&&(g=e,e=function(a){return n().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=n.guid++)),a.each(function(){n.event.add(this,b,e,d,c)})}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=n.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return"undefined"==typeof n||a&&n.event.triggered===a.type?void 0:n.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(G)||[""],h=b.length;while(h--)f=oa.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=n.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=n.event.special[o]||{},l=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},i),(m=g[o])||(m=g[o]=[],m.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,l):m.push(l),n.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n.hasData(a)&&n._data(a);if(r&&(k=r.events)){b=(b||"").match(G)||[""],j=b.length;while(j--)if(h=oa.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;while(f--)g=m[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(k)&&(delete r.handle,n._removeData(a,"events"))}},trigger:function(b,c,e,f){var g,h,i,j,l,m,o,p=[e||d],q=k.call(b,"type")?b.type:b,r=k.call(b,"namespace")?b.namespace.split("."):[];if(i=m=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!na.test(q+n.event.triggered)&&(q.indexOf(".")>-1&&(r=q.split("."),q=r.shift(),r.sort()),h=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=r.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:n.makeArray(c,[b]),l=n.event.special[q]||{},f||!l.trigger||l.trigger.apply(e,c)!==!1)){if(!f&&!l.noBubble&&!n.isWindow(e)){for(j=l.delegateType||q,na.test(j+q)||(i=i.parentNode);i;i=i.parentNode)p.push(i),m=i;m===(e.ownerDocument||d)&&p.push(m.defaultView||m.parentWindow||a)}o=0;while((i=p[o++])&&!b.isPropagationStopped())b.type=o>1?j:l.bindType||q,g=(n._data(i,"events")||{})[b.type]&&n._data(i,"handle"),g&&g.apply(i,c),g=h&&i[h],g&&g.apply&&M(i)&&(b.result=g.apply(i,c),b.result===!1&&b.preventDefault());if(b.type=q,!f&&!b.isDefaultPrevented()&&(!l._default||l._default.apply(p.pop(),c)===!1)&&M(e)&&h&&e[q]&&!n.isWindow(e)){m=e[h],m&&(e[h]=null),n.event.triggered=q;try{e[q]()}catch(s){}n.event.triggered=void 0,m&&(e[h]=m)}return b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,d,f,g,h=[],i=e.call(arguments),j=(n._data(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())a.rnamespace&&!a.rnamespace.test(g.namespace)||(a.handleObj=g,a.data=g.data,d=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==d&&(a.result=d)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&("click"!==a.type||isNaN(a.button)||a.button<1))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>-1:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]","i"),va=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,wa=/\s*$/g,Aa=ca(d),Ba=Aa.appendChild(d.createElement("div"));function Ca(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function Da(a){return a.type=(null!==n.find.attr(a,"type"))+"/"+a.type,a}function Ea(a){var b=ya.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Fa(a,b){if(1===b.nodeType&&n.hasData(a)){var c,d,e,f=n._data(a),g=n._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)n.event.add(b,c,h[c][d])}g.data&&(g.data=n.extend({},g.data))}}function Ga(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!l.noCloneEvent&&b[n.expando]){e=n._data(b);for(d in e.events)n.removeEvent(b,d,e.handle);b.removeAttribute(n.expando)}"script"===c&&b.text!==a.text?(Da(b).text=a.text,Ea(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),l.html5Clone&&a.innerHTML&&!n.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&Z.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:"input"!==c&&"textarea"!==c||(b.defaultValue=a.defaultValue)}}function Ha(a,b,c,d){b=f.apply([],b);var e,g,h,i,j,k,m=0,o=a.length,p=o-1,q=b[0],r=n.isFunction(q);if(r||o>1&&"string"==typeof q&&!l.checkClone&&xa.test(q))return a.each(function(e){var f=a.eq(e);r&&(b[0]=q.call(this,e,f.html())),Ha(f,b,c,d)});if(o&&(k=ja(b,a[0].ownerDocument,!1,a,d),e=k.firstChild,1===k.childNodes.length&&(k=e),e||d)){for(i=n.map(ea(k,"script"),Da),h=i.length;o>m;m++)g=k,m!==p&&(g=n.clone(g,!0,!0),h&&n.merge(i,ea(g,"script"))),c.call(a[m],g,m);if(h)for(j=i[i.length-1].ownerDocument,n.map(i,Ea),m=0;h>m;m++)g=i[m],_.test(g.type||"")&&!n._data(g,"globalEval")&&n.contains(j,g)&&(g.src?n._evalUrl&&n._evalUrl(g.src):n.globalEval((g.text||g.textContent||g.innerHTML||"").replace(za,"")));k=e=null}return a}function Ia(a,b,c){for(var d,e=b?n.filter(b,a):a,f=0;null!=(d=e[f]);f++)c||1!==d.nodeType||n.cleanData(ea(d)),d.parentNode&&(c&&n.contains(d.ownerDocument,d)&&fa(ea(d,"script")),d.parentNode.removeChild(d));return a}n.extend({htmlPrefilter:function(a){return a.replace(va,"<$1>")},clone:function(a,b,c){var d,e,f,g,h,i=n.contains(a.ownerDocument,a);if(l.html5Clone||n.isXMLDoc(a)||!ua.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(Ba.innerHTML=a.outerHTML,Ba.removeChild(f=Ba.firstChild)),!(l.noCloneEvent&&l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(d=ea(f),h=ea(a),g=0;null!=(e=h[g]);++g)d[g]&&Ga(e,d[g]);if(b)if(c)for(h=h||ea(a),d=d||ea(f),g=0;null!=(e=h[g]);g++)Fa(e,d[g]);else Fa(a,f);return d=ea(f,"script"),d.length>0&&fa(d,!i&&ea(a,"script")),d=h=e=null,f},cleanData:function(a,b){for(var d,e,f,g,h=0,i=n.expando,j=n.cache,k=l.attributes,m=n.event.special;null!=(d=a[h]);h++)if((b||M(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)m[e]?n.event.remove(d,e):n.removeEvent(d,e,g.handle);j[f]&&(delete j[f],k||"undefined"==typeof d.removeAttribute?d[i]=void 0:d.removeAttribute(i),c.push(f))}}}),n.fn.extend({domManip:Ha,detach:function(a){return Ia(this,a,!0)},remove:function(a){return Ia(this,a)},text:function(a){return Y(this,function(a){return void 0===a?n.text(this):this.empty().append((this[0]&&this[0].ownerDocument||d).createTextNode(a))},null,a,arguments.length)},append:function(){return Ha(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ca(this,a);b.appendChild(a)}})},prepend:function(){return Ha(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ca(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ha(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ha(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&n.cleanData(ea(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&n.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return Y(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(ta,""):void 0;if("string"==typeof a&&!wa.test(a)&&(l.htmlSerialize||!ua.test(a))&&(l.leadingWhitespace||!aa.test(a))&&!da[($.exec(a)||["",""])[1].toLowerCase()]){a=n.htmlPrefilter(a);try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ea(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=[];return Ha(this,arguments,function(b){var c=this.parentNode;n.inArray(this,a)<0&&(n.cleanData(ea(this)),c&&c.replaceChild(b,this))},a)}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=0,e=[],f=n(a),h=f.length-1;h>=d;d++)c=d===h?this:this.clone(!0),n(f[d])[b](c),g.apply(e,c.get());return this.pushStack(e)}});var Ja,Ka={HTML:"block",BODY:"block"};function La(a,b){var c=n(b.createElement(a)).appendTo(b.body),d=n.css(c[0],"display");return c.detach(),d}function Ma(a){var b=d,c=Ka[a];return c||(c=La(a,b),"none"!==c&&c||(Ja=(Ja||n("