From 6b911f0f6900d512825c23d4a8cd60d857c61550 Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Thu, 13 Apr 2023 22:04:02 +0200 Subject: [PATCH] settings/personal: timezone field, use tom-select to get search field --- Cargo.lock | 79 +- crates/ezidam/Cargo.toml | 1 + crates/ezidam/src/routes/settings.rs | 2 + crates/ezidam/src/routes/settings/personal.rs | 17 + .../ezidam/static/css/tabler-vendors.min.css | 9 + crates/ezidam/static/libs/list.js/list.js | 2020 ++++++ crates/ezidam/static/libs/list.js/list.js.map | 1 + .../static/libs/list.js/list.min.js.map | 1 + .../static/libs/tom-select/tom-select.base.js | 4687 ++++++++++++++ .../libs/tom-select/tom-select.base.js.map | 1 + .../libs/tom-select/tom-select.base.min.js | 359 ++ .../tom-select/tom-select.base.min.js.map | 1 + .../libs/tom-select/tom-select.complete.js | 5504 +++++++++++++++++ .../tom-select/tom-select.complete.js.map | 1 + .../tom-select/tom-select.complete.min.js | 421 ++ .../tom-select/tom-select.complete.min.js.map | 1 + .../libs/tom-select/tom-select.popular.js | 4941 +++++++++++++++ .../libs/tom-select/tom-select.popular.js.map | 1 + .../libs/tom-select/tom-select.popular.min.js | 379 ++ .../tom-select/tom-select.popular.min.js.map | 1 + crates/ezidam/templates/base.html.tera | 1 + .../pages/settings/personal.html.tera | 56 +- 22 files changed, 18474 insertions(+), 10 deletions(-) create mode 100644 crates/ezidam/static/css/tabler-vendors.min.css create mode 100644 crates/ezidam/static/libs/list.js/list.js create mode 100644 crates/ezidam/static/libs/list.js/list.js.map create mode 100644 crates/ezidam/static/libs/list.js/list.min.js.map create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.base.js create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.base.js.map create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.base.min.js create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.base.min.js.map create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.complete.js create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.complete.js.map create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.complete.min.js create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.complete.min.js.map create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.popular.js create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.popular.js.map create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.popular.min.js create mode 100644 crates/ezidam/static/libs/tom-select/tom-select.popular.min.js.map diff --git a/Cargo.lock b/Cargo.lock index 64e3c90..0d46f0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,8 +270,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58549f1842da3080ce63002102d5bc954c7bc843d4f47818e642abdc36253552" dependencies = [ "chrono", - "chrono-tz-build", - "phf", + "chrono-tz-build 0.0.2", + "phf 0.10.1", +] + +[[package]] +name = "chrono-tz" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9cc2b23599e6d7479755f3594285efb3f74a1bdca7a7374948bc831e23a552" +dependencies = [ + "chrono", + "chrono-tz-build 0.1.0", + "phf 0.11.1", ] [[package]] @@ -281,8 +292,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db058d493fb2f65f41861bfed7e3fe6335264a9f0f92710cab5bdf01fef09069" dependencies = [ "parse-zoneinfo", - "phf", - "phf_codegen", + "phf 0.10.1", + "phf_codegen 0.10.0", +] + +[[package]] +name = "chrono-tz-build" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9998fb9f7e9b2111641485bf8beb32f92945f97f92a3d061f744cfef335f751" +dependencies = [ + "parse-zoneinfo", + "phf 0.11.1", + "phf_codegen 0.11.1", ] [[package]] @@ -723,6 +745,7 @@ dependencies = [ "apps", "authorization_codes", "base64 0.21.0", + "chrono-tz 0.8.2", "database_pool", "email_address", "erased-serde", @@ -2052,7 +2075,16 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" dependencies = [ - "phf_shared", + "phf_shared 0.10.0", +] + +[[package]] +name = "phf" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c" +dependencies = [ + "phf_shared 0.11.1", ] [[package]] @@ -2061,8 +2093,18 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.10.0", + "phf_shared 0.10.0", +] + +[[package]] +name = "phf_codegen" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56ac890c5e3ca598bbdeaa99964edb5b0258a583a9eb6ef4e89fc85d9224770" +dependencies = [ + "phf_generator 0.11.1", + "phf_shared 0.11.1", ] [[package]] @@ -2071,7 +2113,17 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" dependencies = [ - "phf_shared", + "phf_shared 0.10.0", + "rand", +] + +[[package]] +name = "phf_generator" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf" +dependencies = [ + "phf_shared 0.11.1", "rand", ] @@ -2085,6 +2137,15 @@ dependencies = [ "uncased", ] +[[package]] +name = "phf_shared" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.0.12" @@ -3044,7 +3105,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a665751302f22a03c56721e23094e4dc22b04a80f381e6737a07bf7a7c70c0" dependencies = [ "chrono", - "chrono-tz", + "chrono-tz 0.6.1", "globwalk", "humansize", "lazy_static", diff --git a/crates/ezidam/Cargo.toml b/crates/ezidam/Cargo.toml index 863fa87..d7f517d 100644 --- a/crates/ezidam/Cargo.toml +++ b/crates/ezidam/Cargo.toml @@ -15,6 +15,7 @@ futures = "0.3" base64 = "0.21.0" rocket_cors = "0.6.0-alpha2" email_address = { workspace = true } +chrono-tz = "0.8.2" # local crates database_pool = { path = "../database_pool" } diff --git a/crates/ezidam/src/routes/settings.rs b/crates/ezidam/src/routes/settings.rs index 49cac3f..e895587 100644 --- a/crates/ezidam/src/routes/settings.rs +++ b/crates/ezidam/src/routes/settings.rs @@ -38,6 +38,8 @@ pub mod content { pub username: String, pub name: Option, pub email: Option, + pub timezone: String, + pub list_timezones: Vec<&'static str>, } #[derive(Serialize)] diff --git a/crates/ezidam/src/routes/settings/personal.rs b/crates/ezidam/src/routes/settings/personal.rs index 55066d0..7afded3 100644 --- a/crates/ezidam/src/routes/settings/personal.rs +++ b/crates/ezidam/src/routes/settings/personal.rs @@ -15,11 +15,21 @@ pub async fn user_settings_personal( .await? .ok_or_else(|| Error::not_found(jwt_user.0.subject.to_string()))?; + // List possible timezones + let timezones = chrono_tz::TZ_VARIANTS + .into_iter() + .filter(|tz| tz.name().contains('/')) + .filter(|tz| !tz.name().starts_with("Etc")) + .map(|timezone| timezone.name()) + .collect::>(); + let page = Page::UserPersonalSettings(super::content::UserPersonalSettings { user: jwt_user.0, username: user.username().into(), name: user.name().map(String::from), email: user.email().map(String::from), + timezone: user.timezone().into(), + list_timezones: timezones, }); Ok(flash @@ -32,6 +42,7 @@ pub struct UpdatePersonalSettings<'r> { pub username: &'r str, pub name: &'r str, pub email: &'r str, + pub timezone: &'r str, } #[post("/settings/personal", data = "
")] @@ -103,6 +114,12 @@ pub async fn user_settings_personal_form( } } + // Update timezone + let form_timezone = form.timezone.parse().unwrap_or(chrono_tz::UTC).name(); + if user.timezone() != form_timezone { + user.set_timezone(&mut transaction, form_timezone).await?; + } + transaction.commit().await?; Ok(Flash::new( diff --git a/crates/ezidam/static/css/tabler-vendors.min.css b/crates/ezidam/static/css/tabler-vendors.min.css new file mode 100644 index 0000000..e848bcb --- /dev/null +++ b/crates/ezidam/static/css/tabler-vendors.min.css @@ -0,0 +1,9 @@ +/*! +* Tabler v1.0.0-beta17 (https://tabler.io) +* @version 1.0.0-beta17 +* @link https://tabler.io +* Copyright 2018-2023 The Tabler Authors +* Copyright 2018-2023 codecalm.net Paweł Kuna +* Licensed under MIT (https://github.com/tabler/tabler/blob/master/LICENSE) +*/ +.noUi-target,.noUi-target *{-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;touch-action:none;-ms-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box}.noUi-target{position:relative}.noUi-base,.noUi-connects{width:100%;height:100%;position:relative;z-index:1}.noUi-connects{overflow:hidden;z-index:0}.noUi-connect,.noUi-origin{will-change:transform;position:absolute;z-index:1;top:0;right:0;height:100%;width:100%;-ms-transform-origin:0 0;-webkit-transform-origin:0 0;-webkit-transform-style:preserve-3d;transform-origin:0 0;transform-style:flat}.noUi-txt-dir-rtl.noUi-horizontal .noUi-origin{left:0;right:auto}.noUi-vertical .noUi-origin{top:-100%;width:0}.noUi-horizontal .noUi-origin{height:0}.noUi-handle{-webkit-backface-visibility:hidden;backface-visibility:hidden;position:absolute}.noUi-touch-area{height:100%;width:100%}.noUi-state-tap .noUi-connect,.noUi-state-tap .noUi-origin{transition:transform .3s}.noUi-state-drag *{cursor:inherit!important}.noUi-horizontal{height:18px}.noUi-horizontal .noUi-handle{width:34px;height:28px;right:-17px;top:-6px}.noUi-vertical{width:18px}.noUi-vertical .noUi-handle{width:28px;height:34px;right:-6px;bottom:-17px}.noUi-txt-dir-rtl.noUi-horizontal .noUi-handle{left:-17px;right:auto}.noUi-target{background:#fafafa;border-radius:4px;border:1px solid #d3d3d3;box-shadow:inset 0 1px 1px #f0f0f0,0 3px 6px -5px #bbb}.noUi-connects{border-radius:3px}.noUi-connect{background:#3fb8af}.noUi-draggable{cursor:ew-resize}.noUi-vertical .noUi-draggable{cursor:ns-resize}.noUi-handle{border:1px solid #d9d9d9;border-radius:3px;background:#fff;cursor:default;box-shadow:inset 0 0 1px #fff,inset 0 1px 7px #ebebeb,0 3px 6px -3px #bbb}.noUi-active{box-shadow:inset 0 0 1px #fff,inset 0 1px 7px #ddd,0 3px 6px -3px #bbb}.noUi-handle:after,.noUi-handle:before{content:"";display:block;position:absolute;height:14px;width:1px;background:#e8e7e6;left:14px;top:6px}.noUi-handle:after{left:17px}.noUi-vertical .noUi-handle:after,.noUi-vertical .noUi-handle:before{width:14px;height:1px;left:6px;top:14px}.noUi-vertical .noUi-handle:after{top:17px}[disabled] .noUi-connect{background:#b8b8b8}[disabled] .noUi-handle,[disabled].noUi-handle,[disabled].noUi-target{cursor:not-allowed}.noUi-pips,.noUi-pips *{box-sizing:border-box}.noUi-pips{position:absolute;color:#999}.noUi-value{position:absolute;white-space:nowrap;text-align:center}.noUi-value-sub{color:#ccc;font-size:10px}.noUi-marker{position:absolute;background:#ccc}.noUi-marker-sub{background:#aaa}.noUi-marker-large{background:#aaa}.noUi-pips-horizontal{padding:10px 0;height:80px;top:100%;left:0;width:100%}.noUi-value-horizontal{transform:translate(-50%,50%)}.noUi-rtl .noUi-value-horizontal{transform:translate(50%,50%)}.noUi-marker-horizontal.noUi-marker{margin-left:-1px;width:2px;height:5px}.noUi-marker-horizontal.noUi-marker-sub{height:10px}.noUi-marker-horizontal.noUi-marker-large{height:15px}.noUi-pips-vertical{padding:0 10px;height:100%;top:0;left:100%}.noUi-value-vertical{transform:translate(0,-50%);padding-left:25px}.noUi-rtl .noUi-value-vertical{transform:translate(0,50%)}.noUi-marker-vertical.noUi-marker{width:5px;height:2px;margin-top:-1px}.noUi-marker-vertical.noUi-marker-sub{width:10px}.noUi-marker-vertical.noUi-marker-large{width:15px}.noUi-tooltip{display:block;position:absolute;border:1px solid #d9d9d9;border-radius:3px;background:#fff;color:#000;padding:5px;text-align:center;white-space:nowrap}.noUi-horizontal .noUi-tooltip{transform:translate(-50%,0);left:50%;bottom:120%}.noUi-vertical .noUi-tooltip{transform:translate(0,-50%);top:50%;right:120%}.noUi-horizontal .noUi-origin>.noUi-tooltip{transform:translate(50%,0);left:auto;bottom:10px}.noUi-vertical .noUi-origin>.noUi-tooltip{transform:translate(0,-18px);top:auto;right:28px}.noUi-target{border:0;box-shadow:none;background:0 0;border-radius:0;color:var(--tblr-primary)}.noUi-horizontal{height:1.25rem;padding:.5rem 0}.noUi-base{background:var(--tblr-border-color);border-radius:1rem}.noUi-handle{width:1rem;height:1rem;border:2px var(--tblr-border-style) #fff;box-shadow:0 .1rem .25rem rgba(0,0,0,.1);border-radius:1rem;background:currentColor;outline:0}.noUi-handle:after,.noUi-handle:before{content:none}.noUi-horizontal .noUi-handle{width:1rem;height:1rem;top:-.5rem;right:-.5rem;margin:1px 1px 0 0}.noUi-handle.noUi-active,.noUi-handle:focus{box-shadow:0 0 0 1px #f1f5f9,0 0 0 .25rem rgba(32,107,196,.25)}.noUi-connect{background:currentColor}.litepicker{--litepicker-month-weekday-color:var(--tblr-muted);--litepicker-button-prev-month-color:var(--tblr-muted);--litepicker-button-next-month-color:var(--tblr-muted);--litepicker-button-prev-month-color-hover:var(--tblr-primary);--litepicker-button-next-month-color-hover:var(--tblr-primary);--litepicker-day-color:var(--tblr-body-color);--litepicker-day-color-hover:var(--tblr-primary);--litepicker-is-end-color-bg:var(--tblr-primary);--litepicker-is-today-color:var(--tblr-primary);--litepicker-month-header-color:var(--tblr-body-color);--litepicker-container-months-color-bg:var(--tblr-bg-surface);font:inherit;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.litepicker svg{fill:none!important}.litepicker .container__main{border:var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);border-radius:var(--tblr-border-radius);box-shadow:none}.litepicker .container__months .month-item-name,.litepicker .container__months .month-item-year{font-weight:var(--tblr-font-weight-medium)!important}.litepicker .container__months .button-next-month,.litepicker .container__months .button-prev-month{cursor:pointer!important}.litepicker .container__months .month-item-weekdays-row>div{padding:.5rem 0!important;font-size:.75rem}.litepicker .container__days .day-item{cursor:pointer!important;padding:.5rem 0!important;transition:color .3s,background-color .3s,border-color .3s}@media (prefers-reduced-motion:reduce){.litepicker .container__days .day-item{transition:none}}.datepicker-inline .litepicker .container__months{box-shadow:none;background-color:var(--tblr-bg-forms)}:root{--ts-pr-clear-button:0;--ts-pr-caret:0;--ts-pr-min:.75rem}.ts-wrapper.single .ts-control,.ts-wrapper.single .ts-control input{cursor:pointer}.ts-control{padding-right:max(var(--ts-pr-min),var(--ts-pr-clear-button) + var(--ts-pr-caret))!important}.ts-wrapper.plugin-drag_drop.multi>.ts-control>div.ui-sortable-placeholder{visibility:visible!important;background:#f2f2f2!important;background:rgba(0,0,0,.06)!important;border:0 none!important;box-shadow:inset 0 0 12px 4px #fff}.ts-wrapper.plugin-drag_drop .ui-sortable-placeholder::after{content:"!";visibility:hidden}.ts-wrapper.plugin-drag_drop .ui-sortable-helper{box-shadow:0 2px 5px rgba(0,0,0,.2)}.plugin-checkbox_options .option input{margin-right:.5rem}.plugin-clear_button{--ts-pr-clear-button:1em}.plugin-clear_button .clear-button{opacity:0;position:absolute;top:50%;transform:translateY(-50%);right:calc(.75rem - 5px);margin-right:0!important;background:0 0!important;transition:opacity .5s;cursor:pointer}.plugin-clear_button.form-select .clear-button,.plugin-clear_button.single .clear-button{right:max(var(--ts-pr-caret),.75rem)}.plugin-clear_button.focus.has-items .clear-button,.plugin-clear_button:not(.disabled):hover.has-items .clear-button{opacity:1}.ts-wrapper .dropdown-header{position:relative;padding:6px .75rem;border-bottom:1px solid #d0d0d0;background:#f8f8f8;border-radius:var(--tblr-border-radius) var(--tblr-border-radius) 0 0}.ts-wrapper .dropdown-header-close{position:absolute;right:.75rem;top:50%;color:#1d273b;opacity:.4;margin-top:-12px;line-height:20px;font-size:20px!important}.ts-wrapper .dropdown-header-close:hover{color:#000}.plugin-dropdown_input.focus.dropdown-active .ts-control{box-shadow:none;border:1px solid var(--tblr-border-color);box-shadow:inset 0 1px 2px rgba(var(--tblr-body-color-rgb),.075)}.plugin-dropdown_input .dropdown-input{border:1px solid #d0d0d0;border-width:0 0 1px 0;display:block;padding:.4375rem .75rem;box-shadow:none;width:100%;background:0 0}.plugin-dropdown_input.focus .ts-dropdown .dropdown-input{border-color:#90b5e2;outline:0;box-shadow:0 0 0 .25rem rgba(32,107,196,.25)}.plugin-dropdown_input .items-placeholder{border:0 none!important;box-shadow:none!important;width:100%}.plugin-dropdown_input.dropdown-active .items-placeholder,.plugin-dropdown_input.has-items .items-placeholder{display:none!important}.ts-wrapper.plugin-input_autogrow.has-items .ts-control>input{min-width:0}.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control>input{flex:none;min-width:4px}.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control>input::-webkit-input-placeholder{color:transparent}.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control>input::-moz-placeholder{color:transparent}.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control>input:-ms-input-placeholder{color:transparent}.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control>input::-ms-input-placeholder{color:transparent}.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control>input::placeholder{color:transparent}.ts-dropdown.plugin-optgroup_columns .ts-dropdown-content{display:flex}.ts-dropdown.plugin-optgroup_columns .optgroup{border-right:1px solid #f2f2f2;border-top:0 none;flex-grow:1;flex-basis:0;min-width:0}.ts-dropdown.plugin-optgroup_columns .optgroup:last-child{border-right:0 none}.ts-dropdown.plugin-optgroup_columns .optgroup:before{display:none}.ts-dropdown.plugin-optgroup_columns .optgroup-header{border-top:0 none}.ts-wrapper.plugin-remove_button .item{display:inline-flex;align-items:center;padding-right:0!important}.ts-wrapper.plugin-remove_button .item .remove{color:inherit;text-decoration:none;vertical-align:middle;display:inline-block;padding:0 5px;border-radius:0 2px 2px 0;box-sizing:border-box}.ts-wrapper.plugin-remove_button .item .remove:hover{background:rgba(0,0,0,.05)}.ts-wrapper.plugin-remove_button.disabled .item .remove:hover{background:0 0}.ts-wrapper.plugin-remove_button .remove-single{position:absolute;right:0;top:0;font-size:23px}.ts-wrapper.plugin-remove_button:not(.rtl) .item .remove{border-left:1px solid #e6e7e9;margin-left:5px}.ts-wrapper.plugin-remove_button:not(.rtl) .item.active .remove{border-left-color:transparent}.ts-wrapper.plugin-remove_button:not(.rtl).disabled .item .remove{border-left-color:#fff}.ts-wrapper.plugin-remove_button.rtl .item .remove{border-right:1px solid #e6e7e9;margin-right:5px}.ts-wrapper.plugin-remove_button.rtl .item.active .remove{border-right-color:transparent}.ts-wrapper.plugin-remove_button.rtl.disabled .item .remove{border-right-color:#fff}.ts-wrapper{position:relative}.ts-control,.ts-control input,.ts-dropdown{color:#1d273b;font-family:inherit;font-size:inherit;line-height:1.4285714286;font-smoothing:inherit}.ts-control,.ts-wrapper.single.input-active .ts-control{background:var(--tblr-bg-forms);cursor:text}.ts-control{border:1px solid var(--tblr-border-color);padding:.4375rem .75rem;width:100%;overflow:hidden;position:relative;z-index:1;box-sizing:border-box;box-shadow:none;border-radius:var(--tblr-border-radius);display:flex;flex-wrap:wrap}.ts-wrapper.multi.has-items .ts-control{padding:calc(.4375rem - 1px - 0px) .75rem calc(.4375rem - 1px - 3px - 0px)}.full .ts-control{background-color:var(--tblr-bg-forms)}.disabled .ts-control,.disabled .ts-control *{cursor:default!important}.focus .ts-control{box-shadow:none}.ts-control>*{vertical-align:baseline;display:inline-block}.ts-wrapper.multi .ts-control>div{cursor:pointer;margin:0 3px 3px 0;padding:1px 5px;background:#efefef;color:#1d273b;border:0 solid #e6e7e9}.ts-wrapper.multi .ts-control>div.active{background:#206bc4;color:#fff;border:0 solid transparent}.ts-wrapper.multi.disabled .ts-control>div,.ts-wrapper.multi.disabled .ts-control>div.active{color:#797979;background:#fff;border:0 solid #fff}.ts-control>input{flex:1 1 auto;min-width:7rem;display:inline-block!important;padding:0!important;min-height:0!important;max-height:none!important;max-width:100%!important;margin:0!important;text-indent:0!important;border:0 none!important;background:0 0!important;line-height:inherit!important;-webkit-user-select:auto!important;-moz-user-select:auto!important;-ms-user-select:auto!important;user-select:auto!important;box-shadow:none!important}.ts-control>input::-ms-clear{display:none}.ts-control>input:focus{outline:0!important}.has-items .ts-control>input{margin:0 4px!important}.ts-control.rtl{text-align:right}.ts-control.rtl.single .ts-control:after{left:calc(.75rem + 5px);right:auto}.ts-control.rtl .ts-control>input{margin:0 4px 0 -2px!important}.disabled .ts-control{opacity:.5;background-color:var(--tblr-bg-surface-secondary)}.input-hidden .ts-control>input{opacity:0;position:absolute;left:-10000px}.ts-dropdown{position:absolute;top:100%;left:0;width:100%;z-index:10;border:1px solid #d0d0d0;background:#fff;margin:.25rem 0 0 0;border-top:0 none;box-sizing:border-box;box-shadow:0 1px 3px rgba(0,0,0,.1);border-radius:0 0 var(--tblr-border-radius) var(--tblr-border-radius)}.ts-dropdown [data-selectable]{cursor:pointer;overflow:hidden}.ts-dropdown [data-selectable] .highlight{background:rgba(255,237,40,.4);border-radius:1px}.ts-dropdown .create,.ts-dropdown .no-results,.ts-dropdown .optgroup-header,.ts-dropdown .option{padding:3px .75rem}.ts-dropdown .option,.ts-dropdown [data-disabled],.ts-dropdown [data-disabled] [data-selectable].option{cursor:inherit;opacity:.5}.ts-dropdown [data-selectable].option{opacity:1;cursor:pointer}.ts-dropdown .optgroup:first-child .optgroup-header{border-top:0 none}.ts-dropdown .optgroup-header{color:#49566c;background:var(--tblr-bg-surface);cursor:default}.ts-dropdown .active{background-color:rgba(var(--tblr-muted-rgb),.04);color:inherit}.ts-dropdown .active.create{color:inherit}.ts-dropdown .create{color:rgba(29,39,59,.5)}.ts-dropdown .spinner{display:inline-block;width:30px;height:30px;margin:3px .75rem}.ts-dropdown .spinner:after{content:" ";display:block;width:24px;height:24px;margin:3px;border-radius:50%;border:5px solid #d0d0d0;border-color:#d0d0d0 transparent #d0d0d0 transparent;animation:lds-dual-ring 1.2s linear infinite}@keyframes lds-dual-ring{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.ts-dropdown-content{overflow-y:auto;overflow-x:hidden;max-height:200px;overflow-scrolling:touch;scroll-behavior:smooth}.ts-hidden-accessible{border:0!important;clip:rect(0 0 0 0)!important;-webkit-clip-path:inset(50%)!important;clip-path:inset(50%)!important;overflow:hidden!important;padding:0!important;position:absolute!important;width:1px!important;white-space:nowrap!important}.ts-wrapper.form-control,.ts-wrapper.form-select{padding:0!important;height:auto;box-shadow:none;display:flex}.ts-dropdown,.ts-dropdown.form-control,.ts-dropdown.form-select{height:auto;padding:0;z-index:1000;background:#fff;border:1px solid var(--tblr-border-color-translucent);border-radius:4px;box-shadow:0 6px 12px rgba(0,0,0,.175)}.ts-dropdown .optgroup-header{font-size:.765625rem;line-height:1.4285714286}.ts-dropdown .optgroup:first-child:before{display:none}.ts-dropdown .optgroup:before{content:" ";display:block;height:0;margin:.5rem 0;overflow:hidden;border-top:1px solid var(--tblr-border-color-translucent);margin-left:-.75rem;margin-right:-.75rem}.ts-dropdown .create{padding-left:.75rem}.ts-dropdown-content{padding:5px 0}.ts-control{transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;display:flex;align-items:center}@media (prefers-reduced-motion:reduce){.ts-control{transition:none}}.ts-control.dropdown -active{border-radius:var(--tblr-border-radius)}.focus .ts-control{border-color:#90b5e2;outline:0;box-shadow:0 0 0 .25rem rgba(32,107,196,.25)}.ts-control .item{display:flex;align-items:center}.ts-wrapper.is-invalid,.was-validated .invalid,.was-validated :invalid+.ts-wrapper{border-color:var(--tblr-danger-text)}.ts-wrapper.is-invalid:not(.single),.was-validated .invalid:not(.single),.was-validated :invalid+.ts-wrapper:not(.single){background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23d63939' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cline x1='18' y1='6' x2='6' y2='18'%3e%3c/line%3e%3cline x1='6' y1='6' x2='18' y2='18'%3e%3c/line%3e%3c/svg%3e");background-position:right calc(.3571428572em + .21875rem) center;background-size:calc(.7142857143em + .4375rem) calc(.7142857143em + .4375rem);background-repeat:no-repeat}.ts-wrapper.is-invalid.single,.was-validated .invalid.single,.was-validated :invalid+.ts-wrapper.single{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23a5a9b1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"),url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23d63939' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cline x1='18' y1='6' x2='6' y2='18'%3e%3c/line%3e%3cline x1='6' y1='6' x2='18' y2='18'%3e%3c/line%3e%3c/svg%3e");background-position:right .75rem center,center right 2.25rem;background-size:16px 12px,calc(.7142857143em + .4375rem) calc(.7142857143em + .4375rem);background-repeat:no-repeat}.ts-wrapper.is-invalid.focus .ts-control,.was-validated .invalid.focus .ts-control,.was-validated :invalid+.ts-wrapper.focus .ts-control{border-color:var(--tblr-danger-text);box-shadow:0 0 0 .25rem rgba(var(--tblr-danger-text),.25)}.ts-wrapper.is-valid,.was-validated .valid,.was-validated :valid+.ts-wrapper{border-color:var(--tblr-success-text)}.ts-wrapper.is-valid:not(.single),.was-validated .valid:not(.single),.was-validated :valid+.ts-wrapper:not(.single){background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232fb344' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='20 6 9 17 4 12'%3e%3c/polyline%3e%3c/svg%3e");background-position:right calc(.3571428572em + .21875rem) center;background-size:calc(.7142857143em + .4375rem) calc(.7142857143em + .4375rem);background-repeat:no-repeat}.ts-wrapper.is-valid.single,.was-validated .valid.single,.was-validated :valid+.ts-wrapper.single{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23a5a9b1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"),url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232fb344' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='20 6 9 17 4 12'%3e%3c/polyline%3e%3c/svg%3e");background-position:right .75rem center,center right 2.25rem;background-size:16px 12px,calc(.7142857143em + .4375rem) calc(.7142857143em + .4375rem);background-repeat:no-repeat}.ts-wrapper.is-valid.focus .ts-control,.was-validated .valid.focus .ts-control,.was-validated :valid+.ts-wrapper.focus .ts-control{border-color:var(--tblr-success-text);box-shadow:0 0 0 .25rem rgba(var(--tblr-success-text),.25)}.ts-wrapper{min-height:calc(1.4285714286em + .875rem + calc(var(--tblr-border-width) * 2));display:flex}.input-group-sm>.ts-wrapper,.ts-wrapper.form-control-sm,.ts-wrapper.form-select-sm{min-height:calc(1.4285714286em + .25rem + calc(var(--tblr-border-width) * 2))}.input-group-sm>.ts-wrapper .ts-control,.ts-wrapper.form-control-sm .ts-control,.ts-wrapper.form-select-sm .ts-control{border-radius:2px;font-size:.75rem}.input-group-sm>.ts-wrapper.has-items .ts-control,.ts-wrapper.form-control-sm.has-items .ts-control,.ts-wrapper.form-select-sm.has-items .ts-control{font-size:.75rem;padding-bottom:0}.input-group-sm>.ts-wrapper.multi.has-items .ts-control,.ts-wrapper.form-control-sm.multi.has-items .ts-control,.ts-wrapper.form-select-sm.multi.has-items .ts-control{padding-top:calc((calc(1.4285714286em + .25rem + calc(var(--tblr-border-width) * 2)) - (1.4285714286 * .75rem) - 4px)/ 2)!important}.ts-wrapper.multi.has-items .ts-control{padding-left:calc(.75rem - 5px);--ts-pr-min:calc(0.75rem - 5px)}.ts-wrapper.multi .ts-control>div{border-radius:calc(var(--tblr-border-radius) - 1px)}.input-group-lg>.ts-wrapper,.ts-wrapper.form-control-lg,.ts-wrapper.form-select-lg{min-height:calc(1.4285714286em + 1rem + calc(var(--tblr-border-width) * 2))}.input-group-lg>.ts-wrapper .ts-control,.ts-wrapper.form-control-lg .ts-control,.ts-wrapper.form-select-lg .ts-control{border-radius:8px;font-size:1.25rem}.ts-wrapper:not(.form-control):not(.form-select){padding:0;border:none;height:auto;box-shadow:none;background:0 0}.ts-wrapper:not(.form-control):not(.form-select).single .ts-control{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23a5a9b1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right .75rem center;background-size:16px 12px}.ts-wrapper.form-select,.ts-wrapper.single{--ts-pr-caret:2.25rem}.ts-wrapper.form-control .ts-control,.ts-wrapper.form-control.single.input-active .ts-control,.ts-wrapper.form-select .ts-control,.ts-wrapper.form-select.single.input-active .ts-control{border:none!important}.ts-wrapper.form-control:not(.disabled) .ts-control,.ts-wrapper.form-control:not(.disabled).single.input-active .ts-control,.ts-wrapper.form-select:not(.disabled) .ts-control,.ts-wrapper.form-select:not(.disabled).single.input-active .ts-control{background:0 0!important}.input-group>.ts-wrapper{flex-grow:1}.input-group>.ts-wrapper:not(:nth-child(2))>.ts-control{border-top-left-radius:0;border-bottom-left-radius:0}.input-group>.ts-wrapper:not(:last-child)>.ts-control{border-top-right-radius:0;border-bottom-right-radius:0}.ts-input{color:inherit}.ts-control{color:inherit}.ts-control .dropdown-menu{width:100%;height:auto}.apexcharts-tooltip{color:var(--tblr-light)!important;background:var(--tblr-bg-surface-dark)!important;font-size:.765625rem!important;padding:.25rem!important;box-shadow:none!important}.apexcharts-tooltip-title{background:0 0!important;border:0!important;margin:0!important;font-weight:var(--tblr-font-weight-bold);padding:.25rem .5rem!important}.apexcharts-tooltip-y-group{padding:2px 0!important}.apexcharts-tooltip-series-group{padding:0 .5rem 0!important}.apexcharts-tooltip-marker{width:10px!important;height:10px!important}svg{touch-action:none}.jvm-zoomin,.jvm-zoomout,image,text{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.jvm-container{touch-action:none;position:relative;overflow:hidden;height:100%;width:100%}.jvm-tooltip{border-radius:3px;background-color:#5c5cff;font-family:sans-serif,Verdana;font-size:smaller;box-shadow:1px 2px 12px rgba(0,0,0,.2);padding:3px 5px;white-space:nowrap;position:absolute;display:none;color:#fff}.jvm-tooltip.active{display:block}.jvm-zoom-btn{border-radius:3px;background-color:#292929;padding:3px;box-sizing:border-box;position:absolute;line-height:10px;cursor:pointer;color:#fff;height:15px;width:15px;left:10px}.jvm-zoom-btn.jvm-zoomout{top:30px}.jvm-zoom-btn.jvm-zoomin{top:10px}.jvm-series-container{right:15px;position:absolute}.jvm-series-container.jvm-series-h{bottom:15px}.jvm-series-container.jvm-series-v{top:15px}.jvm-series-container .jvm-legend{background-color:#fff;border:1px solid #e5e7eb;margin-left:.75rem;border-radius:.25rem;border-color:#e5e7eb;padding:.6rem;box-shadow:0 1px 2px 0 rgba(0,0,0,.05);float:left}.jvm-series-container .jvm-legend .jvm-legend-title{line-height:1;border-bottom:1px solid #e5e7eb;padding-bottom:.5rem;margin-bottom:.575rem;text-align:left}.jvm-series-container .jvm-legend .jvm-legend-inner{overflow:hidden}.jvm-series-container .jvm-legend .jvm-legend-inner .jvm-legend-tick{overflow:hidden;min-width:40px}.jvm-series-container .jvm-legend .jvm-legend-inner .jvm-legend-tick:not(:first-child){margin-top:.575rem}.jvm-series-container .jvm-legend .jvm-legend-inner .jvm-legend-tick .jvm-legend-tick-sample{border-radius:4px;margin-right:.65rem;height:16px;width:16px;float:left}.jvm-series-container .jvm-legend .jvm-legend-inner .jvm-legend-tick .jvm-legend-tick-text{font-size:12px;text-align:center;float:left}.jvm-line[animation=true]{animation:jvm-line-animation 10s linear forwards infinite}@keyframes jvm-line-animation{from{stroke-dashoffset:250}}.jvm-tooltip{background:#1d273b;font-family:inherit;font-size:.75rem;box-shadow:var(--tblr-shadow-card)}.jvm-series-container .jvm-legend .jvm-legend-title{border-bottom:0;font-weight:var(--tblr-font-weight-medium)}.jvm-series-container .jvm-legend{background-color:var(--tblr-card-bg,var(--tblr-bg-surface));border:var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);min-width:8rem}.jvm-series-container .jvm-legend .jvm-legend-inner .jvm-legend-tick{display:flex;align-items:center}.jvm-series-container .jvm-legend .jvm-legend-inner .jvm-legend-tick .jvm-legend-tick-sample{width:.75rem;height:.75rem}.jvm-zoom-btn{border:var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color);background:var(--tblr-card-bg,var(--tblr-bg-surface));color:var(--tblr-body-color);padding:0;display:flex;align-items:center;justify-content:center;line-height:1;width:1.5rem;height:1.5rem;font-size:1rem;box-shadow:var(--tblr-shadow-card)}.jvm-zoom-btn.jvm-zoomout{top:2.5rem}.dropzone{border:var(--tblr-border-width) dashed var(--tblr-border-color);color:var(--tblr-muted);padding:1rem}.dropzone.dz-drag-hover{border:var(--tblr-border-width) dashed var(--tblr-primary);background:rgba(var(--tblr-primary-rgb),.01);color:var(--tblr-primary)}.dropzone.dz-drag-hover .dz-message{opacity:1}.dropzone .dz-preview{margin:.5rem}.dropzone .dz-preview .dz-image{border-radius:var(--tblr-border-radius)}.dropzone .dz-preview .dz-success-mark{height:54px}.fslightbox-container{font-family:inherit!important;background:rgba(29,39,59,.24)!important;-webkit-backdrop-filter:blur(4px)!important;backdrop-filter:blur(4px)!important}.fslightbox-slide-number-container{color:inherit!important}.fslightbox-slash{background:currentColor!important}body{--plyr-color-main:var(--tblr-primary)}.tox-tinymce{border:var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color)!important;border-radius:4px!important;font-family:var(--tblr-font-sans-serif)!important}.tox-toolbar__group{padding:0 .5rem 0}.tox:not(.tox-tinymce-inline) .tox-editor-header{border-bottom:var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color)!important;box-shadow:none!important;padding:0!important}.tox-tbtn{margin:0!important}.tox-statusbar{border-top:var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color)!important}.tox .tox-toolbar,.tox .tox-toolbar__overflow,.tox .tox-toolbar__primary{background:0 0!important}.tox .tox-toolbar-overlord,.tox:not(.tox-tinymce-inline) .tox-editor-header{background:0 0!important} \ No newline at end of file diff --git a/crates/ezidam/static/libs/list.js/list.js b/crates/ezidam/static/libs/list.js/list.js new file mode 100644 index 0000000..640dece --- /dev/null +++ b/crates/ezidam/static/libs/list.js/list.js @@ -0,0 +1,2020 @@ +var List;List = +/******/ (function() { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ "./src/add-async.js": +/*!**************************!*\ + !*** ./src/add-async.js ***! + \**************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 1:0-14 */ +/***/ (function(module) { + +module.exports = function (list) { + var addAsync = function addAsync(values, callback, items) { + var valuesToAdd = values.splice(0, 50); + items = items || []; + items = items.concat(list.add(valuesToAdd)); + + if (values.length > 0) { + setTimeout(function () { + addAsync(values, callback, items); + }, 1); + } else { + list.update(); + callback(items); + } + }; + + return addAsync; +}; + +/***/ }), + +/***/ "./src/filter.js": +/*!***********************!*\ + !*** ./src/filter.js ***! + \***********************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 1:0-14 */ +/***/ (function(module) { + +module.exports = function (list) { + // Add handlers + list.handlers.filterStart = list.handlers.filterStart || []; + list.handlers.filterComplete = list.handlers.filterComplete || []; + return function (filterFunction) { + list.trigger('filterStart'); + list.i = 1; // Reset paging + + list.reset.filter(); + + if (filterFunction === undefined) { + list.filtered = false; + } else { + list.filtered = true; + var is = list.items; + + for (var i = 0, il = is.length; i < il; i++) { + var item = is[i]; + + if (filterFunction(item)) { + item.filtered = true; + } else { + item.filtered = false; + } + } + } + + list.update(); + list.trigger('filterComplete'); + return list.visibleItems; + }; +}; + +/***/ }), + +/***/ "./src/fuzzy-search.js": +/*!*****************************!*\ + !*** ./src/fuzzy-search.js ***! + \*****************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module, __webpack_require__ */ +/*! CommonJS bailout: module.exports is used directly at 8:0-14 */ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var classes = __webpack_require__(/*! ./utils/classes */ "./src/utils/classes.js"), + events = __webpack_require__(/*! ./utils/events */ "./src/utils/events.js"), + extend = __webpack_require__(/*! ./utils/extend */ "./src/utils/extend.js"), + toString = __webpack_require__(/*! ./utils/to-string */ "./src/utils/to-string.js"), + getByClass = __webpack_require__(/*! ./utils/get-by-class */ "./src/utils/get-by-class.js"), + fuzzy = __webpack_require__(/*! ./utils/fuzzy */ "./src/utils/fuzzy.js"); + +module.exports = function (list, options) { + options = options || {}; + options = extend({ + location: 0, + distance: 100, + threshold: 0.4, + multiSearch: true, + searchClass: 'fuzzy-search' + }, options); + var fuzzySearch = { + search: function search(searchString, columns) { + // Substract arguments from the searchString or put searchString as only argument + var searchArguments = options.multiSearch ? searchString.replace(/ +$/, '').split(/ +/) : [searchString]; + + for (var k = 0, kl = list.items.length; k < kl; k++) { + fuzzySearch.item(list.items[k], columns, searchArguments); + } + }, + item: function item(_item, columns, searchArguments) { + var found = true; + + for (var i = 0; i < searchArguments.length; i++) { + var foundArgument = false; + + for (var j = 0, jl = columns.length; j < jl; j++) { + if (fuzzySearch.values(_item.values(), columns[j], searchArguments[i])) { + foundArgument = true; + } + } + + if (!foundArgument) { + found = false; + } + } + + _item.found = found; + }, + values: function values(_values, value, searchArgument) { + if (_values.hasOwnProperty(value)) { + var text = toString(_values[value]).toLowerCase(); + + if (fuzzy(text, searchArgument, options)) { + return true; + } + } + + return false; + } + }; + events.bind(getByClass(list.listContainer, options.searchClass), 'keyup', list.utils.events.debounce(function (e) { + var target = e.target || e.srcElement; // IE have srcElement + + list.search(target.value, fuzzySearch.search); + }, list.searchDelay)); + return function (str, columns) { + list.search(str, columns, fuzzySearch.search); + }; +}; + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module, __webpack_require__ */ +/*! CommonJS bailout: module.exports is used directly at 11:0-14 */ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var naturalSort = __webpack_require__(/*! string-natural-compare */ "./node_modules/string-natural-compare/natural-compare.js"), + getByClass = __webpack_require__(/*! ./utils/get-by-class */ "./src/utils/get-by-class.js"), + extend = __webpack_require__(/*! ./utils/extend */ "./src/utils/extend.js"), + indexOf = __webpack_require__(/*! ./utils/index-of */ "./src/utils/index-of.js"), + events = __webpack_require__(/*! ./utils/events */ "./src/utils/events.js"), + toString = __webpack_require__(/*! ./utils/to-string */ "./src/utils/to-string.js"), + classes = __webpack_require__(/*! ./utils/classes */ "./src/utils/classes.js"), + getAttribute = __webpack_require__(/*! ./utils/get-attribute */ "./src/utils/get-attribute.js"), + toArray = __webpack_require__(/*! ./utils/to-array */ "./src/utils/to-array.js"); + +module.exports = function (id, options, values) { + var self = this, + init, + Item = __webpack_require__(/*! ./item */ "./src/item.js")(self), + addAsync = __webpack_require__(/*! ./add-async */ "./src/add-async.js")(self), + initPagination = __webpack_require__(/*! ./pagination */ "./src/pagination.js")(self); + + init = { + start: function start() { + self.listClass = 'list'; + self.searchClass = 'search'; + self.sortClass = 'sort'; + self.page = 10000; + self.i = 1; + self.items = []; + self.visibleItems = []; + self.matchingItems = []; + self.searched = false; + self.filtered = false; + self.searchColumns = undefined; + self.searchDelay = 0; + self.handlers = { + updated: [] + }; + self.valueNames = []; + self.utils = { + getByClass: getByClass, + extend: extend, + indexOf: indexOf, + events: events, + toString: toString, + naturalSort: naturalSort, + classes: classes, + getAttribute: getAttribute, + toArray: toArray + }; + self.utils.extend(self, options); + self.listContainer = typeof id === 'string' ? document.getElementById(id) : id; + + if (!self.listContainer) { + return; + } + + self.list = getByClass(self.listContainer, self.listClass, true); + self.parse = __webpack_require__(/*! ./parse */ "./src/parse.js")(self); + self.templater = __webpack_require__(/*! ./templater */ "./src/templater.js")(self); + self.search = __webpack_require__(/*! ./search */ "./src/search.js")(self); + self.filter = __webpack_require__(/*! ./filter */ "./src/filter.js")(self); + self.sort = __webpack_require__(/*! ./sort */ "./src/sort.js")(self); + self.fuzzySearch = __webpack_require__(/*! ./fuzzy-search */ "./src/fuzzy-search.js")(self, options.fuzzySearch); + this.handlers(); + this.items(); + this.pagination(); + self.update(); + }, + handlers: function handlers() { + for (var handler in self.handlers) { + if (self[handler] && self.handlers.hasOwnProperty(handler)) { + self.on(handler, self[handler]); + } + } + }, + items: function items() { + self.parse(self.list); + + if (values !== undefined) { + self.add(values); + } + }, + pagination: function pagination() { + if (options.pagination !== undefined) { + if (options.pagination === true) { + options.pagination = [{}]; + } + + if (options.pagination[0] === undefined) { + options.pagination = [options.pagination]; + } + + for (var i = 0, il = options.pagination.length; i < il; i++) { + initPagination(options.pagination[i]); + } + } + } + }; + /* + * Re-parse the List, use if html have changed + */ + + this.reIndex = function () { + self.items = []; + self.visibleItems = []; + self.matchingItems = []; + self.searched = false; + self.filtered = false; + self.parse(self.list); + }; + + this.toJSON = function () { + var json = []; + + for (var i = 0, il = self.items.length; i < il; i++) { + json.push(self.items[i].values()); + } + + return json; + }; + /* + * Add object to list + */ + + + this.add = function (values, callback) { + if (values.length === 0) { + return; + } + + if (callback) { + addAsync(values.slice(0), callback); + return; + } + + var added = [], + notCreate = false; + + if (values[0] === undefined) { + values = [values]; + } + + for (var i = 0, il = values.length; i < il; i++) { + var item = null; + notCreate = self.items.length > self.page ? true : false; + item = new Item(values[i], undefined, notCreate); + self.items.push(item); + added.push(item); + } + + self.update(); + return added; + }; + + this.show = function (i, page) { + this.i = i; + this.page = page; + self.update(); + return self; + }; + /* Removes object from list. + * Loops through the list and removes objects where + * property "valuename" === value + */ + + + this.remove = function (valueName, value, options) { + var found = 0; + + for (var i = 0, il = self.items.length; i < il; i++) { + if (self.items[i].values()[valueName] == value) { + self.templater.remove(self.items[i], options); + self.items.splice(i, 1); + il--; + i--; + found++; + } + } + + self.update(); + return found; + }; + /* Gets the objects in the list which + * property "valueName" === value + */ + + + this.get = function (valueName, value) { + var matchedItems = []; + + for (var i = 0, il = self.items.length; i < il; i++) { + var item = self.items[i]; + + if (item.values()[valueName] == value) { + matchedItems.push(item); + } + } + + return matchedItems; + }; + /* + * Get size of the list + */ + + + this.size = function () { + return self.items.length; + }; + /* + * Removes all items from the list + */ + + + this.clear = function () { + self.templater.clear(); + self.items = []; + return self; + }; + + this.on = function (event, callback) { + self.handlers[event].push(callback); + return self; + }; + + this.off = function (event, callback) { + var e = self.handlers[event]; + var index = indexOf(e, callback); + + if (index > -1) { + e.splice(index, 1); + } + + return self; + }; + + this.trigger = function (event) { + var i = self.handlers[event].length; + + while (i--) { + self.handlers[event][i](self); + } + + return self; + }; + + this.reset = { + filter: function filter() { + var is = self.items, + il = is.length; + + while (il--) { + is[il].filtered = false; + } + + return self; + }, + search: function search() { + var is = self.items, + il = is.length; + + while (il--) { + is[il].found = false; + } + + return self; + } + }; + + this.update = function () { + var is = self.items, + il = is.length; + self.visibleItems = []; + self.matchingItems = []; + self.templater.clear(); + + for (var i = 0; i < il; i++) { + if (is[i].matching() && self.matchingItems.length + 1 >= self.i && self.visibleItems.length < self.page) { + is[i].show(); + self.visibleItems.push(is[i]); + self.matchingItems.push(is[i]); + } else if (is[i].matching()) { + self.matchingItems.push(is[i]); + is[i].hide(); + } else { + is[i].hide(); + } + } + + self.trigger('updated'); + return self; + }; + + init.start(); +}; + +/***/ }), + +/***/ "./src/item.js": +/*!*********************!*\ + !*** ./src/item.js ***! + \*********************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 1:0-14 */ +/***/ (function(module) { + +module.exports = function (list) { + return function (initValues, element, notCreate) { + var item = this; + this._values = {}; + this.found = false; // Show if list.searched == true and this.found == true + + this.filtered = false; // Show if list.filtered == true and this.filtered == true + + var init = function init(initValues, element, notCreate) { + if (element === undefined) { + if (notCreate) { + item.values(initValues, notCreate); + } else { + item.values(initValues); + } + } else { + item.elm = element; + var values = list.templater.get(item, initValues); + item.values(values); + } + }; + + this.values = function (newValues, notCreate) { + if (newValues !== undefined) { + for (var name in newValues) { + item._values[name] = newValues[name]; + } + + if (notCreate !== true) { + list.templater.set(item, item.values()); + } + } else { + return item._values; + } + }; + + this.show = function () { + list.templater.show(item); + }; + + this.hide = function () { + list.templater.hide(item); + }; + + this.matching = function () { + return list.filtered && list.searched && item.found && item.filtered || list.filtered && !list.searched && item.filtered || !list.filtered && list.searched && item.found || !list.filtered && !list.searched; + }; + + this.visible = function () { + return item.elm && item.elm.parentNode == list.list ? true : false; + }; + + init(initValues, element, notCreate); + }; +}; + +/***/ }), + +/***/ "./src/pagination.js": +/*!***************************!*\ + !*** ./src/pagination.js ***! + \***************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module, __webpack_require__ */ +/*! CommonJS bailout: module.exports is used directly at 5:0-14 */ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var classes = __webpack_require__(/*! ./utils/classes */ "./src/utils/classes.js"), + events = __webpack_require__(/*! ./utils/events */ "./src/utils/events.js"), + List = __webpack_require__(/*! ./index */ "./src/index.js"); + +module.exports = function (list) { + var isHidden = false; + + var refresh = function refresh(pagingList, options) { + if (list.page < 1) { + list.listContainer.style.display = 'none'; + isHidden = true; + return; + } else if (isHidden) { + list.listContainer.style.display = 'block'; + } + + var item, + l = list.matchingItems.length, + index = list.i, + page = list.page, + pages = Math.ceil(l / page), + currentPage = Math.ceil(index / page), + innerWindow = options.innerWindow || 2, + left = options.left || options.outerWindow || 0, + right = options.right || options.outerWindow || 0; + right = pages - right; + pagingList.clear(); + + for (var i = 1; i <= pages; i++) { + var className = currentPage === i ? 'active' : ''; //console.log(i, left, right, currentPage, (currentPage - innerWindow), (currentPage + innerWindow), className); + + if (is.number(i, left, right, currentPage, innerWindow)) { + item = pagingList.add({ + page: i, + dotted: false + })[0]; + + if (className) { + classes(item.elm).add(className); + } + + item.elm.firstChild.setAttribute('data-i', i); + item.elm.firstChild.setAttribute('data-page', page); + } else if (is.dotted(pagingList, i, left, right, currentPage, innerWindow, pagingList.size())) { + item = pagingList.add({ + page: '...', + dotted: true + })[0]; + classes(item.elm).add('disabled'); + } + } + }; + + var is = { + number: function number(i, left, right, currentPage, innerWindow) { + return this.left(i, left) || this.right(i, right) || this.innerWindow(i, currentPage, innerWindow); + }, + left: function left(i, _left) { + return i <= _left; + }, + right: function right(i, _right) { + return i > _right; + }, + innerWindow: function innerWindow(i, currentPage, _innerWindow) { + return i >= currentPage - _innerWindow && i <= currentPage + _innerWindow; + }, + dotted: function dotted(pagingList, i, left, right, currentPage, innerWindow, currentPageItem) { + return this.dottedLeft(pagingList, i, left, right, currentPage, innerWindow) || this.dottedRight(pagingList, i, left, right, currentPage, innerWindow, currentPageItem); + }, + dottedLeft: function dottedLeft(pagingList, i, left, right, currentPage, innerWindow) { + return i == left + 1 && !this.innerWindow(i, currentPage, innerWindow) && !this.right(i, right); + }, + dottedRight: function dottedRight(pagingList, i, left, right, currentPage, innerWindow, currentPageItem) { + if (pagingList.items[currentPageItem - 1].values().dotted) { + return false; + } else { + return i == right && !this.innerWindow(i, currentPage, innerWindow) && !this.right(i, right); + } + } + }; + return function (options) { + var pagingList = new List(list.listContainer.id, { + listClass: options.paginationClass || 'pagination', + item: options.item || "
  • ", + valueNames: ['page', 'dotted'], + searchClass: 'pagination-search-that-is-not-supposed-to-exist', + sortClass: 'pagination-sort-that-is-not-supposed-to-exist' + }); + events.bind(pagingList.listContainer, 'click', function (e) { + var target = e.target || e.srcElement, + page = list.utils.getAttribute(target, 'data-page'), + i = list.utils.getAttribute(target, 'data-i'); + + if (i) { + list.show((i - 1) * page + 1, page); + } + }); + list.on('updated', function () { + refresh(pagingList, options); + }); + refresh(pagingList, options); + }; +}; + +/***/ }), + +/***/ "./src/parse.js": +/*!**********************!*\ + !*** ./src/parse.js ***! + \**********************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module, __webpack_require__ */ +/*! CommonJS bailout: module.exports is used directly at 1:0-14 */ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +module.exports = function (list) { + var Item = __webpack_require__(/*! ./item */ "./src/item.js")(list); + + var getChildren = function getChildren(parent) { + var nodes = parent.childNodes, + items = []; + + for (var i = 0, il = nodes.length; i < il; i++) { + // Only textnodes have a data attribute + if (nodes[i].data === undefined) { + items.push(nodes[i]); + } + } + + return items; + }; + + var parse = function parse(itemElements, valueNames) { + for (var i = 0, il = itemElements.length; i < il; i++) { + list.items.push(new Item(valueNames, itemElements[i])); + } + }; + + var parseAsync = function parseAsync(itemElements, valueNames) { + var itemsToIndex = itemElements.splice(0, 50); // TODO: If < 100 items, what happens in IE etc? + + parse(itemsToIndex, valueNames); + + if (itemElements.length > 0) { + setTimeout(function () { + parseAsync(itemElements, valueNames); + }, 1); + } else { + list.update(); + list.trigger('parseComplete'); + } + }; + + list.handlers.parseComplete = list.handlers.parseComplete || []; + return function () { + var itemsToIndex = getChildren(list.list), + valueNames = list.valueNames; + + if (list.indexAsync) { + parseAsync(itemsToIndex, valueNames); + } else { + parse(itemsToIndex, valueNames); + } + }; +}; + +/***/ }), + +/***/ "./src/search.js": +/*!***********************!*\ + !*** ./src/search.js ***! + \***********************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 1:0-14 */ +/***/ (function(module) { + +module.exports = function (_list) { + var item, text, columns, searchString, customSearch; + var prepare = { + resetList: function resetList() { + _list.i = 1; + + _list.templater.clear(); + + customSearch = undefined; + }, + setOptions: function setOptions(args) { + if (args.length == 2 && args[1] instanceof Array) { + columns = args[1]; + } else if (args.length == 2 && typeof args[1] == 'function') { + columns = undefined; + customSearch = args[1]; + } else if (args.length == 3) { + columns = args[1]; + customSearch = args[2]; + } else { + columns = undefined; + } + }, + setColumns: function setColumns() { + if (_list.items.length === 0) return; + + if (columns === undefined) { + columns = _list.searchColumns === undefined ? prepare.toArray(_list.items[0].values()) : _list.searchColumns; + } + }, + setSearchString: function setSearchString(s) { + s = _list.utils.toString(s).toLowerCase(); + s = s.replace(/[-[\]{}()*+?.,\\^$|#]/g, '\\$&'); // Escape regular expression characters + + searchString = s; + }, + toArray: function toArray(values) { + var tmpColumn = []; + + for (var name in values) { + tmpColumn.push(name); + } + + return tmpColumn; + } + }; + var search = { + list: function list() { + // Extract quoted phrases "word1 word2" from original searchString + // searchString is converted to lowercase by List.js + var words = [], + phrase, + ss = searchString; + + while ((phrase = ss.match(/"([^"]+)"/)) !== null) { + words.push(phrase[1]); + ss = ss.substring(0, phrase.index) + ss.substring(phrase.index + phrase[0].length); + } // Get remaining space-separated words (if any) + + + ss = ss.trim(); + if (ss.length) words = words.concat(ss.split(/\s+/)); + + for (var k = 0, kl = _list.items.length; k < kl; k++) { + var item = _list.items[k]; + item.found = false; + if (!words.length) continue; + + for (var i = 0, il = words.length; i < il; i++) { + var word_found = false; + + for (var j = 0, jl = columns.length; j < jl; j++) { + var values = item.values(), + column = columns[j]; + + if (values.hasOwnProperty(column) && values[column] !== undefined && values[column] !== null) { + var text = typeof values[column] !== 'string' ? values[column].toString() : values[column]; + + if (text.toLowerCase().indexOf(words[i]) !== -1) { + // word found, so no need to check it against any other columns + word_found = true; + break; + } + } + } // this word not found? no need to check any other words, the item cannot match + + + if (!word_found) break; + } + + item.found = word_found; + } + }, + // Removed search.item() and search.values() + reset: function reset() { + _list.reset.search(); + + _list.searched = false; + } + }; + + var searchMethod = function searchMethod(str) { + _list.trigger('searchStart'); + + prepare.resetList(); + prepare.setSearchString(str); + prepare.setOptions(arguments); // str, cols|searchFunction, searchFunction + + prepare.setColumns(); + + if (searchString === '') { + search.reset(); + } else { + _list.searched = true; + + if (customSearch) { + customSearch(searchString, columns); + } else { + search.list(); + } + } + + _list.update(); + + _list.trigger('searchComplete'); + + return _list.visibleItems; + }; + + _list.handlers.searchStart = _list.handlers.searchStart || []; + _list.handlers.searchComplete = _list.handlers.searchComplete || []; + + _list.utils.events.bind(_list.utils.getByClass(_list.listContainer, _list.searchClass), 'keyup', _list.utils.events.debounce(function (e) { + var target = e.target || e.srcElement, + // IE have srcElement + alreadyCleared = target.value === '' && !_list.searched; + + if (!alreadyCleared) { + // If oninput already have resetted the list, do nothing + searchMethod(target.value); + } + }, _list.searchDelay)); // Used to detect click on HTML5 clear button + + + _list.utils.events.bind(_list.utils.getByClass(_list.listContainer, _list.searchClass), 'input', function (e) { + var target = e.target || e.srcElement; + + if (target.value === '') { + searchMethod(''); + } + }); + + return searchMethod; +}; + +/***/ }), + +/***/ "./src/sort.js": +/*!*********************!*\ + !*** ./src/sort.js ***! + \*********************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 1:0-14 */ +/***/ (function(module) { + +module.exports = function (list) { + var buttons = { + els: undefined, + clear: function clear() { + for (var i = 0, il = buttons.els.length; i < il; i++) { + list.utils.classes(buttons.els[i]).remove('asc'); + list.utils.classes(buttons.els[i]).remove('desc'); + } + }, + getOrder: function getOrder(btn) { + var predefinedOrder = list.utils.getAttribute(btn, 'data-order'); + + if (predefinedOrder == 'asc' || predefinedOrder == 'desc') { + return predefinedOrder; + } else if (list.utils.classes(btn).has('desc')) { + return 'asc'; + } else if (list.utils.classes(btn).has('asc')) { + return 'desc'; + } else { + return 'asc'; + } + }, + getInSensitive: function getInSensitive(btn, options) { + var insensitive = list.utils.getAttribute(btn, 'data-insensitive'); + + if (insensitive === 'false') { + options.insensitive = false; + } else { + options.insensitive = true; + } + }, + setOrder: function setOrder(options) { + for (var i = 0, il = buttons.els.length; i < il; i++) { + var btn = buttons.els[i]; + + if (list.utils.getAttribute(btn, 'data-sort') !== options.valueName) { + continue; + } + + var predefinedOrder = list.utils.getAttribute(btn, 'data-order'); + + if (predefinedOrder == 'asc' || predefinedOrder == 'desc') { + if (predefinedOrder == options.order) { + list.utils.classes(btn).add(options.order); + } + } else { + list.utils.classes(btn).add(options.order); + } + } + } + }; + + var sort = function sort() { + list.trigger('sortStart'); + var options = {}; + var target = arguments[0].currentTarget || arguments[0].srcElement || undefined; + + if (target) { + options.valueName = list.utils.getAttribute(target, 'data-sort'); + buttons.getInSensitive(target, options); + options.order = buttons.getOrder(target); + } else { + options = arguments[1] || options; + options.valueName = arguments[0]; + options.order = options.order || 'asc'; + options.insensitive = typeof options.insensitive == 'undefined' ? true : options.insensitive; + } + + buttons.clear(); + buttons.setOrder(options); // caseInsensitive + // alphabet + + var customSortFunction = options.sortFunction || list.sortFunction || null, + multi = options.order === 'desc' ? -1 : 1, + sortFunction; + + if (customSortFunction) { + sortFunction = function sortFunction(itemA, itemB) { + return customSortFunction(itemA, itemB, options) * multi; + }; + } else { + sortFunction = function sortFunction(itemA, itemB) { + var sort = list.utils.naturalSort; + sort.alphabet = list.alphabet || options.alphabet || undefined; + + if (!sort.alphabet && options.insensitive) { + sort = list.utils.naturalSort.caseInsensitive; + } + + return sort(itemA.values()[options.valueName], itemB.values()[options.valueName]) * multi; + }; + } + + list.items.sort(sortFunction); + list.update(); + list.trigger('sortComplete'); + }; // Add handlers + + + list.handlers.sortStart = list.handlers.sortStart || []; + list.handlers.sortComplete = list.handlers.sortComplete || []; + buttons.els = list.utils.getByClass(list.listContainer, list.sortClass); + list.utils.events.bind(buttons.els, 'click', sort); + list.on('searchStart', buttons.clear); + list.on('filterStart', buttons.clear); + return sort; +}; + +/***/ }), + +/***/ "./src/templater.js": +/*!**************************!*\ + !*** ./src/templater.js ***! + \**************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 216:0-14 */ +/***/ (function(module) { + +var Templater = function Templater(list) { + var createItem, + templater = this; + + var init = function init() { + var itemSource; + + if (typeof list.item === 'function') { + createItem = function createItem(values) { + var item = list.item(values); + return getItemSource(item); + }; + + return; + } + + if (typeof list.item === 'string') { + if (list.item.indexOf('<') === -1) { + itemSource = document.getElementById(list.item); + } else { + itemSource = getItemSource(list.item); + } + } else { + /* If item source does not exists, use the first item in list as + source for new items */ + itemSource = getFirstListItem(); + } + + if (!itemSource) { + throw new Error("The list needs to have at least one item on init otherwise you'll have to add a template."); + } + + itemSource = createCleanTemplateItem(itemSource, list.valueNames); + + createItem = function createItem() { + return itemSource.cloneNode(true); + }; + }; + + var createCleanTemplateItem = function createCleanTemplateItem(templateNode, valueNames) { + var el = templateNode.cloneNode(true); + el.removeAttribute('id'); + + for (var i = 0, il = valueNames.length; i < il; i++) { + var elm = undefined, + valueName = valueNames[i]; + + if (valueName.data) { + for (var j = 0, jl = valueName.data.length; j < jl; j++) { + el.setAttribute('data-' + valueName.data[j], ''); + } + } else if (valueName.attr && valueName.name) { + elm = list.utils.getByClass(el, valueName.name, true); + + if (elm) { + elm.setAttribute(valueName.attr, ''); + } + } else { + elm = list.utils.getByClass(el, valueName, true); + + if (elm) { + elm.innerHTML = ''; + } + } + } + + return el; + }; + + var getFirstListItem = function getFirstListItem() { + var nodes = list.list.childNodes; + + for (var i = 0, il = nodes.length; i < il; i++) { + // Only textnodes have a data attribute + if (nodes[i].data === undefined) { + return nodes[i].cloneNode(true); + } + } + + return undefined; + }; + + var getItemSource = function getItemSource(itemHTML) { + if (typeof itemHTML !== 'string') return undefined; + + if (/]/g.exec(itemHTML)) { + var tbody = document.createElement('tbody'); + tbody.innerHTML = itemHTML; + return tbody.firstElementChild; + } else if (itemHTML.indexOf('<') !== -1) { + var div = document.createElement('div'); + div.innerHTML = itemHTML; + return div.firstElementChild; + } + + return undefined; + }; + + var getValueName = function getValueName(name) { + for (var i = 0, il = list.valueNames.length; i < il; i++) { + var valueName = list.valueNames[i]; + + if (valueName.data) { + var data = valueName.data; + + for (var j = 0, jl = data.length; j < jl; j++) { + if (data[j] === name) { + return { + data: name + }; + } + } + } else if (valueName.attr && valueName.name && valueName.name == name) { + return valueName; + } else if (valueName === name) { + return name; + } + } + }; + + var setValue = function setValue(item, name, value) { + var elm = undefined, + valueName = getValueName(name); + if (!valueName) return; + + if (valueName.data) { + item.elm.setAttribute('data-' + valueName.data, value); + } else if (valueName.attr && valueName.name) { + elm = list.utils.getByClass(item.elm, valueName.name, true); + + if (elm) { + elm.setAttribute(valueName.attr, value); + } + } else { + elm = list.utils.getByClass(item.elm, valueName, true); + + if (elm) { + elm.innerHTML = value; + } + } + }; + + this.get = function (item, valueNames) { + templater.create(item); + var values = {}; + + for (var i = 0, il = valueNames.length; i < il; i++) { + var elm = undefined, + valueName = valueNames[i]; + + if (valueName.data) { + for (var j = 0, jl = valueName.data.length; j < jl; j++) { + values[valueName.data[j]] = list.utils.getAttribute(item.elm, 'data-' + valueName.data[j]); + } + } else if (valueName.attr && valueName.name) { + elm = list.utils.getByClass(item.elm, valueName.name, true); + values[valueName.name] = elm ? list.utils.getAttribute(elm, valueName.attr) : ''; + } else { + elm = list.utils.getByClass(item.elm, valueName, true); + values[valueName] = elm ? elm.innerHTML : ''; + } + } + + return values; + }; + + this.set = function (item, values) { + if (!templater.create(item)) { + for (var v in values) { + if (values.hasOwnProperty(v)) { + setValue(item, v, values[v]); + } + } + } + }; + + this.create = function (item) { + if (item.elm !== undefined) { + return false; + } + + item.elm = createItem(item.values()); + templater.set(item, item.values()); + return true; + }; + + this.remove = function (item) { + if (item.elm.parentNode === list.list) { + list.list.removeChild(item.elm); + } + }; + + this.show = function (item) { + templater.create(item); + list.list.appendChild(item.elm); + }; + + this.hide = function (item) { + if (item.elm !== undefined && item.elm.parentNode === list.list) { + list.list.removeChild(item.elm); + } + }; + + this.clear = function () { + /* .innerHTML = ''; fucks up IE */ + if (list.list.hasChildNodes()) { + while (list.list.childNodes.length >= 1) { + list.list.removeChild(list.list.firstChild); + } + } + }; + + init(); +}; + +module.exports = function (list) { + return new Templater(list); +}; + +/***/ }), + +/***/ "./src/utils/classes.js": +/*!******************************!*\ + !*** ./src/utils/classes.js ***! + \******************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module, __webpack_require__ */ +/*! CommonJS bailout: module.exports is used directly at 24:0-14 */ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +/** + * Module dependencies. + */ +var index = __webpack_require__(/*! ./index-of */ "./src/utils/index-of.js"); +/** + * Whitespace regexp. + */ + + +var re = /\s+/; +/** + * toString reference. + */ + +var toString = Object.prototype.toString; +/** + * Wrap `el` in a `ClassList`. + * + * @param {Element} el + * @return {ClassList} + * @api public + */ + +module.exports = function (el) { + return new ClassList(el); +}; +/** + * Initialize a new ClassList for `el`. + * + * @param {Element} el + * @api private + */ + + +function ClassList(el) { + if (!el || !el.nodeType) { + throw new Error('A DOM element reference is required'); + } + + this.el = el; + this.list = el.classList; +} +/** + * Add class `name` if not already present. + * + * @param {String} name + * @return {ClassList} + * @api public + */ + + +ClassList.prototype.add = function (name) { + // classList + if (this.list) { + this.list.add(name); + return this; + } // fallback + + + var arr = this.array(); + var i = index(arr, name); + if (!~i) arr.push(name); + this.el.className = arr.join(' '); + return this; +}; +/** + * Remove class `name` when present, or + * pass a regular expression to remove + * any which match. + * + * @param {String|RegExp} name + * @return {ClassList} + * @api public + */ + + +ClassList.prototype.remove = function (name) { + // classList + if (this.list) { + this.list.remove(name); + return this; + } // fallback + + + var arr = this.array(); + var i = index(arr, name); + if (~i) arr.splice(i, 1); + this.el.className = arr.join(' '); + return this; +}; +/** + * Toggle class `name`, can force state via `force`. + * + * For browsers that support classList, but do not support `force` yet, + * the mistake will be detected and corrected. + * + * @param {String} name + * @param {Boolean} force + * @return {ClassList} + * @api public + */ + + +ClassList.prototype.toggle = function (name, force) { + // classList + if (this.list) { + if ('undefined' !== typeof force) { + if (force !== this.list.toggle(name, force)) { + this.list.toggle(name); // toggle again to correct + } + } else { + this.list.toggle(name); + } + + return this; + } // fallback + + + if ('undefined' !== typeof force) { + if (!force) { + this.remove(name); + } else { + this.add(name); + } + } else { + if (this.has(name)) { + this.remove(name); + } else { + this.add(name); + } + } + + return this; +}; +/** + * Return an array of classes. + * + * @return {Array} + * @api public + */ + + +ClassList.prototype.array = function () { + var className = this.el.getAttribute('class') || ''; + var str = className.replace(/^\s+|\s+$/g, ''); + var arr = str.split(re); + if ('' === arr[0]) arr.shift(); + return arr; +}; +/** + * Check if class `name` is present. + * + * @param {String} name + * @return {ClassList} + * @api public + */ + + +ClassList.prototype.has = ClassList.prototype.contains = function (name) { + return this.list ? this.list.contains(name) : !!~index(this.array(), name); +}; + +/***/ }), + +/***/ "./src/utils/events.js": +/*!*****************************!*\ + !*** ./src/utils/events.js ***! + \*****************************/ +/*! default exports */ +/*! export bind [provided] [no usage info] [missing usage info prevents renaming] */ +/*! export debounce [provided] [no usage info] [missing usage info prevents renaming] */ +/*! export unbind [provided] [no usage info] [missing usage info prevents renaming] */ +/*! other exports [not provided] [no usage info] */ +/*! runtime requirements: __webpack_exports__, __webpack_require__ */ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +var bind = window.addEventListener ? 'addEventListener' : 'attachEvent', + unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent', + prefix = bind !== 'addEventListener' ? 'on' : '', + toArray = __webpack_require__(/*! ./to-array */ "./src/utils/to-array.js"); +/** + * Bind `el` event `type` to `fn`. + * + * @param {Element} el, NodeList, HTMLCollection or Array + * @param {String} type + * @param {Function} fn + * @param {Boolean} capture + * @api public + */ + + +exports.bind = function (el, type, fn, capture) { + el = toArray(el); + + for (var i = 0, il = el.length; i < il; i++) { + el[i][bind](prefix + type, fn, capture || false); + } +}; +/** + * Unbind `el` event `type`'s callback `fn`. + * + * @param {Element} el, NodeList, HTMLCollection or Array + * @param {String} type + * @param {Function} fn + * @param {Boolean} capture + * @api public + */ + + +exports.unbind = function (el, type, fn, capture) { + el = toArray(el); + + for (var i = 0, il = el.length; i < il; i++) { + el[i][unbind](prefix + type, fn, capture || false); + } +}; +/** + * Returns a function, that, as long as it continues to be invoked, will not + * be triggered. The function will be called after it stops being called for + * `wait` milliseconds. If `immediate` is true, trigger the function on the + * leading edge, instead of the trailing. + * + * @param {Function} fn + * @param {Integer} wait + * @param {Boolean} immediate + * @api public + */ + + +exports.debounce = function (fn, wait, immediate) { + var timeout; + return wait ? function () { + var context = this, + args = arguments; + + var later = function later() { + timeout = null; + if (!immediate) fn.apply(context, args); + }; + + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) fn.apply(context, args); + } : fn; +}; + +/***/ }), + +/***/ "./src/utils/extend.js": +/*!*****************************!*\ + !*** ./src/utils/extend.js ***! + \*****************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 4:0-14 */ +/***/ (function(module) { + +/* + * Source: https://github.com/segmentio/extend + */ +module.exports = function extend(object) { + // Takes an unlimited number of extenders. + var args = Array.prototype.slice.call(arguments, 1); // For each extender, copy their properties on our object. + + for (var i = 0, source; source = args[i]; i++) { + if (!source) continue; + + for (var property in source) { + object[property] = source[property]; + } + } + + return object; +}; + +/***/ }), + +/***/ "./src/utils/fuzzy.js": +/*!****************************!*\ + !*** ./src/utils/fuzzy.js ***! + \****************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 1:0-14 */ +/***/ (function(module) { + +module.exports = function (text, pattern, options) { + // Aproximately where in the text is the pattern expected to be found? + var Match_Location = options.location || 0; //Determines how close the match must be to the fuzzy location (specified above). An exact letter match which is 'distance' characters away from the fuzzy location would score as a complete mismatch. A distance of '0' requires the match be at the exact location specified, a threshold of '1000' would require a perfect match to be within 800 characters of the fuzzy location to be found using a 0.8 threshold. + + var Match_Distance = options.distance || 100; // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match (of both letters and location), a threshold of '1.0' would match anything. + + var Match_Threshold = options.threshold || 0.4; + if (pattern === text) return true; // Exact match + + if (pattern.length > 32) return false; // This algorithm cannot be used + // Set starting location at beginning text and initialise the alphabet. + + var loc = Match_Location, + s = function () { + var q = {}, + i; + + for (i = 0; i < pattern.length; i++) { + q[pattern.charAt(i)] = 0; + } + + for (i = 0; i < pattern.length; i++) { + q[pattern.charAt(i)] |= 1 << pattern.length - i - 1; + } + + return q; + }(); // Compute and return the score for a match with e errors and x location. + // Accesses loc and pattern through being a closure. + + + function match_bitapScore_(e, x) { + var accuracy = e / pattern.length, + proximity = Math.abs(loc - x); + + if (!Match_Distance) { + // Dodge divide by zero error. + return proximity ? 1.0 : accuracy; + } + + return accuracy + proximity / Match_Distance; + } + + var score_threshold = Match_Threshold, + // Highest score beyond which we give up. + best_loc = text.indexOf(pattern, loc); // Is there a nearby exact match? (speedup) + + if (best_loc != -1) { + score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold); // What about in the other direction? (speedup) + + best_loc = text.lastIndexOf(pattern, loc + pattern.length); + + if (best_loc != -1) { + score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold); + } + } // Initialise the bit arrays. + + + var matchmask = 1 << pattern.length - 1; + best_loc = -1; + var bin_min, bin_mid; + var bin_max = pattern.length + text.length; + var last_rd; + + for (var d = 0; d < pattern.length; d++) { + // Scan for the best match; each iteration allows for one more error. + // Run a binary search to determine how far from 'loc' we can stray at this + // error level. + bin_min = 0; + bin_mid = bin_max; + + while (bin_min < bin_mid) { + if (match_bitapScore_(d, loc + bin_mid) <= score_threshold) { + bin_min = bin_mid; + } else { + bin_max = bin_mid; + } + + bin_mid = Math.floor((bin_max - bin_min) / 2 + bin_min); + } // Use the result from this iteration as the maximum for the next. + + + bin_max = bin_mid; + var start = Math.max(1, loc - bin_mid + 1); + var finish = Math.min(loc + bin_mid, text.length) + pattern.length; + var rd = Array(finish + 2); + rd[finish + 1] = (1 << d) - 1; + + for (var j = finish; j >= start; j--) { + // The alphabet (s) is a sparse hash, so the following line generates + // warnings. + var charMatch = s[text.charAt(j - 1)]; + + if (d === 0) { + // First pass: exact match. + rd[j] = (rd[j + 1] << 1 | 1) & charMatch; + } else { + // Subsequent passes: fuzzy match. + rd[j] = (rd[j + 1] << 1 | 1) & charMatch | ((last_rd[j + 1] | last_rd[j]) << 1 | 1) | last_rd[j + 1]; + } + + if (rd[j] & matchmask) { + var score = match_bitapScore_(d, j - 1); // This match will almost certainly be better than any existing match. + // But check anyway. + + if (score <= score_threshold) { + // Told you so. + score_threshold = score; + best_loc = j - 1; + + if (best_loc > loc) { + // When passing loc, don't exceed our current distance from loc. + start = Math.max(1, 2 * loc - best_loc); + } else { + // Already passed loc, downhill from here on in. + break; + } + } + } + } // No hope for a (better) match at greater error levels. + + + if (match_bitapScore_(d + 1, loc) > score_threshold) { + break; + } + + last_rd = rd; + } + + return best_loc < 0 ? false : true; +}; + +/***/ }), + +/***/ "./src/utils/get-attribute.js": +/*!************************************!*\ + !*** ./src/utils/get-attribute.js ***! + \************************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 11:0-14 */ +/***/ (function(module) { + +/** + * A cross-browser implementation of getAttribute. + * Source found here: http://stackoverflow.com/a/3755343/361337 written by Vivin Paliath + * + * Return the value for `attr` at `element`. + * + * @param {Element} el + * @param {String} attr + * @api public + */ +module.exports = function (el, attr) { + var result = el.getAttribute && el.getAttribute(attr) || null; + + if (!result) { + var attrs = el.attributes; + var length = attrs.length; + + for (var i = 0; i < length; i++) { + if (attrs[i] !== undefined) { + if (attrs[i].nodeName === attr) { + result = attrs[i].nodeValue; + } + } + } + } + + return result; +}; + +/***/ }), + +/***/ "./src/utils/get-by-class.js": +/*!***********************************!*\ + !*** ./src/utils/get-by-class.js ***! + \***********************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 53:0-14 */ +/***/ (function(module) { + +/** + * A cross-browser implementation of getElementsByClass. + * Heavily based on Dustin Diaz's function: http://dustindiaz.com/getelementsbyclass. + * + * Find all elements with class `className` inside `container`. + * Use `single = true` to increase performance in older browsers + * when only one element is needed. + * + * @param {String} className + * @param {Element} container + * @param {Boolean} single + * @api public + */ +var getElementsByClassName = function getElementsByClassName(container, className, single) { + if (single) { + return container.getElementsByClassName(className)[0]; + } else { + return container.getElementsByClassName(className); + } +}; + +var querySelector = function querySelector(container, className, single) { + className = '.' + className; + + if (single) { + return container.querySelector(className); + } else { + return container.querySelectorAll(className); + } +}; + +var polyfill = function polyfill(container, className, single) { + var classElements = [], + tag = '*'; + var els = container.getElementsByTagName(tag); + var elsLen = els.length; + var pattern = new RegExp('(^|\\s)' + className + '(\\s|$)'); + + for (var i = 0, j = 0; i < elsLen; i++) { + if (pattern.test(els[i].className)) { + if (single) { + return els[i]; + } else { + classElements[j] = els[i]; + j++; + } + } + } + + return classElements; +}; + +module.exports = function () { + return function (container, className, single, options) { + options = options || {}; + + if (options.test && options.getElementsByClassName || !options.test && document.getElementsByClassName) { + return getElementsByClassName(container, className, single); + } else if (options.test && options.querySelector || !options.test && document.querySelector) { + return querySelector(container, className, single); + } else { + return polyfill(container, className, single); + } + }; +}(); + +/***/ }), + +/***/ "./src/utils/index-of.js": +/*!*******************************!*\ + !*** ./src/utils/index-of.js ***! + \*******************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 3:0-14 */ +/***/ (function(module) { + +var indexOf = [].indexOf; + +module.exports = function (arr, obj) { + if (indexOf) return arr.indexOf(obj); + + for (var i = 0, il = arr.length; i < il; ++i) { + if (arr[i] === obj) return i; + } + + return -1; +}; + +/***/ }), + +/***/ "./src/utils/to-array.js": +/*!*******************************!*\ + !*** ./src/utils/to-array.js ***! + \*******************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 11:0-14 */ +/***/ (function(module) { + +/** + * Source: https://github.com/timoxley/to-array + * + * Convert an array-like object into an `Array`. + * If `collection` is already an `Array`, then will return a clone of `collection`. + * + * @param {Array | Mixed} collection An `Array` or array-like object to convert e.g. `arguments` or `NodeList` + * @return {Array} Naive conversion of `collection` to a new `Array`. + * @api public + */ +module.exports = function toArray(collection) { + if (typeof collection === 'undefined') return []; + if (collection === null) return [null]; + if (collection === window) return [window]; + if (typeof collection === 'string') return [collection]; + if (isArray(collection)) return collection; + if (typeof collection.length != 'number') return [collection]; + if (typeof collection === 'function' && collection instanceof Function) return [collection]; + var arr = []; + + for (var i = 0, il = collection.length; i < il; i++) { + if (Object.prototype.hasOwnProperty.call(collection, i) || i in collection) { + arr.push(collection[i]); + } + } + + if (!arr.length) return []; + return arr; +}; + +function isArray(arr) { + return Object.prototype.toString.call(arr) === '[object Array]'; +} + +/***/ }), + +/***/ "./src/utils/to-string.js": +/*!********************************!*\ + !*** ./src/utils/to-string.js ***! + \********************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 1:0-14 */ +/***/ (function(module) { + +module.exports = function (s) { + s = s === undefined ? '' : s; + s = s === null ? '' : s; + s = s.toString(); + return s; +}; + +/***/ }), + +/***/ "./node_modules/string-natural-compare/natural-compare.js": +/*!****************************************************************!*\ + !*** ./node_modules/string-natural-compare/natural-compare.js ***! + \****************************************************************/ +/*! unknown exports (runtime-defined) */ +/*! runtime requirements: module */ +/*! CommonJS bailout: module.exports is used directly at 124:0-14 */ +/***/ (function(module) { + +"use strict"; + + +var alphabet; +var alphabetIndexMap; +var alphabetIndexMapLength = 0; + +function isNumberCode(code) { + return code >= 48 && code <= 57; +} + +function naturalCompare(a, b) { + var lengthA = (a += '').length; + var lengthB = (b += '').length; + var aIndex = 0; + var bIndex = 0; + + while (aIndex < lengthA && bIndex < lengthB) { + var charCodeA = a.charCodeAt(aIndex); + var charCodeB = b.charCodeAt(bIndex); + + if (isNumberCode(charCodeA)) { + if (!isNumberCode(charCodeB)) { + return charCodeA - charCodeB; + } + + var numStartA = aIndex; + var numStartB = bIndex; + + while (charCodeA === 48 && ++numStartA < lengthA) { + charCodeA = a.charCodeAt(numStartA); + } + while (charCodeB === 48 && ++numStartB < lengthB) { + charCodeB = b.charCodeAt(numStartB); + } + + var numEndA = numStartA; + var numEndB = numStartB; + + while (numEndA < lengthA && isNumberCode(a.charCodeAt(numEndA))) { + ++numEndA; + } + while (numEndB < lengthB && isNumberCode(b.charCodeAt(numEndB))) { + ++numEndB; + } + + var difference = numEndA - numStartA - numEndB + numStartB; // numA length - numB length + if (difference) { + return difference; + } + + while (numStartA < numEndA) { + difference = a.charCodeAt(numStartA++) - b.charCodeAt(numStartB++); + if (difference) { + return difference; + } + } + + aIndex = numEndA; + bIndex = numEndB; + continue; + } + + if (charCodeA !== charCodeB) { + if ( + charCodeA < alphabetIndexMapLength && + charCodeB < alphabetIndexMapLength && + alphabetIndexMap[charCodeA] !== -1 && + alphabetIndexMap[charCodeB] !== -1 + ) { + return alphabetIndexMap[charCodeA] - alphabetIndexMap[charCodeB]; + } + + return charCodeA - charCodeB; + } + + ++aIndex; + ++bIndex; + } + + if (aIndex >= lengthA && bIndex < lengthB && lengthA >= lengthB) { + return -1; + } + + if (bIndex >= lengthB && aIndex < lengthA && lengthB >= lengthA) { + return 1; + } + + return lengthA - lengthB; +} + +naturalCompare.caseInsensitive = naturalCompare.i = function(a, b) { + return naturalCompare(('' + a).toLowerCase(), ('' + b).toLowerCase()); +}; + +Object.defineProperties(naturalCompare, { + alphabet: { + get: function() { + return alphabet; + }, + + set: function(value) { + alphabet = value; + alphabetIndexMap = []; + + var i = 0; + + if (alphabet) { + for (; i < alphabet.length; i++) { + alphabetIndexMap[alphabet.charCodeAt(i)] = i; + } + } + + alphabetIndexMapLength = alphabetIndexMap.length; + + for (i = 0; i < alphabetIndexMapLength; i++) { + if (alphabetIndexMap[i] === undefined) { + alphabetIndexMap[i] = -1; + } + } + }, + }, +}); + +module.exports = naturalCompare; + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ // module exports must be returned from runtime so entry inlining is disabled +/******/ // startup +/******/ // Load entry module and return exports +/******/ return __webpack_require__("./src/index.js"); +/******/ })() +; +//# sourceMappingURL=list.js.map \ No newline at end of file diff --git a/crates/ezidam/static/libs/list.js/list.js.map b/crates/ezidam/static/libs/list.js/list.js.map new file mode 100644 index 0000000..0583dbe --- /dev/null +++ b/crates/ezidam/static/libs/list.js/list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"list.js","sources":["webpack://List/./src/add-async.js","webpack://List/./src/filter.js","webpack://List/./src/fuzzy-search.js","webpack://List/./src/index.js","webpack://List/./src/item.js","webpack://List/./src/pagination.js","webpack://List/./src/parse.js","webpack://List/./src/search.js","webpack://List/./src/sort.js","webpack://List/./src/templater.js","webpack://List/./src/utils/classes.js","webpack://List/./src/utils/events.js","webpack://List/./src/utils/extend.js","webpack://List/./src/utils/fuzzy.js","webpack://List/./src/utils/get-attribute.js","webpack://List/./src/utils/get-by-class.js","webpack://List/./src/utils/index-of.js","webpack://List/./src/utils/to-array.js","webpack://List/./src/utils/to-string.js","webpack://List/./node_modules/string-natural-compare/natural-compare.js","webpack://List/webpack/bootstrap","webpack://List/webpack/startup"],"sourcesContent":["module.exports = function (list) {\n var addAsync = function (values, callback, items) {\n var valuesToAdd = values.splice(0, 50)\n items = items || []\n items = items.concat(list.add(valuesToAdd))\n if (values.length > 0) {\n setTimeout(function () {\n addAsync(values, callback, items)\n }, 1)\n } else {\n list.update()\n callback(items)\n }\n }\n return addAsync\n}\n","module.exports = function (list) {\n // Add handlers\n list.handlers.filterStart = list.handlers.filterStart || []\n list.handlers.filterComplete = list.handlers.filterComplete || []\n\n return function (filterFunction) {\n list.trigger('filterStart')\n list.i = 1 // Reset paging\n list.reset.filter()\n if (filterFunction === undefined) {\n list.filtered = false\n } else {\n list.filtered = true\n var is = list.items\n for (var i = 0, il = is.length; i < il; i++) {\n var item = is[i]\n if (filterFunction(item)) {\n item.filtered = true\n } else {\n item.filtered = false\n }\n }\n }\n list.update()\n list.trigger('filterComplete')\n return list.visibleItems\n }\n}\n","var classes = require('./utils/classes'),\n events = require('./utils/events'),\n extend = require('./utils/extend'),\n toString = require('./utils/to-string'),\n getByClass = require('./utils/get-by-class'),\n fuzzy = require('./utils/fuzzy')\n\nmodule.exports = function (list, options) {\n options = options || {}\n\n options = extend(\n {\n location: 0,\n distance: 100,\n threshold: 0.4,\n multiSearch: true,\n searchClass: 'fuzzy-search',\n },\n options\n )\n\n var fuzzySearch = {\n search: function (searchString, columns) {\n // Substract arguments from the searchString or put searchString as only argument\n var searchArguments = options.multiSearch ? searchString.replace(/ +$/, '').split(/ +/) : [searchString]\n\n for (var k = 0, kl = list.items.length; k < kl; k++) {\n fuzzySearch.item(list.items[k], columns, searchArguments)\n }\n },\n item: function (item, columns, searchArguments) {\n var found = true\n for (var i = 0; i < searchArguments.length; i++) {\n var foundArgument = false\n for (var j = 0, jl = columns.length; j < jl; j++) {\n if (fuzzySearch.values(item.values(), columns[j], searchArguments[i])) {\n foundArgument = true\n }\n }\n if (!foundArgument) {\n found = false\n }\n }\n item.found = found\n },\n values: function (values, value, searchArgument) {\n if (values.hasOwnProperty(value)) {\n var text = toString(values[value]).toLowerCase()\n\n if (fuzzy(text, searchArgument, options)) {\n return true\n }\n }\n return false\n },\n }\n\n events.bind(\n getByClass(list.listContainer, options.searchClass),\n 'keyup',\n list.utils.events.debounce(function (e) {\n var target = e.target || e.srcElement // IE have srcElement\n list.search(target.value, fuzzySearch.search)\n }, list.searchDelay)\n )\n\n return function (str, columns) {\n list.search(str, columns, fuzzySearch.search)\n }\n}\n","var naturalSort = require('string-natural-compare'),\n getByClass = require('./utils/get-by-class'),\n extend = require('./utils/extend'),\n indexOf = require('./utils/index-of'),\n events = require('./utils/events'),\n toString = require('./utils/to-string'),\n classes = require('./utils/classes'),\n getAttribute = require('./utils/get-attribute'),\n toArray = require('./utils/to-array')\n\nmodule.exports = function (id, options, values) {\n var self = this,\n init,\n Item = require('./item')(self),\n addAsync = require('./add-async')(self),\n initPagination = require('./pagination')(self)\n\n init = {\n start: function () {\n self.listClass = 'list'\n self.searchClass = 'search'\n self.sortClass = 'sort'\n self.page = 10000\n self.i = 1\n self.items = []\n self.visibleItems = []\n self.matchingItems = []\n self.searched = false\n self.filtered = false\n self.searchColumns = undefined\n self.searchDelay = 0\n self.handlers = { updated: [] }\n self.valueNames = []\n self.utils = {\n getByClass: getByClass,\n extend: extend,\n indexOf: indexOf,\n events: events,\n toString: toString,\n naturalSort: naturalSort,\n classes: classes,\n getAttribute: getAttribute,\n toArray: toArray,\n }\n\n self.utils.extend(self, options)\n\n self.listContainer = typeof id === 'string' ? document.getElementById(id) : id\n if (!self.listContainer) {\n return\n }\n self.list = getByClass(self.listContainer, self.listClass, true)\n\n self.parse = require('./parse')(self)\n self.templater = require('./templater')(self)\n self.search = require('./search')(self)\n self.filter = require('./filter')(self)\n self.sort = require('./sort')(self)\n self.fuzzySearch = require('./fuzzy-search')(self, options.fuzzySearch)\n\n this.handlers()\n this.items()\n this.pagination()\n\n self.update()\n },\n handlers: function () {\n for (var handler in self.handlers) {\n if (self[handler] && self.handlers.hasOwnProperty(handler)) {\n self.on(handler, self[handler])\n }\n }\n },\n items: function () {\n self.parse(self.list)\n if (values !== undefined) {\n self.add(values)\n }\n },\n pagination: function () {\n if (options.pagination !== undefined) {\n if (options.pagination === true) {\n options.pagination = [{}]\n }\n if (options.pagination[0] === undefined) {\n options.pagination = [options.pagination]\n }\n for (var i = 0, il = options.pagination.length; i < il; i++) {\n initPagination(options.pagination[i])\n }\n }\n },\n }\n\n /*\n * Re-parse the List, use if html have changed\n */\n this.reIndex = function () {\n self.items = []\n self.visibleItems = []\n self.matchingItems = []\n self.searched = false\n self.filtered = false\n self.parse(self.list)\n }\n\n this.toJSON = function () {\n var json = []\n for (var i = 0, il = self.items.length; i < il; i++) {\n json.push(self.items[i].values())\n }\n return json\n }\n\n /*\n * Add object to list\n */\n this.add = function (values, callback) {\n if (values.length === 0) {\n return\n }\n if (callback) {\n addAsync(values.slice(0), callback)\n return\n }\n var added = [],\n notCreate = false\n if (values[0] === undefined) {\n values = [values]\n }\n for (var i = 0, il = values.length; i < il; i++) {\n var item = null\n notCreate = self.items.length > self.page ? true : false\n item = new Item(values[i], undefined, notCreate)\n self.items.push(item)\n added.push(item)\n }\n self.update()\n return added\n }\n\n this.show = function (i, page) {\n this.i = i\n this.page = page\n self.update()\n return self\n }\n\n /* Removes object from list.\n * Loops through the list and removes objects where\n * property \"valuename\" === value\n */\n this.remove = function (valueName, value, options) {\n var found = 0\n for (var i = 0, il = self.items.length; i < il; i++) {\n if (self.items[i].values()[valueName] == value) {\n self.templater.remove(self.items[i], options)\n self.items.splice(i, 1)\n il--\n i--\n found++\n }\n }\n self.update()\n return found\n }\n\n /* Gets the objects in the list which\n * property \"valueName\" === value\n */\n this.get = function (valueName, value) {\n var matchedItems = []\n for (var i = 0, il = self.items.length; i < il; i++) {\n var item = self.items[i]\n if (item.values()[valueName] == value) {\n matchedItems.push(item)\n }\n }\n return matchedItems\n }\n\n /*\n * Get size of the list\n */\n this.size = function () {\n return self.items.length\n }\n\n /*\n * Removes all items from the list\n */\n this.clear = function () {\n self.templater.clear()\n self.items = []\n return self\n }\n\n this.on = function (event, callback) {\n self.handlers[event].push(callback)\n return self\n }\n\n this.off = function (event, callback) {\n var e = self.handlers[event]\n var index = indexOf(e, callback)\n if (index > -1) {\n e.splice(index, 1)\n }\n return self\n }\n\n this.trigger = function (event) {\n var i = self.handlers[event].length\n while (i--) {\n self.handlers[event][i](self)\n }\n return self\n }\n\n this.reset = {\n filter: function () {\n var is = self.items,\n il = is.length\n while (il--) {\n is[il].filtered = false\n }\n return self\n },\n search: function () {\n var is = self.items,\n il = is.length\n while (il--) {\n is[il].found = false\n }\n return self\n },\n }\n\n this.update = function () {\n var is = self.items,\n il = is.length\n\n self.visibleItems = []\n self.matchingItems = []\n self.templater.clear()\n for (var i = 0; i < il; i++) {\n if (is[i].matching() && self.matchingItems.length + 1 >= self.i && self.visibleItems.length < self.page) {\n is[i].show()\n self.visibleItems.push(is[i])\n self.matchingItems.push(is[i])\n } else if (is[i].matching()) {\n self.matchingItems.push(is[i])\n is[i].hide()\n } else {\n is[i].hide()\n }\n }\n self.trigger('updated')\n return self\n }\n\n init.start()\n}\n","module.exports = function (list) {\n return function (initValues, element, notCreate) {\n var item = this\n\n this._values = {}\n\n this.found = false // Show if list.searched == true and this.found == true\n this.filtered = false // Show if list.filtered == true and this.filtered == true\n\n var init = function (initValues, element, notCreate) {\n if (element === undefined) {\n if (notCreate) {\n item.values(initValues, notCreate)\n } else {\n item.values(initValues)\n }\n } else {\n item.elm = element\n var values = list.templater.get(item, initValues)\n item.values(values)\n }\n }\n\n this.values = function (newValues, notCreate) {\n if (newValues !== undefined) {\n for (var name in newValues) {\n item._values[name] = newValues[name]\n }\n if (notCreate !== true) {\n list.templater.set(item, item.values())\n }\n } else {\n return item._values\n }\n }\n\n this.show = function () {\n list.templater.show(item)\n }\n\n this.hide = function () {\n list.templater.hide(item)\n }\n\n this.matching = function () {\n return (\n (list.filtered && list.searched && item.found && item.filtered) ||\n (list.filtered && !list.searched && item.filtered) ||\n (!list.filtered && list.searched && item.found) ||\n (!list.filtered && !list.searched)\n )\n }\n\n this.visible = function () {\n return item.elm && item.elm.parentNode == list.list ? true : false\n }\n\n init(initValues, element, notCreate)\n }\n}\n","var classes = require('./utils/classes'),\n events = require('./utils/events'),\n List = require('./index')\n\nmodule.exports = function (list) {\n var isHidden = false\n\n var refresh = function (pagingList, options) {\n if (list.page < 1) {\n list.listContainer.style.display = 'none'\n isHidden = true\n return\n } else if (isHidden) {\n list.listContainer.style.display = 'block'\n }\n\n var item,\n l = list.matchingItems.length,\n index = list.i,\n page = list.page,\n pages = Math.ceil(l / page),\n currentPage = Math.ceil(index / page),\n innerWindow = options.innerWindow || 2,\n left = options.left || options.outerWindow || 0,\n right = options.right || options.outerWindow || 0\n\n right = pages - right\n pagingList.clear()\n for (var i = 1; i <= pages; i++) {\n var className = currentPage === i ? 'active' : ''\n\n //console.log(i, left, right, currentPage, (currentPage - innerWindow), (currentPage + innerWindow), className);\n\n if (is.number(i, left, right, currentPage, innerWindow)) {\n item = pagingList.add({\n page: i,\n dotted: false,\n })[0]\n if (className) {\n classes(item.elm).add(className)\n }\n item.elm.firstChild.setAttribute('data-i', i)\n item.elm.firstChild.setAttribute('data-page', page)\n } else if (is.dotted(pagingList, i, left, right, currentPage, innerWindow, pagingList.size())) {\n item = pagingList.add({\n page: '...',\n dotted: true,\n })[0]\n classes(item.elm).add('disabled')\n }\n }\n }\n\n var is = {\n number: function (i, left, right, currentPage, innerWindow) {\n return this.left(i, left) || this.right(i, right) || this.innerWindow(i, currentPage, innerWindow)\n },\n left: function (i, left) {\n return i <= left\n },\n right: function (i, right) {\n return i > right\n },\n innerWindow: function (i, currentPage, innerWindow) {\n return i >= currentPage - innerWindow && i <= currentPage + innerWindow\n },\n dotted: function (pagingList, i, left, right, currentPage, innerWindow, currentPageItem) {\n return (\n this.dottedLeft(pagingList, i, left, right, currentPage, innerWindow) ||\n this.dottedRight(pagingList, i, left, right, currentPage, innerWindow, currentPageItem)\n )\n },\n dottedLeft: function (pagingList, i, left, right, currentPage, innerWindow) {\n return i == left + 1 && !this.innerWindow(i, currentPage, innerWindow) && !this.right(i, right)\n },\n dottedRight: function (pagingList, i, left, right, currentPage, innerWindow, currentPageItem) {\n if (pagingList.items[currentPageItem - 1].values().dotted) {\n return false\n } else {\n return i == right && !this.innerWindow(i, currentPage, innerWindow) && !this.right(i, right)\n }\n },\n }\n\n return function (options) {\n var pagingList = new List(list.listContainer.id, {\n listClass: options.paginationClass || 'pagination',\n item: options.item || \"
  • \",\n valueNames: ['page', 'dotted'],\n searchClass: 'pagination-search-that-is-not-supposed-to-exist',\n sortClass: 'pagination-sort-that-is-not-supposed-to-exist',\n })\n\n events.bind(pagingList.listContainer, 'click', function (e) {\n var target = e.target || e.srcElement,\n page = list.utils.getAttribute(target, 'data-page'),\n i = list.utils.getAttribute(target, 'data-i')\n if (i) {\n list.show((i - 1) * page + 1, page)\n }\n })\n\n list.on('updated', function () {\n refresh(pagingList, options)\n })\n refresh(pagingList, options)\n }\n}\n","module.exports = function (list) {\n var Item = require('./item')(list)\n\n var getChildren = function (parent) {\n var nodes = parent.childNodes,\n items = []\n for (var i = 0, il = nodes.length; i < il; i++) {\n // Only textnodes have a data attribute\n if (nodes[i].data === undefined) {\n items.push(nodes[i])\n }\n }\n return items\n }\n\n var parse = function (itemElements, valueNames) {\n for (var i = 0, il = itemElements.length; i < il; i++) {\n list.items.push(new Item(valueNames, itemElements[i]))\n }\n }\n var parseAsync = function (itemElements, valueNames) {\n var itemsToIndex = itemElements.splice(0, 50) // TODO: If < 100 items, what happens in IE etc?\n parse(itemsToIndex, valueNames)\n if (itemElements.length > 0) {\n setTimeout(function () {\n parseAsync(itemElements, valueNames)\n }, 1)\n } else {\n list.update()\n list.trigger('parseComplete')\n }\n }\n\n list.handlers.parseComplete = list.handlers.parseComplete || []\n\n return function () {\n var itemsToIndex = getChildren(list.list),\n valueNames = list.valueNames\n\n if (list.indexAsync) {\n parseAsync(itemsToIndex, valueNames)\n } else {\n parse(itemsToIndex, valueNames)\n }\n }\n}\n","module.exports = function (list) {\n var item, text, columns, searchString, customSearch\n\n var prepare = {\n resetList: function () {\n list.i = 1\n list.templater.clear()\n customSearch = undefined\n },\n setOptions: function (args) {\n if (args.length == 2 && args[1] instanceof Array) {\n columns = args[1]\n } else if (args.length == 2 && typeof args[1] == 'function') {\n columns = undefined\n customSearch = args[1]\n } else if (args.length == 3) {\n columns = args[1]\n customSearch = args[2]\n } else {\n columns = undefined\n }\n },\n setColumns: function () {\n if (list.items.length === 0) return\n if (columns === undefined) {\n columns = list.searchColumns === undefined ? prepare.toArray(list.items[0].values()) : list.searchColumns\n }\n },\n setSearchString: function (s) {\n s = list.utils.toString(s).toLowerCase()\n s = s.replace(/[-[\\]{}()*+?.,\\\\^$|#]/g, '\\\\$&') // Escape regular expression characters\n searchString = s\n },\n toArray: function (values) {\n var tmpColumn = []\n for (var name in values) {\n tmpColumn.push(name)\n }\n return tmpColumn\n },\n }\n var search = {\n list: function () {\n // Extract quoted phrases \"word1 word2\" from original searchString\n // searchString is converted to lowercase by List.js\n var words = [],\n phrase,\n ss = searchString\n while ((phrase = ss.match(/\"([^\"]+)\"/)) !== null) {\n words.push(phrase[1])\n ss = ss.substring(0, phrase.index) + ss.substring(phrase.index + phrase[0].length)\n }\n // Get remaining space-separated words (if any)\n ss = ss.trim()\n if (ss.length) words = words.concat(ss.split(/\\s+/))\n for (var k = 0, kl = list.items.length; k < kl; k++) {\n var item = list.items[k]\n item.found = false\n if (!words.length) continue\n for (var i = 0, il = words.length; i < il; i++) {\n var word_found = false\n for (var j = 0, jl = columns.length; j < jl; j++) {\n var values = item.values(),\n column = columns[j]\n if (values.hasOwnProperty(column) && values[column] !== undefined && values[column] !== null) {\n var text = typeof values[column] !== 'string' ? values[column].toString() : values[column]\n if (text.toLowerCase().indexOf(words[i]) !== -1) {\n // word found, so no need to check it against any other columns\n word_found = true\n break\n }\n }\n }\n // this word not found? no need to check any other words, the item cannot match\n if (!word_found) break\n }\n item.found = word_found\n }\n },\n // Removed search.item() and search.values()\n reset: function () {\n list.reset.search()\n list.searched = false\n },\n }\n\n var searchMethod = function (str) {\n list.trigger('searchStart')\n\n prepare.resetList()\n prepare.setSearchString(str)\n prepare.setOptions(arguments) // str, cols|searchFunction, searchFunction\n prepare.setColumns()\n\n if (searchString === '') {\n search.reset()\n } else {\n list.searched = true\n if (customSearch) {\n customSearch(searchString, columns)\n } else {\n search.list()\n }\n }\n\n list.update()\n list.trigger('searchComplete')\n return list.visibleItems\n }\n\n list.handlers.searchStart = list.handlers.searchStart || []\n list.handlers.searchComplete = list.handlers.searchComplete || []\n\n list.utils.events.bind(\n list.utils.getByClass(list.listContainer, list.searchClass),\n 'keyup',\n list.utils.events.debounce(function (e) {\n var target = e.target || e.srcElement, // IE have srcElement\n alreadyCleared = target.value === '' && !list.searched\n if (!alreadyCleared) {\n // If oninput already have resetted the list, do nothing\n searchMethod(target.value)\n }\n }, list.searchDelay)\n )\n\n // Used to detect click on HTML5 clear button\n list.utils.events.bind(list.utils.getByClass(list.listContainer, list.searchClass), 'input', function (e) {\n var target = e.target || e.srcElement\n if (target.value === '') {\n searchMethod('')\n }\n })\n\n return searchMethod\n}\n","module.exports = function (list) {\n var buttons = {\n els: undefined,\n clear: function () {\n for (var i = 0, il = buttons.els.length; i < il; i++) {\n list.utils.classes(buttons.els[i]).remove('asc')\n list.utils.classes(buttons.els[i]).remove('desc')\n }\n },\n getOrder: function (btn) {\n var predefinedOrder = list.utils.getAttribute(btn, 'data-order')\n if (predefinedOrder == 'asc' || predefinedOrder == 'desc') {\n return predefinedOrder\n } else if (list.utils.classes(btn).has('desc')) {\n return 'asc'\n } else if (list.utils.classes(btn).has('asc')) {\n return 'desc'\n } else {\n return 'asc'\n }\n },\n getInSensitive: function (btn, options) {\n var insensitive = list.utils.getAttribute(btn, 'data-insensitive')\n if (insensitive === 'false') {\n options.insensitive = false\n } else {\n options.insensitive = true\n }\n },\n setOrder: function (options) {\n for (var i = 0, il = buttons.els.length; i < il; i++) {\n var btn = buttons.els[i]\n if (list.utils.getAttribute(btn, 'data-sort') !== options.valueName) {\n continue\n }\n var predefinedOrder = list.utils.getAttribute(btn, 'data-order')\n if (predefinedOrder == 'asc' || predefinedOrder == 'desc') {\n if (predefinedOrder == options.order) {\n list.utils.classes(btn).add(options.order)\n }\n } else {\n list.utils.classes(btn).add(options.order)\n }\n }\n },\n }\n\n var sort = function () {\n list.trigger('sortStart')\n var options = {}\n\n var target = arguments[0].currentTarget || arguments[0].srcElement || undefined\n\n if (target) {\n options.valueName = list.utils.getAttribute(target, 'data-sort')\n buttons.getInSensitive(target, options)\n options.order = buttons.getOrder(target)\n } else {\n options = arguments[1] || options\n options.valueName = arguments[0]\n options.order = options.order || 'asc'\n options.insensitive = typeof options.insensitive == 'undefined' ? true : options.insensitive\n }\n\n buttons.clear()\n buttons.setOrder(options)\n\n // caseInsensitive\n // alphabet\n var customSortFunction = options.sortFunction || list.sortFunction || null,\n multi = options.order === 'desc' ? -1 : 1,\n sortFunction\n\n if (customSortFunction) {\n sortFunction = function (itemA, itemB) {\n return customSortFunction(itemA, itemB, options) * multi\n }\n } else {\n sortFunction = function (itemA, itemB) {\n var sort = list.utils.naturalSort\n sort.alphabet = list.alphabet || options.alphabet || undefined\n if (!sort.alphabet && options.insensitive) {\n sort = list.utils.naturalSort.caseInsensitive\n }\n return sort(itemA.values()[options.valueName], itemB.values()[options.valueName]) * multi\n }\n }\n\n list.items.sort(sortFunction)\n list.update()\n list.trigger('sortComplete')\n }\n\n // Add handlers\n list.handlers.sortStart = list.handlers.sortStart || []\n list.handlers.sortComplete = list.handlers.sortComplete || []\n\n buttons.els = list.utils.getByClass(list.listContainer, list.sortClass)\n list.utils.events.bind(buttons.els, 'click', sort)\n list.on('searchStart', buttons.clear)\n list.on('filterStart', buttons.clear)\n\n return sort\n}\n","var Templater = function (list) {\n var createItem,\n templater = this\n\n var init = function () {\n var itemSource\n\n if (typeof list.item === 'function') {\n createItem = function (values) {\n var item = list.item(values)\n return getItemSource(item)\n }\n return\n }\n\n if (typeof list.item === 'string') {\n if (list.item.indexOf('<') === -1) {\n itemSource = document.getElementById(list.item)\n } else {\n itemSource = getItemSource(list.item)\n }\n } else {\n /* If item source does not exists, use the first item in list as\n source for new items */\n itemSource = getFirstListItem()\n }\n\n if (!itemSource) {\n throw new Error(\"The list needs to have at least one item on init otherwise you'll have to add a template.\")\n }\n\n itemSource = createCleanTemplateItem(itemSource, list.valueNames)\n\n createItem = function () {\n return itemSource.cloneNode(true)\n }\n }\n\n var createCleanTemplateItem = function (templateNode, valueNames) {\n var el = templateNode.cloneNode(true)\n el.removeAttribute('id')\n\n for (var i = 0, il = valueNames.length; i < il; i++) {\n var elm = undefined,\n valueName = valueNames[i]\n if (valueName.data) {\n for (var j = 0, jl = valueName.data.length; j < jl; j++) {\n el.setAttribute('data-' + valueName.data[j], '')\n }\n } else if (valueName.attr && valueName.name) {\n elm = list.utils.getByClass(el, valueName.name, true)\n if (elm) {\n elm.setAttribute(valueName.attr, '')\n }\n } else {\n elm = list.utils.getByClass(el, valueName, true)\n if (elm) {\n elm.innerHTML = ''\n }\n }\n }\n return el\n }\n\n var getFirstListItem = function () {\n var nodes = list.list.childNodes\n\n for (var i = 0, il = nodes.length; i < il; i++) {\n // Only textnodes have a data attribute\n if (nodes[i].data === undefined) {\n return nodes[i].cloneNode(true)\n }\n }\n return undefined\n }\n\n var getItemSource = function (itemHTML) {\n if (typeof itemHTML !== 'string') return undefined\n if (/]/g.exec(itemHTML)) {\n var tbody = document.createElement('tbody')\n tbody.innerHTML = itemHTML\n return tbody.firstElementChild\n } else if (itemHTML.indexOf('<') !== -1) {\n var div = document.createElement('div')\n div.innerHTML = itemHTML\n return div.firstElementChild\n }\n return undefined\n }\n\n var getValueName = function (name) {\n for (var i = 0, il = list.valueNames.length; i < il; i++) {\n var valueName = list.valueNames[i]\n if (valueName.data) {\n var data = valueName.data\n for (var j = 0, jl = data.length; j < jl; j++) {\n if (data[j] === name) {\n return { data: name }\n }\n }\n } else if (valueName.attr && valueName.name && valueName.name == name) {\n return valueName\n } else if (valueName === name) {\n return name\n }\n }\n }\n\n var setValue = function (item, name, value) {\n var elm = undefined,\n valueName = getValueName(name)\n if (!valueName) return\n if (valueName.data) {\n item.elm.setAttribute('data-' + valueName.data, value)\n } else if (valueName.attr && valueName.name) {\n elm = list.utils.getByClass(item.elm, valueName.name, true)\n if (elm) {\n elm.setAttribute(valueName.attr, value)\n }\n } else {\n elm = list.utils.getByClass(item.elm, valueName, true)\n if (elm) {\n elm.innerHTML = value\n }\n }\n }\n\n this.get = function (item, valueNames) {\n templater.create(item)\n var values = {}\n for (var i = 0, il = valueNames.length; i < il; i++) {\n var elm = undefined,\n valueName = valueNames[i]\n if (valueName.data) {\n for (var j = 0, jl = valueName.data.length; j < jl; j++) {\n values[valueName.data[j]] = list.utils.getAttribute(item.elm, 'data-' + valueName.data[j])\n }\n } else if (valueName.attr && valueName.name) {\n elm = list.utils.getByClass(item.elm, valueName.name, true)\n values[valueName.name] = elm ? list.utils.getAttribute(elm, valueName.attr) : ''\n } else {\n elm = list.utils.getByClass(item.elm, valueName, true)\n values[valueName] = elm ? elm.innerHTML : ''\n }\n }\n return values\n }\n\n this.set = function (item, values) {\n if (!templater.create(item)) {\n for (var v in values) {\n if (values.hasOwnProperty(v)) {\n setValue(item, v, values[v])\n }\n }\n }\n }\n\n this.create = function (item) {\n if (item.elm !== undefined) {\n return false\n }\n item.elm = createItem(item.values())\n templater.set(item, item.values())\n return true\n }\n this.remove = function (item) {\n if (item.elm.parentNode === list.list) {\n list.list.removeChild(item.elm)\n }\n }\n this.show = function (item) {\n templater.create(item)\n list.list.appendChild(item.elm)\n }\n this.hide = function (item) {\n if (item.elm !== undefined && item.elm.parentNode === list.list) {\n list.list.removeChild(item.elm)\n }\n }\n this.clear = function () {\n /* .innerHTML = ''; fucks up IE */\n if (list.list.hasChildNodes()) {\n while (list.list.childNodes.length >= 1) {\n list.list.removeChild(list.list.firstChild)\n }\n }\n }\n\n init()\n}\n\nmodule.exports = function (list) {\n return new Templater(list)\n}\n","/**\n * Module dependencies.\n */\n\nvar index = require('./index-of')\n\n/**\n * Whitespace regexp.\n */\n\nvar re = /\\s+/\n\n/**\n * toString reference.\n */\n\nvar toString = Object.prototype.toString\n\n/**\n * Wrap `el` in a `ClassList`.\n *\n * @param {Element} el\n * @return {ClassList}\n * @api public\n */\n\nmodule.exports = function (el) {\n return new ClassList(el)\n}\n\n/**\n * Initialize a new ClassList for `el`.\n *\n * @param {Element} el\n * @api private\n */\n\nfunction ClassList(el) {\n if (!el || !el.nodeType) {\n throw new Error('A DOM element reference is required')\n }\n this.el = el\n this.list = el.classList\n}\n\n/**\n * Add class `name` if not already present.\n *\n * @param {String} name\n * @return {ClassList}\n * @api public\n */\n\nClassList.prototype.add = function (name) {\n // classList\n if (this.list) {\n this.list.add(name)\n return this\n }\n\n // fallback\n var arr = this.array()\n var i = index(arr, name)\n if (!~i) arr.push(name)\n this.el.className = arr.join(' ')\n return this\n}\n\n/**\n * Remove class `name` when present, or\n * pass a regular expression to remove\n * any which match.\n *\n * @param {String|RegExp} name\n * @return {ClassList}\n * @api public\n */\n\nClassList.prototype.remove = function (name) {\n // classList\n if (this.list) {\n this.list.remove(name)\n return this\n }\n\n // fallback\n var arr = this.array()\n var i = index(arr, name)\n if (~i) arr.splice(i, 1)\n this.el.className = arr.join(' ')\n return this\n}\n\n/**\n * Toggle class `name`, can force state via `force`.\n *\n * For browsers that support classList, but do not support `force` yet,\n * the mistake will be detected and corrected.\n *\n * @param {String} name\n * @param {Boolean} force\n * @return {ClassList}\n * @api public\n */\n\nClassList.prototype.toggle = function (name, force) {\n // classList\n if (this.list) {\n if ('undefined' !== typeof force) {\n if (force !== this.list.toggle(name, force)) {\n this.list.toggle(name) // toggle again to correct\n }\n } else {\n this.list.toggle(name)\n }\n return this\n }\n\n // fallback\n if ('undefined' !== typeof force) {\n if (!force) {\n this.remove(name)\n } else {\n this.add(name)\n }\n } else {\n if (this.has(name)) {\n this.remove(name)\n } else {\n this.add(name)\n }\n }\n\n return this\n}\n\n/**\n * Return an array of classes.\n *\n * @return {Array}\n * @api public\n */\n\nClassList.prototype.array = function () {\n var className = this.el.getAttribute('class') || ''\n var str = className.replace(/^\\s+|\\s+$/g, '')\n var arr = str.split(re)\n if ('' === arr[0]) arr.shift()\n return arr\n}\n\n/**\n * Check if class `name` is present.\n *\n * @param {String} name\n * @return {ClassList}\n * @api public\n */\n\nClassList.prototype.has = ClassList.prototype.contains = function (name) {\n return this.list ? this.list.contains(name) : !!~index(this.array(), name)\n}\n","var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',\n unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',\n prefix = bind !== 'addEventListener' ? 'on' : '',\n toArray = require('./to-array')\n\n/**\n * Bind `el` event `type` to `fn`.\n *\n * @param {Element} el, NodeList, HTMLCollection or Array\n * @param {String} type\n * @param {Function} fn\n * @param {Boolean} capture\n * @api public\n */\n\nexports.bind = function (el, type, fn, capture) {\n el = toArray(el)\n for (var i = 0, il = el.length; i < il; i++) {\n el[i][bind](prefix + type, fn, capture || false)\n }\n}\n\n/**\n * Unbind `el` event `type`'s callback `fn`.\n *\n * @param {Element} el, NodeList, HTMLCollection or Array\n * @param {String} type\n * @param {Function} fn\n * @param {Boolean} capture\n * @api public\n */\n\nexports.unbind = function (el, type, fn, capture) {\n el = toArray(el)\n for (var i = 0, il = el.length; i < il; i++) {\n el[i][unbind](prefix + type, fn, capture || false)\n }\n}\n\n/**\n * Returns a function, that, as long as it continues to be invoked, will not\n * be triggered. The function will be called after it stops being called for\n * `wait` milliseconds. If `immediate` is true, trigger the function on the\n * leading edge, instead of the trailing.\n *\n * @param {Function} fn\n * @param {Integer} wait\n * @param {Boolean} immediate\n * @api public\n */\n\nexports.debounce = function (fn, wait, immediate) {\n var timeout\n return wait\n ? function () {\n var context = this,\n args = arguments\n var later = function () {\n timeout = null\n if (!immediate) fn.apply(context, args)\n }\n var callNow = immediate && !timeout\n clearTimeout(timeout)\n timeout = setTimeout(later, wait)\n if (callNow) fn.apply(context, args)\n }\n : fn\n}\n","/*\n * Source: https://github.com/segmentio/extend\n */\n\nmodule.exports = function extend(object) {\n // Takes an unlimited number of extenders.\n var args = Array.prototype.slice.call(arguments, 1)\n\n // For each extender, copy their properties on our object.\n for (var i = 0, source; (source = args[i]); i++) {\n if (!source) continue\n for (var property in source) {\n object[property] = source[property]\n }\n }\n\n return object\n}\n","module.exports = function (text, pattern, options) {\n // Aproximately where in the text is the pattern expected to be found?\n var Match_Location = options.location || 0\n\n //Determines how close the match must be to the fuzzy location (specified above). An exact letter match which is 'distance' characters away from the fuzzy location would score as a complete mismatch. A distance of '0' requires the match be at the exact location specified, a threshold of '1000' would require a perfect match to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.\n var Match_Distance = options.distance || 100\n\n // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match (of both letters and location), a threshold of '1.0' would match anything.\n var Match_Threshold = options.threshold || 0.4\n\n if (pattern === text) return true // Exact match\n if (pattern.length > 32) return false // This algorithm cannot be used\n\n // Set starting location at beginning text and initialise the alphabet.\n var loc = Match_Location,\n s = (function () {\n var q = {},\n i\n\n for (i = 0; i < pattern.length; i++) {\n q[pattern.charAt(i)] = 0\n }\n\n for (i = 0; i < pattern.length; i++) {\n q[pattern.charAt(i)] |= 1 << (pattern.length - i - 1)\n }\n\n return q\n })()\n\n // Compute and return the score for a match with e errors and x location.\n // Accesses loc and pattern through being a closure.\n\n function match_bitapScore_(e, x) {\n var accuracy = e / pattern.length,\n proximity = Math.abs(loc - x)\n\n if (!Match_Distance) {\n // Dodge divide by zero error.\n return proximity ? 1.0 : accuracy\n }\n return accuracy + proximity / Match_Distance\n }\n\n var score_threshold = Match_Threshold, // Highest score beyond which we give up.\n best_loc = text.indexOf(pattern, loc) // Is there a nearby exact match? (speedup)\n\n if (best_loc != -1) {\n score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold)\n // What about in the other direction? (speedup)\n best_loc = text.lastIndexOf(pattern, loc + pattern.length)\n\n if (best_loc != -1) {\n score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold)\n }\n }\n\n // Initialise the bit arrays.\n var matchmask = 1 << (pattern.length - 1)\n best_loc = -1\n\n var bin_min, bin_mid\n var bin_max = pattern.length + text.length\n var last_rd\n for (var d = 0; d < pattern.length; d++) {\n // Scan for the best match; each iteration allows for one more error.\n // Run a binary search to determine how far from 'loc' we can stray at this\n // error level.\n bin_min = 0\n bin_mid = bin_max\n while (bin_min < bin_mid) {\n if (match_bitapScore_(d, loc + bin_mid) <= score_threshold) {\n bin_min = bin_mid\n } else {\n bin_max = bin_mid\n }\n bin_mid = Math.floor((bin_max - bin_min) / 2 + bin_min)\n }\n // Use the result from this iteration as the maximum for the next.\n bin_max = bin_mid\n var start = Math.max(1, loc - bin_mid + 1)\n var finish = Math.min(loc + bin_mid, text.length) + pattern.length\n\n var rd = Array(finish + 2)\n rd[finish + 1] = (1 << d) - 1\n for (var j = finish; j >= start; j--) {\n // The alphabet (s) is a sparse hash, so the following line generates\n // warnings.\n var charMatch = s[text.charAt(j - 1)]\n if (d === 0) {\n // First pass: exact match.\n rd[j] = ((rd[j + 1] << 1) | 1) & charMatch\n } else {\n // Subsequent passes: fuzzy match.\n rd[j] = (((rd[j + 1] << 1) | 1) & charMatch) | (((last_rd[j + 1] | last_rd[j]) << 1) | 1) | last_rd[j + 1]\n }\n if (rd[j] & matchmask) {\n var score = match_bitapScore_(d, j - 1)\n // This match will almost certainly be better than any existing match.\n // But check anyway.\n if (score <= score_threshold) {\n // Told you so.\n score_threshold = score\n best_loc = j - 1\n if (best_loc > loc) {\n // When passing loc, don't exceed our current distance from loc.\n start = Math.max(1, 2 * loc - best_loc)\n } else {\n // Already passed loc, downhill from here on in.\n break\n }\n }\n }\n }\n // No hope for a (better) match at greater error levels.\n if (match_bitapScore_(d + 1, loc) > score_threshold) {\n break\n }\n last_rd = rd\n }\n\n return best_loc < 0 ? false : true\n}\n","/**\n * A cross-browser implementation of getAttribute.\n * Source found here: http://stackoverflow.com/a/3755343/361337 written by Vivin Paliath\n *\n * Return the value for `attr` at `element`.\n *\n * @param {Element} el\n * @param {String} attr\n * @api public\n */\n\nmodule.exports = function (el, attr) {\n var result = (el.getAttribute && el.getAttribute(attr)) || null\n if (!result) {\n var attrs = el.attributes\n var length = attrs.length\n for (var i = 0; i < length; i++) {\n if (attrs[i] !== undefined) {\n if (attrs[i].nodeName === attr) {\n result = attrs[i].nodeValue\n }\n }\n }\n }\n return result\n}\n","/**\n * A cross-browser implementation of getElementsByClass.\n * Heavily based on Dustin Diaz's function: http://dustindiaz.com/getelementsbyclass.\n *\n * Find all elements with class `className` inside `container`.\n * Use `single = true` to increase performance in older browsers\n * when only one element is needed.\n *\n * @param {String} className\n * @param {Element} container\n * @param {Boolean} single\n * @api public\n */\n\nvar getElementsByClassName = function (container, className, single) {\n if (single) {\n return container.getElementsByClassName(className)[0]\n } else {\n return container.getElementsByClassName(className)\n }\n}\n\nvar querySelector = function (container, className, single) {\n className = '.' + className\n if (single) {\n return container.querySelector(className)\n } else {\n return container.querySelectorAll(className)\n }\n}\n\nvar polyfill = function (container, className, single) {\n var classElements = [],\n tag = '*'\n\n var els = container.getElementsByTagName(tag)\n var elsLen = els.length\n var pattern = new RegExp('(^|\\\\s)' + className + '(\\\\s|$)')\n for (var i = 0, j = 0; i < elsLen; i++) {\n if (pattern.test(els[i].className)) {\n if (single) {\n return els[i]\n } else {\n classElements[j] = els[i]\n j++\n }\n }\n }\n return classElements\n}\n\nmodule.exports = (function () {\n return function (container, className, single, options) {\n options = options || {}\n if ((options.test && options.getElementsByClassName) || (!options.test && document.getElementsByClassName)) {\n return getElementsByClassName(container, className, single)\n } else if ((options.test && options.querySelector) || (!options.test && document.querySelector)) {\n return querySelector(container, className, single)\n } else {\n return polyfill(container, className, single)\n }\n }\n})()\n","var indexOf = [].indexOf\n\nmodule.exports = function(arr, obj){\n if (indexOf) return arr.indexOf(obj);\n for (var i = 0, il = arr.length; i < il; ++i) {\n if (arr[i] === obj) return i;\n }\n return -1\n}\n","/**\n * Source: https://github.com/timoxley/to-array\n *\n * Convert an array-like object into an `Array`.\n * If `collection` is already an `Array`, then will return a clone of `collection`.\n *\n * @param {Array | Mixed} collection An `Array` or array-like object to convert e.g. `arguments` or `NodeList`\n * @return {Array} Naive conversion of `collection` to a new `Array`.\n * @api public\n */\n\nmodule.exports = function toArray(collection) {\n if (typeof collection === 'undefined') return []\n if (collection === null) return [null]\n if (collection === window) return [window]\n if (typeof collection === 'string') return [collection]\n if (isArray(collection)) return collection\n if (typeof collection.length != 'number') return [collection]\n if (typeof collection === 'function' && collection instanceof Function) return [collection]\n\n var arr = [];\n for (var i = 0, il = collection.length; i < il; i++) {\n if (Object.prototype.hasOwnProperty.call(collection, i) || i in collection) {\n arr.push(collection[i])\n }\n }\n if (!arr.length) return []\n return arr\n}\n\nfunction isArray(arr) {\n return Object.prototype.toString.call(arr) === '[object Array]'\n}\n","module.exports = function (s) {\n s = s === undefined ? '' : s\n s = s === null ? '' : s\n s = s.toString()\n return s\n}\n","'use strict';\n\nvar alphabet;\nvar alphabetIndexMap;\nvar alphabetIndexMapLength = 0;\n\nfunction isNumberCode(code) {\n return code >= 48 && code <= 57;\n}\n\nfunction naturalCompare(a, b) {\n var lengthA = (a += '').length;\n var lengthB = (b += '').length;\n var aIndex = 0;\n var bIndex = 0;\n\n while (aIndex < lengthA && bIndex < lengthB) {\n var charCodeA = a.charCodeAt(aIndex);\n var charCodeB = b.charCodeAt(bIndex);\n\n if (isNumberCode(charCodeA)) {\n if (!isNumberCode(charCodeB)) {\n return charCodeA - charCodeB;\n }\n\n var numStartA = aIndex;\n var numStartB = bIndex;\n\n while (charCodeA === 48 && ++numStartA < lengthA) {\n charCodeA = a.charCodeAt(numStartA);\n }\n while (charCodeB === 48 && ++numStartB < lengthB) {\n charCodeB = b.charCodeAt(numStartB);\n }\n\n var numEndA = numStartA;\n var numEndB = numStartB;\n\n while (numEndA < lengthA && isNumberCode(a.charCodeAt(numEndA))) {\n ++numEndA;\n }\n while (numEndB < lengthB && isNumberCode(b.charCodeAt(numEndB))) {\n ++numEndB;\n }\n\n var difference = numEndA - numStartA - numEndB + numStartB; // numA length - numB length\n if (difference) {\n return difference;\n }\n\n while (numStartA < numEndA) {\n difference = a.charCodeAt(numStartA++) - b.charCodeAt(numStartB++);\n if (difference) {\n return difference;\n }\n }\n\n aIndex = numEndA;\n bIndex = numEndB;\n continue;\n }\n\n if (charCodeA !== charCodeB) {\n if (\n charCodeA < alphabetIndexMapLength &&\n charCodeB < alphabetIndexMapLength &&\n alphabetIndexMap[charCodeA] !== -1 &&\n alphabetIndexMap[charCodeB] !== -1\n ) {\n return alphabetIndexMap[charCodeA] - alphabetIndexMap[charCodeB];\n }\n\n return charCodeA - charCodeB;\n }\n\n ++aIndex;\n ++bIndex;\n }\n\n if (aIndex >= lengthA && bIndex < lengthB && lengthA >= lengthB) {\n return -1;\n }\n\n if (bIndex >= lengthB && aIndex < lengthA && lengthB >= lengthA) {\n return 1;\n }\n\n return lengthA - lengthB;\n}\n\nnaturalCompare.caseInsensitive = naturalCompare.i = function(a, b) {\n return naturalCompare(('' + a).toLowerCase(), ('' + b).toLowerCase());\n};\n\nObject.defineProperties(naturalCompare, {\n alphabet: {\n get: function() {\n return alphabet;\n },\n\n set: function(value) {\n alphabet = value;\n alphabetIndexMap = [];\n\n var i = 0;\n\n if (alphabet) {\n for (; i < alphabet.length; i++) {\n alphabetIndexMap[alphabet.charCodeAt(i)] = i;\n }\n }\n\n alphabetIndexMapLength = alphabetIndexMap.length;\n\n for (i = 0; i < alphabetIndexMapLength; i++) {\n if (alphabetIndexMap[i] === undefined) {\n alphabetIndexMap[i] = -1;\n }\n }\n },\n },\n});\n\nmodule.exports = naturalCompare;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(\"./src/index.js\");\n"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;A;;;;;;;;;;;AChBA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;AC5BA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAMA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AALA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AAjCA;AAoCA;AAIA;AACA;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;ACtEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AASA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATA;AAYA;AAEA;AACA;AAAA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AA1EA;AA6EA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AADA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AADA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AADA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AADA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AADA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AAhBA;AACA;AAkBA;AACA;AAAA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;ACvQA;AACA;AACA;AAEA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;AC5DA;AAAA;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AACA;AACA;AAFA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAFA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA5BA;AA+BA;AACA;AACA;AACA;AACA;AACA;AACA;AALA;AAQA;AACA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;AC5GA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;AC9CA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AApCA;AAsCA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AA1CA;AACA;AA4CA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;ACxIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA3CA;AACA;AA6CA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAAA;AAAA;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;A;;;;;;;;;;;ACxGA;AACA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;ACnMA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;A;;;;;;;;;;;;;;AClKA;AAAA;AAAA;AAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;A;;;;;;;;;;;ACpEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;AClBA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAAA;AAEA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAAA;AACA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;AC3HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;A;;;;;;;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;AC/DA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;A;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;;;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtBA;AACA;AACA;AACA;;A","sourceRoot":""} \ No newline at end of file diff --git a/crates/ezidam/static/libs/list.js/list.min.js.map b/crates/ezidam/static/libs/list.js/list.min.js.map new file mode 100644 index 0000000..7718607 --- /dev/null +++ b/crates/ezidam/static/libs/list.js/list.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"list.min.js","sources":["webpack://List/list.min.js"],"mappings":"AAAA","sourceRoot":""} \ No newline at end of file diff --git a/crates/ezidam/static/libs/tom-select/tom-select.base.js b/crates/ezidam/static/libs/tom-select/tom-select.base.js new file mode 100644 index 0000000..ece9e41 --- /dev/null +++ b/crates/ezidam/static/libs/tom-select/tom-select.base.js @@ -0,0 +1,4687 @@ +/** +* Tom Select v2.2.2 +* Licensed under the Apache License, Version 2.0 (the "License"); +*/ + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.TomSelect = factory()); +})(this, (function () { 'use strict'; + + /** + * MicroEvent - to make any js object an event emitter + * + * - pure javascript - server compatible, browser compatible + * - dont rely on the browser doms + * - super simple - you get it immediatly, no mistery, no magic involved + * + * @author Jerome Etienne (https://github.com/jeromeetienne) + */ + + /** + * Execute callback for each event in space separated list of event names + * + */ + function forEvents(events, callback) { + events.split(/\s+/).forEach(event => { + callback(event); + }); + } + + class MicroEvent { + constructor() { + this._events = void 0; + this._events = {}; + } + + on(events, fct) { + forEvents(events, event => { + const event_array = this._events[event] || []; + event_array.push(fct); + this._events[event] = event_array; + }); + } + + off(events, fct) { + var n = arguments.length; + + if (n === 0) { + this._events = {}; + return; + } + + forEvents(events, event => { + if (n === 1) { + delete this._events[event]; + return; + } + + const event_array = this._events[event]; + if (event_array === undefined) return; + event_array.splice(event_array.indexOf(fct), 1); + this._events[event] = event_array; + }); + } + + trigger(events, ...args) { + var self = this; + forEvents(events, event => { + const event_array = self._events[event]; + if (event_array === undefined) return; + event_array.forEach(fct => { + fct.apply(self, args); + }); + }); + } + + } + + /** + * microplugin.js + * Copyright (c) 2013 Brian Reavis & contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this + * file except in compliance with the License. You may obtain a copy of the License at: + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF + * ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + * + * @author Brian Reavis + */ + function MicroPlugin(Interface) { + Interface.plugins = {}; + return class extends Interface { + constructor(...args) { + super(...args); + this.plugins = { + names: [], + settings: {}, + requested: {}, + loaded: {} + }; + } + + /** + * Registers a plugin. + * + * @param {function} fn + */ + static define(name, fn) { + Interface.plugins[name] = { + 'name': name, + 'fn': fn + }; + } + /** + * Initializes the listed plugins (with options). + * Acceptable formats: + * + * List (without options): + * ['a', 'b', 'c'] + * + * List (with options): + * [{'name': 'a', options: {}}, {'name': 'b', options: {}}] + * + * Hash (with options): + * {'a': { ... }, 'b': { ... }, 'c': { ... }} + * + * @param {array|object} plugins + */ + + + initializePlugins(plugins) { + var key, name; + const self = this; + const queue = []; + + if (Array.isArray(plugins)) { + plugins.forEach(plugin => { + if (typeof plugin === 'string') { + queue.push(plugin); + } else { + self.plugins.settings[plugin.name] = plugin.options; + queue.push(plugin.name); + } + }); + } else if (plugins) { + for (key in plugins) { + if (plugins.hasOwnProperty(key)) { + self.plugins.settings[key] = plugins[key]; + queue.push(key); + } + } + } + + while (name = queue.shift()) { + self.require(name); + } + } + + loadPlugin(name) { + var self = this; + var plugins = self.plugins; + var plugin = Interface.plugins[name]; + + if (!Interface.plugins.hasOwnProperty(name)) { + throw new Error('Unable to find "' + name + '" plugin'); + } + + plugins.requested[name] = true; + plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]); + plugins.names.push(name); + } + /** + * Initializes a plugin. + * + */ + + + require(name) { + var self = this; + var plugins = self.plugins; + + if (!self.plugins.loaded.hasOwnProperty(name)) { + if (plugins.requested[name]) { + throw new Error('Plugin has circular dependency ("' + name + '")'); + } + + self.loadPlugin(name); + } + + return plugins.loaded[name]; + } + + }; + } + + /*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */ + /** + * Convert array of strings to a regular expression + * ex ['ab','a'] => (?:ab|a) + * ex ['a','b'] => [ab] + * @param {string[]} chars + * @return {string} + */ + const arrayToPattern = chars => { + chars = chars.filter(Boolean); + + if (chars.length < 2) { + return chars[0] || ''; + } + + return maxValueLength(chars) == 1 ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')'; + }; + /** + * @param {string[]} array + * @return {string} + */ + + const sequencePattern = array => { + if (!hasDuplicates(array)) { + return array.join(''); + } + + let pattern = ''; + let prev_char_count = 0; + + const prev_pattern = () => { + if (prev_char_count > 1) { + pattern += '{' + prev_char_count + '}'; + } + }; + + array.forEach((char, i) => { + if (char === array[i - 1]) { + prev_char_count++; + return; + } + + prev_pattern(); + pattern += char; + prev_char_count = 1; + }); + prev_pattern(); + return pattern; + }; + /** + * Convert array of strings to a regular expression + * ex ['ab','a'] => (?:ab|a) + * ex ['a','b'] => [ab] + * @param {Set} chars + * @return {string} + */ + + const setToPattern = chars => { + let array = toArray(chars); + return arrayToPattern(array); + }; + /** + * + * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values + * @param {any[]} array + */ + + const hasDuplicates = array => { + return new Set(array).size !== array.length; + }; + /** + * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error + * @param {string} str + * @return {string} + */ + + const escape_regex = str => { + return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1'); + }; + /** + * Return the max length of array values + * @param {string[]} array + * + */ + + const maxValueLength = array => { + return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0); + }; + /** + * @param {string} str + */ + + const unicodeLength = str => { + return toArray(str).length; + }; + /** + * @param {any} p + * @return {any[]} + */ + + const toArray = p => Array.from(p); + + /*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */ + /** + * Get all possible combinations of substrings that add up to the given string + * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string + * @param {string} input + * @return {string[][]} + */ + const allSubstrings = input => { + if (input.length === 1) return [[input]]; + /** @type {string[][]} */ + + let result = []; + const start = input.substring(1); + const suba = allSubstrings(start); + suba.forEach(function (subresult) { + let tmp = subresult.slice(0); + tmp[0] = input.charAt(0) + tmp[0]; + result.push(tmp); + tmp = subresult.slice(0); + tmp.unshift(input.charAt(0)); + result.push(tmp); + }); + return result; + }; + + /*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */ + + /** + * @typedef {{[key:string]:string}} TUnicodeMap + * @typedef {{[key:string]:Set}} TUnicodeSets + * @typedef {[[number,number]]} TCodePoints + * @typedef {{folded:string,composed:string,code_point:number}} TCodePointObj + * @typedef {{start:number,end:number,length:number,substr:string}} TSequencePart + */ + /** @type {TCodePoints} */ + + const code_points = [[0, 65535]]; + const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]'; + /** @type {TUnicodeMap} */ + + let unicode_map; + /** @type {RegExp} */ + + let multi_char_reg; + const max_char_length = 3; + /** @type {TUnicodeMap} */ + + const latin_convert = {}; + /** @type {TUnicodeMap} */ + + const latin_condensed = { + '/': '⁄∕', + '0': '߀', + "a": "ⱥɐɑ", + "aa": "ꜳ", + "ae": "æǽǣ", + "ao": "ꜵ", + "au": "ꜷ", + "av": "ꜹꜻ", + "ay": "ꜽ", + "b": "ƀɓƃ", + "c": "ꜿƈȼↄ", + "d": "đɗɖᴅƌꮷԁɦ", + "e": "ɛǝᴇɇ", + "f": "ꝼƒ", + "g": "ǥɠꞡᵹꝿɢ", + "h": "ħⱨⱶɥ", + "i": "ɨı", + "j": "ɉȷ", + "k": "ƙⱪꝁꝃꝅꞣ", + "l": "łƚɫⱡꝉꝇꞁɭ", + "m": "ɱɯϻ", + "n": "ꞥƞɲꞑᴎлԉ", + "o": "øǿɔɵꝋꝍᴑ", + "oe": "œ", + "oi": "ƣ", + "oo": "ꝏ", + "ou": "ȣ", + "p": "ƥᵽꝑꝓꝕρ", + "q": "ꝗꝙɋ", + "r": "ɍɽꝛꞧꞃ", + "s": "ßȿꞩꞅʂ", + "t": "ŧƭʈⱦꞇ", + "th": "þ", + "tz": "ꜩ", + "u": "ʉ", + "v": "ʋꝟʌ", + "vy": "ꝡ", + "w": "ⱳ", + "y": "ƴɏỿ", + "z": "ƶȥɀⱬꝣ", + "hv": "ƕ" + }; + + for (let latin in latin_condensed) { + let unicode = latin_condensed[latin] || ''; + + for (let i = 0; i < unicode.length; i++) { + let char = unicode.substring(i, i + 1); + latin_convert[char] = latin; + } + } + + const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu'); + /** + * Initialize the unicode_map from the give code point ranges + * + * @param {TCodePoints=} _code_points + */ + + const initialize = _code_points => { + if (unicode_map !== undefined) return; + unicode_map = generateMap(_code_points || code_points); + }; + /** + * Helper method for normalize a string + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize + * @param {string} str + * @param {string} form + */ + + const normalize = (str, form = 'NFKD') => str.normalize(form); + /** + * Remove accents without reordering string + * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595} + * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703 + * @param {string} str + * @return {string} + */ + + const asciifold = str => { + return toArray(str).reduce( + /** + * @param {string} result + * @param {string} char + */ + (result, char) => { + return result + _asciifold(char); + }, ''); + }; + /** + * @param {string} str + * @return {string} + */ + + const _asciifold = str => { + str = normalize(str).toLowerCase().replace(convert_pat, ( + /** @type {string} */ + char) => { + return latin_convert[char] || ''; + }); //return str; + + return normalize(str, 'NFC'); + }; + /** + * Generate a list of unicode variants from the list of code points + * @param {TCodePoints} code_points + * @yield {TCodePointObj} + */ + + function* generator(code_points) { + for (const [code_point_min, code_point_max] of code_points) { + for (let i = code_point_min; i <= code_point_max; i++) { + let composed = String.fromCharCode(i); + let folded = asciifold(composed); + + if (folded == composed.toLowerCase()) { + continue; + } // skip when folded is a string longer than 3 characters long + // bc the resulting regex patterns will be long + // eg: + // folded صلى الله عليه وسلم length 18 code point 65018 + // folded جل جلاله length 8 code point 65019 + + + if (folded.length > max_char_length) { + continue; + } + + if (folded.length == 0) { + continue; + } + + yield { + folded: folded, + composed: composed, + code_point: i + }; + } + } + } + /** + * Generate a unicode map from the list of code points + * @param {TCodePoints} code_points + * @return {TUnicodeSets} + */ + + const generateSets = code_points => { + /** @type {{[key:string]:Set}} */ + const unicode_sets = {}; + /** + * @param {string} folded + * @param {string} to_add + */ + + const addMatching = (folded, to_add) => { + /** @type {Set} */ + const folded_set = unicode_sets[folded] || new Set(); + const patt = new RegExp('^' + setToPattern(folded_set) + '$', 'iu'); + + if (to_add.match(patt)) { + return; + } + + folded_set.add(escape_regex(to_add)); + unicode_sets[folded] = folded_set; + }; + + for (let value of generator(code_points)) { + addMatching(value.folded, value.folded); + addMatching(value.folded, value.composed); + } + + return unicode_sets; + }; + /** + * Generate a unicode map from the list of code points + * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...)) + * + * @param {TCodePoints} code_points + * @return {TUnicodeMap} + */ + + const generateMap = code_points => { + /** @type {TUnicodeSets} */ + const unicode_sets = generateSets(code_points); + /** @type {TUnicodeMap} */ + + const unicode_map = {}; + /** @type {string[]} */ + + let multi_char = []; + + for (let folded in unicode_sets) { + let set = unicode_sets[folded]; + + if (set) { + unicode_map[folded] = setToPattern(set); + } + + if (folded.length > 1) { + multi_char.push(escape_regex(folded)); + } + } + + multi_char.sort((a, b) => b.length - a.length); + const multi_char_patt = arrayToPattern(multi_char); + multi_char_reg = new RegExp('^' + multi_char_patt, 'u'); + return unicode_map; + }; + /** + * Map each element of an array from it's folded value to all possible unicode matches + * @param {string[]} strings + * @param {number} min_replacement + * @return {string} + */ + + const mapSequence = (strings, min_replacement = 1) => { + let chars_replaced = 0; + strings = strings.map(str => { + if (unicode_map[str]) { + chars_replaced += str.length; + } + + return unicode_map[str] || str; + }); + + if (chars_replaced >= min_replacement) { + return sequencePattern(strings); + } + + return ''; + }; + /** + * Convert a short string and split it into all possible patterns + * Keep a pattern only if min_replacement is met + * + * 'abc' + * => [['abc'],['ab','c'],['a','bc'],['a','b','c']] + * => ['abc-pattern','ab-c-pattern'...] + * + * + * @param {string} str + * @param {number} min_replacement + * @return {string} + */ + + const substringsToPattern = (str, min_replacement = 1) => { + min_replacement = Math.max(min_replacement, str.length - 1); + return arrayToPattern(allSubstrings(str).map(sub_pat => { + return mapSequence(sub_pat, min_replacement); + })); + }; + /** + * Convert an array of sequences into a pattern + * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...) + * + * @param {Sequence[]} sequences + * @param {boolean} all + */ + + const sequencesToPattern = (sequences, all = true) => { + let min_replacement = sequences.length > 1 ? 1 : 0; + return arrayToPattern(sequences.map(sequence => { + let seq = []; + const len = all ? sequence.length() : sequence.length() - 1; + + for (let j = 0; j < len; j++) { + seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement)); + } + + return sequencePattern(seq); + })); + }; + /** + * Return true if the sequence is already in the sequences + * @param {Sequence} needle_seq + * @param {Sequence[]} sequences + */ + + + const inSequences = (needle_seq, sequences) => { + for (const seq of sequences) { + if (seq.start != needle_seq.start || seq.end != needle_seq.end) { + continue; + } + + if (seq.substrs.join('') !== needle_seq.substrs.join('')) { + continue; + } + + let needle_parts = needle_seq.parts; + /** + * @param {TSequencePart} part + */ + + const filter = part => { + for (const needle_part of needle_parts) { + if (needle_part.start === part.start && needle_part.substr === part.substr) { + return false; + } + + if (part.length == 1 || needle_part.length == 1) { + continue; + } // check for overlapping parts + // a = ['::=','=='] + // b = ['::','==='] + // a = ['r','sm'] + // b = ['rs','m'] + + + if (part.start < needle_part.start && part.end > needle_part.start) { + return true; + } + + if (needle_part.start < part.start && needle_part.end > part.start) { + return true; + } + } + + return false; + }; + + let filtered = seq.parts.filter(filter); + + if (filtered.length > 0) { + continue; + } + + return true; + } + + return false; + }; + + class Sequence { + constructor() { + /** @type {TSequencePart[]} */ + this.parts = []; + /** @type {string[]} */ + + this.substrs = []; + this.start = 0; + this.end = 0; + } + /** + * @param {TSequencePart|undefined} part + */ + + + add(part) { + if (part) { + this.parts.push(part); + this.substrs.push(part.substr); + this.start = Math.min(part.start, this.start); + this.end = Math.max(part.end, this.end); + } + } + + last() { + return this.parts[this.parts.length - 1]; + } + + length() { + return this.parts.length; + } + /** + * @param {number} position + * @param {TSequencePart} last_piece + */ + + + clone(position, last_piece) { + let clone = new Sequence(); + let parts = JSON.parse(JSON.stringify(this.parts)); + let last_part = parts.pop(); + + for (const part of parts) { + clone.add(part); + } + + let last_substr = last_piece.substr.substring(0, position - last_part.start); + let clone_last_len = last_substr.length; + clone.add({ + start: last_part.start, + end: last_part.start + clone_last_len, + length: clone_last_len, + substr: last_substr + }); + return clone; + } + + } + /** + * Expand a regular expression pattern to include unicode variants + * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/ + * + * Issue: + * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ] + * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ] + * + * İIJ = IIJ = ⅡJ + * + * 1/2/4 + * + * @param {string} str + * @return {string|undefined} + */ + + + const getPattern = str => { + initialize(); + str = asciifold(str); + let pattern = ''; + let sequences = [new Sequence()]; + + for (let i = 0; i < str.length; i++) { + let substr = str.substring(i); + let match = substr.match(multi_char_reg); + const char = str.substring(i, i + 1); + const match_str = match ? match[0] : null; // loop through sequences + // add either the char or multi_match + + let overlapping = []; + let added_types = new Set(); + + for (const sequence of sequences) { + const last_piece = sequence.last(); + + if (!last_piece || last_piece.length == 1 || last_piece.end <= i) { + // if we have a multi match + if (match_str) { + const len = match_str.length; + sequence.add({ + start: i, + end: i + len, + length: len, + substr: match_str + }); + added_types.add('1'); + } else { + sequence.add({ + start: i, + end: i + 1, + length: 1, + substr: char + }); + added_types.add('2'); + } + } else if (match_str) { + let clone = sequence.clone(i, last_piece); + const len = match_str.length; + clone.add({ + start: i, + end: i + len, + length: len, + substr: match_str + }); + overlapping.push(clone); + } else { + // don't add char + // adding would create invalid patterns: 234 => [2,34,4] + added_types.add('3'); + } + } // if we have overlapping + + + if (overlapping.length > 0) { + // ['ii','iii'] before ['i','i','iii'] + overlapping = overlapping.sort((a, b) => { + return a.length() - b.length(); + }); + + for (let clone of overlapping) { + // don't add if we already have an equivalent sequence + if (inSequences(clone, sequences)) { + continue; + } + + sequences.push(clone); + } + + continue; + } // if we haven't done anything unique + // clean up the patterns + // helps keep patterns smaller + // if str = 'r₨㎧aarss', pattern will be 446 instead of 655 + + + if (i > 0 && added_types.size == 1 && !added_types.has('3')) { + pattern += sequencesToPattern(sequences, false); + let new_seq = new Sequence(); + const old_seq = sequences[0]; + + if (old_seq) { + new_seq.add(old_seq.last()); + } + + sequences = [new_seq]; + } + } + + pattern += sequencesToPattern(sequences, true); + return pattern; + }; + + /*! sifter.js | https://github.com/orchidjs/sifter.js | Apache License (v2) */ + + /** + * A property getter resolving dot-notation + * @param {Object} obj The root object to fetch property on + * @param {String} name The optionally dotted property name to fetch + * @return {Object} The resolved property value + */ + const getAttr = (obj, name) => { + if (!obj) return; + return obj[name]; + }; + /** + * A property getter resolving dot-notation + * @param {Object} obj The root object to fetch property on + * @param {String} name The optionally dotted property name to fetch + * @return {Object} The resolved property value + */ + + const getAttrNesting = (obj, name) => { + if (!obj) return; + var part, + names = name.split("."); + + while ((part = names.shift()) && (obj = obj[part])); + + return obj; + }; + /** + * Calculates how close of a match the + * given value is against a search token. + * + */ + + const scoreValue = (value, token, weight) => { + var score, pos; + if (!value) return 0; + value = value + ''; + if (token.regex == null) return 0; + pos = value.search(token.regex); + if (pos === -1) return 0; + score = token.string.length / value.length; + if (pos === 0) score += 0.5; + return score * weight; + }; + /** + * Cast object property to an array if it exists and has a value + * + */ + + const propToArray = (obj, key) => { + var value = obj[key]; + if (typeof value == 'function') return value; + + if (value && !Array.isArray(value)) { + obj[key] = [value]; + } + }; + /** + * Iterates over arrays and hashes. + * + * ``` + * iterate(this.items, function(item, id) { + * // invoked for each item + * }); + * ``` + * + */ + + const iterate$1 = (object, callback) => { + if (Array.isArray(object)) { + object.forEach(callback); + } else { + for (var key in object) { + if (object.hasOwnProperty(key)) { + callback(object[key], key); + } + } + } + }; + const cmp = (a, b) => { + if (typeof a === 'number' && typeof b === 'number') { + return a > b ? 1 : a < b ? -1 : 0; + } + + a = asciifold(a + '').toLowerCase(); + b = asciifold(b + '').toLowerCase(); + if (a > b) return 1; + if (b > a) return -1; + return 0; + }; + + /*! sifter.js | https://github.com/orchidjs/sifter.js | Apache License (v2) */ + + /** + * sifter.js + * Copyright (c) 2013–2020 Brian Reavis & contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this + * file except in compliance with the License. You may obtain a copy of the License at: + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF + * ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + * + * @author Brian Reavis + */ + + class Sifter { + // []|{}; + + /** + * Textually searches arrays and hashes of objects + * by property (or multiple properties). Designed + * specifically for autocomplete. + * + */ + constructor(items, settings) { + this.items = void 0; + this.settings = void 0; + this.items = items; + this.settings = settings || { + diacritics: true + }; + } + + /** + * Splits a search string into an array of individual + * regexps to be used to match results. + * + */ + tokenize(query, respect_word_boundaries, weights) { + if (!query || !query.length) return []; + const tokens = []; + const words = query.split(/\s+/); + var field_regex; + + if (weights) { + field_regex = new RegExp('^(' + Object.keys(weights).map(escape_regex).join('|') + ')\:(.*)$'); + } + + words.forEach(word => { + let field_match; + let field = null; + let regex = null; // look for "field:query" tokens + + if (field_regex && (field_match = word.match(field_regex))) { + field = field_match[1]; + word = field_match[2]; + } + + if (word.length > 0) { + if (this.settings.diacritics) { + regex = getPattern(word) || null; + } else { + regex = escape_regex(word); + } + + if (regex && respect_word_boundaries) regex = "\\b" + regex; + } + + tokens.push({ + string: word, + regex: regex ? new RegExp(regex, 'iu') : null, + field: field + }); + }); + return tokens; + } + + /** + * Returns a function to be used to score individual results. + * + * Good matches will have a higher score than poor matches. + * If an item is not a match, 0 will be returned by the function. + * + * @returns {T.ScoreFn} + */ + getScoreFunction(query, options) { + var search = this.prepareSearch(query, options); + return this._getScoreFunction(search); + } + /** + * @returns {T.ScoreFn} + * + */ + + + _getScoreFunction(search) { + const tokens = search.tokens, + token_count = tokens.length; + + if (!token_count) { + return function () { + return 0; + }; + } + + const fields = search.options.fields, + weights = search.weights, + field_count = fields.length, + getAttrFn = search.getAttrFn; + + if (!field_count) { + return function () { + return 1; + }; + } + /** + * Calculates the score of an object + * against the search query. + * + */ + + + const scoreObject = function () { + if (field_count === 1) { + return function (token, data) { + const field = fields[0].field; + return scoreValue(getAttrFn(data, field), token, weights[field] || 1); + }; + } + + return function (token, data) { + var sum = 0; // is the token specific to a field? + + if (token.field) { + const value = getAttrFn(data, token.field); + + if (!token.regex && value) { + sum += 1 / field_count; + } else { + sum += scoreValue(value, token, 1); + } + } else { + iterate$1(weights, (weight, field) => { + sum += scoreValue(getAttrFn(data, field), token, weight); + }); + } + + return sum / field_count; + }; + }(); + + if (token_count === 1) { + return function (data) { + return scoreObject(tokens[0], data); + }; + } + + if (search.options.conjunction === 'and') { + return function (data) { + var score, + sum = 0; + + for (let token of tokens) { + score = scoreObject(token, data); + if (score <= 0) return 0; + sum += score; + } + + return sum / token_count; + }; + } else { + return function (data) { + var sum = 0; + iterate$1(tokens, token => { + sum += scoreObject(token, data); + }); + return sum / token_count; + }; + } + } + + /** + * Returns a function that can be used to compare two + * results, for sorting purposes. If no sorting should + * be performed, `null` will be returned. + * + * @return function(a,b) + */ + getSortFunction(query, options) { + var search = this.prepareSearch(query, options); + return this._getSortFunction(search); + } + + _getSortFunction(search) { + var implicit_score, + sort_flds = []; + const self = this, + options = search.options, + sort = !search.query && options.sort_empty ? options.sort_empty : options.sort; + + if (typeof sort == 'function') { + return sort.bind(this); + } + /** + * Fetches the specified sort field value + * from a search result item. + * + */ + + + const get_field = function get_field(name, result) { + if (name === '$score') return result.score; + return search.getAttrFn(self.items[result.id], name); + }; // parse options + + + if (sort) { + for (let s of sort) { + if (search.query || s.field !== '$score') { + sort_flds.push(s); + } + } + } // the "$score" field is implied to be the primary + // sort field, unless it's manually specified + + + if (search.query) { + implicit_score = true; + + for (let fld of sort_flds) { + if (fld.field === '$score') { + implicit_score = false; + break; + } + } + + if (implicit_score) { + sort_flds.unshift({ + field: '$score', + direction: 'desc' + }); + } // without a search.query, all items will have the same score + + } else { + sort_flds = sort_flds.filter(fld => fld.field !== '$score'); + } // build function + + + const sort_flds_count = sort_flds.length; + + if (!sort_flds_count) { + return null; + } + + return function (a, b) { + var result, field; + + for (let sort_fld of sort_flds) { + field = sort_fld.field; + let multiplier = sort_fld.direction === 'desc' ? -1 : 1; + result = multiplier * cmp(get_field(field, a), get_field(field, b)); + if (result) return result; + } + + return 0; + }; + } + + /** + * Parses a search query and returns an object + * with tokens and fields ready to be populated + * with results. + * + */ + prepareSearch(query, optsUser) { + const weights = {}; + var options = Object.assign({}, optsUser); + propToArray(options, 'sort'); + propToArray(options, 'sort_empty'); // convert fields to new format + + if (options.fields) { + propToArray(options, 'fields'); + const fields = []; + options.fields.forEach(field => { + if (typeof field == 'string') { + field = { + field: field, + weight: 1 + }; + } + + fields.push(field); + weights[field.field] = 'weight' in field ? field.weight : 1; + }); + options.fields = fields; + } + + return { + options: options, + query: query.toLowerCase().trim(), + tokens: this.tokenize(query, options.respect_word_boundaries, weights), + total: 0, + items: [], + weights: weights, + getAttrFn: options.nesting ? getAttrNesting : getAttr + }; + } + + /** + * Searches through all items and returns a sorted array of matches. + * + */ + search(query, options) { + var self = this, + score, + search; + search = this.prepareSearch(query, options); + options = search.options; + query = search.query; // generate result scoring function + + const fn_score = options.score || self._getScoreFunction(search); // perform search and sort + + + if (query.length) { + iterate$1(self.items, (item, id) => { + score = fn_score(item); + + if (options.filter === false || score > 0) { + search.items.push({ + 'score': score, + 'id': id + }); + } + }); + } else { + iterate$1(self.items, (_, id) => { + search.items.push({ + 'score': 1, + 'id': id + }); + }); + } + + const fn_sort = self._getSortFunction(search); + + if (fn_sort) search.items.sort(fn_sort); // apply limits + + search.total = search.items.length; + + if (typeof options.limit === 'number') { + search.items = search.items.slice(0, options.limit); + } + + return search; + } + + } + + /** + * Iterates over arrays and hashes. + * + * ``` + * iterate(this.items, function(item, id) { + * // invoked for each item + * }); + * ``` + * + */ + + const iterate = (object, callback) => { + if (Array.isArray(object)) { + object.forEach(callback); + } else { + for (var key in object) { + if (object.hasOwnProperty(key)) { + callback(object[key], key); + } + } + } + }; + + /** + * Return a dom element from either a dom query string, jQuery object, a dom element or html string + * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518 + * + * param query should be {} + */ + + const getDom = query => { + if (query.jquery) { + return query[0]; + } + + if (query instanceof HTMLElement) { + return query; + } + + if (isHtmlString(query)) { + var tpl = document.createElement('template'); + tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result + + return tpl.content.firstChild; + } + + return document.querySelector(query); + }; + const isHtmlString = arg => { + if (typeof arg === 'string' && arg.indexOf('<') > -1) { + return true; + } + + return false; + }; + const escapeQuery = query => { + return query.replace(/['"\\]/g, '\\$&'); + }; + /** + * Dispatch an event + * + */ + + const triggerEvent = (dom_el, event_name) => { + var event = document.createEvent('HTMLEvents'); + event.initEvent(event_name, true, false); + dom_el.dispatchEvent(event); + }; + /** + * Apply CSS rules to a dom element + * + */ + + const applyCSS = (dom_el, css) => { + Object.assign(dom_el.style, css); + }; + /** + * Add css classes + * + */ + + const addClasses = (elmts, ...classes) => { + var norm_classes = classesArray(classes); + elmts = castAsArray(elmts); + elmts.map(el => { + norm_classes.map(cls => { + el.classList.add(cls); + }); + }); + }; + /** + * Remove css classes + * + */ + + const removeClasses = (elmts, ...classes) => { + var norm_classes = classesArray(classes); + elmts = castAsArray(elmts); + elmts.map(el => { + norm_classes.map(cls => { + el.classList.remove(cls); + }); + }); + }; + /** + * Return arguments + * + */ + + const classesArray = args => { + var classes = []; + iterate(args, _classes => { + if (typeof _classes === 'string') { + _classes = _classes.trim().split(/[\11\12\14\15\40]/); + } + + if (Array.isArray(_classes)) { + classes = classes.concat(_classes); + } + }); + return classes.filter(Boolean); + }; + /** + * Create an array from arg if it's not already an array + * + */ + + const castAsArray = arg => { + if (!Array.isArray(arg)) { + arg = [arg]; + } + + return arg; + }; + /** + * Get the closest node to the evt.target matching the selector + * Stops at wrapper + * + */ + + const parentMatch = (target, selector, wrapper) => { + if (wrapper && !wrapper.contains(target)) { + return; + } + + while (target && target.matches) { + if (target.matches(selector)) { + return target; + } + + target = target.parentNode; + } + }; + /** + * Get the first or last item from an array + * + * > 0 - right (last) + * <= 0 - left (first) + * + */ + + const getTail = (list, direction = 0) => { + if (direction > 0) { + return list[list.length - 1]; + } + + return list[0]; + }; + /** + * Return true if an object is empty + * + */ + + const isEmptyObject = obj => { + return Object.keys(obj).length === 0; + }; + /** + * Get the index of an element amongst sibling nodes of the same type + * + */ + + const nodeIndex = (el, amongst) => { + if (!el) return -1; + amongst = amongst || el.nodeName; + var i = 0; + + while (el = el.previousElementSibling) { + if (el.matches(amongst)) { + i++; + } + } + + return i; + }; + /** + * Set attributes of an element + * + */ + + const setAttr = (el, attrs) => { + iterate(attrs, (val, attr) => { + if (val == null) { + el.removeAttribute(attr); + } else { + el.setAttribute(attr, '' + val); + } + }); + }; + /** + * Replace a node + */ + + const replaceNode = (existing, replacement) => { + if (existing.parentNode) existing.parentNode.replaceChild(replacement, existing); + }; + + /** + * highlight v3 | MIT license | Johann Burkard + * Highlights arbitrary terms in a node. + * + * - Modified by Marshal 2011-6-24 (added regex) + * - Modified by Brian Reavis 2012-8-27 (cleanup) + */ + const highlight = (element, regex) => { + if (regex === null) return; // convet string to regex + + if (typeof regex === 'string') { + if (!regex.length) return; + regex = new RegExp(regex, 'i'); + } // Wrap matching part of text node with highlighting , e.g. + // Soccer -> Soccer for regex = /soc/i + + + const highlightText = node => { + var match = node.data.match(regex); + + if (match && node.data.length > 0) { + var spannode = document.createElement('span'); + spannode.className = 'highlight'; + var middlebit = node.splitText(match.index); + middlebit.splitText(match[0].length); + var middleclone = middlebit.cloneNode(true); + spannode.appendChild(middleclone); + replaceNode(middlebit, spannode); + return 1; + } + + return 0; + }; // Recurse element node, looking for child text nodes to highlight, unless element + // is childless, +{% endblock lib_js %} + +{% block additional_js %} + +{% endblock additional_js %}