renalware-core 2.0.137 → 2.0.138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/images/renalware/icons/home.svg +1 -0
- data/app/assets/images/renalware/icons/settings.svg +1 -0
- data/app/assets/javascripts/renalware/components/hd.js +0 -109
- data/app/assets/javascripts/renalware/components/toggler.js +0 -29
- data/app/assets/javascripts/renalware/core.js.erb +5 -1
- data/app/assets/javascripts/renalware/rollup_compiled.js +3888 -0
- data/app/assets/stylesheets/renalware/modules/_hd.scss +40 -17
- data/app/assets/stylesheets/renalware/partials/_dashboards.scss +1 -1
- data/app/assets/stylesheets/renalware/partials/_modal_window.scss +1 -0
- data/app/assets/stylesheets/renalware/partials/_navigation.scss +45 -2
- data/app/assets/stylesheets/renalware/partials/_pagination.scss +21 -0
- data/app/assets/stylesheets/renalware/partials/_tables.scss +9 -0
- data/app/assets/stylesheets/renalware/protocol_pdf.scss +45 -6
- data/app/components/renalware/application_component.rb +1 -1
- data/app/components/renalware/hd/administer_prescription_dropdown_component.html.slim +22 -0
- data/app/components/renalware/hd/administer_prescription_dropdown_component.rb +22 -0
- data/app/components/renalware/hd/prescription_last_administration_component.html.slim +6 -0
- data/app/components/renalware/hd/prescription_last_administration_component.rb +19 -0
- data/app/components/renalware/letters/letters_in_progress_component.html.slim +1 -1
- data/app/components/renalware/system/admin_menu_component.html.slim +25 -0
- data/app/components/renalware/system/admin_menu_component.rb +56 -0
- data/app/components/renalware/system/users_awaiting_approval_component.html.slim +6 -0
- data/app/components/renalware/system/users_awaiting_approval_component.rb +25 -0
- data/app/controllers/renalware/admin/dashboards_controller.rb +9 -0
- data/app/controllers/renalware/hd/base_controller.rb +4 -0
- data/app/controllers/renalware/hd/prescription_administrations_controller.rb +87 -0
- data/app/controllers/renalware/hd/sessions_controller.rb +6 -44
- data/app/controllers/renalware/hd/transmission_logs_controller.rb +7 -6
- data/app/controllers/renalware/hd/witnesses_controller.rb +62 -0
- data/app/helpers/renalware/application_helper.rb +1 -0
- data/app/helpers/renalware/layout_helper.rb +12 -0
- data/app/helpers/renalware/toggle_helper.rb +13 -4
- data/app/javascript/renalware/controllers/another_test_controller.js +8 -0
- data/app/javascript/renalware/controllers/hd/prescription_administration_controller.js +22 -0
- data/app/javascript/renalware/controllers/test_controller.js +8 -0
- data/app/javascript/renalware/controllers/toggle_controller.js +36 -0
- data/app/javascript/renalware/index.js +25 -0
- data/app/models/renalware/hd/patient.rb +1 -0
- data/app/models/renalware/hd/prescription_administration.rb +57 -33
- data/app/models/renalware/hd/prescription_last_administration_query.rb +29 -0
- data/app/models/renalware/hd/sessions/save_session.rb +1 -25
- data/app/models/renalware/hd/witness_form.rb +31 -0
- data/app/policies/renalware/hd/prescription_administration_policy.rb +8 -0
- data/app/presenters/renalware/admin/users/{summary_part.rb → summary_part.rb.dead} +0 -0
- data/app/presenters/renalware/hd/dashboard_presenter.rb +16 -7
- data/app/views/renalware/accesses/plans/_details.html.slim +1 -1
- data/app/views/renalware/admin/cache/show.html.slim +1 -1
- data/app/views/renalware/admin/dashboards/show.html.slim +4 -0
- data/app/views/renalware/admin/users/{_summary_part.html.slim → _summary_part.html.slim.dead} +1 -1
- data/app/views/renalware/admin/users/edit.html.slim +1 -1
- data/app/views/renalware/admin/users/index.html.slim +1 -1
- data/app/views/renalware/admissions/_summary_part.html.slim +5 -4
- data/app/views/renalware/admissions/consults/_summary_part.html.slim +7 -7
- data/app/views/renalware/dashboard/dashboards/_content.html.slim +5 -5
- data/app/views/renalware/drugs/drugs/edit.html.slim +2 -2
- data/app/views/renalware/drugs/drugs/index.html.slim +1 -1
- data/app/views/renalware/drugs/drugs/new.html.slim +1 -1
- data/app/views/renalware/events/types/edit.html.slim +1 -1
- data/app/views/renalware/events/types/index.html.slim +1 -1
- data/app/views/renalware/events/types/new.html.slim +1 -1
- data/app/views/renalware/hd/cannulation_types/edit.html.slim +1 -1
- data/app/views/renalware/hd/cannulation_types/index.html.slim +5 -5
- data/app/views/renalware/hd/cannulation_types/new.html.slim +1 -1
- data/app/views/renalware/hd/dashboards/_page_actions.html.slim +4 -1
- data/app/views/renalware/hd/dashboards/show.html.slim +1 -0
- data/app/views/renalware/hd/dialysates/edit.html.slim +1 -1
- data/app/views/renalware/hd/dialysates/index.html.slim +1 -1
- data/app/views/renalware/hd/dialysates/new.html.slim +1 -1
- data/app/views/renalware/hd/dialysers/edit.html.slim +1 -1
- data/app/views/renalware/hd/dialysers/index.html.slim +4 -5
- data/app/views/renalware/hd/dialysers/new.html.slim +1 -1
- data/app/views/renalware/hd/prescription_administrations/_form.html.slim +96 -0
- data/app/views/renalware/hd/prescription_administrations/_row.html.slim +25 -0
- data/app/views/renalware/hd/prescription_administrations/_table.html.slim +8 -0
- data/app/views/renalware/hd/prescription_administrations/_thead.html.slim +11 -0
- data/app/views/renalware/hd/prescription_administrations/create.js.erb +4 -0
- data/app/views/renalware/hd/prescription_administrations/edit.html.slim +5 -0
- data/app/views/renalware/hd/prescription_administrations/edit.js.erb +11 -0
- data/app/views/renalware/hd/prescription_administrations/index.html.slim +3 -0
- data/app/views/renalware/hd/prescription_administrations/new.html.slim +3 -0
- data/app/views/renalware/hd/prescription_administrations/new.js.erb +5 -0
- data/app/views/renalware/hd/protocols/_allergies.html.slim +3 -0
- data/app/views/renalware/hd/protocols/_latest_dry_weight.html.slim +3 -2
- data/app/views/renalware/hd/protocols/_prescriptions.html.slim +15 -7
- data/app/views/renalware/hd/protocols/_profile.html.slim +12 -12
- data/app/views/renalware/hd/protocols/_protocol.pdf.slim +2 -3
- data/app/views/renalware/hd/sessions/_form.html.slim +2 -6
- data/app/views/renalware/hd/sessions/_index_tabs.html.slim +11 -0
- data/app/views/renalware/hd/sessions/_list.html.slim +21 -1
- data/app/views/renalware/hd/sessions/_table.html.slim +1 -18
- data/app/views/renalware/hd/sessions/closed/_form.html.slim +1 -2
- data/app/views/renalware/hd/sessions/edit.html.slim +1 -2
- data/app/views/renalware/hd/sessions/new.html.slim +1 -2
- data/app/views/renalware/hd/sessions/open/_form.html.slim +1 -2
- data/app/views/renalware/hd/transmission_logs/index.html.slim +2 -2
- data/app/views/renalware/hd/witnesses/_form.html.slim +49 -0
- data/app/views/renalware/hd/witnesses/edit.html.slim +1 -0
- data/app/views/renalware/hd/witnesses/edit.js.erb +3 -0
- data/app/views/renalware/hd/witnesses/update.js.erb +4 -0
- data/app/views/renalware/layouts/_admin.html.slim +28 -0
- data/app/views/renalware/layouts/_patient.html.slim +1 -1
- data/app/views/renalware/letters/batches/index.html.slim +1 -1
- data/app/views/renalware/letters/letters/_letter.html.slim +1 -1
- data/app/views/renalware/modalities/descriptions/edit.html.slim +1 -1
- data/app/views/renalware/modalities/descriptions/index.html.slim +1 -1
- data/app/views/renalware/modalities/descriptions/new.html.slim +1 -1
- data/app/views/renalware/navigation/_admin.html.slim +1 -1
- data/app/views/renalware/navigation/_menu.html.slim +7 -6
- data/app/views/renalware/navigation/_user.html.slim +3 -4
- data/app/views/renalware/pathology/observation_requests/_filters.html.slim +1 -1
- data/app/views/renalware/pathology/requests/requests/index.html.slim +1 -1
- data/app/views/renalware/pathology/requests/rules/index.html.slim +1 -1
- data/app/views/renalware/patients/_layout.html.slim +1 -1
- data/app/views/renalware/patients/_summary_part.html.slim +1 -1
- data/app/views/renalware/patients/primary_care_physicians/edit.html.slim +1 -1
- data/app/views/renalware/patients/primary_care_physicians/index.html.slim +3 -5
- data/app/views/renalware/patients/primary_care_physicians/new.html.slim +1 -1
- data/app/views/renalware/pd/bag_types/edit.html.slim +1 -1
- data/app/views/renalware/pd/bag_types/index.html.slim +1 -1
- data/app/views/renalware/pd/bag_types/new.html.slim +1 -1
- data/app/views/renalware/problems/problems/_summary_part.html.slim +1 -1
- data/app/views/renalware/research/study_participants/index.html.slim +2 -3
- data/app/views/renalware/surveys/_pos_s_summary_part.html.slim +2 -1
- data/app/views/renalware/system/email_templates/index.html.slim +5 -1
- data/app/views/renalware/system/messages/edit.html.slim +1 -1
- data/app/views/renalware/system/messages/index.html.slim +1 -1
- data/app/views/renalware/system/messages/new.html.slim +1 -1
- data/app/views/renalware/system/user_feedback/edit.html.slim +1 -1
- data/app/views/renalware/system/user_feedback/index.html.slim +1 -1
- data/app/views/renalware/transplants/mdm/_bottom.html.slim +1 -1
- data/config/initializers/pagy.rb +9 -0
- data/config/locales/renalware/hd/dashboards.en.yml +1 -0
- data/config/locales/renalware/hd/session.en.yml +2 -1
- data/config/routes/admin.rb +1 -0
- data/config/routes/hd.rb +9 -0
- data/db/migrate/20190627141751_add_tokens_to_hd_prescription_administrations.rb +0 -2
- data/db/migrate/20200204153231_alter_hd_prescription_administrations.rb +18 -0
- data/db/seeds/default/accesses/access_pd_catheter_insertion_techniques.rb +0 -1
- data/db/seeds/default/accesses/access_plan_types.rb +0 -1
- data/db/seeds/default/accesses/access_sites.rb +0 -1
- data/db/seeds/default/clinics/clinics.rb +0 -1
- data/db/seeds/default/events/event_types.rb +0 -1
- data/db/seeds/default/hd/cannulation_types.rb +0 -1
- data/db/seeds/default/hd/dialysers.rb +0 -1
- data/db/seeds/default/modalities/reasons.rb +19 -19
- data/db/seeds/default/pathology/measurement_units.rb +0 -1
- data/db/seeds/default/patients/patients_ethnicities.rb +0 -1
- data/db/seeds/default/patients/patients_languages.rb +1 -0
- data/db/seeds/default/patients/patients_religions.rb +0 -1
- data/db/seeds/default/pd/bag_types.rb +0 -1
- data/db/seeds/default/pd/organisms.rb +0 -1
- data/db/seeds/default/pd/systems.rb +0 -1
- data/db/seeds/default/pd/training_sites.rb +0 -1
- data/db/seeds/default/pd/training_types.rb +0 -1
- data/db/seeds/default/practices/practices.rb +2 -2
- data/db/seeds/default/practices/primary_care_physicians.rb +1 -2
- data/db/seeds/default/renal/prd_descriptions.rb +1 -0
- data/db/seeds/default/system/roles.rb +1 -1
- data/lib/renalware/engine.rb +1 -0
- data/lib/renalware/version.rb +1 -1
- data/spec/factories/hd/prescription_administrations.rb +17 -0
- data/spec/support/factory_bot.rb +2 -0
- data/spec/support/pages/hd/prescription_administration_dialog.rb +132 -0
- metadata +62 -12
- data/app/assets/javascripts/renalware/components/bla.es6 +0 -1
- data/app/controllers/renalware/hd/prescription_administration_authorisations_controller.rb +0 -27
- data/app/javascript/controllers/clipboard_controller.js.dead +0 -16
- data/app/views/renalware/hd/sessions/_administered_drugs_row.html.slim +0 -27
- data/app/views/renalware/hd/sessions/_administered_drugs_thead.html.slim +0 -11
- data/app/views/renalware/hd/sessions/_prescription_administrations.html.slim +0 -20
- data/app/views/renalware/hd/sessions/closed/_administered_drugs_row.html.slim +0 -3
- data/app/views/renalware/hd/sessions/form/_drugs_to_be_administered.html.slim +0 -84
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f8f7059d114355fbc49605fcde385d8044508d02c5c1b7aeefa2c42b8f335335
|
|
4
|
+
data.tar.gz: 1835b91beea4880a15219eb58df05a47e5833f81613d65ae6a9910938652648c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7dd8130e88327dfb88d0e0447917642723af2adab2f23ac7992d4891633eb2804f0b5200701d9a91cd4065bc5a7980a61d73e6375d0623e40429b81bca134911
|
|
7
|
+
data.tar.gz: 5a3b2ecbd70ca5484c3527c2550c97cd067169ace37ebbc1c7d78cf704d8411feb5f4c109f8d43fabc6cbca1084bd056749832c992174f294e165c5180e0aaf5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#DDD" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#DDD" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-settings"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>
|
|
@@ -1,112 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
These are functions relating to the authorisation by nurse + witness of prescriptions
|
|
3
|
-
within the HD Session form.
|
|
4
|
-
TODO: This needs refactoring.
|
|
5
|
-
*/
|
|
6
|
-
$(document).ready(function() {
|
|
7
|
-
/*
|
|
8
|
-
If enter is pressed in a password field (out of habit as enter is oftern used when logging in,
|
|
9
|
-
after entering their password) throw it away. We could map it to a tab but frankly that gets
|
|
10
|
-
a bit complicated - see here:
|
|
11
|
-
https://stackoverflow.com/questions/2335553/jquery-how-to-catch-enter-key-and-change-event-to-tab
|
|
12
|
-
*/
|
|
13
|
-
$("input.user-password").on("keypress", function(e) {
|
|
14
|
-
if (e.keyCode == 13) { return false; }
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
$(".hd-drug-administered input[type='radio']").on("change", function(e) {
|
|
18
|
-
var checked = ($(this).val() == "true");
|
|
19
|
-
var container = $(this).closest(".hd-drug-administration");
|
|
20
|
-
$(container).toggleClass("administered", checked);
|
|
21
|
-
$(container).toggleClass("not-administered", !checked);
|
|
22
|
-
$(container).removeClass("undecided");
|
|
23
|
-
$(".authentication", container).toggle(checked);
|
|
24
|
-
$(".authentication", container).toggleClass("disabled-with-faded-overlay", !checked);
|
|
25
|
-
$(".reason-why-not-administered", container).toggle(!checked)
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
$(".hd-drug-administration .authentication-user-id").on("select2:select", function(e) {
|
|
29
|
-
var container = $(this).closest(".user-and-password");
|
|
30
|
-
var topContainer = $(container).closest(".hd-drug-administration");
|
|
31
|
-
$(container).find(".authentication-token").val("");
|
|
32
|
-
$("input.user-password", container).val("");
|
|
33
|
-
$(container).removeClass("authorised");
|
|
34
|
-
var tokenCount = $(topContainer).find(".authorised").length;
|
|
35
|
-
$(topContainer).attr("data-token-count", tokenCount);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// When a user clicks the link to clear the authorisation (they might have used the wrong user
|
|
40
|
-
// for instance) the clear the relevant token and password fields and classes.
|
|
41
|
-
$(".hd-drug-administration .user-and-password .user-and-password--clear").on("click", function(e) {
|
|
42
|
-
e.preventDefault();
|
|
43
|
-
var container = $(this).closest(".user-and-password");
|
|
44
|
-
var topContainer = $(container).closest(".hd-drug-administration");
|
|
45
|
-
$(container).find(".authentication-token").val("");
|
|
46
|
-
$("input.user-password", container).val("");
|
|
47
|
-
$(container).removeClass("authorised");
|
|
48
|
-
var tokenCount = $(topContainer).find(".authorised").length;
|
|
49
|
-
$(topContainer).attr("data-token-count", tokenCount);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// When the user has entered a password and leaves the password field, make an ajax POST to
|
|
53
|
-
// authenticate the user and on success return an authorisation token which is added to the html
|
|
54
|
-
// form - it will be validated when the form is submitted.
|
|
55
|
-
// TODO: also do this if enter pressed while in the password field.
|
|
56
|
-
$(".user-and-password input.user-password").on("blur", function(e) {
|
|
57
|
-
var container = $(this).closest(".user-and-password");
|
|
58
|
-
var topContainer = $(container).closest(".hd-drug-administration");
|
|
59
|
-
var authUrl = $(container).closest(".authentication").data("authentication-url");
|
|
60
|
-
var userSelect = $(container).find(".authentication-user-id");
|
|
61
|
-
var userId = $(userSelect).find("option:selected").val();
|
|
62
|
-
var authorisationTokenHiddenField = $(container).find(".authentication-token");
|
|
63
|
-
var password = $(this).val();
|
|
64
|
-
|
|
65
|
-
// Prevent the a 401 xhr code from redirecting us to the login page - see ajax_errors.js
|
|
66
|
-
$(document).off('ajaxError');
|
|
67
|
-
|
|
68
|
-
if (userId && password) {
|
|
69
|
-
$.ajax({
|
|
70
|
-
async: false, /* needed as if pwd field has focus and user clicks submit, it would not wait for ajax */
|
|
71
|
-
url: authUrl,
|
|
72
|
-
type: "POST",
|
|
73
|
-
data: "[user][id]=" + userId + "&[user][password]=" + password,
|
|
74
|
-
beforeSend: function() {
|
|
75
|
-
// Add a 'working' class during ajax operations so we can show a spinner for example
|
|
76
|
-
$(container).addClass("working");
|
|
77
|
-
$(container).removeClass("error");
|
|
78
|
-
// $(".hd-session-form button[type='submit]").prop("disabled", "disabled")
|
|
79
|
-
},
|
|
80
|
-
complete: function() {
|
|
81
|
-
$(container).removeClass("working");
|
|
82
|
-
// $(".hd-session-form input[type='submit']").removeProp("disabled")
|
|
83
|
-
},
|
|
84
|
-
statusCode: {
|
|
85
|
-
200: function (token) {
|
|
86
|
-
// The user id/password combination is valid and a token has been returned.
|
|
87
|
-
// We save the token to a hidden field so it wikll be submitted in the session form.
|
|
88
|
-
$(authorisationTokenHiddenField).val(token);
|
|
89
|
-
$(container).removeClass("unauthorised").addClass("authorised").removeClass("error");
|
|
90
|
-
// $(userSelect).prop("disabled", true);
|
|
91
|
-
var tokenCount = $(topContainer).find(".authorised").length;
|
|
92
|
-
$(topContainer).attr("data-token-count", tokenCount);
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
401: function (data) {
|
|
96
|
-
// The user id/password combination was not valid
|
|
97
|
-
console.log('401: Unauthenticated');
|
|
98
|
-
$(authorisationTokenHiddenField).prop("value", "");
|
|
99
|
-
$(container).removeClass("authorised").addClass("error");
|
|
100
|
-
|
|
101
|
-
var tokenCount = $(topContainer).find(".authorised").length;
|
|
102
|
-
$(topContainer).attr("data-token-count", tokenCount);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
1
|
var Renalware = typeof Renalware === 'undefined' ? {} : Renalware;
|
|
111
2
|
|
|
112
3
|
Renalware.HD = (function() {
|
|
@@ -57,35 +57,6 @@ function initTogglers() {
|
|
|
57
57
|
triggerMasonryLayoutRefresh();
|
|
58
58
|
})
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
// These two handlers mimic the row-toggler stimulus stimulus controller methods which
|
|
62
|
-
// are not ywt wired up because of lack of stimulus polyfill support in the asset pipline
|
|
63
|
-
// which means stimulus will not work with IE11. Hence the use of data-action etc here so
|
|
64
|
-
// once stimulus is working we can remove these 2 handlers without changing any markup.
|
|
65
|
-
|
|
66
|
-
// This handler toggles the last tr in the current tbody. We use multiple tbodys in each table
|
|
67
|
-
// to make toggling like this simpler, and to group the related (visible and toggleable) rows
|
|
68
|
-
// together.
|
|
69
|
-
// Note table must have the .toggleable class
|
|
70
|
-
$("a[data-action='row-toggler#toggleRow']").on("click", function(event) {
|
|
71
|
-
event.preventDefault();
|
|
72
|
-
$(event.target).closest("tbody").toggleClass("toggleable--open");
|
|
73
|
-
triggerMasonryLayoutRefresh();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// This handler toggles the last tr in each tbody in the current table.
|
|
77
|
-
// The link will probably sit in a thead < th
|
|
78
|
-
$("a[data-action='row-toggler#toggleTable']").on("click", function(event) {
|
|
79
|
-
event.preventDefault();
|
|
80
|
-
var link = event.target;
|
|
81
|
-
var table = $(link).closest("table");
|
|
82
|
-
var thead = $(link).closest("thead");
|
|
83
|
-
var tbodies = $("tbody", table);
|
|
84
|
-
var hide = thead.hasClass("toggleable--open");
|
|
85
|
-
thead.toggleClass("toggleable--open");
|
|
86
|
-
$(tbodies).toggleClass("toggleable--open", !hide);
|
|
87
|
-
triggerMasonryLayoutRefresh();
|
|
88
|
-
});
|
|
89
60
|
}
|
|
90
61
|
|
|
91
62
|
$(function() {
|
|
@@ -44,7 +44,11 @@
|
|
|
44
44
|
//= require print-js/dist/print
|
|
45
45
|
//= require moment/moment
|
|
46
46
|
//= require_directory ./components
|
|
47
|
-
|
|
47
|
+
|
|
48
|
+
// This next file is compiled by rollup using files in app/javascripts.
|
|
49
|
+
// We need to ensure it is always up to date, perhaps using a precommit hook
|
|
50
|
+
// and CI check
|
|
51
|
+
//= require ./rollup_compiled
|
|
48
52
|
|
|
49
53
|
// Define a console.log if one does not yet exist - e.g. we in IE11
|
|
50
54
|
window.console = window.console || { log: function() {} };
|
|
@@ -0,0 +1,3888 @@
|
|
|
1
|
+
function createCommonjsModule(fn, module) {
|
|
2
|
+
return module = {
|
|
3
|
+
exports: {}
|
|
4
|
+
}, fn(module, module.exports), module.exports;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var _global = createCommonjsModule(function(module) {
|
|
8
|
+
var global = module.exports = typeof window != "undefined" && window.Math == Math ? window : typeof self != "undefined" && self.Math == Math ? self : Function("return this")();
|
|
9
|
+
if (typeof __g == "number") __g = global;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
var _core = createCommonjsModule(function(module) {
|
|
13
|
+
var core = module.exports = {
|
|
14
|
+
version: "2.6.11"
|
|
15
|
+
};
|
|
16
|
+
if (typeof __e == "number") __e = core;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var _core_1 = _core.version;
|
|
20
|
+
|
|
21
|
+
var _isObject = function(it) {
|
|
22
|
+
return typeof it === "object" ? it !== null : typeof it === "function";
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var _anObject = function(it) {
|
|
26
|
+
if (!_isObject(it)) throw TypeError(it + " is not an object!");
|
|
27
|
+
return it;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var _fails = function(exec) {
|
|
31
|
+
try {
|
|
32
|
+
return !!exec();
|
|
33
|
+
} catch (e) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var _descriptors = !_fails(function() {
|
|
39
|
+
return Object.defineProperty({}, "a", {
|
|
40
|
+
get: function() {
|
|
41
|
+
return 7;
|
|
42
|
+
}
|
|
43
|
+
}).a != 7;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var document$1 = _global.document;
|
|
47
|
+
|
|
48
|
+
var is = _isObject(document$1) && _isObject(document$1.createElement);
|
|
49
|
+
|
|
50
|
+
var _domCreate = function(it) {
|
|
51
|
+
return is ? document$1.createElement(it) : {};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var _ie8DomDefine = !_descriptors && !_fails(function() {
|
|
55
|
+
return Object.defineProperty(_domCreate("div"), "a", {
|
|
56
|
+
get: function() {
|
|
57
|
+
return 7;
|
|
58
|
+
}
|
|
59
|
+
}).a != 7;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
var _toPrimitive = function(it, S) {
|
|
63
|
+
if (!_isObject(it)) return it;
|
|
64
|
+
var fn, val;
|
|
65
|
+
if (S && typeof (fn = it.toString) == "function" && !_isObject(val = fn.call(it))) return val;
|
|
66
|
+
if (typeof (fn = it.valueOf) == "function" && !_isObject(val = fn.call(it))) return val;
|
|
67
|
+
if (!S && typeof (fn = it.toString) == "function" && !_isObject(val = fn.call(it))) return val;
|
|
68
|
+
throw TypeError("Can't convert object to primitive value");
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
var dP = Object.defineProperty;
|
|
72
|
+
|
|
73
|
+
var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
|
|
74
|
+
_anObject(O);
|
|
75
|
+
P = _toPrimitive(P, true);
|
|
76
|
+
_anObject(Attributes);
|
|
77
|
+
if (_ie8DomDefine) try {
|
|
78
|
+
return dP(O, P, Attributes);
|
|
79
|
+
} catch (e) {}
|
|
80
|
+
if ("get" in Attributes || "set" in Attributes) throw TypeError("Accessors not supported!");
|
|
81
|
+
if ("value" in Attributes) O[P] = Attributes.value;
|
|
82
|
+
return O;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
var _objectDp = {
|
|
86
|
+
f: f
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
var _propertyDesc = function(bitmap, value) {
|
|
90
|
+
return {
|
|
91
|
+
enumerable: !(bitmap & 1),
|
|
92
|
+
configurable: !(bitmap & 2),
|
|
93
|
+
writable: !(bitmap & 4),
|
|
94
|
+
value: value
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
var _hide = _descriptors ? function(object, key, value) {
|
|
99
|
+
return _objectDp.f(object, key, _propertyDesc(1, value));
|
|
100
|
+
} : function(object, key, value) {
|
|
101
|
+
object[key] = value;
|
|
102
|
+
return object;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
106
|
+
|
|
107
|
+
var _has = function(it, key) {
|
|
108
|
+
return hasOwnProperty.call(it, key);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
var id = 0;
|
|
112
|
+
|
|
113
|
+
var px = Math.random();
|
|
114
|
+
|
|
115
|
+
var _uid = function(key) {
|
|
116
|
+
return "Symbol(".concat(key === undefined ? "" : key, ")_", (++id + px).toString(36));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
var _shared = createCommonjsModule(function(module) {
|
|
120
|
+
var SHARED = "__core-js_shared__";
|
|
121
|
+
var store = _global[SHARED] || (_global[SHARED] = {});
|
|
122
|
+
(module.exports = function(key, value) {
|
|
123
|
+
return store[key] || (store[key] = value !== undefined ? value : {});
|
|
124
|
+
})("versions", []).push({
|
|
125
|
+
version: _core.version,
|
|
126
|
+
mode: "global",
|
|
127
|
+
copyright: "© 2019 Denis Pushkarev (zloirock.ru)"
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
var _functionToString = _shared("native-function-to-string", Function.toString);
|
|
132
|
+
|
|
133
|
+
var _redefine = createCommonjsModule(function(module) {
|
|
134
|
+
var SRC = _uid("src");
|
|
135
|
+
var TO_STRING = "toString";
|
|
136
|
+
var TPL = ("" + _functionToString).split(TO_STRING);
|
|
137
|
+
_core.inspectSource = function(it) {
|
|
138
|
+
return _functionToString.call(it);
|
|
139
|
+
};
|
|
140
|
+
(module.exports = function(O, key, val, safe) {
|
|
141
|
+
var isFunction = typeof val == "function";
|
|
142
|
+
if (isFunction) _has(val, "name") || _hide(val, "name", key);
|
|
143
|
+
if (O[key] === val) return;
|
|
144
|
+
if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? "" + O[key] : TPL.join(String(key)));
|
|
145
|
+
if (O === _global) {
|
|
146
|
+
O[key] = val;
|
|
147
|
+
} else if (!safe) {
|
|
148
|
+
delete O[key];
|
|
149
|
+
_hide(O, key, val);
|
|
150
|
+
} else if (O[key]) {
|
|
151
|
+
O[key] = val;
|
|
152
|
+
} else {
|
|
153
|
+
_hide(O, key, val);
|
|
154
|
+
}
|
|
155
|
+
})(Function.prototype, TO_STRING, function toString() {
|
|
156
|
+
return typeof this == "function" && this[SRC] || _functionToString.call(this);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
var _aFunction = function(it) {
|
|
161
|
+
if (typeof it != "function") throw TypeError(it + " is not a function!");
|
|
162
|
+
return it;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
var _ctx = function(fn, that, length) {
|
|
166
|
+
_aFunction(fn);
|
|
167
|
+
if (that === undefined) return fn;
|
|
168
|
+
switch (length) {
|
|
169
|
+
case 1:
|
|
170
|
+
return function(a) {
|
|
171
|
+
return fn.call(that, a);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
case 2:
|
|
175
|
+
return function(a, b) {
|
|
176
|
+
return fn.call(that, a, b);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
case 3:
|
|
180
|
+
return function(a, b, c) {
|
|
181
|
+
return fn.call(that, a, b, c);
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return function() {
|
|
185
|
+
return fn.apply(that, arguments);
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
var PROTOTYPE = "prototype";
|
|
190
|
+
|
|
191
|
+
var $export = function(type, name, source) {
|
|
192
|
+
var IS_FORCED = type & $export.F;
|
|
193
|
+
var IS_GLOBAL = type & $export.G;
|
|
194
|
+
var IS_STATIC = type & $export.S;
|
|
195
|
+
var IS_PROTO = type & $export.P;
|
|
196
|
+
var IS_BIND = type & $export.B;
|
|
197
|
+
var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
|
|
198
|
+
var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
|
|
199
|
+
var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
|
|
200
|
+
var key, own, out, exp;
|
|
201
|
+
if (IS_GLOBAL) source = name;
|
|
202
|
+
for (key in source) {
|
|
203
|
+
own = !IS_FORCED && target && target[key] !== undefined;
|
|
204
|
+
out = (own ? target : source)[key];
|
|
205
|
+
exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == "function" ? _ctx(Function.call, out) : out;
|
|
206
|
+
if (target) _redefine(target, key, out, type & $export.U);
|
|
207
|
+
if (exports[key] != out) _hide(exports, key, exp);
|
|
208
|
+
if (IS_PROTO && expProto[key] != out) expProto[key] = out;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
_global.core = _core;
|
|
213
|
+
|
|
214
|
+
$export.F = 1;
|
|
215
|
+
|
|
216
|
+
$export.G = 2;
|
|
217
|
+
|
|
218
|
+
$export.S = 4;
|
|
219
|
+
|
|
220
|
+
$export.P = 8;
|
|
221
|
+
|
|
222
|
+
$export.B = 16;
|
|
223
|
+
|
|
224
|
+
$export.W = 32;
|
|
225
|
+
|
|
226
|
+
$export.U = 64;
|
|
227
|
+
|
|
228
|
+
$export.R = 128;
|
|
229
|
+
|
|
230
|
+
var _export = $export;
|
|
231
|
+
|
|
232
|
+
var toString = {}.toString;
|
|
233
|
+
|
|
234
|
+
var _cof = function(it) {
|
|
235
|
+
return toString.call(it).slice(8, -1);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
var _iobject = Object("z").propertyIsEnumerable(0) ? Object : function(it) {
|
|
239
|
+
return _cof(it) == "String" ? it.split("") : Object(it);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
var _defined = function(it) {
|
|
243
|
+
if (it == undefined) throw TypeError("Can't call method on " + it);
|
|
244
|
+
return it;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
var _toObject = function(it) {
|
|
248
|
+
return Object(_defined(it));
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
var ceil = Math.ceil;
|
|
252
|
+
|
|
253
|
+
var floor = Math.floor;
|
|
254
|
+
|
|
255
|
+
var _toInteger = function(it) {
|
|
256
|
+
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
var min = Math.min;
|
|
260
|
+
|
|
261
|
+
var _toLength = function(it) {
|
|
262
|
+
return it > 0 ? min(_toInteger(it), 9007199254740991) : 0;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
var _isArray = Array.isArray || function isArray(arg) {
|
|
266
|
+
return _cof(arg) == "Array";
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
var _wks = createCommonjsModule(function(module) {
|
|
270
|
+
var store = _shared("wks");
|
|
271
|
+
var Symbol = _global.Symbol;
|
|
272
|
+
var USE_SYMBOL = typeof Symbol == "function";
|
|
273
|
+
var $exports = module.exports = function(name) {
|
|
274
|
+
return store[name] || (store[name] = USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)("Symbol." + name));
|
|
275
|
+
};
|
|
276
|
+
$exports.store = store;
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
var SPECIES = _wks("species");
|
|
280
|
+
|
|
281
|
+
var _arraySpeciesConstructor = function(original) {
|
|
282
|
+
var C;
|
|
283
|
+
if (_isArray(original)) {
|
|
284
|
+
C = original.constructor;
|
|
285
|
+
if (typeof C == "function" && (C === Array || _isArray(C.prototype))) C = undefined;
|
|
286
|
+
if (_isObject(C)) {
|
|
287
|
+
C = C[SPECIES];
|
|
288
|
+
if (C === null) C = undefined;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return C === undefined ? Array : C;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
var _arraySpeciesCreate = function(original, length) {
|
|
295
|
+
return new (_arraySpeciesConstructor(original))(length);
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
var _arrayMethods = function(TYPE, $create) {
|
|
299
|
+
var IS_MAP = TYPE == 1;
|
|
300
|
+
var IS_FILTER = TYPE == 2;
|
|
301
|
+
var IS_SOME = TYPE == 3;
|
|
302
|
+
var IS_EVERY = TYPE == 4;
|
|
303
|
+
var IS_FIND_INDEX = TYPE == 6;
|
|
304
|
+
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
|
|
305
|
+
var create = $create || _arraySpeciesCreate;
|
|
306
|
+
return function($this, callbackfn, that) {
|
|
307
|
+
var O = _toObject($this);
|
|
308
|
+
var self = _iobject(O);
|
|
309
|
+
var f = _ctx(callbackfn, that, 3);
|
|
310
|
+
var length = _toLength(self.length);
|
|
311
|
+
var index = 0;
|
|
312
|
+
var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
|
|
313
|
+
var val, res;
|
|
314
|
+
for (;length > index; index++) if (NO_HOLES || index in self) {
|
|
315
|
+
val = self[index];
|
|
316
|
+
res = f(val, index, O);
|
|
317
|
+
if (TYPE) {
|
|
318
|
+
if (IS_MAP) result[index] = res; else if (res) switch (TYPE) {
|
|
319
|
+
case 3:
|
|
320
|
+
return true;
|
|
321
|
+
|
|
322
|
+
case 5:
|
|
323
|
+
return val;
|
|
324
|
+
|
|
325
|
+
case 6:
|
|
326
|
+
return index;
|
|
327
|
+
|
|
328
|
+
case 2:
|
|
329
|
+
result.push(val);
|
|
330
|
+
} else if (IS_EVERY) return false;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
var UNSCOPABLES = _wks("unscopables");
|
|
338
|
+
|
|
339
|
+
var ArrayProto = Array.prototype;
|
|
340
|
+
|
|
341
|
+
if (ArrayProto[UNSCOPABLES] == undefined) _hide(ArrayProto, UNSCOPABLES, {});
|
|
342
|
+
|
|
343
|
+
var _addToUnscopables = function(key) {
|
|
344
|
+
ArrayProto[UNSCOPABLES][key] = true;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
var $find = _arrayMethods(5);
|
|
348
|
+
|
|
349
|
+
var KEY = "find";
|
|
350
|
+
|
|
351
|
+
var forced = true;
|
|
352
|
+
|
|
353
|
+
if (KEY in []) Array(1)[KEY](function() {
|
|
354
|
+
forced = false;
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
_export(_export.P + _export.F * forced, "Array", {
|
|
358
|
+
find: function find(callbackfn) {
|
|
359
|
+
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
_addToUnscopables(KEY);
|
|
364
|
+
|
|
365
|
+
var find = _core.Array.find;
|
|
366
|
+
|
|
367
|
+
var $find$1 = _arrayMethods(6);
|
|
368
|
+
|
|
369
|
+
var KEY$1 = "findIndex";
|
|
370
|
+
|
|
371
|
+
var forced$1 = true;
|
|
372
|
+
|
|
373
|
+
if (KEY$1 in []) Array(1)[KEY$1](function() {
|
|
374
|
+
forced$1 = false;
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
_export(_export.P + _export.F * forced$1, "Array", {
|
|
378
|
+
findIndex: function findIndex(callbackfn) {
|
|
379
|
+
return $find$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
_addToUnscopables(KEY$1);
|
|
384
|
+
|
|
385
|
+
var findIndex = _core.Array.findIndex;
|
|
386
|
+
|
|
387
|
+
var _stringAt = function(TO_STRING) {
|
|
388
|
+
return function(that, pos) {
|
|
389
|
+
var s = String(_defined(that));
|
|
390
|
+
var i = _toInteger(pos);
|
|
391
|
+
var l = s.length;
|
|
392
|
+
var a, b;
|
|
393
|
+
if (i < 0 || i >= l) return TO_STRING ? "" : undefined;
|
|
394
|
+
a = s.charCodeAt(i);
|
|
395
|
+
return a < 55296 || a > 56319 || i + 1 === l || (b = s.charCodeAt(i + 1)) < 56320 || b > 57343 ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 55296 << 10) + (b - 56320) + 65536;
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
var _iterators = {};
|
|
400
|
+
|
|
401
|
+
var _toIobject = function(it) {
|
|
402
|
+
return _iobject(_defined(it));
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
var max = Math.max;
|
|
406
|
+
|
|
407
|
+
var min$1 = Math.min;
|
|
408
|
+
|
|
409
|
+
var _toAbsoluteIndex = function(index, length) {
|
|
410
|
+
index = _toInteger(index);
|
|
411
|
+
return index < 0 ? max(index + length, 0) : min$1(index, length);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
var _arrayIncludes = function(IS_INCLUDES) {
|
|
415
|
+
return function($this, el, fromIndex) {
|
|
416
|
+
var O = _toIobject($this);
|
|
417
|
+
var length = _toLength(O.length);
|
|
418
|
+
var index = _toAbsoluteIndex(fromIndex, length);
|
|
419
|
+
var value;
|
|
420
|
+
if (IS_INCLUDES && el != el) while (length > index) {
|
|
421
|
+
value = O[index++];
|
|
422
|
+
if (value != value) return true;
|
|
423
|
+
} else for (;length > index; index++) if (IS_INCLUDES || index in O) {
|
|
424
|
+
if (O[index] === el) return IS_INCLUDES || index || 0;
|
|
425
|
+
}
|
|
426
|
+
return !IS_INCLUDES && -1;
|
|
427
|
+
};
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
var shared = _shared("keys");
|
|
431
|
+
|
|
432
|
+
var _sharedKey = function(key) {
|
|
433
|
+
return shared[key] || (shared[key] = _uid(key));
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
var arrayIndexOf = _arrayIncludes(false);
|
|
437
|
+
|
|
438
|
+
var IE_PROTO = _sharedKey("IE_PROTO");
|
|
439
|
+
|
|
440
|
+
var _objectKeysInternal = function(object, names) {
|
|
441
|
+
var O = _toIobject(object);
|
|
442
|
+
var i = 0;
|
|
443
|
+
var result = [];
|
|
444
|
+
var key;
|
|
445
|
+
for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
|
|
446
|
+
while (names.length > i) if (_has(O, key = names[i++])) {
|
|
447
|
+
~arrayIndexOf(result, key) || result.push(key);
|
|
448
|
+
}
|
|
449
|
+
return result;
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
var _enumBugKeys = "constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",");
|
|
453
|
+
|
|
454
|
+
var _objectKeys = Object.keys || function keys(O) {
|
|
455
|
+
return _objectKeysInternal(O, _enumBugKeys);
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
|
|
459
|
+
_anObject(O);
|
|
460
|
+
var keys = _objectKeys(Properties);
|
|
461
|
+
var length = keys.length;
|
|
462
|
+
var i = 0;
|
|
463
|
+
var P;
|
|
464
|
+
while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
|
|
465
|
+
return O;
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
var document$2 = _global.document;
|
|
469
|
+
|
|
470
|
+
var _html = document$2 && document$2.documentElement;
|
|
471
|
+
|
|
472
|
+
var IE_PROTO$1 = _sharedKey("IE_PROTO");
|
|
473
|
+
|
|
474
|
+
var Empty = function() {};
|
|
475
|
+
|
|
476
|
+
var PROTOTYPE$1 = "prototype";
|
|
477
|
+
|
|
478
|
+
var createDict = function() {
|
|
479
|
+
var iframe = _domCreate("iframe");
|
|
480
|
+
var i = _enumBugKeys.length;
|
|
481
|
+
var lt = "<";
|
|
482
|
+
var gt = ">";
|
|
483
|
+
var iframeDocument;
|
|
484
|
+
iframe.style.display = "none";
|
|
485
|
+
_html.appendChild(iframe);
|
|
486
|
+
iframe.src = "javascript:";
|
|
487
|
+
iframeDocument = iframe.contentWindow.document;
|
|
488
|
+
iframeDocument.open();
|
|
489
|
+
iframeDocument.write(lt + "script" + gt + "document.F=Object" + lt + "/script" + gt);
|
|
490
|
+
iframeDocument.close();
|
|
491
|
+
createDict = iframeDocument.F;
|
|
492
|
+
while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
|
|
493
|
+
return createDict();
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
var _objectCreate = Object.create || function create(O, Properties) {
|
|
497
|
+
var result;
|
|
498
|
+
if (O !== null) {
|
|
499
|
+
Empty[PROTOTYPE$1] = _anObject(O);
|
|
500
|
+
result = new Empty();
|
|
501
|
+
Empty[PROTOTYPE$1] = null;
|
|
502
|
+
result[IE_PROTO$1] = O;
|
|
503
|
+
} else result = createDict();
|
|
504
|
+
return Properties === undefined ? result : _objectDps(result, Properties);
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
var def = _objectDp.f;
|
|
508
|
+
|
|
509
|
+
var TAG = _wks("toStringTag");
|
|
510
|
+
|
|
511
|
+
var _setToStringTag = function(it, tag, stat) {
|
|
512
|
+
if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
|
|
513
|
+
configurable: true,
|
|
514
|
+
value: tag
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
var IteratorPrototype = {};
|
|
519
|
+
|
|
520
|
+
_hide(IteratorPrototype, _wks("iterator"), function() {
|
|
521
|
+
return this;
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
var _iterCreate = function(Constructor, NAME, next) {
|
|
525
|
+
Constructor.prototype = _objectCreate(IteratorPrototype, {
|
|
526
|
+
next: _propertyDesc(1, next)
|
|
527
|
+
});
|
|
528
|
+
_setToStringTag(Constructor, NAME + " Iterator");
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
var IE_PROTO$2 = _sharedKey("IE_PROTO");
|
|
532
|
+
|
|
533
|
+
var ObjectProto = Object.prototype;
|
|
534
|
+
|
|
535
|
+
var _objectGpo = Object.getPrototypeOf || function(O) {
|
|
536
|
+
O = _toObject(O);
|
|
537
|
+
if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
|
|
538
|
+
if (typeof O.constructor == "function" && O instanceof O.constructor) {
|
|
539
|
+
return O.constructor.prototype;
|
|
540
|
+
}
|
|
541
|
+
return O instanceof Object ? ObjectProto : null;
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
var ITERATOR = _wks("iterator");
|
|
545
|
+
|
|
546
|
+
var BUGGY = !([].keys && "next" in [].keys());
|
|
547
|
+
|
|
548
|
+
var FF_ITERATOR = "@@iterator";
|
|
549
|
+
|
|
550
|
+
var KEYS = "keys";
|
|
551
|
+
|
|
552
|
+
var VALUES = "values";
|
|
553
|
+
|
|
554
|
+
var returnThis = function() {
|
|
555
|
+
return this;
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
var _iterDefine = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
|
|
559
|
+
_iterCreate(Constructor, NAME, next);
|
|
560
|
+
var getMethod = function(kind) {
|
|
561
|
+
if (!BUGGY && kind in proto) return proto[kind];
|
|
562
|
+
switch (kind) {
|
|
563
|
+
case KEYS:
|
|
564
|
+
return function keys() {
|
|
565
|
+
return new Constructor(this, kind);
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
case VALUES:
|
|
569
|
+
return function values() {
|
|
570
|
+
return new Constructor(this, kind);
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
return function entries() {
|
|
574
|
+
return new Constructor(this, kind);
|
|
575
|
+
};
|
|
576
|
+
};
|
|
577
|
+
var TAG = NAME + " Iterator";
|
|
578
|
+
var DEF_VALUES = DEFAULT == VALUES;
|
|
579
|
+
var VALUES_BUG = false;
|
|
580
|
+
var proto = Base.prototype;
|
|
581
|
+
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
|
|
582
|
+
var $default = $native || getMethod(DEFAULT);
|
|
583
|
+
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod("entries") : undefined;
|
|
584
|
+
var $anyNative = NAME == "Array" ? proto.entries || $native : $native;
|
|
585
|
+
var methods, key, IteratorPrototype;
|
|
586
|
+
if ($anyNative) {
|
|
587
|
+
IteratorPrototype = _objectGpo($anyNative.call(new Base()));
|
|
588
|
+
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
|
|
589
|
+
_setToStringTag(IteratorPrototype, TAG, true);
|
|
590
|
+
if (typeof IteratorPrototype[ITERATOR] != "function") _hide(IteratorPrototype, ITERATOR, returnThis);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
if (DEF_VALUES && $native && $native.name !== VALUES) {
|
|
594
|
+
VALUES_BUG = true;
|
|
595
|
+
$default = function values() {
|
|
596
|
+
return $native.call(this);
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
if (BUGGY || VALUES_BUG || !proto[ITERATOR]) {
|
|
600
|
+
_hide(proto, ITERATOR, $default);
|
|
601
|
+
}
|
|
602
|
+
_iterators[NAME] = $default;
|
|
603
|
+
_iterators[TAG] = returnThis;
|
|
604
|
+
if (DEFAULT) {
|
|
605
|
+
methods = {
|
|
606
|
+
values: DEF_VALUES ? $default : getMethod(VALUES),
|
|
607
|
+
keys: IS_SET ? $default : getMethod(KEYS),
|
|
608
|
+
entries: $entries
|
|
609
|
+
};
|
|
610
|
+
if (FORCED) for (key in methods) {
|
|
611
|
+
if (!(key in proto)) _redefine(proto, key, methods[key]);
|
|
612
|
+
} else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
|
|
613
|
+
}
|
|
614
|
+
return methods;
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
var $at = _stringAt(true);
|
|
618
|
+
|
|
619
|
+
_iterDefine(String, "String", function(iterated) {
|
|
620
|
+
this._t = String(iterated);
|
|
621
|
+
this._i = 0;
|
|
622
|
+
}, function() {
|
|
623
|
+
var O = this._t;
|
|
624
|
+
var index = this._i;
|
|
625
|
+
var point;
|
|
626
|
+
if (index >= O.length) return {
|
|
627
|
+
value: undefined,
|
|
628
|
+
done: true
|
|
629
|
+
};
|
|
630
|
+
point = $at(O, index);
|
|
631
|
+
this._i += point.length;
|
|
632
|
+
return {
|
|
633
|
+
value: point,
|
|
634
|
+
done: false
|
|
635
|
+
};
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
var _iterCall = function(iterator, fn, value, entries) {
|
|
639
|
+
try {
|
|
640
|
+
return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
|
|
641
|
+
} catch (e) {
|
|
642
|
+
var ret = iterator["return"];
|
|
643
|
+
if (ret !== undefined) _anObject(ret.call(iterator));
|
|
644
|
+
throw e;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
var ITERATOR$1 = _wks("iterator");
|
|
649
|
+
|
|
650
|
+
var ArrayProto$1 = Array.prototype;
|
|
651
|
+
|
|
652
|
+
var _isArrayIter = function(it) {
|
|
653
|
+
return it !== undefined && (_iterators.Array === it || ArrayProto$1[ITERATOR$1] === it);
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
var _createProperty = function(object, index, value) {
|
|
657
|
+
if (index in object) _objectDp.f(object, index, _propertyDesc(0, value)); else object[index] = value;
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
var TAG$1 = _wks("toStringTag");
|
|
661
|
+
|
|
662
|
+
var ARG = _cof(function() {
|
|
663
|
+
return arguments;
|
|
664
|
+
}()) == "Arguments";
|
|
665
|
+
|
|
666
|
+
var tryGet = function(it, key) {
|
|
667
|
+
try {
|
|
668
|
+
return it[key];
|
|
669
|
+
} catch (e) {}
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
var _classof = function(it) {
|
|
673
|
+
var O, T, B;
|
|
674
|
+
return it === undefined ? "Undefined" : it === null ? "Null" : typeof (T = tryGet(O = Object(it), TAG$1)) == "string" ? T : ARG ? _cof(O) : (B = _cof(O)) == "Object" && typeof O.callee == "function" ? "Arguments" : B;
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
var ITERATOR$2 = _wks("iterator");
|
|
678
|
+
|
|
679
|
+
var core_getIteratorMethod = _core.getIteratorMethod = function(it) {
|
|
680
|
+
if (it != undefined) return it[ITERATOR$2] || it["@@iterator"] || _iterators[_classof(it)];
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
var ITERATOR$3 = _wks("iterator");
|
|
684
|
+
|
|
685
|
+
var SAFE_CLOSING = false;
|
|
686
|
+
|
|
687
|
+
try {
|
|
688
|
+
var riter = [ 7 ][ITERATOR$3]();
|
|
689
|
+
riter["return"] = function() {
|
|
690
|
+
SAFE_CLOSING = true;
|
|
691
|
+
};
|
|
692
|
+
Array.from(riter, function() {
|
|
693
|
+
throw 2;
|
|
694
|
+
});
|
|
695
|
+
} catch (e) {}
|
|
696
|
+
|
|
697
|
+
var _iterDetect = function(exec, skipClosing) {
|
|
698
|
+
if (!skipClosing && !SAFE_CLOSING) return false;
|
|
699
|
+
var safe = false;
|
|
700
|
+
try {
|
|
701
|
+
var arr = [ 7 ];
|
|
702
|
+
var iter = arr[ITERATOR$3]();
|
|
703
|
+
iter.next = function() {
|
|
704
|
+
return {
|
|
705
|
+
done: safe = true
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
arr[ITERATOR$3] = function() {
|
|
709
|
+
return iter;
|
|
710
|
+
};
|
|
711
|
+
exec(arr);
|
|
712
|
+
} catch (e) {}
|
|
713
|
+
return safe;
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
_export(_export.S + _export.F * !_iterDetect(function(iter) {
|
|
717
|
+
Array.from(iter);
|
|
718
|
+
}), "Array", {
|
|
719
|
+
from: function from(arrayLike) {
|
|
720
|
+
var O = _toObject(arrayLike);
|
|
721
|
+
var C = typeof this == "function" ? this : Array;
|
|
722
|
+
var aLen = arguments.length;
|
|
723
|
+
var mapfn = aLen > 1 ? arguments[1] : undefined;
|
|
724
|
+
var mapping = mapfn !== undefined;
|
|
725
|
+
var index = 0;
|
|
726
|
+
var iterFn = core_getIteratorMethod(O);
|
|
727
|
+
var length, result, step, iterator;
|
|
728
|
+
if (mapping) mapfn = _ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
|
|
729
|
+
if (iterFn != undefined && !(C == Array && _isArrayIter(iterFn))) {
|
|
730
|
+
for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
|
|
731
|
+
_createProperty(result, index, mapping ? _iterCall(iterator, mapfn, [ step.value, index ], true) : step.value);
|
|
732
|
+
}
|
|
733
|
+
} else {
|
|
734
|
+
length = _toLength(O.length);
|
|
735
|
+
for (result = new C(length); length > index; index++) {
|
|
736
|
+
_createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
result.length = index;
|
|
740
|
+
return result;
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
var from_1 = _core.Array.from;
|
|
745
|
+
|
|
746
|
+
var test = {};
|
|
747
|
+
|
|
748
|
+
test[_wks("toStringTag")] = "z";
|
|
749
|
+
|
|
750
|
+
if (test + "" != "[object z]") {
|
|
751
|
+
_redefine(Object.prototype, "toString", function toString() {
|
|
752
|
+
return "[object " + _classof(this) + "]";
|
|
753
|
+
}, true);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
var _iterStep = function(done, value) {
|
|
757
|
+
return {
|
|
758
|
+
value: value,
|
|
759
|
+
done: !!done
|
|
760
|
+
};
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
var es6_array_iterator = _iterDefine(Array, "Array", function(iterated, kind) {
|
|
764
|
+
this._t = _toIobject(iterated);
|
|
765
|
+
this._i = 0;
|
|
766
|
+
this._k = kind;
|
|
767
|
+
}, function() {
|
|
768
|
+
var O = this._t;
|
|
769
|
+
var kind = this._k;
|
|
770
|
+
var index = this._i++;
|
|
771
|
+
if (!O || index >= O.length) {
|
|
772
|
+
this._t = undefined;
|
|
773
|
+
return _iterStep(1);
|
|
774
|
+
}
|
|
775
|
+
if (kind == "keys") return _iterStep(0, index);
|
|
776
|
+
if (kind == "values") return _iterStep(0, O[index]);
|
|
777
|
+
return _iterStep(0, [ index, O[index] ]);
|
|
778
|
+
}, "values");
|
|
779
|
+
|
|
780
|
+
_iterators.Arguments = _iterators.Array;
|
|
781
|
+
|
|
782
|
+
_addToUnscopables("keys");
|
|
783
|
+
|
|
784
|
+
_addToUnscopables("values");
|
|
785
|
+
|
|
786
|
+
_addToUnscopables("entries");
|
|
787
|
+
|
|
788
|
+
var ITERATOR$4 = _wks("iterator");
|
|
789
|
+
|
|
790
|
+
var TO_STRING_TAG = _wks("toStringTag");
|
|
791
|
+
|
|
792
|
+
var ArrayValues = _iterators.Array;
|
|
793
|
+
|
|
794
|
+
var DOMIterables = {
|
|
795
|
+
CSSRuleList: true,
|
|
796
|
+
CSSStyleDeclaration: false,
|
|
797
|
+
CSSValueList: false,
|
|
798
|
+
ClientRectList: false,
|
|
799
|
+
DOMRectList: false,
|
|
800
|
+
DOMStringList: false,
|
|
801
|
+
DOMTokenList: true,
|
|
802
|
+
DataTransferItemList: false,
|
|
803
|
+
FileList: false,
|
|
804
|
+
HTMLAllCollection: false,
|
|
805
|
+
HTMLCollection: false,
|
|
806
|
+
HTMLFormElement: false,
|
|
807
|
+
HTMLSelectElement: false,
|
|
808
|
+
MediaList: true,
|
|
809
|
+
MimeTypeArray: false,
|
|
810
|
+
NamedNodeMap: false,
|
|
811
|
+
NodeList: true,
|
|
812
|
+
PaintRequestList: false,
|
|
813
|
+
Plugin: false,
|
|
814
|
+
PluginArray: false,
|
|
815
|
+
SVGLengthList: false,
|
|
816
|
+
SVGNumberList: false,
|
|
817
|
+
SVGPathSegList: false,
|
|
818
|
+
SVGPointList: false,
|
|
819
|
+
SVGStringList: false,
|
|
820
|
+
SVGTransformList: false,
|
|
821
|
+
SourceBufferList: false,
|
|
822
|
+
StyleSheetList: true,
|
|
823
|
+
TextTrackCueList: false,
|
|
824
|
+
TextTrackList: false,
|
|
825
|
+
TouchList: false
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
for (var collections = _objectKeys(DOMIterables), i = 0; i < collections.length; i++) {
|
|
829
|
+
var NAME = collections[i];
|
|
830
|
+
var explicit = DOMIterables[NAME];
|
|
831
|
+
var Collection = _global[NAME];
|
|
832
|
+
var proto = Collection && Collection.prototype;
|
|
833
|
+
var key;
|
|
834
|
+
if (proto) {
|
|
835
|
+
if (!proto[ITERATOR$4]) _hide(proto, ITERATOR$4, ArrayValues);
|
|
836
|
+
if (!proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
|
|
837
|
+
_iterators[NAME] = ArrayValues;
|
|
838
|
+
if (explicit) for (key in es6_array_iterator) if (!proto[key]) _redefine(proto, key, es6_array_iterator[key], true);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
var _redefineAll = function(target, src, safe) {
|
|
843
|
+
for (var key in src) _redefine(target, key, src[key], safe);
|
|
844
|
+
return target;
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
var _anInstance = function(it, Constructor, name, forbiddenField) {
|
|
848
|
+
if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) {
|
|
849
|
+
throw TypeError(name + ": incorrect invocation!");
|
|
850
|
+
}
|
|
851
|
+
return it;
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
var _forOf = createCommonjsModule(function(module) {
|
|
855
|
+
var BREAK = {};
|
|
856
|
+
var RETURN = {};
|
|
857
|
+
var exports = module.exports = function(iterable, entries, fn, that, ITERATOR) {
|
|
858
|
+
var iterFn = ITERATOR ? function() {
|
|
859
|
+
return iterable;
|
|
860
|
+
} : core_getIteratorMethod(iterable);
|
|
861
|
+
var f = _ctx(fn, that, entries ? 2 : 1);
|
|
862
|
+
var index = 0;
|
|
863
|
+
var length, step, iterator, result;
|
|
864
|
+
if (typeof iterFn != "function") throw TypeError(iterable + " is not iterable!");
|
|
865
|
+
if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) {
|
|
866
|
+
result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
|
|
867
|
+
if (result === BREAK || result === RETURN) return result;
|
|
868
|
+
} else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done; ) {
|
|
869
|
+
result = _iterCall(iterator, f, step.value, entries);
|
|
870
|
+
if (result === BREAK || result === RETURN) return result;
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
exports.BREAK = BREAK;
|
|
874
|
+
exports.RETURN = RETURN;
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
var SPECIES$1 = _wks("species");
|
|
878
|
+
|
|
879
|
+
var _setSpecies = function(KEY) {
|
|
880
|
+
var C = _global[KEY];
|
|
881
|
+
if (_descriptors && C && !C[SPECIES$1]) _objectDp.f(C, SPECIES$1, {
|
|
882
|
+
configurable: true,
|
|
883
|
+
get: function() {
|
|
884
|
+
return this;
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
};
|
|
888
|
+
|
|
889
|
+
var _meta = createCommonjsModule(function(module) {
|
|
890
|
+
var META = _uid("meta");
|
|
891
|
+
var setDesc = _objectDp.f;
|
|
892
|
+
var id = 0;
|
|
893
|
+
var isExtensible = Object.isExtensible || function() {
|
|
894
|
+
return true;
|
|
895
|
+
};
|
|
896
|
+
var FREEZE = !_fails(function() {
|
|
897
|
+
return isExtensible(Object.preventExtensions({}));
|
|
898
|
+
});
|
|
899
|
+
var setMeta = function(it) {
|
|
900
|
+
setDesc(it, META, {
|
|
901
|
+
value: {
|
|
902
|
+
i: "O" + ++id,
|
|
903
|
+
w: {}
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
};
|
|
907
|
+
var fastKey = function(it, create) {
|
|
908
|
+
if (!_isObject(it)) return typeof it == "symbol" ? it : (typeof it == "string" ? "S" : "P") + it;
|
|
909
|
+
if (!_has(it, META)) {
|
|
910
|
+
if (!isExtensible(it)) return "F";
|
|
911
|
+
if (!create) return "E";
|
|
912
|
+
setMeta(it);
|
|
913
|
+
}
|
|
914
|
+
return it[META].i;
|
|
915
|
+
};
|
|
916
|
+
var getWeak = function(it, create) {
|
|
917
|
+
if (!_has(it, META)) {
|
|
918
|
+
if (!isExtensible(it)) return true;
|
|
919
|
+
if (!create) return false;
|
|
920
|
+
setMeta(it);
|
|
921
|
+
}
|
|
922
|
+
return it[META].w;
|
|
923
|
+
};
|
|
924
|
+
var onFreeze = function(it) {
|
|
925
|
+
if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it);
|
|
926
|
+
return it;
|
|
927
|
+
};
|
|
928
|
+
var meta = module.exports = {
|
|
929
|
+
KEY: META,
|
|
930
|
+
NEED: false,
|
|
931
|
+
fastKey: fastKey,
|
|
932
|
+
getWeak: getWeak,
|
|
933
|
+
onFreeze: onFreeze
|
|
934
|
+
};
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
var _meta_1 = _meta.KEY;
|
|
938
|
+
|
|
939
|
+
var _meta_2 = _meta.NEED;
|
|
940
|
+
|
|
941
|
+
var _meta_3 = _meta.fastKey;
|
|
942
|
+
|
|
943
|
+
var _meta_4 = _meta.getWeak;
|
|
944
|
+
|
|
945
|
+
var _meta_5 = _meta.onFreeze;
|
|
946
|
+
|
|
947
|
+
var _validateCollection = function(it, TYPE) {
|
|
948
|
+
if (!_isObject(it) || it._t !== TYPE) throw TypeError("Incompatible receiver, " + TYPE + " required!");
|
|
949
|
+
return it;
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
var dP$1 = _objectDp.f;
|
|
953
|
+
|
|
954
|
+
var fastKey = _meta.fastKey;
|
|
955
|
+
|
|
956
|
+
var SIZE = _descriptors ? "_s" : "size";
|
|
957
|
+
|
|
958
|
+
var getEntry = function(that, key) {
|
|
959
|
+
var index = fastKey(key);
|
|
960
|
+
var entry;
|
|
961
|
+
if (index !== "F") return that._i[index];
|
|
962
|
+
for (entry = that._f; entry; entry = entry.n) {
|
|
963
|
+
if (entry.k == key) return entry;
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
var _collectionStrong = {
|
|
968
|
+
getConstructor: function(wrapper, NAME, IS_MAP, ADDER) {
|
|
969
|
+
var C = wrapper(function(that, iterable) {
|
|
970
|
+
_anInstance(that, C, NAME, "_i");
|
|
971
|
+
that._t = NAME;
|
|
972
|
+
that._i = _objectCreate(null);
|
|
973
|
+
that._f = undefined;
|
|
974
|
+
that._l = undefined;
|
|
975
|
+
that[SIZE] = 0;
|
|
976
|
+
if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
|
|
977
|
+
});
|
|
978
|
+
_redefineAll(C.prototype, {
|
|
979
|
+
clear: function clear() {
|
|
980
|
+
for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
|
|
981
|
+
entry.r = true;
|
|
982
|
+
if (entry.p) entry.p = entry.p.n = undefined;
|
|
983
|
+
delete data[entry.i];
|
|
984
|
+
}
|
|
985
|
+
that._f = that._l = undefined;
|
|
986
|
+
that[SIZE] = 0;
|
|
987
|
+
},
|
|
988
|
+
delete: function(key) {
|
|
989
|
+
var that = _validateCollection(this, NAME);
|
|
990
|
+
var entry = getEntry(that, key);
|
|
991
|
+
if (entry) {
|
|
992
|
+
var next = entry.n;
|
|
993
|
+
var prev = entry.p;
|
|
994
|
+
delete that._i[entry.i];
|
|
995
|
+
entry.r = true;
|
|
996
|
+
if (prev) prev.n = next;
|
|
997
|
+
if (next) next.p = prev;
|
|
998
|
+
if (that._f == entry) that._f = next;
|
|
999
|
+
if (that._l == entry) that._l = prev;
|
|
1000
|
+
that[SIZE]--;
|
|
1001
|
+
}
|
|
1002
|
+
return !!entry;
|
|
1003
|
+
},
|
|
1004
|
+
forEach: function forEach(callbackfn) {
|
|
1005
|
+
_validateCollection(this, NAME);
|
|
1006
|
+
var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
|
|
1007
|
+
var entry;
|
|
1008
|
+
while (entry = entry ? entry.n : this._f) {
|
|
1009
|
+
f(entry.v, entry.k, this);
|
|
1010
|
+
while (entry && entry.r) entry = entry.p;
|
|
1011
|
+
}
|
|
1012
|
+
},
|
|
1013
|
+
has: function has(key) {
|
|
1014
|
+
return !!getEntry(_validateCollection(this, NAME), key);
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
if (_descriptors) dP$1(C.prototype, "size", {
|
|
1018
|
+
get: function() {
|
|
1019
|
+
return _validateCollection(this, NAME)[SIZE];
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
1022
|
+
return C;
|
|
1023
|
+
},
|
|
1024
|
+
def: function(that, key, value) {
|
|
1025
|
+
var entry = getEntry(that, key);
|
|
1026
|
+
var prev, index;
|
|
1027
|
+
if (entry) {
|
|
1028
|
+
entry.v = value;
|
|
1029
|
+
} else {
|
|
1030
|
+
that._l = entry = {
|
|
1031
|
+
i: index = fastKey(key, true),
|
|
1032
|
+
k: key,
|
|
1033
|
+
v: value,
|
|
1034
|
+
p: prev = that._l,
|
|
1035
|
+
n: undefined,
|
|
1036
|
+
r: false
|
|
1037
|
+
};
|
|
1038
|
+
if (!that._f) that._f = entry;
|
|
1039
|
+
if (prev) prev.n = entry;
|
|
1040
|
+
that[SIZE]++;
|
|
1041
|
+
if (index !== "F") that._i[index] = entry;
|
|
1042
|
+
}
|
|
1043
|
+
return that;
|
|
1044
|
+
},
|
|
1045
|
+
getEntry: getEntry,
|
|
1046
|
+
setStrong: function(C, NAME, IS_MAP) {
|
|
1047
|
+
_iterDefine(C, NAME, function(iterated, kind) {
|
|
1048
|
+
this._t = _validateCollection(iterated, NAME);
|
|
1049
|
+
this._k = kind;
|
|
1050
|
+
this._l = undefined;
|
|
1051
|
+
}, function() {
|
|
1052
|
+
var that = this;
|
|
1053
|
+
var kind = that._k;
|
|
1054
|
+
var entry = that._l;
|
|
1055
|
+
while (entry && entry.r) entry = entry.p;
|
|
1056
|
+
if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
|
|
1057
|
+
that._t = undefined;
|
|
1058
|
+
return _iterStep(1);
|
|
1059
|
+
}
|
|
1060
|
+
if (kind == "keys") return _iterStep(0, entry.k);
|
|
1061
|
+
if (kind == "values") return _iterStep(0, entry.v);
|
|
1062
|
+
return _iterStep(0, [ entry.k, entry.v ]);
|
|
1063
|
+
}, IS_MAP ? "entries" : "values", !IS_MAP, true);
|
|
1064
|
+
_setSpecies(NAME);
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
var f$1 = {}.propertyIsEnumerable;
|
|
1069
|
+
|
|
1070
|
+
var _objectPie = {
|
|
1071
|
+
f: f$1
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
var gOPD = Object.getOwnPropertyDescriptor;
|
|
1075
|
+
|
|
1076
|
+
var f$2 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) {
|
|
1077
|
+
O = _toIobject(O);
|
|
1078
|
+
P = _toPrimitive(P, true);
|
|
1079
|
+
if (_ie8DomDefine) try {
|
|
1080
|
+
return gOPD(O, P);
|
|
1081
|
+
} catch (e) {}
|
|
1082
|
+
if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]);
|
|
1083
|
+
};
|
|
1084
|
+
|
|
1085
|
+
var _objectGopd = {
|
|
1086
|
+
f: f$2
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
var check = function(O, proto) {
|
|
1090
|
+
_anObject(O);
|
|
1091
|
+
if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
var _setProto = {
|
|
1095
|
+
set: Object.setPrototypeOf || ("__proto__" in {} ? function(test, buggy, set) {
|
|
1096
|
+
try {
|
|
1097
|
+
set = _ctx(Function.call, _objectGopd.f(Object.prototype, "__proto__").set, 2);
|
|
1098
|
+
set(test, []);
|
|
1099
|
+
buggy = !(test instanceof Array);
|
|
1100
|
+
} catch (e) {
|
|
1101
|
+
buggy = true;
|
|
1102
|
+
}
|
|
1103
|
+
return function setPrototypeOf(O, proto) {
|
|
1104
|
+
check(O, proto);
|
|
1105
|
+
if (buggy) O.__proto__ = proto; else set(O, proto);
|
|
1106
|
+
return O;
|
|
1107
|
+
};
|
|
1108
|
+
}({}, false) : undefined),
|
|
1109
|
+
check: check
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
var setPrototypeOf = _setProto.set;
|
|
1113
|
+
|
|
1114
|
+
var _inheritIfRequired = function(that, target, C) {
|
|
1115
|
+
var S = target.constructor;
|
|
1116
|
+
var P;
|
|
1117
|
+
if (S !== C && typeof S == "function" && (P = S.prototype) !== C.prototype && _isObject(P) && setPrototypeOf) {
|
|
1118
|
+
setPrototypeOf(that, P);
|
|
1119
|
+
}
|
|
1120
|
+
return that;
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1123
|
+
var _collection = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
|
|
1124
|
+
var Base = _global[NAME];
|
|
1125
|
+
var C = Base;
|
|
1126
|
+
var ADDER = IS_MAP ? "set" : "add";
|
|
1127
|
+
var proto = C && C.prototype;
|
|
1128
|
+
var O = {};
|
|
1129
|
+
var fixMethod = function(KEY) {
|
|
1130
|
+
var fn = proto[KEY];
|
|
1131
|
+
_redefine(proto, KEY, KEY == "delete" ? function(a) {
|
|
1132
|
+
return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
|
|
1133
|
+
} : KEY == "has" ? function has(a) {
|
|
1134
|
+
return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
|
|
1135
|
+
} : KEY == "get" ? function get(a) {
|
|
1136
|
+
return IS_WEAK && !_isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
|
|
1137
|
+
} : KEY == "add" ? function add(a) {
|
|
1138
|
+
fn.call(this, a === 0 ? 0 : a);
|
|
1139
|
+
return this;
|
|
1140
|
+
} : function set(a, b) {
|
|
1141
|
+
fn.call(this, a === 0 ? 0 : a, b);
|
|
1142
|
+
return this;
|
|
1143
|
+
});
|
|
1144
|
+
};
|
|
1145
|
+
if (typeof C != "function" || !(IS_WEAK || proto.forEach && !_fails(function() {
|
|
1146
|
+
new C().entries().next();
|
|
1147
|
+
}))) {
|
|
1148
|
+
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
|
|
1149
|
+
_redefineAll(C.prototype, methods);
|
|
1150
|
+
_meta.NEED = true;
|
|
1151
|
+
} else {
|
|
1152
|
+
var instance = new C();
|
|
1153
|
+
var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
|
|
1154
|
+
var THROWS_ON_PRIMITIVES = _fails(function() {
|
|
1155
|
+
instance.has(1);
|
|
1156
|
+
});
|
|
1157
|
+
var ACCEPT_ITERABLES = _iterDetect(function(iter) {
|
|
1158
|
+
new C(iter);
|
|
1159
|
+
});
|
|
1160
|
+
var BUGGY_ZERO = !IS_WEAK && _fails(function() {
|
|
1161
|
+
var $instance = new C();
|
|
1162
|
+
var index = 5;
|
|
1163
|
+
while (index--) $instance[ADDER](index, index);
|
|
1164
|
+
return !$instance.has(-0);
|
|
1165
|
+
});
|
|
1166
|
+
if (!ACCEPT_ITERABLES) {
|
|
1167
|
+
C = wrapper(function(target, iterable) {
|
|
1168
|
+
_anInstance(target, C, NAME);
|
|
1169
|
+
var that = _inheritIfRequired(new Base(), target, C);
|
|
1170
|
+
if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
|
|
1171
|
+
return that;
|
|
1172
|
+
});
|
|
1173
|
+
C.prototype = proto;
|
|
1174
|
+
proto.constructor = C;
|
|
1175
|
+
}
|
|
1176
|
+
if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
|
|
1177
|
+
fixMethod("delete");
|
|
1178
|
+
fixMethod("has");
|
|
1179
|
+
IS_MAP && fixMethod("get");
|
|
1180
|
+
}
|
|
1181
|
+
if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
|
|
1182
|
+
if (IS_WEAK && proto.clear) delete proto.clear;
|
|
1183
|
+
}
|
|
1184
|
+
_setToStringTag(C, NAME);
|
|
1185
|
+
O[NAME] = C;
|
|
1186
|
+
_export(_export.G + _export.W + _export.F * (C != Base), O);
|
|
1187
|
+
if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
|
|
1188
|
+
return C;
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
var MAP = "Map";
|
|
1192
|
+
|
|
1193
|
+
var es6_map = _collection(MAP, function(get) {
|
|
1194
|
+
return function Map() {
|
|
1195
|
+
return get(this, arguments.length > 0 ? arguments[0] : undefined);
|
|
1196
|
+
};
|
|
1197
|
+
}, {
|
|
1198
|
+
get: function get(key) {
|
|
1199
|
+
var entry = _collectionStrong.getEntry(_validateCollection(this, MAP), key);
|
|
1200
|
+
return entry && entry.v;
|
|
1201
|
+
},
|
|
1202
|
+
set: function set(key, value) {
|
|
1203
|
+
return _collectionStrong.def(_validateCollection(this, MAP), key === 0 ? 0 : key, value);
|
|
1204
|
+
}
|
|
1205
|
+
}, _collectionStrong, true);
|
|
1206
|
+
|
|
1207
|
+
var _arrayFromIterable = function(iter, ITERATOR) {
|
|
1208
|
+
var result = [];
|
|
1209
|
+
_forOf(iter, false, result.push, result, ITERATOR);
|
|
1210
|
+
return result;
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
var _collectionToJson = function(NAME) {
|
|
1214
|
+
return function toJSON() {
|
|
1215
|
+
if (_classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
|
|
1216
|
+
return _arrayFromIterable(this);
|
|
1217
|
+
};
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
_export(_export.P + _export.R, "Map", {
|
|
1221
|
+
toJSON: _collectionToJson("Map")
|
|
1222
|
+
});
|
|
1223
|
+
|
|
1224
|
+
var _setCollectionOf = function(COLLECTION) {
|
|
1225
|
+
_export(_export.S, COLLECTION, {
|
|
1226
|
+
of: function of() {
|
|
1227
|
+
var length = arguments.length;
|
|
1228
|
+
var A = new Array(length);
|
|
1229
|
+
while (length--) A[length] = arguments[length];
|
|
1230
|
+
return new this(A);
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1233
|
+
};
|
|
1234
|
+
|
|
1235
|
+
_setCollectionOf("Map");
|
|
1236
|
+
|
|
1237
|
+
var _setCollectionFrom = function(COLLECTION) {
|
|
1238
|
+
_export(_export.S, COLLECTION, {
|
|
1239
|
+
from: function from(source) {
|
|
1240
|
+
var mapFn = arguments[1];
|
|
1241
|
+
var mapping, A, n, cb;
|
|
1242
|
+
_aFunction(this);
|
|
1243
|
+
mapping = mapFn !== undefined;
|
|
1244
|
+
if (mapping) _aFunction(mapFn);
|
|
1245
|
+
if (source == undefined) return new this();
|
|
1246
|
+
A = [];
|
|
1247
|
+
if (mapping) {
|
|
1248
|
+
n = 0;
|
|
1249
|
+
cb = _ctx(mapFn, arguments[2], 2);
|
|
1250
|
+
_forOf(source, false, function(nextItem) {
|
|
1251
|
+
A.push(cb(nextItem, n++));
|
|
1252
|
+
});
|
|
1253
|
+
} else {
|
|
1254
|
+
_forOf(source, false, A.push, A);
|
|
1255
|
+
}
|
|
1256
|
+
return new this(A);
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
_setCollectionFrom("Map");
|
|
1262
|
+
|
|
1263
|
+
var map = _core.Map;
|
|
1264
|
+
|
|
1265
|
+
var f$3 = Object.getOwnPropertySymbols;
|
|
1266
|
+
|
|
1267
|
+
var _objectGops = {
|
|
1268
|
+
f: f$3
|
|
1269
|
+
};
|
|
1270
|
+
|
|
1271
|
+
var $assign = Object.assign;
|
|
1272
|
+
|
|
1273
|
+
var _objectAssign = !$assign || _fails(function() {
|
|
1274
|
+
var A = {};
|
|
1275
|
+
var B = {};
|
|
1276
|
+
var S = Symbol();
|
|
1277
|
+
var K = "abcdefghijklmnopqrst";
|
|
1278
|
+
A[S] = 7;
|
|
1279
|
+
K.split("").forEach(function(k) {
|
|
1280
|
+
B[k] = k;
|
|
1281
|
+
});
|
|
1282
|
+
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join("") != K;
|
|
1283
|
+
}) ? function assign(target, source) {
|
|
1284
|
+
var T = _toObject(target);
|
|
1285
|
+
var aLen = arguments.length;
|
|
1286
|
+
var index = 1;
|
|
1287
|
+
var getSymbols = _objectGops.f;
|
|
1288
|
+
var isEnum = _objectPie.f;
|
|
1289
|
+
while (aLen > index) {
|
|
1290
|
+
var S = _iobject(arguments[index++]);
|
|
1291
|
+
var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
|
|
1292
|
+
var length = keys.length;
|
|
1293
|
+
var j = 0;
|
|
1294
|
+
var key;
|
|
1295
|
+
while (length > j) {
|
|
1296
|
+
key = keys[j++];
|
|
1297
|
+
if (!_descriptors || isEnum.call(S, key)) T[key] = S[key];
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
return T;
|
|
1301
|
+
} : $assign;
|
|
1302
|
+
|
|
1303
|
+
_export(_export.S + _export.F, "Object", {
|
|
1304
|
+
assign: _objectAssign
|
|
1305
|
+
});
|
|
1306
|
+
|
|
1307
|
+
var assign = _core.Object.assign;
|
|
1308
|
+
|
|
1309
|
+
var SPECIES$2 = _wks("species");
|
|
1310
|
+
|
|
1311
|
+
var _speciesConstructor = function(O, D) {
|
|
1312
|
+
var C = _anObject(O).constructor;
|
|
1313
|
+
var S;
|
|
1314
|
+
return C === undefined || (S = _anObject(C)[SPECIES$2]) == undefined ? D : _aFunction(S);
|
|
1315
|
+
};
|
|
1316
|
+
|
|
1317
|
+
var _invoke = function(fn, args, that) {
|
|
1318
|
+
var un = that === undefined;
|
|
1319
|
+
switch (args.length) {
|
|
1320
|
+
case 0:
|
|
1321
|
+
return un ? fn() : fn.call(that);
|
|
1322
|
+
|
|
1323
|
+
case 1:
|
|
1324
|
+
return un ? fn(args[0]) : fn.call(that, args[0]);
|
|
1325
|
+
|
|
1326
|
+
case 2:
|
|
1327
|
+
return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]);
|
|
1328
|
+
|
|
1329
|
+
case 3:
|
|
1330
|
+
return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]);
|
|
1331
|
+
|
|
1332
|
+
case 4:
|
|
1333
|
+
return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]);
|
|
1334
|
+
}
|
|
1335
|
+
return fn.apply(that, args);
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
var process = _global.process;
|
|
1339
|
+
|
|
1340
|
+
var setTask = _global.setImmediate;
|
|
1341
|
+
|
|
1342
|
+
var clearTask = _global.clearImmediate;
|
|
1343
|
+
|
|
1344
|
+
var MessageChannel = _global.MessageChannel;
|
|
1345
|
+
|
|
1346
|
+
var Dispatch = _global.Dispatch;
|
|
1347
|
+
|
|
1348
|
+
var counter = 0;
|
|
1349
|
+
|
|
1350
|
+
var queue = {};
|
|
1351
|
+
|
|
1352
|
+
var ONREADYSTATECHANGE = "onreadystatechange";
|
|
1353
|
+
|
|
1354
|
+
var defer, channel, port;
|
|
1355
|
+
|
|
1356
|
+
var run = function() {
|
|
1357
|
+
var id = +this;
|
|
1358
|
+
if (queue.hasOwnProperty(id)) {
|
|
1359
|
+
var fn = queue[id];
|
|
1360
|
+
delete queue[id];
|
|
1361
|
+
fn();
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
var listener = function(event) {
|
|
1366
|
+
run.call(event.data);
|
|
1367
|
+
};
|
|
1368
|
+
|
|
1369
|
+
if (!setTask || !clearTask) {
|
|
1370
|
+
setTask = function setImmediate(fn) {
|
|
1371
|
+
var args = [];
|
|
1372
|
+
var i = 1;
|
|
1373
|
+
while (arguments.length > i) args.push(arguments[i++]);
|
|
1374
|
+
queue[++counter] = function() {
|
|
1375
|
+
_invoke(typeof fn == "function" ? fn : Function(fn), args);
|
|
1376
|
+
};
|
|
1377
|
+
defer(counter);
|
|
1378
|
+
return counter;
|
|
1379
|
+
};
|
|
1380
|
+
clearTask = function clearImmediate(id) {
|
|
1381
|
+
delete queue[id];
|
|
1382
|
+
};
|
|
1383
|
+
if (_cof(process) == "process") {
|
|
1384
|
+
defer = function(id) {
|
|
1385
|
+
process.nextTick(_ctx(run, id, 1));
|
|
1386
|
+
};
|
|
1387
|
+
} else if (Dispatch && Dispatch.now) {
|
|
1388
|
+
defer = function(id) {
|
|
1389
|
+
Dispatch.now(_ctx(run, id, 1));
|
|
1390
|
+
};
|
|
1391
|
+
} else if (MessageChannel) {
|
|
1392
|
+
channel = new MessageChannel();
|
|
1393
|
+
port = channel.port2;
|
|
1394
|
+
channel.port1.onmessage = listener;
|
|
1395
|
+
defer = _ctx(port.postMessage, port, 1);
|
|
1396
|
+
} else if (_global.addEventListener && typeof postMessage == "function" && !_global.importScripts) {
|
|
1397
|
+
defer = function(id) {
|
|
1398
|
+
_global.postMessage(id + "", "*");
|
|
1399
|
+
};
|
|
1400
|
+
_global.addEventListener("message", listener, false);
|
|
1401
|
+
} else if (ONREADYSTATECHANGE in _domCreate("script")) {
|
|
1402
|
+
defer = function(id) {
|
|
1403
|
+
_html.appendChild(_domCreate("script"))[ONREADYSTATECHANGE] = function() {
|
|
1404
|
+
_html.removeChild(this);
|
|
1405
|
+
run.call(id);
|
|
1406
|
+
};
|
|
1407
|
+
};
|
|
1408
|
+
} else {
|
|
1409
|
+
defer = function(id) {
|
|
1410
|
+
setTimeout(_ctx(run, id, 1), 0);
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
var _task = {
|
|
1416
|
+
set: setTask,
|
|
1417
|
+
clear: clearTask
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1420
|
+
var macrotask = _task.set;
|
|
1421
|
+
|
|
1422
|
+
var Observer = _global.MutationObserver || _global.WebKitMutationObserver;
|
|
1423
|
+
|
|
1424
|
+
var process$1 = _global.process;
|
|
1425
|
+
|
|
1426
|
+
var Promise$1 = _global.Promise;
|
|
1427
|
+
|
|
1428
|
+
var isNode = _cof(process$1) == "process";
|
|
1429
|
+
|
|
1430
|
+
var _microtask = function() {
|
|
1431
|
+
var head, last, notify;
|
|
1432
|
+
var flush = function() {
|
|
1433
|
+
var parent, fn;
|
|
1434
|
+
if (isNode && (parent = process$1.domain)) parent.exit();
|
|
1435
|
+
while (head) {
|
|
1436
|
+
fn = head.fn;
|
|
1437
|
+
head = head.next;
|
|
1438
|
+
try {
|
|
1439
|
+
fn();
|
|
1440
|
+
} catch (e) {
|
|
1441
|
+
if (head) notify(); else last = undefined;
|
|
1442
|
+
throw e;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
last = undefined;
|
|
1446
|
+
if (parent) parent.enter();
|
|
1447
|
+
};
|
|
1448
|
+
if (isNode) {
|
|
1449
|
+
notify = function() {
|
|
1450
|
+
process$1.nextTick(flush);
|
|
1451
|
+
};
|
|
1452
|
+
} else if (Observer && !(_global.navigator && _global.navigator.standalone)) {
|
|
1453
|
+
var toggle = true;
|
|
1454
|
+
var node = document.createTextNode("");
|
|
1455
|
+
new Observer(flush).observe(node, {
|
|
1456
|
+
characterData: true
|
|
1457
|
+
});
|
|
1458
|
+
notify = function() {
|
|
1459
|
+
node.data = toggle = !toggle;
|
|
1460
|
+
};
|
|
1461
|
+
} else if (Promise$1 && Promise$1.resolve) {
|
|
1462
|
+
var promise = Promise$1.resolve(undefined);
|
|
1463
|
+
notify = function() {
|
|
1464
|
+
promise.then(flush);
|
|
1465
|
+
};
|
|
1466
|
+
} else {
|
|
1467
|
+
notify = function() {
|
|
1468
|
+
macrotask.call(_global, flush);
|
|
1469
|
+
};
|
|
1470
|
+
}
|
|
1471
|
+
return function(fn) {
|
|
1472
|
+
var task = {
|
|
1473
|
+
fn: fn,
|
|
1474
|
+
next: undefined
|
|
1475
|
+
};
|
|
1476
|
+
if (last) last.next = task;
|
|
1477
|
+
if (!head) {
|
|
1478
|
+
head = task;
|
|
1479
|
+
notify();
|
|
1480
|
+
}
|
|
1481
|
+
last = task;
|
|
1482
|
+
};
|
|
1483
|
+
};
|
|
1484
|
+
|
|
1485
|
+
function PromiseCapability(C) {
|
|
1486
|
+
var resolve, reject;
|
|
1487
|
+
this.promise = new C(function($$resolve, $$reject) {
|
|
1488
|
+
if (resolve !== undefined || reject !== undefined) throw TypeError("Bad Promise constructor");
|
|
1489
|
+
resolve = $$resolve;
|
|
1490
|
+
reject = $$reject;
|
|
1491
|
+
});
|
|
1492
|
+
this.resolve = _aFunction(resolve);
|
|
1493
|
+
this.reject = _aFunction(reject);
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
var f$4 = function(C) {
|
|
1497
|
+
return new PromiseCapability(C);
|
|
1498
|
+
};
|
|
1499
|
+
|
|
1500
|
+
var _newPromiseCapability = {
|
|
1501
|
+
f: f$4
|
|
1502
|
+
};
|
|
1503
|
+
|
|
1504
|
+
var _perform = function(exec) {
|
|
1505
|
+
try {
|
|
1506
|
+
return {
|
|
1507
|
+
e: false,
|
|
1508
|
+
v: exec()
|
|
1509
|
+
};
|
|
1510
|
+
} catch (e) {
|
|
1511
|
+
return {
|
|
1512
|
+
e: true,
|
|
1513
|
+
v: e
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
var navigator = _global.navigator;
|
|
1519
|
+
|
|
1520
|
+
var _userAgent = navigator && navigator.userAgent || "";
|
|
1521
|
+
|
|
1522
|
+
var _promiseResolve = function(C, x) {
|
|
1523
|
+
_anObject(C);
|
|
1524
|
+
if (_isObject(x) && x.constructor === C) return x;
|
|
1525
|
+
var promiseCapability = _newPromiseCapability.f(C);
|
|
1526
|
+
var resolve = promiseCapability.resolve;
|
|
1527
|
+
resolve(x);
|
|
1528
|
+
return promiseCapability.promise;
|
|
1529
|
+
};
|
|
1530
|
+
|
|
1531
|
+
var task = _task.set;
|
|
1532
|
+
|
|
1533
|
+
var microtask = _microtask();
|
|
1534
|
+
|
|
1535
|
+
var PROMISE = "Promise";
|
|
1536
|
+
|
|
1537
|
+
var TypeError$1 = _global.TypeError;
|
|
1538
|
+
|
|
1539
|
+
var process$2 = _global.process;
|
|
1540
|
+
|
|
1541
|
+
var versions = process$2 && process$2.versions;
|
|
1542
|
+
|
|
1543
|
+
var v8 = versions && versions.v8 || "";
|
|
1544
|
+
|
|
1545
|
+
var $Promise = _global[PROMISE];
|
|
1546
|
+
|
|
1547
|
+
var isNode$1 = _classof(process$2) == "process";
|
|
1548
|
+
|
|
1549
|
+
var empty = function() {};
|
|
1550
|
+
|
|
1551
|
+
var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
|
|
1552
|
+
|
|
1553
|
+
var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f;
|
|
1554
|
+
|
|
1555
|
+
var USE_NATIVE = !!function() {
|
|
1556
|
+
try {
|
|
1557
|
+
var promise = $Promise.resolve(1);
|
|
1558
|
+
var FakePromise = (promise.constructor = {})[_wks("species")] = function(exec) {
|
|
1559
|
+
exec(empty, empty);
|
|
1560
|
+
};
|
|
1561
|
+
return (isNode$1 || typeof PromiseRejectionEvent == "function") && promise.then(empty) instanceof FakePromise && v8.indexOf("6.6") !== 0 && _userAgent.indexOf("Chrome/66") === -1;
|
|
1562
|
+
} catch (e) {}
|
|
1563
|
+
}();
|
|
1564
|
+
|
|
1565
|
+
var isThenable = function(it) {
|
|
1566
|
+
var then;
|
|
1567
|
+
return _isObject(it) && typeof (then = it.then) == "function" ? then : false;
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
var notify = function(promise, isReject) {
|
|
1571
|
+
if (promise._n) return;
|
|
1572
|
+
promise._n = true;
|
|
1573
|
+
var chain = promise._c;
|
|
1574
|
+
microtask(function() {
|
|
1575
|
+
var value = promise._v;
|
|
1576
|
+
var ok = promise._s == 1;
|
|
1577
|
+
var i = 0;
|
|
1578
|
+
var run = function(reaction) {
|
|
1579
|
+
var handler = ok ? reaction.ok : reaction.fail;
|
|
1580
|
+
var resolve = reaction.resolve;
|
|
1581
|
+
var reject = reaction.reject;
|
|
1582
|
+
var domain = reaction.domain;
|
|
1583
|
+
var result, then, exited;
|
|
1584
|
+
try {
|
|
1585
|
+
if (handler) {
|
|
1586
|
+
if (!ok) {
|
|
1587
|
+
if (promise._h == 2) onHandleUnhandled(promise);
|
|
1588
|
+
promise._h = 1;
|
|
1589
|
+
}
|
|
1590
|
+
if (handler === true) result = value; else {
|
|
1591
|
+
if (domain) domain.enter();
|
|
1592
|
+
result = handler(value);
|
|
1593
|
+
if (domain) {
|
|
1594
|
+
domain.exit();
|
|
1595
|
+
exited = true;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
if (result === reaction.promise) {
|
|
1599
|
+
reject(TypeError$1("Promise-chain cycle"));
|
|
1600
|
+
} else if (then = isThenable(result)) {
|
|
1601
|
+
then.call(result, resolve, reject);
|
|
1602
|
+
} else resolve(result);
|
|
1603
|
+
} else reject(value);
|
|
1604
|
+
} catch (e) {
|
|
1605
|
+
if (domain && !exited) domain.exit();
|
|
1606
|
+
reject(e);
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
while (chain.length > i) run(chain[i++]);
|
|
1610
|
+
promise._c = [];
|
|
1611
|
+
promise._n = false;
|
|
1612
|
+
if (isReject && !promise._h) onUnhandled(promise);
|
|
1613
|
+
});
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1616
|
+
var onUnhandled = function(promise) {
|
|
1617
|
+
task.call(_global, function() {
|
|
1618
|
+
var value = promise._v;
|
|
1619
|
+
var unhandled = isUnhandled(promise);
|
|
1620
|
+
var result, handler, console;
|
|
1621
|
+
if (unhandled) {
|
|
1622
|
+
result = _perform(function() {
|
|
1623
|
+
if (isNode$1) {
|
|
1624
|
+
process$2.emit("unhandledRejection", value, promise);
|
|
1625
|
+
} else if (handler = _global.onunhandledrejection) {
|
|
1626
|
+
handler({
|
|
1627
|
+
promise: promise,
|
|
1628
|
+
reason: value
|
|
1629
|
+
});
|
|
1630
|
+
} else if ((console = _global.console) && console.error) {
|
|
1631
|
+
console.error("Unhandled promise rejection", value);
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1;
|
|
1635
|
+
}
|
|
1636
|
+
promise._a = undefined;
|
|
1637
|
+
if (unhandled && result.e) throw result.v;
|
|
1638
|
+
});
|
|
1639
|
+
};
|
|
1640
|
+
|
|
1641
|
+
var isUnhandled = function(promise) {
|
|
1642
|
+
return promise._h !== 1 && (promise._a || promise._c).length === 0;
|
|
1643
|
+
};
|
|
1644
|
+
|
|
1645
|
+
var onHandleUnhandled = function(promise) {
|
|
1646
|
+
task.call(_global, function() {
|
|
1647
|
+
var handler;
|
|
1648
|
+
if (isNode$1) {
|
|
1649
|
+
process$2.emit("rejectionHandled", promise);
|
|
1650
|
+
} else if (handler = _global.onrejectionhandled) {
|
|
1651
|
+
handler({
|
|
1652
|
+
promise: promise,
|
|
1653
|
+
reason: promise._v
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
};
|
|
1658
|
+
|
|
1659
|
+
var $reject = function(value) {
|
|
1660
|
+
var promise = this;
|
|
1661
|
+
if (promise._d) return;
|
|
1662
|
+
promise._d = true;
|
|
1663
|
+
promise = promise._w || promise;
|
|
1664
|
+
promise._v = value;
|
|
1665
|
+
promise._s = 2;
|
|
1666
|
+
if (!promise._a) promise._a = promise._c.slice();
|
|
1667
|
+
notify(promise, true);
|
|
1668
|
+
};
|
|
1669
|
+
|
|
1670
|
+
var $resolve = function(value) {
|
|
1671
|
+
var promise = this;
|
|
1672
|
+
var then;
|
|
1673
|
+
if (promise._d) return;
|
|
1674
|
+
promise._d = true;
|
|
1675
|
+
promise = promise._w || promise;
|
|
1676
|
+
try {
|
|
1677
|
+
if (promise === value) throw TypeError$1("Promise can't be resolved itself");
|
|
1678
|
+
if (then = isThenable(value)) {
|
|
1679
|
+
microtask(function() {
|
|
1680
|
+
var wrapper = {
|
|
1681
|
+
_w: promise,
|
|
1682
|
+
_d: false
|
|
1683
|
+
};
|
|
1684
|
+
try {
|
|
1685
|
+
then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1));
|
|
1686
|
+
} catch (e) {
|
|
1687
|
+
$reject.call(wrapper, e);
|
|
1688
|
+
}
|
|
1689
|
+
});
|
|
1690
|
+
} else {
|
|
1691
|
+
promise._v = value;
|
|
1692
|
+
promise._s = 1;
|
|
1693
|
+
notify(promise, false);
|
|
1694
|
+
}
|
|
1695
|
+
} catch (e) {
|
|
1696
|
+
$reject.call({
|
|
1697
|
+
_w: promise,
|
|
1698
|
+
_d: false
|
|
1699
|
+
}, e);
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1702
|
+
|
|
1703
|
+
if (!USE_NATIVE) {
|
|
1704
|
+
$Promise = function Promise(executor) {
|
|
1705
|
+
_anInstance(this, $Promise, PROMISE, "_h");
|
|
1706
|
+
_aFunction(executor);
|
|
1707
|
+
Internal.call(this);
|
|
1708
|
+
try {
|
|
1709
|
+
executor(_ctx($resolve, this, 1), _ctx($reject, this, 1));
|
|
1710
|
+
} catch (err) {
|
|
1711
|
+
$reject.call(this, err);
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
Internal = function Promise(executor) {
|
|
1715
|
+
this._c = [];
|
|
1716
|
+
this._a = undefined;
|
|
1717
|
+
this._s = 0;
|
|
1718
|
+
this._d = false;
|
|
1719
|
+
this._v = undefined;
|
|
1720
|
+
this._h = 0;
|
|
1721
|
+
this._n = false;
|
|
1722
|
+
};
|
|
1723
|
+
Internal.prototype = _redefineAll($Promise.prototype, {
|
|
1724
|
+
then: function then(onFulfilled, onRejected) {
|
|
1725
|
+
var reaction = newPromiseCapability(_speciesConstructor(this, $Promise));
|
|
1726
|
+
reaction.ok = typeof onFulfilled == "function" ? onFulfilled : true;
|
|
1727
|
+
reaction.fail = typeof onRejected == "function" && onRejected;
|
|
1728
|
+
reaction.domain = isNode$1 ? process$2.domain : undefined;
|
|
1729
|
+
this._c.push(reaction);
|
|
1730
|
+
if (this._a) this._a.push(reaction);
|
|
1731
|
+
if (this._s) notify(this, false);
|
|
1732
|
+
return reaction.promise;
|
|
1733
|
+
},
|
|
1734
|
+
catch: function(onRejected) {
|
|
1735
|
+
return this.then(undefined, onRejected);
|
|
1736
|
+
}
|
|
1737
|
+
});
|
|
1738
|
+
OwnPromiseCapability = function() {
|
|
1739
|
+
var promise = new Internal();
|
|
1740
|
+
this.promise = promise;
|
|
1741
|
+
this.resolve = _ctx($resolve, promise, 1);
|
|
1742
|
+
this.reject = _ctx($reject, promise, 1);
|
|
1743
|
+
};
|
|
1744
|
+
_newPromiseCapability.f = newPromiseCapability = function(C) {
|
|
1745
|
+
return C === $Promise || C === Wrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
_export(_export.G + _export.W + _export.F * !USE_NATIVE, {
|
|
1750
|
+
Promise: $Promise
|
|
1751
|
+
});
|
|
1752
|
+
|
|
1753
|
+
_setToStringTag($Promise, PROMISE);
|
|
1754
|
+
|
|
1755
|
+
_setSpecies(PROMISE);
|
|
1756
|
+
|
|
1757
|
+
Wrapper = _core[PROMISE];
|
|
1758
|
+
|
|
1759
|
+
_export(_export.S + _export.F * !USE_NATIVE, PROMISE, {
|
|
1760
|
+
reject: function reject(r) {
|
|
1761
|
+
var capability = newPromiseCapability(this);
|
|
1762
|
+
var $$reject = capability.reject;
|
|
1763
|
+
$$reject(r);
|
|
1764
|
+
return capability.promise;
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
|
|
1768
|
+
_export(_export.S + _export.F * !USE_NATIVE, PROMISE, {
|
|
1769
|
+
resolve: function resolve(x) {
|
|
1770
|
+
return _promiseResolve(this, x);
|
|
1771
|
+
}
|
|
1772
|
+
});
|
|
1773
|
+
|
|
1774
|
+
_export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function(iter) {
|
|
1775
|
+
$Promise.all(iter)["catch"](empty);
|
|
1776
|
+
})), PROMISE, {
|
|
1777
|
+
all: function all(iterable) {
|
|
1778
|
+
var C = this;
|
|
1779
|
+
var capability = newPromiseCapability(C);
|
|
1780
|
+
var resolve = capability.resolve;
|
|
1781
|
+
var reject = capability.reject;
|
|
1782
|
+
var result = _perform(function() {
|
|
1783
|
+
var values = [];
|
|
1784
|
+
var index = 0;
|
|
1785
|
+
var remaining = 1;
|
|
1786
|
+
_forOf(iterable, false, function(promise) {
|
|
1787
|
+
var $index = index++;
|
|
1788
|
+
var alreadyCalled = false;
|
|
1789
|
+
values.push(undefined);
|
|
1790
|
+
remaining++;
|
|
1791
|
+
C.resolve(promise).then(function(value) {
|
|
1792
|
+
if (alreadyCalled) return;
|
|
1793
|
+
alreadyCalled = true;
|
|
1794
|
+
values[$index] = value;
|
|
1795
|
+
--remaining || resolve(values);
|
|
1796
|
+
}, reject);
|
|
1797
|
+
});
|
|
1798
|
+
--remaining || resolve(values);
|
|
1799
|
+
});
|
|
1800
|
+
if (result.e) reject(result.v);
|
|
1801
|
+
return capability.promise;
|
|
1802
|
+
},
|
|
1803
|
+
race: function race(iterable) {
|
|
1804
|
+
var C = this;
|
|
1805
|
+
var capability = newPromiseCapability(C);
|
|
1806
|
+
var reject = capability.reject;
|
|
1807
|
+
var result = _perform(function() {
|
|
1808
|
+
_forOf(iterable, false, function(promise) {
|
|
1809
|
+
C.resolve(promise).then(capability.resolve, reject);
|
|
1810
|
+
});
|
|
1811
|
+
});
|
|
1812
|
+
if (result.e) reject(result.v);
|
|
1813
|
+
return capability.promise;
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
|
|
1817
|
+
_export(_export.P + _export.R, "Promise", {
|
|
1818
|
+
finally: function(onFinally) {
|
|
1819
|
+
var C = _speciesConstructor(this, _core.Promise || _global.Promise);
|
|
1820
|
+
var isFunction = typeof onFinally == "function";
|
|
1821
|
+
return this.then(isFunction ? function(x) {
|
|
1822
|
+
return _promiseResolve(C, onFinally()).then(function() {
|
|
1823
|
+
return x;
|
|
1824
|
+
});
|
|
1825
|
+
} : onFinally, isFunction ? function(e) {
|
|
1826
|
+
return _promiseResolve(C, onFinally()).then(function() {
|
|
1827
|
+
throw e;
|
|
1828
|
+
});
|
|
1829
|
+
} : onFinally);
|
|
1830
|
+
}
|
|
1831
|
+
});
|
|
1832
|
+
|
|
1833
|
+
_export(_export.S, "Promise", {
|
|
1834
|
+
try: function(callbackfn) {
|
|
1835
|
+
var promiseCapability = _newPromiseCapability.f(this);
|
|
1836
|
+
var result = _perform(callbackfn);
|
|
1837
|
+
(result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
|
|
1838
|
+
return promiseCapability.promise;
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
|
|
1842
|
+
var promise = _core.Promise;
|
|
1843
|
+
|
|
1844
|
+
var SET = "Set";
|
|
1845
|
+
|
|
1846
|
+
var es6_set = _collection(SET, function(get) {
|
|
1847
|
+
return function Set() {
|
|
1848
|
+
return get(this, arguments.length > 0 ? arguments[0] : undefined);
|
|
1849
|
+
};
|
|
1850
|
+
}, {
|
|
1851
|
+
add: function add(value) {
|
|
1852
|
+
return _collectionStrong.def(_validateCollection(this, SET), value = value === 0 ? 0 : value, value);
|
|
1853
|
+
}
|
|
1854
|
+
}, _collectionStrong);
|
|
1855
|
+
|
|
1856
|
+
_export(_export.P + _export.R, "Set", {
|
|
1857
|
+
toJSON: _collectionToJson("Set")
|
|
1858
|
+
});
|
|
1859
|
+
|
|
1860
|
+
_setCollectionOf("Set");
|
|
1861
|
+
|
|
1862
|
+
_setCollectionFrom("Set");
|
|
1863
|
+
|
|
1864
|
+
var set = _core.Set;
|
|
1865
|
+
|
|
1866
|
+
(function(ElementProto) {
|
|
1867
|
+
if (typeof ElementProto.matches !== "function") {
|
|
1868
|
+
ElementProto.matches = ElementProto.msMatchesSelector || ElementProto.mozMatchesSelector || ElementProto.webkitMatchesSelector || function matches(selector) {
|
|
1869
|
+
var element = this;
|
|
1870
|
+
var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
|
|
1871
|
+
var index = 0;
|
|
1872
|
+
while (elements[index] && elements[index] !== element) {
|
|
1873
|
+
++index;
|
|
1874
|
+
}
|
|
1875
|
+
return Boolean(elements[index]);
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
if (typeof ElementProto.closest !== "function") {
|
|
1879
|
+
ElementProto.closest = function closest(selector) {
|
|
1880
|
+
var element = this;
|
|
1881
|
+
while (element && element.nodeType === 1) {
|
|
1882
|
+
if (element.matches(selector)) {
|
|
1883
|
+
return element;
|
|
1884
|
+
}
|
|
1885
|
+
element = element.parentNode;
|
|
1886
|
+
}
|
|
1887
|
+
return null;
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1890
|
+
})(window.Element.prototype);
|
|
1891
|
+
|
|
1892
|
+
if (window.MutationObserver) {
|
|
1893
|
+
var element = document.createElement("div");
|
|
1894
|
+
element.innerHTML = "<div><div></div></div>";
|
|
1895
|
+
new MutationObserver(function(mutations, observer) {
|
|
1896
|
+
observer.disconnect();
|
|
1897
|
+
if (mutations[0] && mutations[0].type == "childList" && mutations[0].removedNodes[0].childNodes.length == 0) {
|
|
1898
|
+
var prototype = HTMLElement.prototype;
|
|
1899
|
+
var descriptor = Object.getOwnPropertyDescriptor(prototype, "innerHTML");
|
|
1900
|
+
if (descriptor && descriptor.set) {
|
|
1901
|
+
Object.defineProperty(prototype, "innerHTML", {
|
|
1902
|
+
set: function(value) {
|
|
1903
|
+
while (this.lastChild) this.removeChild(this.lastChild);
|
|
1904
|
+
descriptor.set.call(this, value);
|
|
1905
|
+
}
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
}).observe(element, {
|
|
1910
|
+
childList: true,
|
|
1911
|
+
subtree: true
|
|
1912
|
+
});
|
|
1913
|
+
element.innerHTML = "";
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
var EventListener = function() {
|
|
1917
|
+
function EventListener(eventTarget, eventName) {
|
|
1918
|
+
this.eventTarget = eventTarget;
|
|
1919
|
+
this.eventName = eventName;
|
|
1920
|
+
this.unorderedBindings = new Set();
|
|
1921
|
+
}
|
|
1922
|
+
EventListener.prototype.connect = function() {
|
|
1923
|
+
this.eventTarget.addEventListener(this.eventName, this, false);
|
|
1924
|
+
};
|
|
1925
|
+
EventListener.prototype.disconnect = function() {
|
|
1926
|
+
this.eventTarget.removeEventListener(this.eventName, this, false);
|
|
1927
|
+
};
|
|
1928
|
+
EventListener.prototype.bindingConnected = function(binding) {
|
|
1929
|
+
this.unorderedBindings.add(binding);
|
|
1930
|
+
};
|
|
1931
|
+
EventListener.prototype.bindingDisconnected = function(binding) {
|
|
1932
|
+
this.unorderedBindings.delete(binding);
|
|
1933
|
+
};
|
|
1934
|
+
EventListener.prototype.handleEvent = function(event) {
|
|
1935
|
+
var extendedEvent = extendEvent(event);
|
|
1936
|
+
for (var _i = 0, _a = this.bindings; _i < _a.length; _i++) {
|
|
1937
|
+
var binding = _a[_i];
|
|
1938
|
+
if (extendedEvent.immediatePropagationStopped) {
|
|
1939
|
+
break;
|
|
1940
|
+
} else {
|
|
1941
|
+
binding.handleEvent(extendedEvent);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
};
|
|
1945
|
+
Object.defineProperty(EventListener.prototype, "bindings", {
|
|
1946
|
+
get: function() {
|
|
1947
|
+
return Array.from(this.unorderedBindings).sort(function(left, right) {
|
|
1948
|
+
var leftIndex = left.index, rightIndex = right.index;
|
|
1949
|
+
return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0;
|
|
1950
|
+
});
|
|
1951
|
+
},
|
|
1952
|
+
enumerable: true,
|
|
1953
|
+
configurable: true
|
|
1954
|
+
});
|
|
1955
|
+
return EventListener;
|
|
1956
|
+
}();
|
|
1957
|
+
|
|
1958
|
+
function extendEvent(event) {
|
|
1959
|
+
if ("immediatePropagationStopped" in event) {
|
|
1960
|
+
return event;
|
|
1961
|
+
} else {
|
|
1962
|
+
var stopImmediatePropagation_1 = event.stopImmediatePropagation;
|
|
1963
|
+
return Object.assign(event, {
|
|
1964
|
+
immediatePropagationStopped: false,
|
|
1965
|
+
stopImmediatePropagation: function() {
|
|
1966
|
+
this.immediatePropagationStopped = true;
|
|
1967
|
+
stopImmediatePropagation_1.call(this);
|
|
1968
|
+
}
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
var Dispatcher = function() {
|
|
1974
|
+
function Dispatcher(application) {
|
|
1975
|
+
this.application = application;
|
|
1976
|
+
this.eventListenerMaps = new Map();
|
|
1977
|
+
this.started = false;
|
|
1978
|
+
}
|
|
1979
|
+
Dispatcher.prototype.start = function() {
|
|
1980
|
+
if (!this.started) {
|
|
1981
|
+
this.started = true;
|
|
1982
|
+
this.eventListeners.forEach(function(eventListener) {
|
|
1983
|
+
return eventListener.connect();
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
Dispatcher.prototype.stop = function() {
|
|
1988
|
+
if (this.started) {
|
|
1989
|
+
this.started = false;
|
|
1990
|
+
this.eventListeners.forEach(function(eventListener) {
|
|
1991
|
+
return eventListener.disconnect();
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
};
|
|
1995
|
+
Object.defineProperty(Dispatcher.prototype, "eventListeners", {
|
|
1996
|
+
get: function() {
|
|
1997
|
+
return Array.from(this.eventListenerMaps.values()).reduce(function(listeners, map) {
|
|
1998
|
+
return listeners.concat(Array.from(map.values()));
|
|
1999
|
+
}, []);
|
|
2000
|
+
},
|
|
2001
|
+
enumerable: true,
|
|
2002
|
+
configurable: true
|
|
2003
|
+
});
|
|
2004
|
+
Dispatcher.prototype.bindingConnected = function(binding) {
|
|
2005
|
+
this.fetchEventListenerForBinding(binding).bindingConnected(binding);
|
|
2006
|
+
};
|
|
2007
|
+
Dispatcher.prototype.bindingDisconnected = function(binding) {
|
|
2008
|
+
this.fetchEventListenerForBinding(binding).bindingDisconnected(binding);
|
|
2009
|
+
};
|
|
2010
|
+
Dispatcher.prototype.handleError = function(error, message, detail) {
|
|
2011
|
+
if (detail === void 0) {
|
|
2012
|
+
detail = {};
|
|
2013
|
+
}
|
|
2014
|
+
this.application.handleError(error, "Error " + message, detail);
|
|
2015
|
+
};
|
|
2016
|
+
Dispatcher.prototype.fetchEventListenerForBinding = function(binding) {
|
|
2017
|
+
var eventTarget = binding.eventTarget, eventName = binding.eventName;
|
|
2018
|
+
return this.fetchEventListener(eventTarget, eventName);
|
|
2019
|
+
};
|
|
2020
|
+
Dispatcher.prototype.fetchEventListener = function(eventTarget, eventName) {
|
|
2021
|
+
var eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget);
|
|
2022
|
+
var eventListener = eventListenerMap.get(eventName);
|
|
2023
|
+
if (!eventListener) {
|
|
2024
|
+
eventListener = this.createEventListener(eventTarget, eventName);
|
|
2025
|
+
eventListenerMap.set(eventName, eventListener);
|
|
2026
|
+
}
|
|
2027
|
+
return eventListener;
|
|
2028
|
+
};
|
|
2029
|
+
Dispatcher.prototype.createEventListener = function(eventTarget, eventName) {
|
|
2030
|
+
var eventListener = new EventListener(eventTarget, eventName);
|
|
2031
|
+
if (this.started) {
|
|
2032
|
+
eventListener.connect();
|
|
2033
|
+
}
|
|
2034
|
+
return eventListener;
|
|
2035
|
+
};
|
|
2036
|
+
Dispatcher.prototype.fetchEventListenerMapForEventTarget = function(eventTarget) {
|
|
2037
|
+
var eventListenerMap = this.eventListenerMaps.get(eventTarget);
|
|
2038
|
+
if (!eventListenerMap) {
|
|
2039
|
+
eventListenerMap = new Map();
|
|
2040
|
+
this.eventListenerMaps.set(eventTarget, eventListenerMap);
|
|
2041
|
+
}
|
|
2042
|
+
return eventListenerMap;
|
|
2043
|
+
};
|
|
2044
|
+
return Dispatcher;
|
|
2045
|
+
}();
|
|
2046
|
+
|
|
2047
|
+
var descriptorPattern = /^((.+?)(@(window|document))?->)?(.+?)(#(.+))?$/;
|
|
2048
|
+
|
|
2049
|
+
function parseDescriptorString(descriptorString) {
|
|
2050
|
+
var source = descriptorString.trim();
|
|
2051
|
+
var matches = source.match(descriptorPattern) || [];
|
|
2052
|
+
return {
|
|
2053
|
+
eventTarget: parseEventTarget(matches[4]),
|
|
2054
|
+
eventName: matches[2],
|
|
2055
|
+
identifier: matches[5],
|
|
2056
|
+
methodName: matches[7]
|
|
2057
|
+
};
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
function parseEventTarget(eventTargetName) {
|
|
2061
|
+
if (eventTargetName == "window") {
|
|
2062
|
+
return window;
|
|
2063
|
+
} else if (eventTargetName == "document") {
|
|
2064
|
+
return document;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
function stringifyEventTarget(eventTarget) {
|
|
2069
|
+
if (eventTarget == window) {
|
|
2070
|
+
return "window";
|
|
2071
|
+
} else if (eventTarget == document) {
|
|
2072
|
+
return "document";
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
var Action = function() {
|
|
2077
|
+
function Action(element, index, descriptor) {
|
|
2078
|
+
this.element = element;
|
|
2079
|
+
this.index = index;
|
|
2080
|
+
this.eventTarget = descriptor.eventTarget || element;
|
|
2081
|
+
this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name");
|
|
2082
|
+
this.identifier = descriptor.identifier || error("missing identifier");
|
|
2083
|
+
this.methodName = descriptor.methodName || error("missing method name");
|
|
2084
|
+
}
|
|
2085
|
+
Action.forToken = function(token) {
|
|
2086
|
+
return new this(token.element, token.index, parseDescriptorString(token.content));
|
|
2087
|
+
};
|
|
2088
|
+
Action.prototype.toString = function() {
|
|
2089
|
+
var eventNameSuffix = this.eventTargetName ? "@" + this.eventTargetName : "";
|
|
2090
|
+
return "" + this.eventName + eventNameSuffix + "->" + this.identifier + "#" + this.methodName;
|
|
2091
|
+
};
|
|
2092
|
+
Object.defineProperty(Action.prototype, "eventTargetName", {
|
|
2093
|
+
get: function() {
|
|
2094
|
+
return stringifyEventTarget(this.eventTarget);
|
|
2095
|
+
},
|
|
2096
|
+
enumerable: true,
|
|
2097
|
+
configurable: true
|
|
2098
|
+
});
|
|
2099
|
+
return Action;
|
|
2100
|
+
}();
|
|
2101
|
+
|
|
2102
|
+
var defaultEventNames = {
|
|
2103
|
+
a: function(e) {
|
|
2104
|
+
return "click";
|
|
2105
|
+
},
|
|
2106
|
+
button: function(e) {
|
|
2107
|
+
return "click";
|
|
2108
|
+
},
|
|
2109
|
+
form: function(e) {
|
|
2110
|
+
return "submit";
|
|
2111
|
+
},
|
|
2112
|
+
input: function(e) {
|
|
2113
|
+
return e.getAttribute("type") == "submit" ? "click" : "change";
|
|
2114
|
+
},
|
|
2115
|
+
select: function(e) {
|
|
2116
|
+
return "change";
|
|
2117
|
+
},
|
|
2118
|
+
textarea: function(e) {
|
|
2119
|
+
return "change";
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
|
|
2123
|
+
function getDefaultEventNameForElement(element) {
|
|
2124
|
+
var tagName = element.tagName.toLowerCase();
|
|
2125
|
+
if (tagName in defaultEventNames) {
|
|
2126
|
+
return defaultEventNames[tagName](element);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
function error(message) {
|
|
2131
|
+
throw new Error(message);
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
var Binding = function() {
|
|
2135
|
+
function Binding(context, action) {
|
|
2136
|
+
this.context = context;
|
|
2137
|
+
this.action = action;
|
|
2138
|
+
}
|
|
2139
|
+
Object.defineProperty(Binding.prototype, "index", {
|
|
2140
|
+
get: function() {
|
|
2141
|
+
return this.action.index;
|
|
2142
|
+
},
|
|
2143
|
+
enumerable: true,
|
|
2144
|
+
configurable: true
|
|
2145
|
+
});
|
|
2146
|
+
Object.defineProperty(Binding.prototype, "eventTarget", {
|
|
2147
|
+
get: function() {
|
|
2148
|
+
return this.action.eventTarget;
|
|
2149
|
+
},
|
|
2150
|
+
enumerable: true,
|
|
2151
|
+
configurable: true
|
|
2152
|
+
});
|
|
2153
|
+
Object.defineProperty(Binding.prototype, "identifier", {
|
|
2154
|
+
get: function() {
|
|
2155
|
+
return this.context.identifier;
|
|
2156
|
+
},
|
|
2157
|
+
enumerable: true,
|
|
2158
|
+
configurable: true
|
|
2159
|
+
});
|
|
2160
|
+
Binding.prototype.handleEvent = function(event) {
|
|
2161
|
+
if (this.willBeInvokedByEvent(event)) {
|
|
2162
|
+
this.invokeWithEvent(event);
|
|
2163
|
+
}
|
|
2164
|
+
};
|
|
2165
|
+
Object.defineProperty(Binding.prototype, "eventName", {
|
|
2166
|
+
get: function() {
|
|
2167
|
+
return this.action.eventName;
|
|
2168
|
+
},
|
|
2169
|
+
enumerable: true,
|
|
2170
|
+
configurable: true
|
|
2171
|
+
});
|
|
2172
|
+
Object.defineProperty(Binding.prototype, "method", {
|
|
2173
|
+
get: function() {
|
|
2174
|
+
var method = this.controller[this.methodName];
|
|
2175
|
+
if (typeof method == "function") {
|
|
2176
|
+
return method;
|
|
2177
|
+
}
|
|
2178
|
+
throw new Error('Action "' + this.action + '" references undefined method "' + this.methodName + '"');
|
|
2179
|
+
},
|
|
2180
|
+
enumerable: true,
|
|
2181
|
+
configurable: true
|
|
2182
|
+
});
|
|
2183
|
+
Binding.prototype.invokeWithEvent = function(event) {
|
|
2184
|
+
try {
|
|
2185
|
+
this.method.call(this.controller, event);
|
|
2186
|
+
} catch (error) {
|
|
2187
|
+
var _a = this, identifier = _a.identifier, controller = _a.controller, element = _a.element, index = _a.index;
|
|
2188
|
+
var detail = {
|
|
2189
|
+
identifier: identifier,
|
|
2190
|
+
controller: controller,
|
|
2191
|
+
element: element,
|
|
2192
|
+
index: index,
|
|
2193
|
+
event: event
|
|
2194
|
+
};
|
|
2195
|
+
this.context.handleError(error, 'invoking action "' + this.action + '"', detail);
|
|
2196
|
+
}
|
|
2197
|
+
};
|
|
2198
|
+
Binding.prototype.willBeInvokedByEvent = function(event) {
|
|
2199
|
+
var eventTarget = event.target;
|
|
2200
|
+
if (this.element === eventTarget) {
|
|
2201
|
+
return true;
|
|
2202
|
+
} else if (eventTarget instanceof Element && this.element.contains(eventTarget)) {
|
|
2203
|
+
return this.scope.containsElement(eventTarget);
|
|
2204
|
+
} else {
|
|
2205
|
+
return true;
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2208
|
+
Object.defineProperty(Binding.prototype, "controller", {
|
|
2209
|
+
get: function() {
|
|
2210
|
+
return this.context.controller;
|
|
2211
|
+
},
|
|
2212
|
+
enumerable: true,
|
|
2213
|
+
configurable: true
|
|
2214
|
+
});
|
|
2215
|
+
Object.defineProperty(Binding.prototype, "methodName", {
|
|
2216
|
+
get: function() {
|
|
2217
|
+
return this.action.methodName;
|
|
2218
|
+
},
|
|
2219
|
+
enumerable: true,
|
|
2220
|
+
configurable: true
|
|
2221
|
+
});
|
|
2222
|
+
Object.defineProperty(Binding.prototype, "element", {
|
|
2223
|
+
get: function() {
|
|
2224
|
+
return this.scope.element;
|
|
2225
|
+
},
|
|
2226
|
+
enumerable: true,
|
|
2227
|
+
configurable: true
|
|
2228
|
+
});
|
|
2229
|
+
Object.defineProperty(Binding.prototype, "scope", {
|
|
2230
|
+
get: function() {
|
|
2231
|
+
return this.context.scope;
|
|
2232
|
+
},
|
|
2233
|
+
enumerable: true,
|
|
2234
|
+
configurable: true
|
|
2235
|
+
});
|
|
2236
|
+
return Binding;
|
|
2237
|
+
}();
|
|
2238
|
+
|
|
2239
|
+
var ElementObserver = function() {
|
|
2240
|
+
function ElementObserver(element, delegate) {
|
|
2241
|
+
var _this = this;
|
|
2242
|
+
this.element = element;
|
|
2243
|
+
this.started = false;
|
|
2244
|
+
this.delegate = delegate;
|
|
2245
|
+
this.elements = new Set();
|
|
2246
|
+
this.mutationObserver = new MutationObserver(function(mutations) {
|
|
2247
|
+
return _this.processMutations(mutations);
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
ElementObserver.prototype.start = function() {
|
|
2251
|
+
if (!this.started) {
|
|
2252
|
+
this.started = true;
|
|
2253
|
+
this.mutationObserver.observe(this.element, {
|
|
2254
|
+
attributes: true,
|
|
2255
|
+
childList: true,
|
|
2256
|
+
subtree: true
|
|
2257
|
+
});
|
|
2258
|
+
this.refresh();
|
|
2259
|
+
}
|
|
2260
|
+
};
|
|
2261
|
+
ElementObserver.prototype.stop = function() {
|
|
2262
|
+
if (this.started) {
|
|
2263
|
+
this.mutationObserver.takeRecords();
|
|
2264
|
+
this.mutationObserver.disconnect();
|
|
2265
|
+
this.started = false;
|
|
2266
|
+
}
|
|
2267
|
+
};
|
|
2268
|
+
ElementObserver.prototype.refresh = function() {
|
|
2269
|
+
if (this.started) {
|
|
2270
|
+
var matches = new Set(this.matchElementsInTree());
|
|
2271
|
+
for (var _i = 0, _a = Array.from(this.elements); _i < _a.length; _i++) {
|
|
2272
|
+
var element = _a[_i];
|
|
2273
|
+
if (!matches.has(element)) {
|
|
2274
|
+
this.removeElement(element);
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
for (var _b = 0, _c = Array.from(matches); _b < _c.length; _b++) {
|
|
2278
|
+
var element = _c[_b];
|
|
2279
|
+
this.addElement(element);
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
};
|
|
2283
|
+
ElementObserver.prototype.processMutations = function(mutations) {
|
|
2284
|
+
if (this.started) {
|
|
2285
|
+
for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
|
|
2286
|
+
var mutation = mutations_1[_i];
|
|
2287
|
+
this.processMutation(mutation);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
};
|
|
2291
|
+
ElementObserver.prototype.processMutation = function(mutation) {
|
|
2292
|
+
if (mutation.type == "attributes") {
|
|
2293
|
+
this.processAttributeChange(mutation.target, mutation.attributeName);
|
|
2294
|
+
} else if (mutation.type == "childList") {
|
|
2295
|
+
this.processRemovedNodes(mutation.removedNodes);
|
|
2296
|
+
this.processAddedNodes(mutation.addedNodes);
|
|
2297
|
+
}
|
|
2298
|
+
};
|
|
2299
|
+
ElementObserver.prototype.processAttributeChange = function(node, attributeName) {
|
|
2300
|
+
var element = node;
|
|
2301
|
+
if (this.elements.has(element)) {
|
|
2302
|
+
if (this.delegate.elementAttributeChanged && this.matchElement(element)) {
|
|
2303
|
+
this.delegate.elementAttributeChanged(element, attributeName);
|
|
2304
|
+
} else {
|
|
2305
|
+
this.removeElement(element);
|
|
2306
|
+
}
|
|
2307
|
+
} else if (this.matchElement(element)) {
|
|
2308
|
+
this.addElement(element);
|
|
2309
|
+
}
|
|
2310
|
+
};
|
|
2311
|
+
ElementObserver.prototype.processRemovedNodes = function(nodes) {
|
|
2312
|
+
for (var _i = 0, _a = Array.from(nodes); _i < _a.length; _i++) {
|
|
2313
|
+
var node = _a[_i];
|
|
2314
|
+
var element = this.elementFromNode(node);
|
|
2315
|
+
if (element) {
|
|
2316
|
+
this.processTree(element, this.removeElement);
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
ElementObserver.prototype.processAddedNodes = function(nodes) {
|
|
2321
|
+
for (var _i = 0, _a = Array.from(nodes); _i < _a.length; _i++) {
|
|
2322
|
+
var node = _a[_i];
|
|
2323
|
+
var element = this.elementFromNode(node);
|
|
2324
|
+
if (element && this.elementIsActive(element)) {
|
|
2325
|
+
this.processTree(element, this.addElement);
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
};
|
|
2329
|
+
ElementObserver.prototype.matchElement = function(element) {
|
|
2330
|
+
return this.delegate.matchElement(element);
|
|
2331
|
+
};
|
|
2332
|
+
ElementObserver.prototype.matchElementsInTree = function(tree) {
|
|
2333
|
+
if (tree === void 0) {
|
|
2334
|
+
tree = this.element;
|
|
2335
|
+
}
|
|
2336
|
+
return this.delegate.matchElementsInTree(tree);
|
|
2337
|
+
};
|
|
2338
|
+
ElementObserver.prototype.processTree = function(tree, processor) {
|
|
2339
|
+
for (var _i = 0, _a = this.matchElementsInTree(tree); _i < _a.length; _i++) {
|
|
2340
|
+
var element = _a[_i];
|
|
2341
|
+
processor.call(this, element);
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2344
|
+
ElementObserver.prototype.elementFromNode = function(node) {
|
|
2345
|
+
if (node.nodeType == Node.ELEMENT_NODE) {
|
|
2346
|
+
return node;
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
ElementObserver.prototype.elementIsActive = function(element) {
|
|
2350
|
+
if (element.isConnected != this.element.isConnected) {
|
|
2351
|
+
return false;
|
|
2352
|
+
} else {
|
|
2353
|
+
return this.element.contains(element);
|
|
2354
|
+
}
|
|
2355
|
+
};
|
|
2356
|
+
ElementObserver.prototype.addElement = function(element) {
|
|
2357
|
+
if (!this.elements.has(element)) {
|
|
2358
|
+
if (this.elementIsActive(element)) {
|
|
2359
|
+
this.elements.add(element);
|
|
2360
|
+
if (this.delegate.elementMatched) {
|
|
2361
|
+
this.delegate.elementMatched(element);
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
ElementObserver.prototype.removeElement = function(element) {
|
|
2367
|
+
if (this.elements.has(element)) {
|
|
2368
|
+
this.elements.delete(element);
|
|
2369
|
+
if (this.delegate.elementUnmatched) {
|
|
2370
|
+
this.delegate.elementUnmatched(element);
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
};
|
|
2374
|
+
return ElementObserver;
|
|
2375
|
+
}();
|
|
2376
|
+
|
|
2377
|
+
var AttributeObserver = function() {
|
|
2378
|
+
function AttributeObserver(element, attributeName, delegate) {
|
|
2379
|
+
this.attributeName = attributeName;
|
|
2380
|
+
this.delegate = delegate;
|
|
2381
|
+
this.elementObserver = new ElementObserver(element, this);
|
|
2382
|
+
}
|
|
2383
|
+
Object.defineProperty(AttributeObserver.prototype, "element", {
|
|
2384
|
+
get: function() {
|
|
2385
|
+
return this.elementObserver.element;
|
|
2386
|
+
},
|
|
2387
|
+
enumerable: true,
|
|
2388
|
+
configurable: true
|
|
2389
|
+
});
|
|
2390
|
+
Object.defineProperty(AttributeObserver.prototype, "selector", {
|
|
2391
|
+
get: function() {
|
|
2392
|
+
return "[" + this.attributeName + "]";
|
|
2393
|
+
},
|
|
2394
|
+
enumerable: true,
|
|
2395
|
+
configurable: true
|
|
2396
|
+
});
|
|
2397
|
+
AttributeObserver.prototype.start = function() {
|
|
2398
|
+
this.elementObserver.start();
|
|
2399
|
+
};
|
|
2400
|
+
AttributeObserver.prototype.stop = function() {
|
|
2401
|
+
this.elementObserver.stop();
|
|
2402
|
+
};
|
|
2403
|
+
AttributeObserver.prototype.refresh = function() {
|
|
2404
|
+
this.elementObserver.refresh();
|
|
2405
|
+
};
|
|
2406
|
+
Object.defineProperty(AttributeObserver.prototype, "started", {
|
|
2407
|
+
get: function() {
|
|
2408
|
+
return this.elementObserver.started;
|
|
2409
|
+
},
|
|
2410
|
+
enumerable: true,
|
|
2411
|
+
configurable: true
|
|
2412
|
+
});
|
|
2413
|
+
AttributeObserver.prototype.matchElement = function(element) {
|
|
2414
|
+
return element.hasAttribute(this.attributeName);
|
|
2415
|
+
};
|
|
2416
|
+
AttributeObserver.prototype.matchElementsInTree = function(tree) {
|
|
2417
|
+
var match = this.matchElement(tree) ? [ tree ] : [];
|
|
2418
|
+
var matches = Array.from(tree.querySelectorAll(this.selector));
|
|
2419
|
+
return match.concat(matches);
|
|
2420
|
+
};
|
|
2421
|
+
AttributeObserver.prototype.elementMatched = function(element) {
|
|
2422
|
+
if (this.delegate.elementMatchedAttribute) {
|
|
2423
|
+
this.delegate.elementMatchedAttribute(element, this.attributeName);
|
|
2424
|
+
}
|
|
2425
|
+
};
|
|
2426
|
+
AttributeObserver.prototype.elementUnmatched = function(element) {
|
|
2427
|
+
if (this.delegate.elementUnmatchedAttribute) {
|
|
2428
|
+
this.delegate.elementUnmatchedAttribute(element, this.attributeName);
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
AttributeObserver.prototype.elementAttributeChanged = function(element, attributeName) {
|
|
2432
|
+
if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) {
|
|
2433
|
+
this.delegate.elementAttributeValueChanged(element, attributeName);
|
|
2434
|
+
}
|
|
2435
|
+
};
|
|
2436
|
+
return AttributeObserver;
|
|
2437
|
+
}();
|
|
2438
|
+
|
|
2439
|
+
function add(map, key, value) {
|
|
2440
|
+
fetch(map, key).add(value);
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
function del(map, key, value) {
|
|
2444
|
+
fetch(map, key).delete(value);
|
|
2445
|
+
prune(map, key);
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
function fetch(map, key) {
|
|
2449
|
+
var values = map.get(key);
|
|
2450
|
+
if (!values) {
|
|
2451
|
+
values = new Set();
|
|
2452
|
+
map.set(key, values);
|
|
2453
|
+
}
|
|
2454
|
+
return values;
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
function prune(map, key) {
|
|
2458
|
+
var values = map.get(key);
|
|
2459
|
+
if (values != null && values.size == 0) {
|
|
2460
|
+
map.delete(key);
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
var Multimap = function() {
|
|
2465
|
+
function Multimap() {
|
|
2466
|
+
this.valuesByKey = new Map();
|
|
2467
|
+
}
|
|
2468
|
+
Object.defineProperty(Multimap.prototype, "values", {
|
|
2469
|
+
get: function() {
|
|
2470
|
+
var sets = Array.from(this.valuesByKey.values());
|
|
2471
|
+
return sets.reduce(function(values, set) {
|
|
2472
|
+
return values.concat(Array.from(set));
|
|
2473
|
+
}, []);
|
|
2474
|
+
},
|
|
2475
|
+
enumerable: true,
|
|
2476
|
+
configurable: true
|
|
2477
|
+
});
|
|
2478
|
+
Object.defineProperty(Multimap.prototype, "size", {
|
|
2479
|
+
get: function() {
|
|
2480
|
+
var sets = Array.from(this.valuesByKey.values());
|
|
2481
|
+
return sets.reduce(function(size, set) {
|
|
2482
|
+
return size + set.size;
|
|
2483
|
+
}, 0);
|
|
2484
|
+
},
|
|
2485
|
+
enumerable: true,
|
|
2486
|
+
configurable: true
|
|
2487
|
+
});
|
|
2488
|
+
Multimap.prototype.add = function(key, value) {
|
|
2489
|
+
add(this.valuesByKey, key, value);
|
|
2490
|
+
};
|
|
2491
|
+
Multimap.prototype.delete = function(key, value) {
|
|
2492
|
+
del(this.valuesByKey, key, value);
|
|
2493
|
+
};
|
|
2494
|
+
Multimap.prototype.has = function(key, value) {
|
|
2495
|
+
var values = this.valuesByKey.get(key);
|
|
2496
|
+
return values != null && values.has(value);
|
|
2497
|
+
};
|
|
2498
|
+
Multimap.prototype.hasKey = function(key) {
|
|
2499
|
+
return this.valuesByKey.has(key);
|
|
2500
|
+
};
|
|
2501
|
+
Multimap.prototype.hasValue = function(value) {
|
|
2502
|
+
var sets = Array.from(this.valuesByKey.values());
|
|
2503
|
+
return sets.some(function(set) {
|
|
2504
|
+
return set.has(value);
|
|
2505
|
+
});
|
|
2506
|
+
};
|
|
2507
|
+
Multimap.prototype.getValuesForKey = function(key) {
|
|
2508
|
+
var values = this.valuesByKey.get(key);
|
|
2509
|
+
return values ? Array.from(values) : [];
|
|
2510
|
+
};
|
|
2511
|
+
Multimap.prototype.getKeysForValue = function(value) {
|
|
2512
|
+
return Array.from(this.valuesByKey).filter(function(_a) {
|
|
2513
|
+
var key = _a[0], values = _a[1];
|
|
2514
|
+
return values.has(value);
|
|
2515
|
+
}).map(function(_a) {
|
|
2516
|
+
var key = _a[0], values = _a[1];
|
|
2517
|
+
return key;
|
|
2518
|
+
});
|
|
2519
|
+
};
|
|
2520
|
+
return Multimap;
|
|
2521
|
+
}();
|
|
2522
|
+
|
|
2523
|
+
var __extends = window && window.__extends || function() {
|
|
2524
|
+
var extendStatics = Object.setPrototypeOf || {
|
|
2525
|
+
__proto__: []
|
|
2526
|
+
} instanceof Array && function(d, b) {
|
|
2527
|
+
d.__proto__ = b;
|
|
2528
|
+
} || function(d, b) {
|
|
2529
|
+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
2530
|
+
};
|
|
2531
|
+
return function(d, b) {
|
|
2532
|
+
extendStatics(d, b);
|
|
2533
|
+
function __() {
|
|
2534
|
+
this.constructor = d;
|
|
2535
|
+
}
|
|
2536
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2537
|
+
};
|
|
2538
|
+
}();
|
|
2539
|
+
|
|
2540
|
+
var IndexedMultimap = function(_super) {
|
|
2541
|
+
__extends(IndexedMultimap, _super);
|
|
2542
|
+
function IndexedMultimap() {
|
|
2543
|
+
var _this = _super.call(this) || this;
|
|
2544
|
+
_this.keysByValue = new Map();
|
|
2545
|
+
return _this;
|
|
2546
|
+
}
|
|
2547
|
+
Object.defineProperty(IndexedMultimap.prototype, "values", {
|
|
2548
|
+
get: function() {
|
|
2549
|
+
return Array.from(this.keysByValue.keys());
|
|
2550
|
+
},
|
|
2551
|
+
enumerable: true,
|
|
2552
|
+
configurable: true
|
|
2553
|
+
});
|
|
2554
|
+
IndexedMultimap.prototype.add = function(key, value) {
|
|
2555
|
+
_super.prototype.add.call(this, key, value);
|
|
2556
|
+
add(this.keysByValue, value, key);
|
|
2557
|
+
};
|
|
2558
|
+
IndexedMultimap.prototype.delete = function(key, value) {
|
|
2559
|
+
_super.prototype.delete.call(this, key, value);
|
|
2560
|
+
del(this.keysByValue, value, key);
|
|
2561
|
+
};
|
|
2562
|
+
IndexedMultimap.prototype.hasValue = function(value) {
|
|
2563
|
+
return this.keysByValue.has(value);
|
|
2564
|
+
};
|
|
2565
|
+
IndexedMultimap.prototype.getKeysForValue = function(value) {
|
|
2566
|
+
var set = this.keysByValue.get(value);
|
|
2567
|
+
return set ? Array.from(set) : [];
|
|
2568
|
+
};
|
|
2569
|
+
return IndexedMultimap;
|
|
2570
|
+
}(Multimap);
|
|
2571
|
+
|
|
2572
|
+
var TokenListObserver = function() {
|
|
2573
|
+
function TokenListObserver(element, attributeName, delegate) {
|
|
2574
|
+
this.attributeObserver = new AttributeObserver(element, attributeName, this);
|
|
2575
|
+
this.delegate = delegate;
|
|
2576
|
+
this.tokensByElement = new Multimap();
|
|
2577
|
+
}
|
|
2578
|
+
Object.defineProperty(TokenListObserver.prototype, "started", {
|
|
2579
|
+
get: function() {
|
|
2580
|
+
return this.attributeObserver.started;
|
|
2581
|
+
},
|
|
2582
|
+
enumerable: true,
|
|
2583
|
+
configurable: true
|
|
2584
|
+
});
|
|
2585
|
+
TokenListObserver.prototype.start = function() {
|
|
2586
|
+
this.attributeObserver.start();
|
|
2587
|
+
};
|
|
2588
|
+
TokenListObserver.prototype.stop = function() {
|
|
2589
|
+
this.attributeObserver.stop();
|
|
2590
|
+
};
|
|
2591
|
+
TokenListObserver.prototype.refresh = function() {
|
|
2592
|
+
this.attributeObserver.refresh();
|
|
2593
|
+
};
|
|
2594
|
+
Object.defineProperty(TokenListObserver.prototype, "element", {
|
|
2595
|
+
get: function() {
|
|
2596
|
+
return this.attributeObserver.element;
|
|
2597
|
+
},
|
|
2598
|
+
enumerable: true,
|
|
2599
|
+
configurable: true
|
|
2600
|
+
});
|
|
2601
|
+
Object.defineProperty(TokenListObserver.prototype, "attributeName", {
|
|
2602
|
+
get: function() {
|
|
2603
|
+
return this.attributeObserver.attributeName;
|
|
2604
|
+
},
|
|
2605
|
+
enumerable: true,
|
|
2606
|
+
configurable: true
|
|
2607
|
+
});
|
|
2608
|
+
TokenListObserver.prototype.elementMatchedAttribute = function(element) {
|
|
2609
|
+
this.tokensMatched(this.readTokensForElement(element));
|
|
2610
|
+
};
|
|
2611
|
+
TokenListObserver.prototype.elementAttributeValueChanged = function(element) {
|
|
2612
|
+
var _a = this.refreshTokensForElement(element), unmatchedTokens = _a[0], matchedTokens = _a[1];
|
|
2613
|
+
this.tokensUnmatched(unmatchedTokens);
|
|
2614
|
+
this.tokensMatched(matchedTokens);
|
|
2615
|
+
};
|
|
2616
|
+
TokenListObserver.prototype.elementUnmatchedAttribute = function(element) {
|
|
2617
|
+
this.tokensUnmatched(this.tokensByElement.getValuesForKey(element));
|
|
2618
|
+
};
|
|
2619
|
+
TokenListObserver.prototype.tokensMatched = function(tokens) {
|
|
2620
|
+
var _this = this;
|
|
2621
|
+
tokens.forEach(function(token) {
|
|
2622
|
+
return _this.tokenMatched(token);
|
|
2623
|
+
});
|
|
2624
|
+
};
|
|
2625
|
+
TokenListObserver.prototype.tokensUnmatched = function(tokens) {
|
|
2626
|
+
var _this = this;
|
|
2627
|
+
tokens.forEach(function(token) {
|
|
2628
|
+
return _this.tokenUnmatched(token);
|
|
2629
|
+
});
|
|
2630
|
+
};
|
|
2631
|
+
TokenListObserver.prototype.tokenMatched = function(token) {
|
|
2632
|
+
this.delegate.tokenMatched(token);
|
|
2633
|
+
this.tokensByElement.add(token.element, token);
|
|
2634
|
+
};
|
|
2635
|
+
TokenListObserver.prototype.tokenUnmatched = function(token) {
|
|
2636
|
+
this.delegate.tokenUnmatched(token);
|
|
2637
|
+
this.tokensByElement.delete(token.element, token);
|
|
2638
|
+
};
|
|
2639
|
+
TokenListObserver.prototype.refreshTokensForElement = function(element) {
|
|
2640
|
+
var previousTokens = this.tokensByElement.getValuesForKey(element);
|
|
2641
|
+
var currentTokens = this.readTokensForElement(element);
|
|
2642
|
+
var firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(function(_a) {
|
|
2643
|
+
var previousToken = _a[0], currentToken = _a[1];
|
|
2644
|
+
return !tokensAreEqual(previousToken, currentToken);
|
|
2645
|
+
});
|
|
2646
|
+
if (firstDifferingIndex == -1) {
|
|
2647
|
+
return [ [], [] ];
|
|
2648
|
+
} else {
|
|
2649
|
+
return [ previousTokens.slice(firstDifferingIndex), currentTokens.slice(firstDifferingIndex) ];
|
|
2650
|
+
}
|
|
2651
|
+
};
|
|
2652
|
+
TokenListObserver.prototype.readTokensForElement = function(element) {
|
|
2653
|
+
var attributeName = this.attributeName;
|
|
2654
|
+
var tokenString = element.getAttribute(attributeName) || "";
|
|
2655
|
+
return parseTokenString(tokenString, element, attributeName);
|
|
2656
|
+
};
|
|
2657
|
+
return TokenListObserver;
|
|
2658
|
+
}();
|
|
2659
|
+
|
|
2660
|
+
function parseTokenString(tokenString, element, attributeName) {
|
|
2661
|
+
return tokenString.trim().split(/\s+/).filter(function(content) {
|
|
2662
|
+
return content.length;
|
|
2663
|
+
}).map(function(content, index) {
|
|
2664
|
+
return {
|
|
2665
|
+
element: element,
|
|
2666
|
+
attributeName: attributeName,
|
|
2667
|
+
content: content,
|
|
2668
|
+
index: index
|
|
2669
|
+
};
|
|
2670
|
+
});
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
function zip(left, right) {
|
|
2674
|
+
var length = Math.max(left.length, right.length);
|
|
2675
|
+
return Array.from({
|
|
2676
|
+
length: length
|
|
2677
|
+
}, function(_, index) {
|
|
2678
|
+
return [ left[index], right[index] ];
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
function tokensAreEqual(left, right) {
|
|
2683
|
+
return left && right && left.index == right.index && left.content == right.content;
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
var ValueListObserver = function() {
|
|
2687
|
+
function ValueListObserver(element, attributeName, delegate) {
|
|
2688
|
+
this.tokenListObserver = new TokenListObserver(element, attributeName, this);
|
|
2689
|
+
this.delegate = delegate;
|
|
2690
|
+
this.parseResultsByToken = new WeakMap();
|
|
2691
|
+
this.valuesByTokenByElement = new WeakMap();
|
|
2692
|
+
}
|
|
2693
|
+
Object.defineProperty(ValueListObserver.prototype, "started", {
|
|
2694
|
+
get: function() {
|
|
2695
|
+
return this.tokenListObserver.started;
|
|
2696
|
+
},
|
|
2697
|
+
enumerable: true,
|
|
2698
|
+
configurable: true
|
|
2699
|
+
});
|
|
2700
|
+
ValueListObserver.prototype.start = function() {
|
|
2701
|
+
this.tokenListObserver.start();
|
|
2702
|
+
};
|
|
2703
|
+
ValueListObserver.prototype.stop = function() {
|
|
2704
|
+
this.tokenListObserver.stop();
|
|
2705
|
+
};
|
|
2706
|
+
ValueListObserver.prototype.refresh = function() {
|
|
2707
|
+
this.tokenListObserver.refresh();
|
|
2708
|
+
};
|
|
2709
|
+
Object.defineProperty(ValueListObserver.prototype, "element", {
|
|
2710
|
+
get: function() {
|
|
2711
|
+
return this.tokenListObserver.element;
|
|
2712
|
+
},
|
|
2713
|
+
enumerable: true,
|
|
2714
|
+
configurable: true
|
|
2715
|
+
});
|
|
2716
|
+
Object.defineProperty(ValueListObserver.prototype, "attributeName", {
|
|
2717
|
+
get: function() {
|
|
2718
|
+
return this.tokenListObserver.attributeName;
|
|
2719
|
+
},
|
|
2720
|
+
enumerable: true,
|
|
2721
|
+
configurable: true
|
|
2722
|
+
});
|
|
2723
|
+
ValueListObserver.prototype.tokenMatched = function(token) {
|
|
2724
|
+
var element = token.element;
|
|
2725
|
+
var value = this.fetchParseResultForToken(token).value;
|
|
2726
|
+
if (value) {
|
|
2727
|
+
this.fetchValuesByTokenForElement(element).set(token, value);
|
|
2728
|
+
this.delegate.elementMatchedValue(element, value);
|
|
2729
|
+
}
|
|
2730
|
+
};
|
|
2731
|
+
ValueListObserver.prototype.tokenUnmatched = function(token) {
|
|
2732
|
+
var element = token.element;
|
|
2733
|
+
var value = this.fetchParseResultForToken(token).value;
|
|
2734
|
+
if (value) {
|
|
2735
|
+
this.fetchValuesByTokenForElement(element).delete(token);
|
|
2736
|
+
this.delegate.elementUnmatchedValue(element, value);
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
ValueListObserver.prototype.fetchParseResultForToken = function(token) {
|
|
2740
|
+
var parseResult = this.parseResultsByToken.get(token);
|
|
2741
|
+
if (!parseResult) {
|
|
2742
|
+
parseResult = this.parseToken(token);
|
|
2743
|
+
this.parseResultsByToken.set(token, parseResult);
|
|
2744
|
+
}
|
|
2745
|
+
return parseResult;
|
|
2746
|
+
};
|
|
2747
|
+
ValueListObserver.prototype.fetchValuesByTokenForElement = function(element) {
|
|
2748
|
+
var valuesByToken = this.valuesByTokenByElement.get(element);
|
|
2749
|
+
if (!valuesByToken) {
|
|
2750
|
+
valuesByToken = new Map();
|
|
2751
|
+
this.valuesByTokenByElement.set(element, valuesByToken);
|
|
2752
|
+
}
|
|
2753
|
+
return valuesByToken;
|
|
2754
|
+
};
|
|
2755
|
+
ValueListObserver.prototype.parseToken = function(token) {
|
|
2756
|
+
try {
|
|
2757
|
+
var value = this.delegate.parseValueForToken(token);
|
|
2758
|
+
return {
|
|
2759
|
+
value: value
|
|
2760
|
+
};
|
|
2761
|
+
} catch (error) {
|
|
2762
|
+
return {
|
|
2763
|
+
error: error
|
|
2764
|
+
};
|
|
2765
|
+
}
|
|
2766
|
+
};
|
|
2767
|
+
return ValueListObserver;
|
|
2768
|
+
}();
|
|
2769
|
+
|
|
2770
|
+
var BindingObserver = function() {
|
|
2771
|
+
function BindingObserver(context, delegate) {
|
|
2772
|
+
this.context = context;
|
|
2773
|
+
this.delegate = delegate;
|
|
2774
|
+
this.bindingsByAction = new Map();
|
|
2775
|
+
}
|
|
2776
|
+
BindingObserver.prototype.start = function() {
|
|
2777
|
+
if (!this.valueListObserver) {
|
|
2778
|
+
this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this);
|
|
2779
|
+
this.valueListObserver.start();
|
|
2780
|
+
}
|
|
2781
|
+
};
|
|
2782
|
+
BindingObserver.prototype.stop = function() {
|
|
2783
|
+
if (this.valueListObserver) {
|
|
2784
|
+
this.valueListObserver.stop();
|
|
2785
|
+
delete this.valueListObserver;
|
|
2786
|
+
this.disconnectAllActions();
|
|
2787
|
+
}
|
|
2788
|
+
};
|
|
2789
|
+
Object.defineProperty(BindingObserver.prototype, "element", {
|
|
2790
|
+
get: function() {
|
|
2791
|
+
return this.context.element;
|
|
2792
|
+
},
|
|
2793
|
+
enumerable: true,
|
|
2794
|
+
configurable: true
|
|
2795
|
+
});
|
|
2796
|
+
Object.defineProperty(BindingObserver.prototype, "identifier", {
|
|
2797
|
+
get: function() {
|
|
2798
|
+
return this.context.identifier;
|
|
2799
|
+
},
|
|
2800
|
+
enumerable: true,
|
|
2801
|
+
configurable: true
|
|
2802
|
+
});
|
|
2803
|
+
Object.defineProperty(BindingObserver.prototype, "actionAttribute", {
|
|
2804
|
+
get: function() {
|
|
2805
|
+
return this.schema.actionAttribute;
|
|
2806
|
+
},
|
|
2807
|
+
enumerable: true,
|
|
2808
|
+
configurable: true
|
|
2809
|
+
});
|
|
2810
|
+
Object.defineProperty(BindingObserver.prototype, "schema", {
|
|
2811
|
+
get: function() {
|
|
2812
|
+
return this.context.schema;
|
|
2813
|
+
},
|
|
2814
|
+
enumerable: true,
|
|
2815
|
+
configurable: true
|
|
2816
|
+
});
|
|
2817
|
+
Object.defineProperty(BindingObserver.prototype, "bindings", {
|
|
2818
|
+
get: function() {
|
|
2819
|
+
return Array.from(this.bindingsByAction.values());
|
|
2820
|
+
},
|
|
2821
|
+
enumerable: true,
|
|
2822
|
+
configurable: true
|
|
2823
|
+
});
|
|
2824
|
+
BindingObserver.prototype.connectAction = function(action) {
|
|
2825
|
+
var binding = new Binding(this.context, action);
|
|
2826
|
+
this.bindingsByAction.set(action, binding);
|
|
2827
|
+
this.delegate.bindingConnected(binding);
|
|
2828
|
+
};
|
|
2829
|
+
BindingObserver.prototype.disconnectAction = function(action) {
|
|
2830
|
+
var binding = this.bindingsByAction.get(action);
|
|
2831
|
+
if (binding) {
|
|
2832
|
+
this.bindingsByAction.delete(action);
|
|
2833
|
+
this.delegate.bindingDisconnected(binding);
|
|
2834
|
+
}
|
|
2835
|
+
};
|
|
2836
|
+
BindingObserver.prototype.disconnectAllActions = function() {
|
|
2837
|
+
var _this = this;
|
|
2838
|
+
this.bindings.forEach(function(binding) {
|
|
2839
|
+
return _this.delegate.bindingDisconnected(binding);
|
|
2840
|
+
});
|
|
2841
|
+
this.bindingsByAction.clear();
|
|
2842
|
+
};
|
|
2843
|
+
BindingObserver.prototype.parseValueForToken = function(token) {
|
|
2844
|
+
var action = Action.forToken(token);
|
|
2845
|
+
if (action.identifier == this.identifier) {
|
|
2846
|
+
return action;
|
|
2847
|
+
}
|
|
2848
|
+
};
|
|
2849
|
+
BindingObserver.prototype.elementMatchedValue = function(element, action) {
|
|
2850
|
+
this.connectAction(action);
|
|
2851
|
+
};
|
|
2852
|
+
BindingObserver.prototype.elementUnmatchedValue = function(element, action) {
|
|
2853
|
+
this.disconnectAction(action);
|
|
2854
|
+
};
|
|
2855
|
+
return BindingObserver;
|
|
2856
|
+
}();
|
|
2857
|
+
|
|
2858
|
+
var Context = function() {
|
|
2859
|
+
function Context(module, scope) {
|
|
2860
|
+
this.module = module;
|
|
2861
|
+
this.scope = scope;
|
|
2862
|
+
this.controller = new module.controllerConstructor(this);
|
|
2863
|
+
this.bindingObserver = new BindingObserver(this, this.dispatcher);
|
|
2864
|
+
try {
|
|
2865
|
+
this.controller.initialize();
|
|
2866
|
+
} catch (error) {
|
|
2867
|
+
this.handleError(error, "initializing controller");
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
Context.prototype.connect = function() {
|
|
2871
|
+
this.bindingObserver.start();
|
|
2872
|
+
try {
|
|
2873
|
+
this.controller.connect();
|
|
2874
|
+
} catch (error) {
|
|
2875
|
+
this.handleError(error, "connecting controller");
|
|
2876
|
+
}
|
|
2877
|
+
};
|
|
2878
|
+
Context.prototype.disconnect = function() {
|
|
2879
|
+
try {
|
|
2880
|
+
this.controller.disconnect();
|
|
2881
|
+
} catch (error) {
|
|
2882
|
+
this.handleError(error, "disconnecting controller");
|
|
2883
|
+
}
|
|
2884
|
+
this.bindingObserver.stop();
|
|
2885
|
+
};
|
|
2886
|
+
Object.defineProperty(Context.prototype, "application", {
|
|
2887
|
+
get: function() {
|
|
2888
|
+
return this.module.application;
|
|
2889
|
+
},
|
|
2890
|
+
enumerable: true,
|
|
2891
|
+
configurable: true
|
|
2892
|
+
});
|
|
2893
|
+
Object.defineProperty(Context.prototype, "identifier", {
|
|
2894
|
+
get: function() {
|
|
2895
|
+
return this.module.identifier;
|
|
2896
|
+
},
|
|
2897
|
+
enumerable: true,
|
|
2898
|
+
configurable: true
|
|
2899
|
+
});
|
|
2900
|
+
Object.defineProperty(Context.prototype, "schema", {
|
|
2901
|
+
get: function() {
|
|
2902
|
+
return this.application.schema;
|
|
2903
|
+
},
|
|
2904
|
+
enumerable: true,
|
|
2905
|
+
configurable: true
|
|
2906
|
+
});
|
|
2907
|
+
Object.defineProperty(Context.prototype, "dispatcher", {
|
|
2908
|
+
get: function() {
|
|
2909
|
+
return this.application.dispatcher;
|
|
2910
|
+
},
|
|
2911
|
+
enumerable: true,
|
|
2912
|
+
configurable: true
|
|
2913
|
+
});
|
|
2914
|
+
Object.defineProperty(Context.prototype, "element", {
|
|
2915
|
+
get: function() {
|
|
2916
|
+
return this.scope.element;
|
|
2917
|
+
},
|
|
2918
|
+
enumerable: true,
|
|
2919
|
+
configurable: true
|
|
2920
|
+
});
|
|
2921
|
+
Object.defineProperty(Context.prototype, "parentElement", {
|
|
2922
|
+
get: function() {
|
|
2923
|
+
return this.element.parentElement;
|
|
2924
|
+
},
|
|
2925
|
+
enumerable: true,
|
|
2926
|
+
configurable: true
|
|
2927
|
+
});
|
|
2928
|
+
Context.prototype.handleError = function(error, message, detail) {
|
|
2929
|
+
if (detail === void 0) {
|
|
2930
|
+
detail = {};
|
|
2931
|
+
}
|
|
2932
|
+
var _a = this, identifier = _a.identifier, controller = _a.controller, element = _a.element;
|
|
2933
|
+
detail = Object.assign({
|
|
2934
|
+
identifier: identifier,
|
|
2935
|
+
controller: controller,
|
|
2936
|
+
element: element
|
|
2937
|
+
}, detail);
|
|
2938
|
+
this.application.handleError(error, "Error " + message, detail);
|
|
2939
|
+
};
|
|
2940
|
+
return Context;
|
|
2941
|
+
}();
|
|
2942
|
+
|
|
2943
|
+
var __extends$1 = window && window.__extends || function() {
|
|
2944
|
+
var extendStatics = Object.setPrototypeOf || {
|
|
2945
|
+
__proto__: []
|
|
2946
|
+
} instanceof Array && function(d, b) {
|
|
2947
|
+
d.__proto__ = b;
|
|
2948
|
+
} || function(d, b) {
|
|
2949
|
+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
2950
|
+
};
|
|
2951
|
+
return function(d, b) {
|
|
2952
|
+
extendStatics(d, b);
|
|
2953
|
+
function __() {
|
|
2954
|
+
this.constructor = d;
|
|
2955
|
+
}
|
|
2956
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2957
|
+
};
|
|
2958
|
+
}();
|
|
2959
|
+
|
|
2960
|
+
function blessDefinition(definition) {
|
|
2961
|
+
return {
|
|
2962
|
+
identifier: definition.identifier,
|
|
2963
|
+
controllerConstructor: blessControllerConstructor(definition.controllerConstructor)
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
function blessControllerConstructor(controllerConstructor) {
|
|
2968
|
+
var constructor = extend(controllerConstructor);
|
|
2969
|
+
constructor.bless();
|
|
2970
|
+
return constructor;
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2973
|
+
var extend = function() {
|
|
2974
|
+
function extendWithReflect(constructor) {
|
|
2975
|
+
function Controller() {
|
|
2976
|
+
var _newTarget = this && this instanceof Controller ? this.constructor : void 0;
|
|
2977
|
+
return Reflect.construct(constructor, arguments, _newTarget);
|
|
2978
|
+
}
|
|
2979
|
+
Controller.prototype = Object.create(constructor.prototype, {
|
|
2980
|
+
constructor: {
|
|
2981
|
+
value: Controller
|
|
2982
|
+
}
|
|
2983
|
+
});
|
|
2984
|
+
Reflect.setPrototypeOf(Controller, constructor);
|
|
2985
|
+
return Controller;
|
|
2986
|
+
}
|
|
2987
|
+
function testReflectExtension() {
|
|
2988
|
+
var a = function() {
|
|
2989
|
+
this.a.call(this);
|
|
2990
|
+
};
|
|
2991
|
+
var b = extendWithReflect(a);
|
|
2992
|
+
b.prototype.a = function() {};
|
|
2993
|
+
return new b();
|
|
2994
|
+
}
|
|
2995
|
+
try {
|
|
2996
|
+
testReflectExtension();
|
|
2997
|
+
return extendWithReflect;
|
|
2998
|
+
} catch (error) {
|
|
2999
|
+
return function(constructor) {
|
|
3000
|
+
return function(_super) {
|
|
3001
|
+
__extends$1(Controller, _super);
|
|
3002
|
+
function Controller() {
|
|
3003
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3004
|
+
}
|
|
3005
|
+
return Controller;
|
|
3006
|
+
}(constructor);
|
|
3007
|
+
};
|
|
3008
|
+
}
|
|
3009
|
+
}();
|
|
3010
|
+
|
|
3011
|
+
var Module = function() {
|
|
3012
|
+
function Module(application, definition) {
|
|
3013
|
+
this.application = application;
|
|
3014
|
+
this.definition = blessDefinition(definition);
|
|
3015
|
+
this.contextsByScope = new WeakMap();
|
|
3016
|
+
this.connectedContexts = new Set();
|
|
3017
|
+
}
|
|
3018
|
+
Object.defineProperty(Module.prototype, "identifier", {
|
|
3019
|
+
get: function() {
|
|
3020
|
+
return this.definition.identifier;
|
|
3021
|
+
},
|
|
3022
|
+
enumerable: true,
|
|
3023
|
+
configurable: true
|
|
3024
|
+
});
|
|
3025
|
+
Object.defineProperty(Module.prototype, "controllerConstructor", {
|
|
3026
|
+
get: function() {
|
|
3027
|
+
return this.definition.controllerConstructor;
|
|
3028
|
+
},
|
|
3029
|
+
enumerable: true,
|
|
3030
|
+
configurable: true
|
|
3031
|
+
});
|
|
3032
|
+
Object.defineProperty(Module.prototype, "contexts", {
|
|
3033
|
+
get: function() {
|
|
3034
|
+
return Array.from(this.connectedContexts);
|
|
3035
|
+
},
|
|
3036
|
+
enumerable: true,
|
|
3037
|
+
configurable: true
|
|
3038
|
+
});
|
|
3039
|
+
Module.prototype.connectContextForScope = function(scope) {
|
|
3040
|
+
var context = this.fetchContextForScope(scope);
|
|
3041
|
+
this.connectedContexts.add(context);
|
|
3042
|
+
context.connect();
|
|
3043
|
+
};
|
|
3044
|
+
Module.prototype.disconnectContextForScope = function(scope) {
|
|
3045
|
+
var context = this.contextsByScope.get(scope);
|
|
3046
|
+
if (context) {
|
|
3047
|
+
this.connectedContexts.delete(context);
|
|
3048
|
+
context.disconnect();
|
|
3049
|
+
}
|
|
3050
|
+
};
|
|
3051
|
+
Module.prototype.fetchContextForScope = function(scope) {
|
|
3052
|
+
var context = this.contextsByScope.get(scope);
|
|
3053
|
+
if (!context) {
|
|
3054
|
+
context = new Context(this, scope);
|
|
3055
|
+
this.contextsByScope.set(scope, context);
|
|
3056
|
+
}
|
|
3057
|
+
return context;
|
|
3058
|
+
};
|
|
3059
|
+
return Module;
|
|
3060
|
+
}();
|
|
3061
|
+
|
|
3062
|
+
var DataMap = function() {
|
|
3063
|
+
function DataMap(scope) {
|
|
3064
|
+
this.scope = scope;
|
|
3065
|
+
}
|
|
3066
|
+
Object.defineProperty(DataMap.prototype, "element", {
|
|
3067
|
+
get: function() {
|
|
3068
|
+
return this.scope.element;
|
|
3069
|
+
},
|
|
3070
|
+
enumerable: true,
|
|
3071
|
+
configurable: true
|
|
3072
|
+
});
|
|
3073
|
+
Object.defineProperty(DataMap.prototype, "identifier", {
|
|
3074
|
+
get: function() {
|
|
3075
|
+
return this.scope.identifier;
|
|
3076
|
+
},
|
|
3077
|
+
enumerable: true,
|
|
3078
|
+
configurable: true
|
|
3079
|
+
});
|
|
3080
|
+
DataMap.prototype.get = function(key) {
|
|
3081
|
+
key = this.getFormattedKey(key);
|
|
3082
|
+
return this.element.getAttribute(key);
|
|
3083
|
+
};
|
|
3084
|
+
DataMap.prototype.set = function(key, value) {
|
|
3085
|
+
key = this.getFormattedKey(key);
|
|
3086
|
+
this.element.setAttribute(key, value);
|
|
3087
|
+
return this.get(key);
|
|
3088
|
+
};
|
|
3089
|
+
DataMap.prototype.has = function(key) {
|
|
3090
|
+
key = this.getFormattedKey(key);
|
|
3091
|
+
return this.element.hasAttribute(key);
|
|
3092
|
+
};
|
|
3093
|
+
DataMap.prototype.delete = function(key) {
|
|
3094
|
+
if (this.has(key)) {
|
|
3095
|
+
key = this.getFormattedKey(key);
|
|
3096
|
+
this.element.removeAttribute(key);
|
|
3097
|
+
return true;
|
|
3098
|
+
} else {
|
|
3099
|
+
return false;
|
|
3100
|
+
}
|
|
3101
|
+
};
|
|
3102
|
+
DataMap.prototype.getFormattedKey = function(key) {
|
|
3103
|
+
return "data-" + this.identifier + "-" + dasherize(key);
|
|
3104
|
+
};
|
|
3105
|
+
return DataMap;
|
|
3106
|
+
}();
|
|
3107
|
+
|
|
3108
|
+
function dasherize(value) {
|
|
3109
|
+
return value.replace(/([A-Z])/g, function(_, char) {
|
|
3110
|
+
return "-" + char.toLowerCase();
|
|
3111
|
+
});
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
function attributeValueContainsToken(attributeName, token) {
|
|
3115
|
+
return "[" + attributeName + '~="' + token + '"]';
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3118
|
+
var TargetSet = function() {
|
|
3119
|
+
function TargetSet(scope) {
|
|
3120
|
+
this.scope = scope;
|
|
3121
|
+
}
|
|
3122
|
+
Object.defineProperty(TargetSet.prototype, "element", {
|
|
3123
|
+
get: function() {
|
|
3124
|
+
return this.scope.element;
|
|
3125
|
+
},
|
|
3126
|
+
enumerable: true,
|
|
3127
|
+
configurable: true
|
|
3128
|
+
});
|
|
3129
|
+
Object.defineProperty(TargetSet.prototype, "identifier", {
|
|
3130
|
+
get: function() {
|
|
3131
|
+
return this.scope.identifier;
|
|
3132
|
+
},
|
|
3133
|
+
enumerable: true,
|
|
3134
|
+
configurable: true
|
|
3135
|
+
});
|
|
3136
|
+
Object.defineProperty(TargetSet.prototype, "schema", {
|
|
3137
|
+
get: function() {
|
|
3138
|
+
return this.scope.schema;
|
|
3139
|
+
},
|
|
3140
|
+
enumerable: true,
|
|
3141
|
+
configurable: true
|
|
3142
|
+
});
|
|
3143
|
+
TargetSet.prototype.has = function(targetName) {
|
|
3144
|
+
return this.find(targetName) != null;
|
|
3145
|
+
};
|
|
3146
|
+
TargetSet.prototype.find = function() {
|
|
3147
|
+
var targetNames = [];
|
|
3148
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3149
|
+
targetNames[_i] = arguments[_i];
|
|
3150
|
+
}
|
|
3151
|
+
var selector = this.getSelectorForTargetNames(targetNames);
|
|
3152
|
+
return this.scope.findElement(selector);
|
|
3153
|
+
};
|
|
3154
|
+
TargetSet.prototype.findAll = function() {
|
|
3155
|
+
var targetNames = [];
|
|
3156
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3157
|
+
targetNames[_i] = arguments[_i];
|
|
3158
|
+
}
|
|
3159
|
+
var selector = this.getSelectorForTargetNames(targetNames);
|
|
3160
|
+
return this.scope.findAllElements(selector);
|
|
3161
|
+
};
|
|
3162
|
+
TargetSet.prototype.getSelectorForTargetNames = function(targetNames) {
|
|
3163
|
+
var _this = this;
|
|
3164
|
+
return targetNames.map(function(targetName) {
|
|
3165
|
+
return _this.getSelectorForTargetName(targetName);
|
|
3166
|
+
}).join(", ");
|
|
3167
|
+
};
|
|
3168
|
+
TargetSet.prototype.getSelectorForTargetName = function(targetName) {
|
|
3169
|
+
var targetDescriptor = this.identifier + "." + targetName;
|
|
3170
|
+
return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor);
|
|
3171
|
+
};
|
|
3172
|
+
return TargetSet;
|
|
3173
|
+
}();
|
|
3174
|
+
|
|
3175
|
+
var Scope = function() {
|
|
3176
|
+
function Scope(schema, identifier, element) {
|
|
3177
|
+
this.schema = schema;
|
|
3178
|
+
this.identifier = identifier;
|
|
3179
|
+
this.element = element;
|
|
3180
|
+
this.targets = new TargetSet(this);
|
|
3181
|
+
this.data = new DataMap(this);
|
|
3182
|
+
}
|
|
3183
|
+
Scope.prototype.findElement = function(selector) {
|
|
3184
|
+
return this.findAllElements(selector)[0];
|
|
3185
|
+
};
|
|
3186
|
+
Scope.prototype.findAllElements = function(selector) {
|
|
3187
|
+
var head = this.element.matches(selector) ? [ this.element ] : [];
|
|
3188
|
+
var tail = this.filterElements(Array.from(this.element.querySelectorAll(selector)));
|
|
3189
|
+
return head.concat(tail);
|
|
3190
|
+
};
|
|
3191
|
+
Scope.prototype.filterElements = function(elements) {
|
|
3192
|
+
var _this = this;
|
|
3193
|
+
return elements.filter(function(element) {
|
|
3194
|
+
return _this.containsElement(element);
|
|
3195
|
+
});
|
|
3196
|
+
};
|
|
3197
|
+
Scope.prototype.containsElement = function(element) {
|
|
3198
|
+
return element.closest(this.controllerSelector) === this.element;
|
|
3199
|
+
};
|
|
3200
|
+
Object.defineProperty(Scope.prototype, "controllerSelector", {
|
|
3201
|
+
get: function() {
|
|
3202
|
+
return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier);
|
|
3203
|
+
},
|
|
3204
|
+
enumerable: true,
|
|
3205
|
+
configurable: true
|
|
3206
|
+
});
|
|
3207
|
+
return Scope;
|
|
3208
|
+
}();
|
|
3209
|
+
|
|
3210
|
+
var ScopeObserver = function() {
|
|
3211
|
+
function ScopeObserver(element, schema, delegate) {
|
|
3212
|
+
this.element = element;
|
|
3213
|
+
this.schema = schema;
|
|
3214
|
+
this.delegate = delegate;
|
|
3215
|
+
this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this);
|
|
3216
|
+
this.scopesByIdentifierByElement = new WeakMap();
|
|
3217
|
+
this.scopeReferenceCounts = new WeakMap();
|
|
3218
|
+
}
|
|
3219
|
+
ScopeObserver.prototype.start = function() {
|
|
3220
|
+
this.valueListObserver.start();
|
|
3221
|
+
};
|
|
3222
|
+
ScopeObserver.prototype.stop = function() {
|
|
3223
|
+
this.valueListObserver.stop();
|
|
3224
|
+
};
|
|
3225
|
+
Object.defineProperty(ScopeObserver.prototype, "controllerAttribute", {
|
|
3226
|
+
get: function() {
|
|
3227
|
+
return this.schema.controllerAttribute;
|
|
3228
|
+
},
|
|
3229
|
+
enumerable: true,
|
|
3230
|
+
configurable: true
|
|
3231
|
+
});
|
|
3232
|
+
ScopeObserver.prototype.parseValueForToken = function(token) {
|
|
3233
|
+
var element = token.element, identifier = token.content;
|
|
3234
|
+
var scopesByIdentifier = this.fetchScopesByIdentifierForElement(element);
|
|
3235
|
+
var scope = scopesByIdentifier.get(identifier);
|
|
3236
|
+
if (!scope) {
|
|
3237
|
+
scope = new Scope(this.schema, identifier, element);
|
|
3238
|
+
scopesByIdentifier.set(identifier, scope);
|
|
3239
|
+
}
|
|
3240
|
+
return scope;
|
|
3241
|
+
};
|
|
3242
|
+
ScopeObserver.prototype.elementMatchedValue = function(element, value) {
|
|
3243
|
+
var referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1;
|
|
3244
|
+
this.scopeReferenceCounts.set(value, referenceCount);
|
|
3245
|
+
if (referenceCount == 1) {
|
|
3246
|
+
this.delegate.scopeConnected(value);
|
|
3247
|
+
}
|
|
3248
|
+
};
|
|
3249
|
+
ScopeObserver.prototype.elementUnmatchedValue = function(element, value) {
|
|
3250
|
+
var referenceCount = this.scopeReferenceCounts.get(value);
|
|
3251
|
+
if (referenceCount) {
|
|
3252
|
+
this.scopeReferenceCounts.set(value, referenceCount - 1);
|
|
3253
|
+
if (referenceCount == 1) {
|
|
3254
|
+
this.delegate.scopeDisconnected(value);
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
};
|
|
3258
|
+
ScopeObserver.prototype.fetchScopesByIdentifierForElement = function(element) {
|
|
3259
|
+
var scopesByIdentifier = this.scopesByIdentifierByElement.get(element);
|
|
3260
|
+
if (!scopesByIdentifier) {
|
|
3261
|
+
scopesByIdentifier = new Map();
|
|
3262
|
+
this.scopesByIdentifierByElement.set(element, scopesByIdentifier);
|
|
3263
|
+
}
|
|
3264
|
+
return scopesByIdentifier;
|
|
3265
|
+
};
|
|
3266
|
+
return ScopeObserver;
|
|
3267
|
+
}();
|
|
3268
|
+
|
|
3269
|
+
var Router = function() {
|
|
3270
|
+
function Router(application) {
|
|
3271
|
+
this.application = application;
|
|
3272
|
+
this.scopeObserver = new ScopeObserver(this.element, this.schema, this);
|
|
3273
|
+
this.scopesByIdentifier = new Multimap();
|
|
3274
|
+
this.modulesByIdentifier = new Map();
|
|
3275
|
+
}
|
|
3276
|
+
Object.defineProperty(Router.prototype, "element", {
|
|
3277
|
+
get: function() {
|
|
3278
|
+
return this.application.element;
|
|
3279
|
+
},
|
|
3280
|
+
enumerable: true,
|
|
3281
|
+
configurable: true
|
|
3282
|
+
});
|
|
3283
|
+
Object.defineProperty(Router.prototype, "schema", {
|
|
3284
|
+
get: function() {
|
|
3285
|
+
return this.application.schema;
|
|
3286
|
+
},
|
|
3287
|
+
enumerable: true,
|
|
3288
|
+
configurable: true
|
|
3289
|
+
});
|
|
3290
|
+
Object.defineProperty(Router.prototype, "controllerAttribute", {
|
|
3291
|
+
get: function() {
|
|
3292
|
+
return this.schema.controllerAttribute;
|
|
3293
|
+
},
|
|
3294
|
+
enumerable: true,
|
|
3295
|
+
configurable: true
|
|
3296
|
+
});
|
|
3297
|
+
Object.defineProperty(Router.prototype, "modules", {
|
|
3298
|
+
get: function() {
|
|
3299
|
+
return Array.from(this.modulesByIdentifier.values());
|
|
3300
|
+
},
|
|
3301
|
+
enumerable: true,
|
|
3302
|
+
configurable: true
|
|
3303
|
+
});
|
|
3304
|
+
Object.defineProperty(Router.prototype, "contexts", {
|
|
3305
|
+
get: function() {
|
|
3306
|
+
return this.modules.reduce(function(contexts, module) {
|
|
3307
|
+
return contexts.concat(module.contexts);
|
|
3308
|
+
}, []);
|
|
3309
|
+
},
|
|
3310
|
+
enumerable: true,
|
|
3311
|
+
configurable: true
|
|
3312
|
+
});
|
|
3313
|
+
Router.prototype.start = function() {
|
|
3314
|
+
this.scopeObserver.start();
|
|
3315
|
+
};
|
|
3316
|
+
Router.prototype.stop = function() {
|
|
3317
|
+
this.scopeObserver.stop();
|
|
3318
|
+
};
|
|
3319
|
+
Router.prototype.loadDefinition = function(definition) {
|
|
3320
|
+
this.unloadIdentifier(definition.identifier);
|
|
3321
|
+
var module = new Module(this.application, definition);
|
|
3322
|
+
this.connectModule(module);
|
|
3323
|
+
};
|
|
3324
|
+
Router.prototype.unloadIdentifier = function(identifier) {
|
|
3325
|
+
var module = this.modulesByIdentifier.get(identifier);
|
|
3326
|
+
if (module) {
|
|
3327
|
+
this.disconnectModule(module);
|
|
3328
|
+
}
|
|
3329
|
+
};
|
|
3330
|
+
Router.prototype.getContextForElementAndIdentifier = function(element, identifier) {
|
|
3331
|
+
var module = this.modulesByIdentifier.get(identifier);
|
|
3332
|
+
if (module) {
|
|
3333
|
+
return module.contexts.find(function(context) {
|
|
3334
|
+
return context.element == element;
|
|
3335
|
+
});
|
|
3336
|
+
}
|
|
3337
|
+
};
|
|
3338
|
+
Router.prototype.handleError = function(error, message, detail) {
|
|
3339
|
+
this.application.handleError(error, message, detail);
|
|
3340
|
+
};
|
|
3341
|
+
Router.prototype.scopeConnected = function(scope) {
|
|
3342
|
+
this.scopesByIdentifier.add(scope.identifier, scope);
|
|
3343
|
+
var module = this.modulesByIdentifier.get(scope.identifier);
|
|
3344
|
+
if (module) {
|
|
3345
|
+
module.connectContextForScope(scope);
|
|
3346
|
+
}
|
|
3347
|
+
};
|
|
3348
|
+
Router.prototype.scopeDisconnected = function(scope) {
|
|
3349
|
+
this.scopesByIdentifier.delete(scope.identifier, scope);
|
|
3350
|
+
var module = this.modulesByIdentifier.get(scope.identifier);
|
|
3351
|
+
if (module) {
|
|
3352
|
+
module.disconnectContextForScope(scope);
|
|
3353
|
+
}
|
|
3354
|
+
};
|
|
3355
|
+
Router.prototype.connectModule = function(module) {
|
|
3356
|
+
this.modulesByIdentifier.set(module.identifier, module);
|
|
3357
|
+
var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier);
|
|
3358
|
+
scopes.forEach(function(scope) {
|
|
3359
|
+
return module.connectContextForScope(scope);
|
|
3360
|
+
});
|
|
3361
|
+
};
|
|
3362
|
+
Router.prototype.disconnectModule = function(module) {
|
|
3363
|
+
this.modulesByIdentifier.delete(module.identifier);
|
|
3364
|
+
var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier);
|
|
3365
|
+
scopes.forEach(function(scope) {
|
|
3366
|
+
return module.disconnectContextForScope(scope);
|
|
3367
|
+
});
|
|
3368
|
+
};
|
|
3369
|
+
return Router;
|
|
3370
|
+
}();
|
|
3371
|
+
|
|
3372
|
+
var defaultSchema = {
|
|
3373
|
+
controllerAttribute: "data-controller",
|
|
3374
|
+
actionAttribute: "data-action",
|
|
3375
|
+
targetAttribute: "data-target"
|
|
3376
|
+
};
|
|
3377
|
+
|
|
3378
|
+
var __awaiter = window && window.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
3379
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
3380
|
+
function fulfilled(value) {
|
|
3381
|
+
try {
|
|
3382
|
+
step(generator.next(value));
|
|
3383
|
+
} catch (e) {
|
|
3384
|
+
reject(e);
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
function rejected(value) {
|
|
3388
|
+
try {
|
|
3389
|
+
step(generator["throw"](value));
|
|
3390
|
+
} catch (e) {
|
|
3391
|
+
reject(e);
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
function step(result) {
|
|
3395
|
+
result.done ? resolve(result.value) : new P(function(resolve) {
|
|
3396
|
+
resolve(result.value);
|
|
3397
|
+
}).then(fulfilled, rejected);
|
|
3398
|
+
}
|
|
3399
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
3400
|
+
});
|
|
3401
|
+
};
|
|
3402
|
+
|
|
3403
|
+
var __generator = window && window.__generator || function(thisArg, body) {
|
|
3404
|
+
var _ = {
|
|
3405
|
+
label: 0,
|
|
3406
|
+
sent: function() {
|
|
3407
|
+
if (t[0] & 1) throw t[1];
|
|
3408
|
+
return t[1];
|
|
3409
|
+
},
|
|
3410
|
+
trys: [],
|
|
3411
|
+
ops: []
|
|
3412
|
+
}, f, y, t, g;
|
|
3413
|
+
return g = {
|
|
3414
|
+
next: verb(0),
|
|
3415
|
+
throw: verb(1),
|
|
3416
|
+
return: verb(2)
|
|
3417
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
3418
|
+
return this;
|
|
3419
|
+
}), g;
|
|
3420
|
+
function verb(n) {
|
|
3421
|
+
return function(v) {
|
|
3422
|
+
return step([ n, v ]);
|
|
3423
|
+
};
|
|
3424
|
+
}
|
|
3425
|
+
function step(op) {
|
|
3426
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
3427
|
+
while (_) try {
|
|
3428
|
+
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
|
3429
|
+
if (y = 0, t) op = [ 0, t.value ];
|
|
3430
|
+
switch (op[0]) {
|
|
3431
|
+
case 0:
|
|
3432
|
+
case 1:
|
|
3433
|
+
t = op;
|
|
3434
|
+
break;
|
|
3435
|
+
|
|
3436
|
+
case 4:
|
|
3437
|
+
_.label++;
|
|
3438
|
+
return {
|
|
3439
|
+
value: op[1],
|
|
3440
|
+
done: false
|
|
3441
|
+
};
|
|
3442
|
+
|
|
3443
|
+
case 5:
|
|
3444
|
+
_.label++;
|
|
3445
|
+
y = op[1];
|
|
3446
|
+
op = [ 0 ];
|
|
3447
|
+
continue;
|
|
3448
|
+
|
|
3449
|
+
case 7:
|
|
3450
|
+
op = _.ops.pop();
|
|
3451
|
+
_.trys.pop();
|
|
3452
|
+
continue;
|
|
3453
|
+
|
|
3454
|
+
default:
|
|
3455
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
3456
|
+
_ = 0;
|
|
3457
|
+
continue;
|
|
3458
|
+
}
|
|
3459
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
3460
|
+
_.label = op[1];
|
|
3461
|
+
break;
|
|
3462
|
+
}
|
|
3463
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
3464
|
+
_.label = t[1];
|
|
3465
|
+
t = op;
|
|
3466
|
+
break;
|
|
3467
|
+
}
|
|
3468
|
+
if (t && _.label < t[2]) {
|
|
3469
|
+
_.label = t[2];
|
|
3470
|
+
_.ops.push(op);
|
|
3471
|
+
break;
|
|
3472
|
+
}
|
|
3473
|
+
if (t[2]) _.ops.pop();
|
|
3474
|
+
_.trys.pop();
|
|
3475
|
+
continue;
|
|
3476
|
+
}
|
|
3477
|
+
op = body.call(thisArg, _);
|
|
3478
|
+
} catch (e) {
|
|
3479
|
+
op = [ 6, e ];
|
|
3480
|
+
y = 0;
|
|
3481
|
+
} finally {
|
|
3482
|
+
f = t = 0;
|
|
3483
|
+
}
|
|
3484
|
+
if (op[0] & 5) throw op[1];
|
|
3485
|
+
return {
|
|
3486
|
+
value: op[0] ? op[1] : void 0,
|
|
3487
|
+
done: true
|
|
3488
|
+
};
|
|
3489
|
+
}
|
|
3490
|
+
};
|
|
3491
|
+
|
|
3492
|
+
var Application = function() {
|
|
3493
|
+
function Application(element, schema) {
|
|
3494
|
+
if (element === void 0) {
|
|
3495
|
+
element = document.documentElement;
|
|
3496
|
+
}
|
|
3497
|
+
if (schema === void 0) {
|
|
3498
|
+
schema = defaultSchema;
|
|
3499
|
+
}
|
|
3500
|
+
this.element = element;
|
|
3501
|
+
this.schema = schema;
|
|
3502
|
+
this.dispatcher = new Dispatcher(this);
|
|
3503
|
+
this.router = new Router(this);
|
|
3504
|
+
}
|
|
3505
|
+
Application.start = function(element, schema) {
|
|
3506
|
+
var application = new Application(element, schema);
|
|
3507
|
+
application.start();
|
|
3508
|
+
return application;
|
|
3509
|
+
};
|
|
3510
|
+
Application.prototype.start = function() {
|
|
3511
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
3512
|
+
return __generator(this, function(_a) {
|
|
3513
|
+
switch (_a.label) {
|
|
3514
|
+
case 0:
|
|
3515
|
+
return [ 4, domReady() ];
|
|
3516
|
+
|
|
3517
|
+
case 1:
|
|
3518
|
+
_a.sent();
|
|
3519
|
+
this.router.start();
|
|
3520
|
+
this.dispatcher.start();
|
|
3521
|
+
return [ 2 ];
|
|
3522
|
+
}
|
|
3523
|
+
});
|
|
3524
|
+
});
|
|
3525
|
+
};
|
|
3526
|
+
Application.prototype.stop = function() {
|
|
3527
|
+
this.router.stop();
|
|
3528
|
+
this.dispatcher.stop();
|
|
3529
|
+
};
|
|
3530
|
+
Application.prototype.register = function(identifier, controllerConstructor) {
|
|
3531
|
+
this.load({
|
|
3532
|
+
identifier: identifier,
|
|
3533
|
+
controllerConstructor: controllerConstructor
|
|
3534
|
+
});
|
|
3535
|
+
};
|
|
3536
|
+
Application.prototype.load = function(head) {
|
|
3537
|
+
var _this = this;
|
|
3538
|
+
var rest = [];
|
|
3539
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3540
|
+
rest[_i - 1] = arguments[_i];
|
|
3541
|
+
}
|
|
3542
|
+
var definitions = Array.isArray(head) ? head : [ head ].concat(rest);
|
|
3543
|
+
definitions.forEach(function(definition) {
|
|
3544
|
+
return _this.router.loadDefinition(definition);
|
|
3545
|
+
});
|
|
3546
|
+
};
|
|
3547
|
+
Application.prototype.unload = function(head) {
|
|
3548
|
+
var _this = this;
|
|
3549
|
+
var rest = [];
|
|
3550
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3551
|
+
rest[_i - 1] = arguments[_i];
|
|
3552
|
+
}
|
|
3553
|
+
var identifiers = Array.isArray(head) ? head : [ head ].concat(rest);
|
|
3554
|
+
identifiers.forEach(function(identifier) {
|
|
3555
|
+
return _this.router.unloadIdentifier(identifier);
|
|
3556
|
+
});
|
|
3557
|
+
};
|
|
3558
|
+
Object.defineProperty(Application.prototype, "controllers", {
|
|
3559
|
+
get: function() {
|
|
3560
|
+
return this.router.contexts.map(function(context) {
|
|
3561
|
+
return context.controller;
|
|
3562
|
+
});
|
|
3563
|
+
},
|
|
3564
|
+
enumerable: true,
|
|
3565
|
+
configurable: true
|
|
3566
|
+
});
|
|
3567
|
+
Application.prototype.getControllerForElementAndIdentifier = function(element, identifier) {
|
|
3568
|
+
var context = this.router.getContextForElementAndIdentifier(element, identifier);
|
|
3569
|
+
return context ? context.controller : null;
|
|
3570
|
+
};
|
|
3571
|
+
Application.prototype.handleError = function(error, message, detail) {
|
|
3572
|
+
console.error("%s\n\n%o\n\n%o", message, error, detail);
|
|
3573
|
+
};
|
|
3574
|
+
return Application;
|
|
3575
|
+
}();
|
|
3576
|
+
|
|
3577
|
+
function domReady() {
|
|
3578
|
+
return new Promise(function(resolve) {
|
|
3579
|
+
if (document.readyState == "loading") {
|
|
3580
|
+
document.addEventListener("DOMContentLoaded", resolve);
|
|
3581
|
+
} else {
|
|
3582
|
+
resolve();
|
|
3583
|
+
}
|
|
3584
|
+
});
|
|
3585
|
+
}
|
|
3586
|
+
|
|
3587
|
+
function defineTargetProperties(constructor) {
|
|
3588
|
+
var prototype = constructor.prototype;
|
|
3589
|
+
var targetNames = getTargetNamesForConstructor(constructor);
|
|
3590
|
+
targetNames.forEach(function(name) {
|
|
3591
|
+
var _a;
|
|
3592
|
+
return defineLinkedProperties(prototype, (_a = {}, _a[name + "Target"] = {
|
|
3593
|
+
get: function() {
|
|
3594
|
+
var target = this.targets.find(name);
|
|
3595
|
+
if (target) {
|
|
3596
|
+
return target;
|
|
3597
|
+
} else {
|
|
3598
|
+
throw new Error('Missing target element "' + this.identifier + "." + name + '"');
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
}, _a[name + "Targets"] = {
|
|
3602
|
+
get: function() {
|
|
3603
|
+
return this.targets.findAll(name);
|
|
3604
|
+
}
|
|
3605
|
+
}, _a["has" + capitalize(name) + "Target"] = {
|
|
3606
|
+
get: function() {
|
|
3607
|
+
return this.targets.has(name);
|
|
3608
|
+
}
|
|
3609
|
+
}, _a));
|
|
3610
|
+
});
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
function getTargetNamesForConstructor(constructor) {
|
|
3614
|
+
var ancestors = getAncestorsForConstructor(constructor);
|
|
3615
|
+
return Array.from(ancestors.reduce(function(targetNames, constructor) {
|
|
3616
|
+
getOwnTargetNamesForConstructor(constructor).forEach(function(name) {
|
|
3617
|
+
return targetNames.add(name);
|
|
3618
|
+
});
|
|
3619
|
+
return targetNames;
|
|
3620
|
+
}, new Set()));
|
|
3621
|
+
}
|
|
3622
|
+
|
|
3623
|
+
function getAncestorsForConstructor(constructor) {
|
|
3624
|
+
var ancestors = [];
|
|
3625
|
+
while (constructor) {
|
|
3626
|
+
ancestors.push(constructor);
|
|
3627
|
+
constructor = Object.getPrototypeOf(constructor);
|
|
3628
|
+
}
|
|
3629
|
+
return ancestors;
|
|
3630
|
+
}
|
|
3631
|
+
|
|
3632
|
+
function getOwnTargetNamesForConstructor(constructor) {
|
|
3633
|
+
var definition = constructor["targets"];
|
|
3634
|
+
return Array.isArray(definition) ? definition : [];
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
function defineLinkedProperties(object, properties) {
|
|
3638
|
+
Object.keys(properties).forEach(function(name) {
|
|
3639
|
+
if (!(name in object)) {
|
|
3640
|
+
var descriptor = properties[name];
|
|
3641
|
+
Object.defineProperty(object, name, descriptor);
|
|
3642
|
+
}
|
|
3643
|
+
});
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
function capitalize(name) {
|
|
3647
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
var Controller = function() {
|
|
3651
|
+
function Controller(context) {
|
|
3652
|
+
this.context = context;
|
|
3653
|
+
}
|
|
3654
|
+
Controller.bless = function() {
|
|
3655
|
+
defineTargetProperties(this);
|
|
3656
|
+
};
|
|
3657
|
+
Object.defineProperty(Controller.prototype, "application", {
|
|
3658
|
+
get: function() {
|
|
3659
|
+
return this.context.application;
|
|
3660
|
+
},
|
|
3661
|
+
enumerable: true,
|
|
3662
|
+
configurable: true
|
|
3663
|
+
});
|
|
3664
|
+
Object.defineProperty(Controller.prototype, "scope", {
|
|
3665
|
+
get: function() {
|
|
3666
|
+
return this.context.scope;
|
|
3667
|
+
},
|
|
3668
|
+
enumerable: true,
|
|
3669
|
+
configurable: true
|
|
3670
|
+
});
|
|
3671
|
+
Object.defineProperty(Controller.prototype, "element", {
|
|
3672
|
+
get: function() {
|
|
3673
|
+
return this.scope.element;
|
|
3674
|
+
},
|
|
3675
|
+
enumerable: true,
|
|
3676
|
+
configurable: true
|
|
3677
|
+
});
|
|
3678
|
+
Object.defineProperty(Controller.prototype, "identifier", {
|
|
3679
|
+
get: function() {
|
|
3680
|
+
return this.scope.identifier;
|
|
3681
|
+
},
|
|
3682
|
+
enumerable: true,
|
|
3683
|
+
configurable: true
|
|
3684
|
+
});
|
|
3685
|
+
Object.defineProperty(Controller.prototype, "targets", {
|
|
3686
|
+
get: function() {
|
|
3687
|
+
return this.scope.targets;
|
|
3688
|
+
},
|
|
3689
|
+
enumerable: true,
|
|
3690
|
+
configurable: true
|
|
3691
|
+
});
|
|
3692
|
+
Object.defineProperty(Controller.prototype, "data", {
|
|
3693
|
+
get: function() {
|
|
3694
|
+
return this.scope.data;
|
|
3695
|
+
},
|
|
3696
|
+
enumerable: true,
|
|
3697
|
+
configurable: true
|
|
3698
|
+
});
|
|
3699
|
+
Controller.prototype.initialize = function() {};
|
|
3700
|
+
Controller.prototype.connect = function() {};
|
|
3701
|
+
Controller.prototype.disconnect = function() {};
|
|
3702
|
+
Controller.targets = [];
|
|
3703
|
+
return Controller;
|
|
3704
|
+
}();
|
|
3705
|
+
|
|
3706
|
+
function _classCallCheck(instance, Constructor) {
|
|
3707
|
+
if (!(instance instanceof Constructor)) {
|
|
3708
|
+
throw new TypeError("Cannot call a class as a function");
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
|
|
3712
|
+
function _defineProperties(target, props) {
|
|
3713
|
+
for (var i = 0; i < props.length; i++) {
|
|
3714
|
+
var descriptor = props[i];
|
|
3715
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
3716
|
+
descriptor.configurable = true;
|
|
3717
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
3718
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
3719
|
+
}
|
|
3720
|
+
}
|
|
3721
|
+
|
|
3722
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
3723
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
3724
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
3725
|
+
return Constructor;
|
|
3726
|
+
}
|
|
3727
|
+
|
|
3728
|
+
function _defineProperty(obj, key, value) {
|
|
3729
|
+
if (key in obj) {
|
|
3730
|
+
Object.defineProperty(obj, key, {
|
|
3731
|
+
value: value,
|
|
3732
|
+
enumerable: true,
|
|
3733
|
+
configurable: true,
|
|
3734
|
+
writable: true
|
|
3735
|
+
});
|
|
3736
|
+
} else {
|
|
3737
|
+
obj[key] = value;
|
|
3738
|
+
}
|
|
3739
|
+
return obj;
|
|
3740
|
+
}
|
|
3741
|
+
|
|
3742
|
+
function _inherits(subClass, superClass) {
|
|
3743
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
3744
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
3745
|
+
}
|
|
3746
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
3747
|
+
constructor: {
|
|
3748
|
+
value: subClass,
|
|
3749
|
+
writable: true,
|
|
3750
|
+
configurable: true
|
|
3751
|
+
}
|
|
3752
|
+
});
|
|
3753
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
3754
|
+
}
|
|
3755
|
+
|
|
3756
|
+
function _getPrototypeOf(o) {
|
|
3757
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
3758
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
3759
|
+
};
|
|
3760
|
+
return _getPrototypeOf(o);
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3763
|
+
function _setPrototypeOf(o, p) {
|
|
3764
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
3765
|
+
o.__proto__ = p;
|
|
3766
|
+
return o;
|
|
3767
|
+
};
|
|
3768
|
+
return _setPrototypeOf(o, p);
|
|
3769
|
+
}
|
|
3770
|
+
|
|
3771
|
+
function _assertThisInitialized(self) {
|
|
3772
|
+
if (self === void 0) {
|
|
3773
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
3774
|
+
}
|
|
3775
|
+
return self;
|
|
3776
|
+
}
|
|
3777
|
+
|
|
3778
|
+
function _possibleConstructorReturn(self, call) {
|
|
3779
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
3780
|
+
return call;
|
|
3781
|
+
}
|
|
3782
|
+
return _assertThisInitialized(self);
|
|
3783
|
+
}
|
|
3784
|
+
|
|
3785
|
+
var _default = function(_Controller) {
|
|
3786
|
+
_inherits(_default, _Controller);
|
|
3787
|
+
function _default() {
|
|
3788
|
+
_classCallCheck(this, _default);
|
|
3789
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(_default).apply(this, arguments));
|
|
3790
|
+
}
|
|
3791
|
+
_createClass(_default, [ {
|
|
3792
|
+
key: "connect",
|
|
3793
|
+
value: function connect() {
|
|
3794
|
+
this.element.textContent = "TestController connected.";
|
|
3795
|
+
}
|
|
3796
|
+
} ]);
|
|
3797
|
+
return _default;
|
|
3798
|
+
}(Controller);
|
|
3799
|
+
|
|
3800
|
+
var _default$1 = function(_Controller) {
|
|
3801
|
+
_inherits(_default, _Controller);
|
|
3802
|
+
function _default() {
|
|
3803
|
+
_classCallCheck(this, _default);
|
|
3804
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(_default).apply(this, arguments));
|
|
3805
|
+
}
|
|
3806
|
+
_createClass(_default, [ {
|
|
3807
|
+
key: "connect",
|
|
3808
|
+
value: function connect() {
|
|
3809
|
+
this.element.textContent = "AnotherTestController connected";
|
|
3810
|
+
}
|
|
3811
|
+
} ]);
|
|
3812
|
+
return _default;
|
|
3813
|
+
}(Controller);
|
|
3814
|
+
|
|
3815
|
+
var $ = window.$;
|
|
3816
|
+
|
|
3817
|
+
var _default$2 = function(_Controller) {
|
|
3818
|
+
_inherits(_default, _Controller);
|
|
3819
|
+
function _default() {
|
|
3820
|
+
_classCallCheck(this, _default);
|
|
3821
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(_default).apply(this, arguments));
|
|
3822
|
+
}
|
|
3823
|
+
_createClass(_default, [ {
|
|
3824
|
+
key: "row",
|
|
3825
|
+
value: function row(event) {
|
|
3826
|
+
event.preventDefault;
|
|
3827
|
+
var tbody = event.target.closest("tbody");
|
|
3828
|
+
tbody.classList.toggle("toggleable--open");
|
|
3829
|
+
$(".grid > .row").masonry("layout");
|
|
3830
|
+
}
|
|
3831
|
+
}, {
|
|
3832
|
+
key: "table",
|
|
3833
|
+
value: function table(event) {
|
|
3834
|
+
event.preventDefault;
|
|
3835
|
+
var table = event.target.closest("table");
|
|
3836
|
+
var thead = event.target.closest("thead");
|
|
3837
|
+
var tbodies = Array.prototype.slice.call(table.querySelectorAll("tbody"));
|
|
3838
|
+
var hide = thead.classList.contains("toggleable--open");
|
|
3839
|
+
thead.classList.toggle("toggleable--open");
|
|
3840
|
+
tbodies.forEach(function(tbody) {
|
|
3841
|
+
tbody.classList.toggle("toggleable--open", !hide);
|
|
3842
|
+
});
|
|
3843
|
+
$(".grid > .row").masonry("layout");
|
|
3844
|
+
}
|
|
3845
|
+
} ]);
|
|
3846
|
+
return _default;
|
|
3847
|
+
}(Controller);
|
|
3848
|
+
|
|
3849
|
+
var $$1 = window.$;
|
|
3850
|
+
|
|
3851
|
+
var _default$3 = function(_Controller) {
|
|
3852
|
+
_inherits(_default, _Controller);
|
|
3853
|
+
function _default() {
|
|
3854
|
+
_classCallCheck(this, _default);
|
|
3855
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(_default).apply(this, arguments));
|
|
3856
|
+
}
|
|
3857
|
+
_createClass(_default, [ {
|
|
3858
|
+
key: "connect",
|
|
3859
|
+
value: function connect() {
|
|
3860
|
+
window.initDatepickersIn(".hd-drug-administration");
|
|
3861
|
+
}
|
|
3862
|
+
}, {
|
|
3863
|
+
key: "toggleAdministered",
|
|
3864
|
+
value: function toggleAdministered() {
|
|
3865
|
+
var checked = event.target.value == "true";
|
|
3866
|
+
this.containerTarget.classList.toggle("administered", checked);
|
|
3867
|
+
this.containerTarget.classList.toggle("not-administered", !checked);
|
|
3868
|
+
this.containerTarget.classList.remove("undecided");
|
|
3869
|
+
$$1(".authentication", this.containerTarget).toggle(checked);
|
|
3870
|
+
$$1(".authentication", this.containerTarget).toggleClass("disabled-with-faded-overlay", !checked);
|
|
3871
|
+
$$1(".reason-why-not-administered", this.containerTarget).toggle(!checked);
|
|
3872
|
+
$$1("#btn_save_and_witness_later").toggle(checked);
|
|
3873
|
+
}
|
|
3874
|
+
} ]);
|
|
3875
|
+
return _default;
|
|
3876
|
+
}(Controller);
|
|
3877
|
+
|
|
3878
|
+
_defineProperty(_default$3, "targets", [ "container", "radio" ]);
|
|
3879
|
+
|
|
3880
|
+
var application = Application.start();
|
|
3881
|
+
|
|
3882
|
+
application.register("test", _default);
|
|
3883
|
+
|
|
3884
|
+
application.register("another_test", _default$1);
|
|
3885
|
+
|
|
3886
|
+
application.register("toggle", _default$2);
|
|
3887
|
+
|
|
3888
|
+
application.register("hd-prescription-administration", _default$3);
|