From 33b1e41f137ebbdf63f771e8424f7dcc81a5cee8 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 28 Feb 2023 11:01:10 +0800 Subject: [PATCH] MDL-75012 js: Full build of all grunt things --- .../analytics/amd/build/log_info.min.js.map | 2 +- .../tool/analytics/amd/build/model.min.js.map | 2 +- .../amd/build/potential-contexts.min.js.map | 2 +- admin/tool/behat/amd/build/steps.min.js.map | 2 +- .../moodle-tool_capability-search-min.js | 2 +- .../amd/build/clipboardwrapper.min.js.map | 2 +- .../amd/build/jsrunner.min.js.map | 2 +- .../amd/build/loader.min.js.map | 2 +- .../componentlibrary/amd/build/lunr.min.js | 2 +- .../amd/build/lunr.min.js.map | 2 +- .../amd/build/mustache.min.js.map | 2 +- .../amd/build/search.min.js.map | 2 +- .../amd/build/selectors.min.js.map | 2 +- .../amd/build/add_category.min.js.map | 2 +- .../amd/build/add_purpose.min.js.map | 2 +- .../amd/build/categoriesactions.min.js.map | 2 +- .../amd/build/contactdpo.min.js.map | 2 +- .../amd/build/data_deletion.min.js.map | 2 +- .../amd/build/data_registry.min.js.map | 2 +- .../amd/build/data_request_modal.min.js.map | 2 +- .../amd/build/defaultsactions.min.js.map | 2 +- .../effective_retention_period.min.js.map | 2 +- .../dataprivacy/amd/build/events.min.js.map | 2 +- .../amd/build/expand_contract.min.js.map | 2 +- .../amd/build/form-user-selector.min.js.map | 2 +- .../amd/build/myrequestactions.min.js.map | 2 +- .../amd/build/purposesactions.min.js.map | 2 +- .../amd/build/request_filter.min.js.map | 2 +- .../amd/build/requestactions.min.js.map | 2 +- .../langimport/amd/build/search.min.js.map | 2 +- .../amd/build/delete_license.min.js.map | 2 +- .../lp/amd/build/actionselector.min.js.map | 2 +- .../tool/lp/amd/build/competencies.min.js.map | 2 +- .../amd/build/competency_outcomes.min.js.map | 2 +- .../competency_plan_navigation.min.js.map | 2 +- .../lp/amd/build/competency_rule.min.js.map | 2 +- .../amd/build/competency_rule_all.min.js.map | 2 +- .../build/competency_rule_points.min.js.map | 2 +- .../lp/amd/build/competencyactions.min.js.map | 2 +- .../amd/build/competencydialogue.min.js.map | 2 +- .../lp/amd/build/competencypicker.min.js.map | 2 +- .../competencypicker_user_plans.min.js.map | 2 +- .../amd/build/competencyruleconfig.min.js.map | 2 +- .../lp/amd/build/competencytree.min.js.map | 2 +- .../course_competency_settings.min.js.map | 2 +- admin/tool/lp/amd/build/dialogue.min.js.map | 2 +- .../lp/amd/build/dragdrop-reorder.min.js.map | 2 +- admin/tool/lp/amd/build/event_base.min.js.map | 2 +- .../lp/amd/build/evidence_delete.min.js.map | 2 +- .../amd/build/form-cohort-selector.min.js.map | 2 +- .../amd/build/form-user-selector.min.js.map | 2 +- .../build/form_competency_element.min.js.map | 2 +- .../lp/amd/build/frameworkactions.min.js.map | 2 +- .../build/frameworks_datasource.min.js.map | 2 +- .../lp/amd/build/grade_dialogue.min.js.map | 2 +- .../grade_user_competency_inline.min.js.map | 2 +- admin/tool/lp/amd/build/menubar.min.js.map | 2 +- .../lp/amd/build/module_navigation.min.js.map | 2 +- .../build/parentcompetency_form.min.js.map | 2 +- .../tool/lp/amd/build/planactions.min.js.map | 2 +- .../tool/lp/amd/build/scaleconfig.min.js.map | 2 +- .../tool/lp/amd/build/scalevalues.min.js.map | 2 +- .../lp/amd/build/templateactions.min.js.map | 2 +- admin/tool/lp/amd/build/tree.min.js.map | 2 +- ...er_competency_course_navigation.min.js.map | 2 +- .../amd/build/user_competency_info.min.js.map | 2 +- .../user_competency_plan_popup.min.js.map | 2 +- .../build/user_competency_workflow.min.js.map | 2 +- .../build/user_evidence_actions.min.js.map | 2 +- .../monitor/amd/build/dropdown.min.js.map | 2 +- .../amd/build/instance_form.min.js.map | 2 +- .../moodlenet/amd/build/select_page.min.js | 2 +- .../amd/build/select_page.min.js.map | 2 +- .../moodlenet/amd/build/selectors.min.js.map | 2 +- .../moodlenet/amd/build/validator.min.js.map | 2 +- .../amd/build/acceptances_filter.min.js.map | 2 +- .../acceptances_filter_datasource.min.js.map | 2 +- .../policy/amd/build/acceptmodal.min.js.map | 2 +- .../jquery-eu-cookie-law-popup.min.js.map | 2 +- .../amd/build/managedocsactions.min.js.map | 2 +- .../policy/amd/build/policyactions.min.js.map | 2 +- .../amd/build/display.min.js.map | 2 +- .../amd/build/search.min.js.map | 2 +- .../usertours/amd/build/events.min.js.map | 2 +- .../amd/build/filter_cssselector.min.js.map | 2 +- .../amd/build/managesteps.min.js.map | 2 +- .../amd/build/managetours.min.js.map | 2 +- .../usertours/amd/build/repository.min.js.map | 2 +- admin/tool/usertours/amd/build/tour.min.js | 2 +- .../tool/usertours/amd/build/tour.min.js.map | 2 +- .../usertours/amd/build/usertours.min.js.map | 2 +- admin/tool/xmldb/amd/build/move.min.js.map | 2 +- .../amd/build/availability_more.min.js.map | 2 +- .../moodle-availability_date-form-min.js | 2 +- .../moodle-core_availability-form-min.js | 6 +- backup/util/ui/amd/build/async_backup.min.js | 2 +- .../util/ui/amd/build/async_backup.min.js.map | 2 +- .../moodle-backup-backupselectall-min.js | 2 +- badges/amd/build/backpackactions.min.js.map | 2 +- badges/amd/build/selectors.min.js.map | 2 +- blocks/accessreview/amd/build/module.min.js | 2 +- .../accessreview/amd/build/module.min.js.map | 2 +- blocks/amd/build/events.min.js.map | 2 +- blocks/myoverview/amd/build/main.min.js.map | 2 +- .../amd/build/repository.min.js.map | 2 +- .../myoverview/amd/build/selectors.min.js.map | 2 +- blocks/myoverview/amd/build/view.min.js | 2 +- blocks/myoverview/amd/build/view.min.js.map | 2 +- .../myoverview/amd/build/view_nav.min.js.map | 2 +- .../amd/build/ajax_response_renderer.min.js | 2 +- .../build/ajax_response_renderer.min.js.map | 2 +- .../amd/build/nav_loader.min.js.map | 2 +- .../navigation/amd/build/navblock.min.js.map | 2 +- .../amd/build/site_admin_loader.min.js.map | 2 +- .../build/change_user_visibility.min.js.map | 2 +- .../amd/build/files_tree.min.js.map | 2 +- .../amd/build/main.min.js.map | 2 +- .../amd/build/main.min.js.map | 2 +- .../amd/build/repository.min.js.map | 2 +- .../amd/build/settingsblock.min.js.map | 2 +- .../starredcourses/amd/build/main.min.js.map | 2 +- .../amd/build/repository.min.js.map | 2 +- .../calendar_events_repository.min.js.map | 2 +- blocks/timeline/amd/build/event_list.min.js | 2 +- .../timeline/amd/build/event_list.min.js.map | 2 +- blocks/timeline/amd/build/main.min.js.map | 2 +- blocks/timeline/amd/build/view.min.js.map | 2 +- blocks/timeline/amd/build/view_courses.min.js | 2 +- .../amd/build/view_courses.min.js.map | 2 +- .../timeline/amd/build/view_dates.min.js.map | 2 +- blocks/timeline/amd/build/view_nav.min.js.map | 2 +- calendar/amd/build/calendar.min.js.map | 2 +- calendar/amd/build/calendar_filter.min.js.map | 2 +- calendar/amd/build/calendar_mini.min.js.map | 2 +- .../amd/build/calendar_threemonth.min.js.map | 2 +- calendar/amd/build/calendar_view.min.js.map | 2 +- calendar/amd/build/crud.min.js.map | 2 +- .../amd/build/drag_drop_data_store.min.js.map | 2 +- calendar/amd/build/event_form.min.js.map | 2 +- calendar/amd/build/events.min.js.map | 2 +- calendar/amd/build/export.min.js.map | 2 +- .../amd/build/manage_subscriptions.min.js.map | 2 +- calendar/amd/build/modal_delete.min.js.map | 2 +- .../amd/build/modal_event_form.min.js.map | 2 +- .../month_navigation_drag_drop.min.js.map | 2 +- .../amd/build/month_view_drag_drop.min.js.map | 2 +- calendar/amd/build/popover.min.js.map | 2 +- calendar/amd/build/repository.min.js | 2 +- calendar/amd/build/repository.min.js.map | 2 +- calendar/amd/build/selectors.min.js.map | 2 +- calendar/amd/build/summary_modal.min.js.map | 2 +- calendar/amd/build/view_manager.min.js | 2 +- calendar/amd/build/view_manager.min.js.map | 2 +- comment/amd/build/admin.min.js.map | 2 +- comment/amd/build/repository.min.js.map | 2 +- contentbank/amd/build/actions.min.js.map | 2 +- contentbank/amd/build/search.min.js.map | 2 +- contentbank/amd/build/selectors.min.js.map | 2 +- contentbank/amd/build/sort.min.js.map | 2 +- contentbank/amd/build/upload.min.js.map | 2 +- course/amd/build/actions.min.js.map | 2 +- course/amd/build/activitychooser.min.js.map | 2 +- course/amd/build/copy_modal.min.js.map | 2 +- course/amd/build/downloadcontent.min.js.map | 2 +- course/amd/build/events.min.js.map | 2 +- course/amd/build/formatchooser.min.js.map | 2 +- .../local/activitychooser/dialogue.min.js.map | 2 +- .../activitychooser/repository.min.js.map | 2 +- .../activitychooser/selectors.min.js.map | 2 +- .../build/manual_completion_toggle.min.js.map | 2 +- course/amd/build/recommendations.min.js.map | 2 +- course/amd/build/repository.min.js | 2 +- course/amd/build/repository.min.js.map | 2 +- course/amd/build/view.min.js.map | 2 +- .../format/amd/build/courseeditor.min.js.map | 2 +- .../format/amd/build/local/content.min.js.map | 2 +- .../build/local/content/actions.min.js.map | 2 +- .../local/content/activity_header.min.js.map | 2 +- .../local/content/bulkedittoggler.min.js.map | 2 +- .../local/content/bulkedittools.min.js.map | 2 +- .../build/local/content/section.min.js.map | 2 +- .../local/content/section/cmitem.min.js.map | 2 +- .../local/content/section/header.min.js.map | 2 +- .../local/courseeditor/contenttree.min.js.map | 2 +- .../local/courseeditor/courseeditor.min.js | 4 +- .../courseeditor/courseeditor.min.js.map | 2 +- .../local/courseeditor/dndcmitem.min.js.map | 2 +- .../local/courseeditor/dndsection.min.js.map | 2 +- .../courseeditor/dndsectionitem.min.js.map | 2 +- .../local/courseeditor/exporter.min.js.map | 2 +- .../local/courseeditor/fileuploader.min.js | 2 +- .../courseeditor/fileuploader.min.js.map | 2 +- .../local/courseeditor/mutations.min.js.map | 2 +- .../amd/build/local/courseindex/cm.min.js.map | 2 +- .../local/courseindex/courseindex.min.js.map | 2 +- .../build/local/courseindex/drawer.min.js.map | 2 +- .../local/courseindex/placeholder.min.js.map | 2 +- .../local/courseindex/section.min.js.map | 2 +- .../local/courseindex/sectiontitle.min.js.map | 2 +- .../format/topics/amd/build/mutations.min.js | 2 +- .../topics/amd/build/mutations.min.js.map | 2 +- .../topics/amd/build/section.min.js.map | 2 +- .../moodle-course-categoryexpander-min.js | 2 +- .../moodle-course-dragdrop-min.js | 4 +- .../moodle-course-management-min.js | 8 +- customfield/amd/build/form.min.js.map | 2 +- enrol/lti/amd/build/content_select.min.js.map | 2 +- enrol/lti/amd/build/tool_endpoints.min.js.map | 2 +- .../form-potential-user-selector.min.js.map | 2 +- .../amd/build/quickenrolment.min.js.map | 2 +- filter/amd/build/events.min.js.map | 2 +- grade/amd/build/edittree_index.min.js.map | 2 +- .../grader/gradingpanel/comparison.min.js.map | 2 +- .../grader/gradingpanel/normalise.min.js.map | 2 +- .../grader/gradingpanel/point.min.js.map | 2 +- .../grader/gradingpanel/repository.min.js.map | 2 +- .../grader/gradingpanel/scale.min.js.map | 2 +- .../build/searchwidget/basewidget.min.js.map | 2 +- grade/amd/build/searchwidget/group.min.js.map | 2 +- .../build/searchwidget/initials.min.js.map | 2 +- .../build/searchwidget/repository.min.js.map | 2 +- .../build/searchwidget/selectors.min.js.map | 2 +- .../amd/build/comment_chooser.min.js.map | 2 +- .../grades/grader/gradingpanel.min.js.map | 2 +- .../grader/gradingpanel/comments.min.js.map | 2 +- .../comments/selectors.min.js.map | 2 +- .../grades/grader/gradingpanel.min.js.map | 2 +- .../grader/amd/build/stickycolspan.min.js.map | 2 +- ...le-gradereport_history-userselector-min.js | 4 +- .../amd/build/bulkactions.min.js.map | 2 +- .../singleview/amd/build/grade.min.js.map | 2 +- .../singleview/amd/build/selectors.min.js.map | 2 +- .../singleview/amd/build/user.min.js.map | 2 +- .../amd/build/gradecategorytoggle.min.js.map | 2 +- grade/report/user/amd/build/user.min.js.map | 2 +- h5p/amd/build/editor_display.min.js.map | 2 +- lib/amd/build/adapter.min.js | 2 +- lib/amd/build/adapter.min.js.map | 2 +- lib/amd/build/addblockmodal.min.js | 2 +- lib/amd/build/addblockmodal.min.js.map | 2 +- lib/amd/build/ajax.min.js.map | 2 +- lib/amd/build/auto_rows.min.js.map | 2 +- lib/amd/build/autoscroll.min.js.map | 2 +- lib/amd/build/backoff_timer.min.js.map | 2 +- lib/amd/build/chart_axis.min.js.map | 2 +- lib/amd/build/chart_bar.min.js | 2 +- lib/amd/build/chart_bar.min.js.map | 2 +- lib/amd/build/chart_base.min.js.map | 2 +- lib/amd/build/chart_builder.min.js.map | 2 +- lib/amd/build/chart_line.min.js.map | 2 +- lib/amd/build/chart_output.min.js.map | 2 +- lib/amd/build/chart_output_base.min.js.map | 2 +- lib/amd/build/chart_output_chartjs.min.js.map | 2 +- .../build/chart_output_htmltable.min.js.map | 2 +- lib/amd/build/chart_pie.min.js.map | 2 +- lib/amd/build/chart_series.min.js.map | 2 +- lib/amd/build/chartjs-lazy.min.js | 2 +- lib/amd/build/chartjs-lazy.min.js.map | 2 +- lib/amd/build/chartjs.min.js.map | 2 +- lib/amd/build/checkbox-toggleall.min.js.map | 2 +- lib/amd/build/config.min.js.map | 2 +- lib/amd/build/copy_to_clipboard.min.js.map | 2 +- .../custom_interaction_events.min.js.map | 2 +- lib/amd/build/datafilter.min.js.map | 2 +- .../build/datafilter/filtertype.min.js.map | 2 +- .../datafilter/filtertypes/country.min.js.map | 2 +- .../filtertypes/courseid.min.js.map | 2 +- .../datafilter/filtertypes/keyword.min.js.map | 2 +- lib/amd/build/datafilter/selectors.min.js.map | 2 +- lib/amd/build/dragdrop.min.js.map | 2 +- lib/amd/build/drawer.min.js.map | 2 +- lib/amd/build/drawer_events.min.js.map | 2 +- lib/amd/build/dynamic_tabs.min.js.map | 2 +- lib/amd/build/edit_switch.min.js.map | 2 +- lib/amd/build/emoji/auto_complete.min.js.map | 2 +- lib/amd/build/emoji/data.min.js.map | 2 +- lib/amd/build/emoji/picker.min.js | 2 +- lib/amd/build/emoji/picker.min.js.map | 2 +- lib/amd/build/event.min.js.map | 2 +- lib/amd/build/event_dispatcher.min.js.map | 2 +- lib/amd/build/first.min.js.map | 2 +- lib/amd/build/form-autocomplete.min.js.map | 2 +- lib/amd/build/form-cohort-selector.min.js.map | 2 +- lib/amd/build/form-course-selector.min.js.map | 2 +- lib/amd/build/fragment.min.js.map | 2 +- lib/amd/build/fullscreen.min.js.map | 2 +- lib/amd/build/icon_system.min.js.map | 2 +- .../build/icon_system_fontawesome.min.js.map | 2 +- lib/amd/build/icon_system_standard.min.js.map | 2 +- lib/amd/build/inplace_editable.min.js.map | 2 +- lib/amd/build/key_codes.min.js.map | 2 +- lib/amd/build/loadingicon.min.js.map | 2 +- .../build/local/aria/aria-hidden.min.js.map | 2 +- lib/amd/build/local/aria/focuslock.min.js.map | 2 +- lib/amd/build/local/aria/selectors.min.js.map | 2 +- .../local/inplace_editable/events.min.js.map | 2 +- lib/amd/build/local/modal/alert.min.js.map | 2 +- .../local/process_monitor/events.min.js.map | 2 +- .../process_monitor/loadingprocess.min.js | 2 +- .../process_monitor/loadingprocess.min.js.map | 2 +- .../local/process_monitor/manager.min.js | 4 +- .../local/process_monitor/manager.min.js.map | 2 +- .../local/process_monitor/monitor.min.js.map | 2 +- .../local/process_monitor/process.min.js.map | 2 +- .../local/process_monitor/processqueue.min.js | 2 +- .../process_monitor/processqueue.min.js.map | 2 +- .../local/reactive/basecomponent.min.js.map | 2 +- lib/amd/build/local/reactive/debug.min.js | 2 +- lib/amd/build/local/reactive/debug.min.js.map | 2 +- .../local/reactive/debugpanel.min.js.map | 2 +- .../build/local/reactive/dragdrop.min.js.map | 2 +- .../build/local/reactive/overlay.min.js.map | 2 +- .../build/local/reactive/reactive.min.js.map | 2 +- .../local/reactive/statemanager.min.js.map | 2 +- .../local/repository/dynamic_tabs.min.js.map | 2 +- lib/amd/build/localstorage.min.js.map | 2 +- lib/amd/build/log.min.js.map | 2 +- lib/amd/build/loglevel.min.js | 2 +- lib/amd/build/loglevel.min.js.map | 2 +- lib/amd/build/menu_navigation.min.js.map | 2 +- lib/amd/build/modal.min.js.map | 2 +- lib/amd/build/modal_backdrop.min.js.map | 2 +- lib/amd/build/modal_cancel.min.js.map | 2 +- lib/amd/build/modal_copy_to_clipboard.min.js | 2 +- .../build/modal_copy_to_clipboard.min.js.map | 2 +- lib/amd/build/modal_delete_cancel.min.js.map | 2 +- lib/amd/build/modal_events.min.js.map | 2 +- lib/amd/build/modal_factory.min.js.map | 2 +- lib/amd/build/modal_registry.min.js.map | 2 +- lib/amd/build/modal_save_cancel.min.js.map | 2 +- lib/amd/build/moremenu.min.js | 2 +- lib/amd/build/moremenu.min.js.map | 2 +- lib/amd/build/mustache.min.js.map | 2 +- lib/amd/build/network.min.js.map | 2 +- lib/amd/build/normalise.min.js.map | 2 +- lib/amd/build/notification.min.js.map | 2 +- lib/amd/build/page_global.min.js.map | 2 +- lib/amd/build/paged_content.min.js.map | 2 +- lib/amd/build/paged_content_events.min.js.map | 2 +- .../build/paged_content_factory.min.js.map | 2 +- lib/amd/build/paged_content_pages.min.js.map | 2 +- .../build/paged_content_paging_bar.min.js.map | 2 +- ...ntent_paging_bar_limit_selector.min.js.map | 2 +- .../paged_content_paging_dropdown.min.js.map | 2 +- lib/amd/build/pending.min.js.map | 2 +- lib/amd/build/permissionmanager.min.js.map | 2 +- .../popover_region_controller.min.js.map | 2 +- lib/amd/build/popper.min.js | 2 +- lib/amd/build/popper.min.js.map | 2 +- lib/amd/build/prefetch.min.js.map | 2 +- lib/amd/build/process_monitor.min.js.map | 2 +- lib/amd/build/pubsub.min.js.map | 2 +- lib/amd/build/reactive.min.js.map | 2 +- lib/amd/build/scroll_manager.min.js.map | 2 +- lib/amd/build/sessionstorage.min.js.map | 2 +- lib/amd/build/showhidesettings.min.js.map | 2 +- lib/amd/build/sortable_list.min.js.map | 2 +- lib/amd/build/sticky-footer.min.js.map | 2 +- lib/amd/build/storagewrapper.min.js.map | 2 +- lib/amd/build/str.min.js.map | 2 +- lib/amd/build/tag.min.js.map | 2 +- lib/amd/build/templates.min.js.map | 2 +- lib/amd/build/toast.min.js.map | 2 +- lib/amd/build/tooltip.min.js.map | 2 +- lib/amd/build/tree.min.js.map | 2 +- lib/amd/build/truncate.min.js.map | 2 +- lib/amd/build/url.min.js.map | 2 +- lib/amd/build/user_date.min.js.map | 2 +- lib/amd/build/userfeedback.min.js.map | 2 +- lib/amd/build/usermenu.min.js.map | 2 +- lib/amd/build/utility.min.js.map | 2 +- lib/amd/build/utils.min.js.map | 2 +- lib/amd/build/yui.min.js.map | 2 +- lib/editor/amd/build/events.min.js.map | 2 +- lib/editor/atto/amd/build/events.min.js.map | 2 +- ...le-atto_accessibilitychecker-button-min.js | 2 +- .../moodle-atto_collapse-button-min.js | 2 +- .../moodle-atto_equation-button-min.js | 2 +- .../moodle-atto_h5p-button-min.js | 2 +- .../moodle-atto_html-beautify-min.js | 42 +++++----- .../moodle-atto_html-codemirror-min.js | 76 +++++++++---------- .../moodle-atto_image-button-min.js | 4 +- .../moodle-atto_indent-button-min.js | 2 +- .../moodle-atto_media-button-min.js | 4 +- .../moodle-atto_recordrtc-button-min.js | 2 +- .../moodle-atto_recordrtc-recording-min.js | 2 +- .../moodle-atto_rtl-button-min.js | 2 +- .../moodle-atto_table-button-min.js | 6 +- .../moodle-atto_undo-button-min.js | 2 +- .../moodle-editor_atto-editor-min.js | 10 +-- .../moodle-editor_atto-plugin-min.js | 4 +- .../moodle-editor_atto-rangy-min.js | 32 ++++---- lib/editor/tiny/amd/build/defaults.min.js.map | 2 +- lib/editor/tiny/amd/build/editor.min.js | 2 +- lib/editor/tiny/amd/build/editor.min.js.map | 2 +- lib/editor/tiny/amd/build/loader.min.js.map | 2 +- lib/editor/tiny/amd/build/options.min.js.map | 2 +- lib/editor/tiny/amd/build/uploader.min.js.map | 2 +- lib/editor/tiny/amd/build/utils.min.js | 2 +- lib/editor/tiny/amd/build/utils.min.js.map | 2 +- .../amd/build/checker.min.js.map | 2 +- .../amd/build/colorbase.min.js | 4 +- .../amd/build/colorbase.min.js.map | 2 +- .../amd/build/commands.min.js.map | 2 +- .../amd/build/common.min.js.map | 2 +- .../amd/build/configuration.min.js.map | 2 +- .../amd/build/plugin.min.js.map | 2 +- .../autosave/amd/build/autosaver.min.js.map | 2 +- .../autosave/amd/build/common.min.js.map | 2 +- .../autosave/amd/build/options.min.js.map | 2 +- .../autosave/amd/build/plugin.min.js.map | 2 +- .../autosave/amd/build/repository.min.js.map | 2 +- .../autosave/amd/build/storage.min.js.map | 2 +- .../equation/amd/build/commands.min.js.map | 2 +- .../equation/amd/build/common.min.js.map | 2 +- .../amd/build/configuration.min.js.map | 2 +- .../equation/amd/build/equation.min.js.map | 2 +- .../plugins/equation/amd/build/modal.min.js | 2 +- .../equation/amd/build/modal.min.js.map | 2 +- .../equation/amd/build/options.min.js.map | 2 +- .../equation/amd/build/plugin.min.js.map | 2 +- .../equation/amd/build/repository.min.js.map | 2 +- .../equation/amd/build/selectors.min.js.map | 2 +- .../plugins/equation/amd/build/ui.min.js.map | 2 +- .../plugins/h5p/amd/build/commands.min.js.map | 2 +- .../plugins/h5p/amd/build/common.min.js.map | 2 +- .../h5p/amd/build/configuration.min.js.map | 2 +- .../h5p/amd/build/filtercontent.min.js.map | 2 +- .../tiny/plugins/h5p/amd/build/modal.min.js | 2 +- .../plugins/h5p/amd/build/modal.min.js.map | 2 +- .../plugins/h5p/amd/build/options.min.js.map | 2 +- .../plugins/h5p/amd/build/plugin.min.js.map | 2 +- .../tiny/plugins/h5p/amd/build/ui.min.js | 2 +- .../tiny/plugins/h5p/amd/build/ui.min.js.map | 2 +- .../media/amd/build/commands.min.js.map | 2 +- .../plugins/media/amd/build/common.min.js.map | 2 +- .../media/amd/build/configuration.min.js.map | 2 +- .../tiny/plugins/media/amd/build/embed.min.js | 2 +- .../plugins/media/amd/build/embed.min.js.map | 2 +- .../plugins/media/amd/build/embedmodal.min.js | 2 +- .../media/amd/build/embedmodal.min.js.map | 2 +- .../tiny/plugins/media/amd/build/image.min.js | 2 +- .../plugins/media/amd/build/image.min.js.map | 2 +- .../plugins/media/amd/build/imagemodal.min.js | 2 +- .../media/amd/build/imagemodal.min.js.map | 2 +- .../plugins/media/amd/build/manager.min.js | 2 +- .../media/amd/build/manager.min.js.map | 2 +- .../media/amd/build/options.min.js.map | 2 +- .../plugins/media/amd/build/plugin.min.js.map | 2 +- .../media/amd/build/selectors.min.js.map | 2 +- .../media/amd/build/usedfiles.min.js.map | 2 +- .../recordrtc/amd/build/audio_recorder.min.js | 2 +- .../amd/build/audio_recorder.min.js.map | 2 +- .../recordrtc/amd/build/base_recorder.min.js | 2 +- .../amd/build/base_recorder.min.js.map | 2 +- .../amd/build/commands_audio.min.js.map | 2 +- .../amd/build/commands_video.min.js.map | 2 +- .../recordrtc/amd/build/common.min.js.map | 2 +- .../amd/build/configuration.min.js.map | 2 +- .../recordrtc/amd/build/modal.min.js.map | 2 +- .../recordrtc/amd/build/options.min.js.map | 2 +- .../recordrtc/amd/build/plugin.min.js.map | 2 +- .../recordrtc/amd/build/video_recorder.min.js | 2 +- .../amd/build/video_recorder.min.js.map | 2 +- lib/form/amd/build/changechecker.min.js.map | 2 +- .../amd/build/collapsesections.min.js.map | 2 +- lib/form/amd/build/defaultcustom.min.js.map | 2 +- lib/form/amd/build/dynamicform.min.js | 2 +- lib/form/amd/build/dynamicform.min.js.map | 2 +- .../amd/build/encryptedpassword.min.js.map | 2 +- lib/form/amd/build/events.min.js.map | 2 +- lib/form/amd/build/filetypes.min.js.map | 2 +- lib/form/amd/build/modalform.min.js | 2 +- lib/form/amd/build/modalform.min.js.map | 2 +- lib/form/amd/build/passwordunmask.min.js.map | 2 +- lib/form/amd/build/showadvanced.min.js.map | 2 +- lib/form/amd/build/submit.min.js.map | 2 +- lib/form/amd/build/util.min.js.map | 2 +- .../moodle-form-dateselector-min.js | 4 +- .../moodle-form-shortforms-min.js | 2 +- lib/table/amd/build/dynamic.min.js | 2 +- lib/table/amd/build/dynamic.min.js.map | 2 +- .../amd/build/local/dynamic/events.min.js.map | 2 +- .../build/local/dynamic/repository.min.js.map | 2 +- .../build/local/dynamic/selectors.min.js.map | 2 +- .../moodle-core-actionmenu-min.js | 2 +- .../moodle-core-blocks-min.js | 4 +- .../moodle-core-chooserdialogue-min.js | 2 +- .../moodle-core-dragdrop-min.js | 4 +- .../moodle-core-languninstallconfirm-min.js | 2 +- .../moodle-core-notification-dialogue-min.js | 4 +- .../moodle-core-widget-focusafterclose-min.js | 2 +- .../videojs/amd/build/Youtube-lazy.min.js.map | 2 +- .../videojs/amd/build/loader.min.js.map | 2 +- .../videojs/amd/build/local/ogv/ogv.min.js | 2 +- .../amd/build/local/ogv/ogv.min.js.map | 2 +- .../videojs/amd/build/video-lazy.min.js | 10 +-- .../videojs/amd/build/video-lazy.min.js.map | 2 +- .../amd/build/videojs-ogvjs-lazy.min.js | 2 +- .../amd/build/videojs-ogvjs-lazy.min.js.map | 2 +- ...efault_notification_preferences.min.js.map | 2 +- message/amd/build/message_drawer.min.js.map | 2 +- .../build/message_drawer_events.min.js.map | 2 +- .../build/message_drawer_helper.min.js.map | 2 +- .../message_drawer_lazy_load_list.min.js.map | 2 +- .../amd/build/message_drawer_router.min.js | 2 +- .../build/message_drawer_router.min.js.map | 2 +- .../build/message_drawer_routes.min.js.map | 2 +- .../message_drawer_view_contact.min.js.map | 2 +- .../message_drawer_view_contacts.min.js.map | 2 +- ..._view_contacts_section_contacts.min.js.map | 2 +- ..._view_contacts_section_requests.min.js.map | 2 +- ...essage_drawer_view_conversation.min.js.map | 2 +- ...wer_view_conversation_constants.min.js.map | 2 +- ...rawer_view_conversation_patcher.min.js.map | 2 +- ...awer_view_conversation_renderer.min.js.map | 2 +- ...view_conversation_state_manager.min.js.map | 2 +- .../message_drawer_view_group_info.min.js.map | 2 +- .../build/message_drawer_view_overview.min.js | 2 +- .../message_drawer_view_overview.min.js.map | 2 +- ...ge_drawer_view_overview_section.min.js.map | 2 +- .../message_drawer_view_search.min.js.map | 2 +- .../message_drawer_view_settings.min.js.map | 2 +- ...message_notification_preference.min.js.map | 2 +- message/amd/build/message_popover.min.js.map | 2 +- .../amd/build/message_preferences.min.js.map | 2 +- .../amd/build/message_repository.min.js.map | 2 +- .../amd/build/message_send_bulk.min.js.map | 2 +- .../amd/build/message_user_button.min.js.map | 2 +- .../build/notification_preference.min.js.map | 2 +- .../build/notification_processor.min.js.map | 2 +- ...notification_processor_settings.min.js.map | 2 +- ...s_notifications_list_controller.min.js.map | 2 +- .../preferences_processor_form.min.js.map | 2 +- .../build/toggle_contact_button.min.js.map | 2 +- ...oodle-message_airnotifier-toolboxes-min.js | 2 +- .../notification_area_content_area.min.js.map | 2 +- .../notification_area_control_area.min.js.map | 2 +- .../build/notification_area_events.min.js.map | 2 +- ...notification_popover_controller.min.js.map | 2 +- .../build/notification_repository.min.js.map | 2 +- .../amd/build/grading_actions.min.js.map | 2 +- .../amd/build/grading_events.min.js.map | 2 +- .../grading_form_change_checker.min.js.map | 2 +- .../amd/build/grading_navigation.min.js.map | 2 +- .../grading_navigation_user_info.min.js.map | 2 +- mod/assign/amd/build/grading_panel.min.js.map | 2 +- .../amd/build/grading_review_panel.min.js.map | 2 +- mod/assign/amd/build/override_form.min.js.map | 2 +- .../amd/build/participant_selector.min.js.map | 2 +- mod/assign/amd/build/timer.min.js.map | 2 +- ...oodle-assignfeedback_editpdf-editor-min.js | 18 ++--- .../amd/build/accept_dpa.min.js.map | 2 +- .../amd/build/actions.min.js.map | 2 +- .../amd/build/events.min.js.map | 2 +- .../amd/build/guest_access_modal.min.js.map | 2 +- .../amd/build/index.min.js.map | 2 +- .../amd/build/modform.min.js.map | 2 +- .../amd/build/recordings.min.js.map | 2 +- .../amd/build/repository.min.js.map | 2 +- .../amd/build/rooms.min.js.map | 2 +- .../amd/build/roomupdater.min.js.map | 2 +- mod/data/amd/build/deletepreset.min.js.map | 2 +- mod/data/amd/build/editpreset.min.js.map | 2 +- .../build/importmappingdialogue.min.js.map | 2 +- mod/data/amd/build/importpresets.min.js.map | 2 +- .../amd/build/resetalltemplates.min.js.map | 2 +- mod/data/amd/build/saveaspreset.min.js.map | 2 +- mod/data/amd/build/selectpreset.min.js.map | 2 +- mod/data/amd/build/templateseditor.min.js.map | 2 +- .../amd/build/createtemplate.min.js.map | 2 +- mod/feedback/amd/build/edit.min.js.map | 2 +- mod/feedback/amd/build/usetemplate.min.js.map | 2 +- mod/forum/amd/build/discussion.min.js.map | 2 +- .../amd/build/discussion_list.min.js.map | 2 +- .../amd/build/discussion_nested_v2.min.js | 2 +- .../amd/build/discussion_nested_v2.min.js.map | 2 +- .../amd/build/favourite_toggle.min.js.map | 2 +- .../amd/build/form-user-selector.min.js.map | 2 +- mod/forum/amd/build/forum_events.min.js.map | 2 +- .../grades/expandconversation.min.js.map | 2 +- mod/forum/amd/build/grades/grader.min.js.map | 2 +- .../build/grades/grader/selectors.min.js.map | 2 +- mod/forum/amd/build/inpage_reply.min.js.map | 2 +- .../amd/build/local/grades/grader.min.js | 2 +- .../amd/build/local/grades/grader.min.js.map | 2 +- .../local/grader/gradingpanel.min.js.map | 2 +- .../grades/local/grader/selectors.min.js.map | 2 +- .../local/grader/user_picker.min.js.map | 2 +- .../grader/user_picker/selectors.min.js.map | 2 +- .../build/local/layout/fullscreen.min.js.map | 2 +- mod/forum/amd/build/lock_toggle.min.js.map | 2 +- mod/forum/amd/build/pin_toggle.min.js.map | 2 +- mod/forum/amd/build/posts_list.min.js.map | 2 +- mod/forum/amd/build/repository.min.js | 2 +- mod/forum/amd/build/repository.min.js.map | 2 +- mod/forum/amd/build/selectors.min.js.map | 2 +- .../amd/build/subscription_toggle.min.js.map | 2 +- .../summary/amd/build/filters.min.js.map | 2 +- .../summary/amd/build/selectors.min.js.map | 2 +- .../cartridge_registration_form.min.js.map | 2 +- mod/lti/amd/build/contentitem.min.js.map | 2 +- .../amd/build/contentitem_return.min.js.map | 2 +- mod/lti/amd/build/events.min.js.map | 2 +- .../build/external_registration.min.js.map | 2 +- .../external_registration_return.min.js.map | 2 +- mod/lti/amd/build/form-field.min.js.map | 2 +- mod/lti/amd/build/keys.min.js.map | 2 +- .../amd/build/tool_card_controller.min.js.map | 2 +- .../tool_configure_controller.min.js.map | 2 +- mod/lti/amd/build/tool_proxy.min.js.map | 2 +- .../tool_proxy_card_controller.min.js.map | 2 +- mod/lti/amd/build/tool_type.min.js.map | 2 +- .../build/tool_types_and_proxies.min.js.map | 2 +- .../seb/amd/build/managetemplates.min.js.map | 2 +- .../amd/build/validate_quiz_access.min.js.map | 2 +- .../accessrule/seb/amd/build/view.min.js.map | 2 +- .../add_question_modal_launcher.min.js.map | 2 +- mod/quiz/amd/build/add_random_form.min.js.map | 2 +- .../amd/build/add_random_question.min.js.map | 2 +- .../modal_add_random_question.min.js.map | 2 +- .../build/modal_quiz_question_bank.min.js.map | 2 +- mod/quiz/amd/build/preflightcheck.min.js.map | 2 +- mod/quiz/amd/build/question_slot.min.js.map | 2 +- .../amd/build/quizquestionbank.min.js.map | 2 +- .../random_question_form_preview.min.js.map | 2 +- mod/quiz/amd/build/repaginate.min.js.map | 2 +- .../build/submission_confirmation.min.js.map | 2 +- .../moodle-mod_quiz-autosave-min.js | 2 +- .../moodle-mod_quiz-dragdrop-min.js | 2 +- .../moodle-mod_quiz-quizbase-min.js | 2 +- .../moodle-mod_quiz-toolboxes-min.js | 6 +- .../moodle-mod_quiz-util-page-min.js | 2 +- .../moodle-mod_quiz-util-slot-min.js | 2 +- mod/survey/amd/build/validation.min.js.map | 2 +- mod/workshop/amd/build/modform.min.js.map | 2 +- .../amd/build/workshopview.min.js.map | 2 +- payment/amd/build/events.min.js.map | 2 +- payment/amd/build/gateways_modal.min.js | 2 +- payment/amd/build/gateways_modal.min.js.map | 2 +- payment/amd/build/modal_gateways.min.js.map | 2 +- payment/amd/build/repository.min.js.map | 2 +- payment/amd/build/selectors.min.js.map | 2 +- .../amd/build/gateways_modal.min.js.map | 2 +- .../paypal/amd/build/repository.min.js.map | 2 +- question/amd/build/edit_tags.min.js.map | 2 +- question/amd/build/question_engine.min.js.map | 2 +- question/amd/build/repository.min.js.map | 2 +- question/amd/build/selectors.min.js.map | 2 +- .../amd/build/sort_columns.min.js.map | 2 +- .../bank/comment/amd/build/comment.min.js.map | 2 +- .../amd/build/question_status.min.js.map | 2 +- .../amd/build/preview.min.js.map | 2 +- .../amd/build/edit_tags.min.js.map | 2 +- .../amd/build/repository.min.js.map | 2 +- .../amd/build/selectors.min.js.map | 2 +- .../bank/usage/amd/build/usage.min.js.map | 2 +- .../ddimageortext/amd/build/form.min.js.map | 2 +- .../amd/build/question.min.js.map | 2 +- .../type/ddmarker/amd/build/form.min.js.map | 2 +- .../ddmarker/amd/build/question.min.js.map | 2 +- .../type/ddmarker/amd/build/shapes.min.js.map | 2 +- .../type/ddwtos/amd/build/ddwtos.min.js.map | 2 +- .../multichoice/amd/build/answers.min.js.map | 2 +- .../amd/build/clearchoice.min.js.map | 2 +- .../amd/build/grading_popup.min.js.map | 2 +- .../build/user_course_navigation.min.js.map | 2 +- ...moodle-report_eventlist-eventfilter-min.js | 2 +- report/insights/amd/build/actions.min.js.map | 2 +- .../amd/build/message_users.min.js.map | 2 +- .../amd/build/participants.min.js.map | 2 +- .../amd/build/completion_override.min.js.map | 2 +- reportbuilder/amd/build/audience.min.js.map | 2 +- reportbuilder/amd/build/editor.min.js.map | 2 +- reportbuilder/amd/build/filters.min.js.map | 2 +- .../build/local/editor/card_view.min.js.map | 2 +- .../amd/build/local/editor/columns.min.js.map | 2 +- .../build/local/editor/conditions.min.js.map | 2 +- .../amd/build/local/editor/filters.min.js.map | 2 +- .../amd/build/local/editor/sorting.min.js.map | 2 +- .../amd/build/local/events.min.js.map | 2 +- .../local/repository/audiences.min.js.map | 2 +- .../build/local/repository/columns.min.js.map | 2 +- .../local/repository/conditions.min.js.map | 2 +- .../build/local/repository/filters.min.js.map | 2 +- .../amd/build/local/repository/modals.min.js | 2 +- .../build/local/repository/modals.min.js.map | 2 +- .../amd/build/local/repository/reports.min.js | 2 +- .../build/local/repository/reports.min.js.map | 2 +- .../local/repository/schedules.min.js.map | 2 +- .../build/local/repository/sorting.min.js.map | 2 +- .../amd/build/local/selectors.min.js.map | 2 +- reportbuilder/amd/build/report.min.js.map | 2 +- .../amd/build/reports_list.min.js.map | 2 +- reportbuilder/amd/build/schedules.min.js.map | 2 +- reportbuilder/amd/build/sidebar.min.js.map | 2 +- .../form-search-user-selector.min.js.map | 2 +- theme/boost/amd/build/aria.min.js | 2 +- theme/boost/amd/build/aria.min.js.map | 2 +- theme/boost/amd/build/bootstrap/alert.min.js | 2 +- .../amd/build/bootstrap/alert.min.js.map | 2 +- .../amd/build/bootstrap/button.min.js.map | 2 +- .../amd/build/bootstrap/carousel.min.js.map | 2 +- .../amd/build/bootstrap/collapse.min.js.map | 2 +- .../amd/build/bootstrap/dropdown.min.js.map | 2 +- theme/boost/amd/build/bootstrap/modal.min.js | 2 +- .../amd/build/bootstrap/modal.min.js.map | 2 +- .../amd/build/bootstrap/popover.min.js.map | 2 +- .../amd/build/bootstrap/scrollspy.min.js.map | 2 +- .../boost/amd/build/bootstrap/tab.min.js.map | 2 +- theme/boost/amd/build/bootstrap/toast.min.js | 2 +- .../amd/build/bootstrap/toast.min.js.map | 2 +- .../bootstrap/tools/sanitizer.min.js.map | 2 +- .../amd/build/bootstrap/tooltip.min.js.map | 2 +- theme/boost/amd/build/bootstrap/util.min.js | 2 +- .../boost/amd/build/bootstrap/util.min.js.map | 2 +- theme/boost/amd/build/drawer.min.js.map | 2 +- theme/boost/amd/build/drawers.min.js | 2 +- theme/boost/amd/build/drawers.min.js.map | 2 +- .../boost/amd/build/footer-popover.min.js.map | 2 +- .../amd/build/form-display-errors.min.js.map | 2 +- theme/boost/amd/build/index.min.js.map | 2 +- theme/boost/amd/build/loader.min.js.map | 2 +- theme/boost/amd/build/pending.min.js.map | 2 +- theme/boost/amd/build/popover.min.js.map | 2 +- .../boost/amd/build/sticky-footer.min.js.map | 2 +- theme/boost/amd/build/toast.min.js.map | 2 +- user/amd/build/edit_profile_fields.min.js.map | 2 +- user/amd/build/form_user_selector.min.js | 2 +- user/amd/build/form_user_selector.min.js.map | 2 +- .../local/participants/bulkactions.min.js.map | 2 +- user/amd/build/participants.min.js.map | 2 +- user/amd/build/participants_filter.min.js.map | 2 +- user/amd/build/private_files.min.js.map | 2 +- user/amd/build/repository.min.js.map | 2 +- user/amd/build/status_field.min.js.map | 2 +- 736 files changed, 845 insertions(+), 845 deletions(-) diff --git a/admin/tool/analytics/amd/build/log_info.min.js.map b/admin/tool/analytics/amd/build/log_info.min.js.map index 38c60d0eedc..eb0a63c98db 100644 --- a/admin/tool/analytics/amd/build/log_info.min.js.map +++ b/admin/tool/analytics/amd/build/log_info.min.js.map @@ -1 +1 @@ -{"version":3,"file":"log_info.min.js","sources":["../src/log_info.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Shows a dialogue with info about this logs.\n *\n * @module tool_analytics/log_info\n * @copyright 2017 David Monllao {@link http://www.davidmonllao.com}\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/modal_factory', 'core/notification'], function($, str, ModalFactory, Notification) {\n\n return /** @alias module:tool_analytics/log_info */ {\n\n /**\n * Prepares a modal info for a log's results.\n *\n * @method loadInfo\n * @param {int} id\n * @param {string[]} info\n */\n loadInfo: function(id, info) {\n\n var link = $('[data-model-log-id=\"' + id + '\"]');\n str.get_string('loginfo', 'tool_analytics').then(function(langString) {\n\n var bodyInfo = $(\"\");\n\n return ModalFactory.create({\n title: langString,\n body: bodyInfo.html(),\n large: true,\n }, link);\n\n }).catch(Notification.exception);\n }\n };\n});\n"],"names":["define","$","str","ModalFactory","Notification","loadInfo","id","info","link","get_string","then","langString","bodyInfo","forEach","item","append","create","title","body","html","large","catch","exception"],"mappings":";;;;;;;AAsBAA,iCAAO,CAAC,SAAU,WAAY,qBAAsB,sBAAsB,SAASC,EAAGC,IAAKC,aAAcC,oBAEjD,CAShDC,SAAU,SAASC,GAAIC,UAEfC,KAAOP,EAAE,uBAAyBK,GAAK,MAC3CJ,IAAIO,WAAW,UAAW,kBAAkBC,MAAK,SAASC,gBAElDC,SAAWX,EAAE,eACjBM,KAAKM,SAAQ,SAASC,MAClBF,SAASG,OAAO,OAASD,KAAO,YAEpCF,SAASG,OAAO,SAETZ,aAAaa,OAAO,CACvBC,MAAON,WACPO,KAAMN,SAASO,OACfC,OAAO,GACRZ,SAEJa,MAAMjB,aAAakB"} \ No newline at end of file +{"version":3,"file":"log_info.min.js","sources":["../src/log_info.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Shows a dialogue with info about this logs.\n *\n * @module tool_analytics/log_info\n * @copyright 2017 David Monllao {@link http://www.davidmonllao.com}\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/modal_factory', 'core/notification'], function($, str, ModalFactory, Notification) {\n\n return /** @alias module:tool_analytics/log_info */ {\n\n /**\n * Prepares a modal info for a log's results.\n *\n * @method loadInfo\n * @param {int} id\n * @param {string[]} info\n */\n loadInfo: function(id, info) {\n\n var link = $('[data-model-log-id=\"' + id + '\"]');\n str.get_string('loginfo', 'tool_analytics').then(function(langString) {\n\n var bodyInfo = $(\"
    \");\n info.forEach(function(item) {\n bodyInfo.append('
  • ' + item + '
  • ');\n });\n bodyInfo.append(\"
\");\n\n return ModalFactory.create({\n title: langString,\n body: bodyInfo.html(),\n large: true,\n }, link);\n\n }).catch(Notification.exception);\n }\n };\n});\n"],"names":["define","$","str","ModalFactory","Notification","loadInfo","id","info","link","get_string","then","langString","bodyInfo","forEach","item","append","create","title","body","html","large","catch","exception"],"mappings":";;;;;;;AAsBAA,iCAAO,CAAC,SAAU,WAAY,qBAAsB,sBAAsB,SAASC,EAAGC,IAAKC,aAAcC,cAErG,MAAoD,CAShDC,SAAU,SAASC,GAAIC,MAEnB,IAAIC,KAAOP,EAAE,uBAAyBK,GAAK,MAC3CJ,IAAIO,WAAW,UAAW,kBAAkBC,MAAK,SAASC,YAEtD,IAAIC,SAAWX,EAAE,QAMjB,OALAM,KAAKM,SAAQ,SAASC,MAClBF,SAASG,OAAO,OAASD,KAAO,QACpC,IACAF,SAASG,OAAO,SAETZ,aAAaa,OAAO,CACvBC,MAAON,WACPO,KAAMN,SAASO,OACfC,OAAO,GACRZ,KAEN,IAAEa,MAAMjB,aAAakB,UAC1B,EAER"} \ No newline at end of file diff --git a/admin/tool/analytics/amd/build/model.min.js.map b/admin/tool/analytics/amd/build/model.min.js.map index f50f1c0f05a..237c1d8d0a5 100644 --- a/admin/tool/analytics/amd/build/model.min.js.map +++ b/admin/tool/analytics/amd/build/model.min.js.map @@ -1 +1 @@ -{"version":3,"file":"model.min.js","sources":["../src/model.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * AMD module for model actions confirmation.\n *\n * @module tool_analytics/model\n * @copyright 2017 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_factory', 'core/modal_events', 'core/templates'],\n function($, Str, log, Notification, ModalFactory, ModalEvents, Templates) {\n\n /**\n * List of actions that require confirmation and confirmation message.\n */\n var actionsList = {\n clear: {\n title: {\n key: 'clearpredictions',\n component: 'tool_analytics'\n }, body: {\n key: 'clearmodelpredictions',\n component: 'tool_analytics'\n }\n\n },\n 'delete': {\n title: {\n key: 'delete',\n component: 'tool_analytics'\n }, body: {\n key: 'deletemodelconfirmation',\n component: 'tool_analytics'\n }\n }\n };\n\n /**\n * Returns the model name.\n *\n * @param {Object} actionItem The action item DOM node.\n * @return {String}\n */\n var getModelName = function(actionItem) {\n var wrap = $(actionItem).closest('[data-model-name]');\n\n if (wrap.length) {\n return wrap.attr('data-model-name');\n\n } else {\n log.error('Unexpected DOM error - unable to obtain the model name');\n return '';\n }\n };\n\n /** @alias module:tool_analytics/model */\n return {\n\n /**\n * Displays a confirm modal window before executing the action.\n *\n * @param {String} actionId\n * @param {String} actionType\n */\n confirmAction: function(actionId, actionType) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n if (typeof actionsList[actionType] === \"undefined\") {\n log.error('Action \"' + actionType + '\" is not allowed.');\n return;\n }\n\n var reqStrings = [\n actionsList[actionType].title,\n actionsList[actionType].body\n ];\n reqStrings[1].param = getModelName(a);\n\n var stringsPromise = Str.get_strings(reqStrings);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n modal.setTitle(strings[0]);\n modal.setBody(strings[1]);\n modal.setSaveButtonText(strings[0]);\n modal.getRoot().on(ModalEvents.save, function() {\n window.location.href = a.attr('href');\n });\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n },\n\n /**\n * Displays evaluation mode and time-splitting method choices.\n *\n * @param {String} actionId\n * @param {Boolean} trainedOnlyExternally\n */\n selectEvaluationOptions: function(actionId, trainedOnlyExternally) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n var timeSplittingMethods = $(this).attr('data-timesplitting-methods');\n\n var stringsPromise = Str.get_strings([\n {\n key: 'evaluatemodel',\n component: 'tool_analytics'\n }, {\n key: 'evaluate',\n component: 'tool_analytics'\n }\n ]);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n var bodyPromise = Templates.render('tool_analytics/evaluation_options', {\n trainedexternally: trainedOnlyExternally,\n timesplittingmethods: JSON.parse(timeSplittingMethods)\n });\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n\n\n modal.getRoot().on(ModalEvents.hidden, modal.destroy.bind(modal));\n\n modal.setTitle(strings[0]);\n modal.setSaveButtonText(strings[1]);\n modal.setBody(bodyPromise);\n\n modal.getRoot().on(ModalEvents.save, function() {\n\n // Evaluation mode.\n var evaluationMode = $(\"input[name='evaluationmode']:checked\").val();\n if (evaluationMode == 'trainedmodel') {\n a.attr('href', a.attr('href') + '&mode=trainedmodel');\n }\n\n // Selected time-splitting id.\n var timeSplittingMethod = $(\"#id-evaluation-timesplitting\").val();\n a.attr('href', a.attr('href') + '×plitting=' + timeSplittingMethod);\n\n window.location.href = a.attr('href');\n return;\n });\n\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n },\n\n /**\n * Displays export options.\n *\n * We have two main options: export training data and export configuration.\n * The 2nd option has an extra option: include the trained algorithm weights.\n *\n * @param {String} actionId\n * @param {Boolean} isTrained\n */\n selectExportOptions: function(actionId, isTrained) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n if (!isTrained) {\n // Export the model configuration if the model is not trained. We can't export anything else.\n a.attr('href', a.attr('href') + '&action=exportmodel&includeweights=0');\n window.location.href = a.attr('href');\n return;\n }\n\n var stringsPromise = Str.get_strings([\n {\n key: 'export',\n component: 'tool_analytics'\n }\n ]);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n var bodyPromise = Templates.render('tool_analytics/export_options', {});\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n\n modal.getRoot().on(ModalEvents.hidden, modal.destroy.bind(modal));\n\n modal.setTitle(strings[0]);\n modal.setSaveButtonText(strings[0]);\n modal.setBody(bodyPromise);\n\n modal.getRoot().on(ModalEvents.save, function() {\n\n var exportOption = $(\"input[name='exportoption']:checked\").val();\n\n if (exportOption == 'exportdata') {\n a.attr('href', a.attr('href') + '&action=exportdata');\n\n } else {\n a.attr('href', a.attr('href') + '&action=exportmodel');\n if ($(\"#id-includeweights\").is(':checked')) {\n a.attr('href', a.attr('href') + '&includeweights=1');\n } else {\n a.attr('href', a.attr('href') + '&includeweights=0');\n }\n }\n\n window.location.href = a.attr('href');\n return;\n });\n\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n }\n };\n});\n"],"names":["define","$","Str","log","Notification","ModalFactory","ModalEvents","Templates","actionsList","clear","title","key","component","body","confirmAction","actionId","actionType","on","ev","preventDefault","a","currentTarget","wrap","reqStrings","param","closest","length","attr","error","stringsPromise","get_strings","modalPromise","create","type","types","SAVE_CANCEL","when","then","strings","modal","setTitle","setBody","setSaveButtonText","getRoot","save","window","location","href","show","fail","exception","selectEvaluationOptions","trainedOnlyExternally","timeSplittingMethods","this","bodyPromise","render","trainedexternally","timesplittingmethods","JSON","parse","hidden","destroy","bind","val","timeSplittingMethod","selectExportOptions","isTrained","is"],"mappings":";;;;;;;AAsBAA,8BAAO,CAAC,SAAU,WAAY,WAAY,oBAAqB,qBAAsB,oBAAqB,mBACtG,SAASC,EAAGC,IAAKC,IAAKC,aAAcC,aAAcC,YAAaC,eAK3DC,YAAc,CACdC,MAAO,CACHC,MAAO,CACHC,IAAK,mBACLC,UAAW,kBACZC,KA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U1B,GAAGX,YAAYsC,MAAM,WAIb,cAFD3C,EAAE,sCAAsC+D,MAGvD5C,EAAEO,KAAK,OAAQP,EAAEO,KAAK,QAAU,uBAGhCP,EAAEO,KAAK,OAAQP,EAAEO,KAAK,QAAU,uBAC5B1B,EAAE,sBAAsBmE,GAAG,YAC3BhD,EAAEO,KAAK,OAAQP,EAAEO,KAAK,QAAU,qBAEhCP,EAAEO,KAAK,OAAQP,EAAEO,KAAK,QAAU,sBAIxCkB,OAAOC,SAASC,KAAO3B,EAAEO,KAAK,WAIlCY,MAAMS,OACCT,SACRU,KAAK7C,aAAa8C"} \ No newline at end of file +{"version":3,"file":"model.min.js","sources":["../src/model.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * AMD module for model actions confirmation.\n *\n * @module tool_analytics/model\n * @copyright 2017 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_factory', 'core/modal_events', 'core/templates'],\n function($, Str, log, Notification, ModalFactory, ModalEvents, Templates) {\n\n /**\n * List of actions that require confirmation and confirmation message.\n */\n var actionsList = {\n clear: {\n title: {\n key: 'clearpredictions',\n component: 'tool_analytics'\n }, body: {\n key: 'clearmodelpredictions',\n component: 'tool_analytics'\n }\n\n },\n 'delete': {\n title: {\n key: 'delete',\n component: 'tool_analytics'\n }, body: {\n key: 'deletemodelconfirmation',\n component: 'tool_analytics'\n }\n }\n };\n\n /**\n * Returns the model name.\n *\n * @param {Object} actionItem The action item DOM node.\n * @return {String}\n */\n var getModelName = function(actionItem) {\n var wrap = $(actionItem).closest('[data-model-name]');\n\n if (wrap.length) {\n return wrap.attr('data-model-name');\n\n } else {\n log.error('Unexpected DOM error - unable to obtain the model name');\n return '';\n }\n };\n\n /** @alias module:tool_analytics/model */\n return {\n\n /**\n * Displays a confirm modal window before executing the action.\n *\n * @param {String} actionId\n * @param {String} actionType\n */\n confirmAction: function(actionId, actionType) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n if (typeof actionsList[actionType] === \"undefined\") {\n log.error('Action \"' + actionType + '\" is not allowed.');\n return;\n }\n\n var reqStrings = [\n actionsList[actionType].title,\n actionsList[actionType].body\n ];\n reqStrings[1].param = getModelName(a);\n\n var stringsPromise = Str.get_strings(reqStrings);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n modal.setTitle(strings[0]);\n modal.setBody(strings[1]);\n modal.setSaveButtonText(strings[0]);\n modal.getRoot().on(ModalEvents.save, function() {\n window.location.href = a.attr('href');\n });\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n },\n\n /**\n * Displays evaluation mode and time-splitting method choices.\n *\n * @param {String} actionId\n * @param {Boolean} trainedOnlyExternally\n */\n selectEvaluationOptions: function(actionId, trainedOnlyExternally) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n var timeSplittingMethods = $(this).attr('data-timesplitting-methods');\n\n var stringsPromise = Str.get_strings([\n {\n key: 'evaluatemodel',\n component: 'tool_analytics'\n }, {\n key: 'evaluate',\n component: 'tool_analytics'\n }\n ]);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n var bodyPromise = Templates.render('tool_analytics/evaluation_options', {\n trainedexternally: trainedOnlyExternally,\n timesplittingmethods: JSON.parse(timeSplittingMethods)\n });\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n\n\n modal.getRoot().on(ModalEvents.hidden, modal.destroy.bind(modal));\n\n modal.setTitle(strings[0]);\n modal.setSaveButtonText(strings[1]);\n modal.setBody(bodyPromise);\n\n modal.getRoot().on(ModalEvents.save, function() {\n\n // Evaluation mode.\n var evaluationMode = $(\"input[name='evaluationmode']:checked\").val();\n if (evaluationMode == 'trainedmodel') {\n a.attr('href', a.attr('href') + '&mode=trainedmodel');\n }\n\n // Selected time-splitting id.\n var timeSplittingMethod = $(\"#id-evaluation-timesplitting\").val();\n a.attr('href', a.attr('href') + '×plitting=' + timeSplittingMethod);\n\n window.location.href = a.attr('href');\n return;\n });\n\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n },\n\n /**\n * Displays export options.\n *\n * We have two main options: export training data and export configuration.\n * The 2nd option has an extra option: include the trained algorithm weights.\n *\n * @param {String} actionId\n * @param {Boolean} isTrained\n */\n selectExportOptions: function(actionId, isTrained) {\n $('[data-action-id=\"' + actionId + '\"]').on('click', function(ev) {\n ev.preventDefault();\n\n var a = $(ev.currentTarget);\n\n if (!isTrained) {\n // Export the model configuration if the model is not trained. We can't export anything else.\n a.attr('href', a.attr('href') + '&action=exportmodel&includeweights=0');\n window.location.href = a.attr('href');\n return;\n }\n\n var stringsPromise = Str.get_strings([\n {\n key: 'export',\n component: 'tool_analytics'\n }\n ]);\n var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});\n var bodyPromise = Templates.render('tool_analytics/export_options', {});\n\n $.when(stringsPromise, modalPromise).then(function(strings, modal) {\n\n modal.getRoot().on(ModalEvents.hidden, modal.destroy.bind(modal));\n\n modal.setTitle(strings[0]);\n modal.setSaveButtonText(strings[0]);\n modal.setBody(bodyPromise);\n\n modal.getRoot().on(ModalEvents.save, function() {\n\n var exportOption = $(\"input[name='exportoption']:checked\").val();\n\n if (exportOption == 'exportdata') {\n a.attr('href', a.attr('href') + '&action=exportdata');\n\n } else {\n a.attr('href', a.attr('href') + '&action=exportmodel');\n if ($(\"#id-includeweights\").is(':checked')) {\n a.attr('href', a.attr('href') + '&includeweights=1');\n } else {\n a.attr('href', a.attr('href') + '&includeweights=0');\n }\n }\n\n window.location.href = a.attr('href');\n return;\n });\n\n modal.show();\n return modal;\n }).fail(Notification.exception);\n });\n }\n };\n});\n"],"names":["define","$","Str","log","Notification","ModalFactory","ModalEvents","Templates","actionsList","clear","title","key","component","body","delete","confirmAction","actionId","actionType","on","ev","preventDefault","a","currentTarget","wrap","reqStrings","param","closest","length","attr","error","stringsPromise","get_strings","modalPromise","create","type","types","SAVE_CANCEL","when","then","strings","modal","setTitle","setBody","setSaveButtonText","getRoot","save","window","location","href","show","fail","exception","selectEvaluationOptions","trainedOnlyExternally","timeSplittingMethods","this","bodyPromise","render","trainedexternally","timesplittingmethods","JSON","parse","hidden","destroy","bind","val","timeSplittingMethod","selectExportOptions","isTrained","is"],"mappings":";;;;;;;AAsBAA,OAAO,uBAAA,CAAC,SAAU,WAAY,WAAY,oBAAqB,qBAAsB,oBAAqB,mBACtG,SAASC,EAAGC,IAAKC,IAAKC,aAAcC,aAAcC,YAAaC,WAK/D,IAAIC,YAAc,CACdC,MAAO,CACHC,MAAO,CACHC,IAAK,mBACLC,UAAW,kBACZC,KAAM,CACLF,IAAK,wBACLC,UAAW,mBAInBE,OAAU,CACNJ,MAAO,CACHC,IAAK,SACLC,UAAW,kBACZC,KAAM,CACLF,IAAK,0BACLC,UAAW,oBAwBvB,MAAO,CAQHG,cAAe,SAASC,SAAUC,YAC9BhB,EAAE,oBAAsBe,SAAW,MAAME,GAAG,SAAS,SAASC,IAC1DA,GAAGC,iBAEH,IAAIC,EAAIpB,EAAEkB,GAAGG,eAEb,QAAuC,IAA5Bd,YAAYS,YAAvB,CAKA,IA/BJM,KA+BQC,WAAa,CACbhB,YAAYS,YAAYP,MACxBF,YAAYS,YAAYJ,MAE5BW,WAAW,GAAGC,OAnClBF,KAAOtB,E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,EAAEO,KAAK,OAAQP,EAAEO,KAAK,QAAU,sBAIxCkB,OAAOC,SAASC,KAAO3B,EAAEO,KAAK,OAElC,IAEAY,MAAMS,OACCT,KACV,IAAEU,KAAK9C,aAAa+C,UACzB,GACJ,EAER"} \ No newline at end of file diff --git a/admin/tool/analytics/amd/build/potential-contexts.min.js.map b/admin/tool/analytics/amd/build/potential-contexts.min.js.map index 82ec224e954..70cac7783d4 100644 --- a/admin/tool/analytics/amd/build/potential-contexts.min.js.map +++ b/admin/tool/analytics/amd/build/potential-contexts.min.js.map @@ -1 +1 @@ -{"version":3,"file":"potential-contexts.min.js","sources":["../src/potential-contexts.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Potential contexts selector module.\n *\n * @module tool_analytics/potential-contexts\n * @copyright 2019 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax'], function($, Ajax) {\n\n return /** @alias module:tool_analytics/potential-contexts */ {\n\n processResults: function(selector, results) {\n var contexts = [];\n if ($.isArray(results)) {\n $.each(results, function(index, context) {\n contexts.push({\n value: context.id,\n label: context.name\n });\n });\n return contexts;\n\n } else {\n return results;\n }\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n\n let modelid = $(selector).attr('modelid') || null;\n promise = Ajax.call([{\n methodname: 'tool_analytics_potential_contexts',\n args: {\n query: query,\n modelid: modelid\n }\n }]);\n\n promise[0].then(success).fail(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","processResults","selector","results","contexts","isArray","each","index","context","push","value","id","label","name","transport","query","success","failure","modelid","attr","call","methodname","args","then","fail"],"mappings":";;;;;;;AAuBAA,2CAAO,CAAC,SAAU,cAAc,SAASC,EAAGC,YAEsB,CAE1DC,eAAgB,SAASC,SAAUC,aAC3BC,SAAW,UACXL,EAAEM,QAAQF,UACVJ,EAAEO,KAAKH,SAAS,SAASI,MAAOC,SAC5BJ,SAASK,KAAK,CACVC,MAAOF,QAAQG,GACfC,MAAOJ,QAAQK,UAGhBT,UAGAD,SAIfW,UAAW,SAASZ,SAAUa,MAAOC,QAASC,aAGtCC,QAAUnB,EAAEG,UAAUiB,KAAK,YAAc,KACnCnB,KAAKoB,KAAK,CAAC,CACjBC,WAAY,oCACZC,KAAM,CACFP,MAAOA,MACPG,QAASA,YAIT,GAAGK,KAAKP,SAASQ,KAAKP"} \ No newline at end of file +{"version":3,"file":"potential-contexts.min.js","sources":["../src/potential-contexts.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Potential contexts selector module.\n *\n * @module tool_analytics/potential-contexts\n * @copyright 2019 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax'], function($, Ajax) {\n\n return /** @alias module:tool_analytics/potential-contexts */ {\n\n processResults: function(selector, results) {\n var contexts = [];\n if ($.isArray(results)) {\n $.each(results, function(index, context) {\n contexts.push({\n value: context.id,\n label: context.name\n });\n });\n return contexts;\n\n } else {\n return results;\n }\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n\n let modelid = $(selector).attr('modelid') || null;\n promise = Ajax.call([{\n methodname: 'tool_analytics_potential_contexts',\n args: {\n query: query,\n modelid: modelid\n }\n }]);\n\n promise[0].then(success).fail(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","processResults","selector","results","contexts","isArray","each","index","context","push","value","id","label","name","transport","query","success","failure","modelid","attr","call","methodname","args","then","fail"],"mappings":";;;;;;;AAuBAA,OAAM,oCAAC,CAAC,SAAU,cAAc,SAASC,EAAGC,MAExC,MAA8D,CAE1DC,eAAgB,SAASC,SAAUC,SAC/B,IAAIC,SAAW,GACf,OAAIL,EAAEM,QAAQF,UACVJ,EAAEO,KAAKH,SAAS,SAASI,MAAOC,SAC5BJ,SAASK,KAAK,CACVC,MAAOF,QAAQG,GACfC,MAAOJ,QAAQK,MAEvB,IACOT,UAGAD,OAEd,EAEDW,UAAW,SAASZ,SAAUa,MAAOC,QAASC,SAG1C,IAAIC,QAAUnB,EAAEG,UAAUiB,KAAK,YAAc,KACnCnB,KAAKoB,KAAK,CAAC,CACjBC,WAAY,oCACZC,KAAM,CACFP,MAAOA,MACPG,QAASA,YAIT,GAAGK,KAAKP,SAASQ,KAAKP,QAClC,EAIR"} \ No newline at end of file diff --git a/admin/tool/behat/amd/build/steps.min.js.map b/admin/tool/behat/amd/build/steps.min.js.map index 55696afe495..4c6561126ff 100644 --- a/admin/tool/behat/amd/build/steps.min.js.map +++ b/admin/tool/behat/amd/build/steps.min.js.map @@ -1 +1 @@ -{"version":3,"file":"steps.min.js","sources":["../src/steps.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\nimport Ajax from 'core/ajax';\nimport Templates from 'core/templates';\nimport PendingJS from 'core/pending';\n\n/**\n * Enhancements for the step definitions page.\n *\n * @module tool_behat/steps\n * @copyright 2022 Catalyst IT EU\n * @author Mark Johnson \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Call the get_entity_generator web service function\n *\n * Takes the name of an entity generator and returns an object containing a list of the required fields.\n *\n * @param {String} entityType\n * @returns {Promise}\n */\nconst getGeneratorEntities = (entityType) => Ajax.call([{\n methodname: 'tool_behat_get_entity_generator',\n args: {entitytype: entityType}\n}])[0];\n\n/**\n * Render HTML for required fields\n *\n * Takes the entity data returned from getGeneratorEntities and renders the HTML to display the required fields.\n *\n * @param {String} entityData\n * @return {Promise}\n */\nconst getRequiredFieldsContent = (entityData) => {\n if (!entityData.required?.length) {\n return Promise.resolve({\n html: '',\n js: ''\n });\n }\n return Templates.renderForPromise('tool_behat/steprequiredfields', {fields: entityData.required});\n};\n\nexport const init = () => {\n // When an entity is selected in the \"the following exist\" step, fetch and display the required fields.\n document.addEventListener('change', async(e) => {\n const entityElement = e.target.closest('.entities');\n const stepElement = e.target.closest('.stepcontent');\n if (!entityElement || !stepElement) {\n return;\n }\n\n const pendingPromise = new PendingJS('tool_behat/steps:change');\n\n const entityData = await getGeneratorEntities(e.target.value);\n const {html, js} = await getRequiredFieldsContent(entityData);\n\n const stepRequiredFields = stepElement.querySelector('.steprequiredfields');\n if (stepRequiredFields) {\n await Templates.replaceNode(stepRequiredFields, html, js);\n } else {\n await Templates.appendNodeContents(stepElement, html, js);\n }\n pendingPromise.resolve();\n });\n};\n"],"names":["document","addEventListener","async","entityElement","e","target","closest","stepElement","pendingPromise","PendingJS","entityData","entityType","value","Ajax","call","methodname","args","entitytype","html","js","required","_entityData$required","length","Templates","renderForPromise","fields","Promise","resolve","getRequiredFieldsContent","stepRequiredFields","querySelector","replaceNode","appendNodeContents"],"mappings":";;;;;;;;4NA2DoB,KAEhBA,SAASC,iBAAiB,UAAUC,MAAAA,UAC1BC,cAAgBC,EAAEC,OAAOC,QAAQ,aACjCC,YAAcH,EAAEC,OAAOC,QAAQ,oBAChCH,gBAAkBI,yBAIjBC,eAAiB,IAAIC,iBAAU,2BAE/BC,iBAlCgBC,WAkCwBP,EAAEC,OAAOO,MAlClBC,cAAKC,KAAK,CAAC,CACpDC,WAAY,kCACZC,KAAM,CAACC,WAAYN,eACnB,IAH0BA,IAAAA,iBAmChBO,KAACA,KAADC,GAAOA,SAtBaT,CAAAA,0EACzBA,WAAWU,0CAAXC,qBAAqBC,OAMnBC,mBAAUC,iBAAiB,gCAAiC,CAACC,OAAQf,WAAWU,WAL5EM,QAAQC,QAAQ,CACnBT,KAAM,GACNC,GAAI,MAkBiBS,CAAyBlB,YAE5CmB,mBAAqBtB,YAAYuB,cAAc,uBACjDD,yBACMN,mBAAUQ,YAAYF,mBAAoBX,KAAMC,UAEhDI,mBAAUS,mBAAmBzB,YAAaW,KAAMC,IAE1DX,eAAemB"} \ No newline at end of file +{"version":3,"file":"steps.min.js","sources":["../src/steps.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\nimport Ajax from 'core/ajax';\nimport Templates from 'core/templates';\nimport PendingJS from 'core/pending';\n\n/**\n * Enhancements for the step definitions page.\n *\n * @module tool_behat/steps\n * @copyright 2022 Catalyst IT EU\n * @author Mark Johnson \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Call the get_entity_generator web service function\n *\n * Takes the name of an entity generator and returns an object containing a list of the required fields.\n *\n * @param {String} entityType\n * @returns {Promise}\n */\nconst getGeneratorEntities = (entityType) => Ajax.call([{\n methodname: 'tool_behat_get_entity_generator',\n args: {entitytype: entityType}\n}])[0];\n\n/**\n * Render HTML for required fields\n *\n * Takes the entity data returned from getGeneratorEntities and renders the HTML to display the required fields.\n *\n * @param {String} entityData\n * @return {Promise}\n */\nconst getRequiredFieldsContent = (entityData) => {\n if (!entityData.required?.length) {\n return Promise.resolve({\n html: '',\n js: ''\n });\n }\n return Templates.renderForPromise('tool_behat/steprequiredfields', {fields: entityData.required});\n};\n\nexport const init = () => {\n // When an entity is selected in the \"the following exist\" step, fetch and display the required fields.\n document.addEventListener('change', async(e) => {\n const entityElement = e.target.closest('.entities');\n const stepElement = e.target.closest('.stepcontent');\n if (!entityElement || !stepElement) {\n return;\n }\n\n const pendingPromise = new PendingJS('tool_behat/steps:change');\n\n const entityData = await getGeneratorEntities(e.target.value);\n const {html, js} = await getRequiredFieldsContent(entityData);\n\n const stepRequiredFields = stepElement.querySelector('.steprequiredfields');\n if (stepRequiredFields) {\n await Templates.replaceNode(stepRequiredFields, html, js);\n } else {\n await Templates.appendNodeContents(stepElement, html, js);\n }\n pendingPromise.resolve();\n });\n};\n"],"names":["_interopRequireDefault","obj","__esModule","default","_ajax","_templates","_pending","_exports","init","document","addEventListener","async","entityElement","e","target","closest","stepElement","pendingPromise","PendingJS","entityData","entityType","value","Ajax","call","methodname","args","entitytype","html","js","_entityData$required","required","length","Templates","renderForPromise","fields","Promise","resolve","getRequiredFieldsContent","stepRequiredFields","querySelector","replaceNode","appendNodeContents"],"mappings":"gIAiBqC,SAAAA,uBAAAC,KAAAA,OAAAA,KAAAA,IAAAC,WAAAD,IAAAE,CAAAA,QAAAF,IAAA;;;;;;;;kFAFrCG,MAAAJ,uBAAAI,OACAC,WAAAL,uBAAAK,YACAC,SAAAN,uBAAAM,UAgEEC,SAAAC,KAtBkBA,KAEhBC,SAASC,iBAAiB,UAAUC,UAChC,MAAMC,cAAgBC,EAAEC,OAAOC,QAAQ,aACjCC,YAAcH,EAAEC,OAAOC,QAAQ,gBACrC,IAAKH,gBAAkBI,YACnB,OAGJ,MAAMC,eAAiB,IAAIC,SAASf,QAAC,2BAE/BgB,iBAlCgBC,WAkCwBP,EAAEC,OAAOO,MAlClBC,cAAKC,KAAK,CAAC,CACpDC,WAAY,kCACZC,KAAM,CAACC,WAAYN,eACnB,IAH0BA,eAmCtB,MAAMO,KAACA,KAAIC,GAAEA,SAtBaT,cAAe,IAAAU,qBAC7C,OAAwBA,QAApBA,qBAACV,WAAWW,gBAAXD,IAAmBA,sBAAnBA,qBAAqBE,OAMnBC,WAAS7B,QAAC8B,iBAAiB,gCAAiC,CAACC,OAAQf,WAAWW,WAL5EK,QAAQC,QAAQ,CACnBT,KAAM,GACNC,GAAI,IAGqF,EAepES,CAAyBlB,YAE5CmB,mBAAqBtB,YAAYuB,cAAc,uBACjDD,yBACMN,WAAAA,QAAUQ,YAAYF,mBAAoBX,KAAMC,UAEhDI,WAAAA,QAAUS,mBAAmBzB,YAAaW,KAAMC,IAE1DX,eAAemB,SAAS,GAC1B,CACJ"} \ No newline at end of file diff --git a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js index fee3a858e71..b90e165c5b8 100644 --- a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js +++ b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js @@ -1 +1 @@ -YUI.add("moodle-tool_capability-search",function(s,t){var e=function(){e.superclass.constructor.apply(this,arguments)};s.extend(e,s.Base,e.prototype={form:null,select:null,selectoptions:{},input:null,button:null,cancel:null,lastsearch:null,initializer:function(){this.form=s.one("#capability-overview-form"),this.select=this.form.one("select[data-search=capability]"),this.select.setStyle("minWidth",this.select.get("offsetWidth")),this.select.get("options").each(function(t){var e=t.get("value");this.selectoptions[e]=t},this),this.button=this.form.all("input[type=submit]"),this.lastsearch=this.form.one("input[name=search]");var t=s.Node.create('
'),e=s.Node.create('");this.cancel=s.Node.create(''),this.input=s.Node.create(''),t.append(e).append(this.input).append(this.cancel),this.select.insert(t,"before"),this.input.on("keyup",this.typed,this),this.select.on("change",this.validate,this),this.cancel.on("click",function(){this.input.set("value",""),this.typed()},this),this.lastsearch&&(this.input.set("value",this.lastsearch.get("value")),this.typed(),this.select.one("option[selected]")&&this.select.set("scrollTop",this.select.one("option[selected]").get("getX"))),this.validate()},validate:function(){this.button.set("disabled",""===this.select.get("value"))},typed:function(){var t,e=this.input.get("value"),s=0,i=null;for(t in this.lastsearch&&this.lastsearch.set("value",e),this.select.all("option").remove(),this.selectoptions)0<=t.indexOf(e)&&(s++,i=this.selectoptions[t],this.select.append(this.selectoptions[t]));0===s?this.input.addClass("error"):(this.input.removeClass("error"),1===s&&i.set("selected",!0)),""!==e?this.cancel.removeClass("d-none"):this.cancel.addClass("d-none"),this.validate()}},{NAME:"tool_capability-search",ATTRS:{strsearch:{}}}),M.tool_capability=M.tool_capability||{},M.tool_capability.init_capability_search=function(t){new e(t)}},"@VERSION@",{requires:["base","node"]}); \ No newline at end of file +YUI.add("moodle-tool_capability-search",function(s,t){var e=function(){e.superclass.constructor.apply(this,arguments)};s.extend(e,s.Base,e.prototype={form:null,select:null,selectoptions:{},input:null,button:null,cancel:null,lastsearch:null,initializer:function(){this.form=s.one("#capability-overview-form"),this.select=this.form.one("select[data-search=capability]"),this.select.setStyle("minWidth",this.select.get("offsetWidth")),this.select.get("options").each(function(t){var e=t.get("value");this.selectoptions[e]=t},this),this.button=this.form.all("input[type=submit]"),this.lastsearch=this.form.one("input[name=search]");var t=s.Node.create('
'),e=s.Node.create('");this.cancel=s.Node.create(''),this.input=s.Node.create(''),t.append(e).append(this.input).append(this.cancel),this.select.insert(t,"before"),this.input.on("keyup",this.typed,this),this.select.on("change",this.validate,this),this.cancel.on("click",function(){this.input.set("value",""),this.typed()},this),this.lastsearch&&(this.input.set("value",this.lastsearch.get("value")),this.typed(),this.select.one("option[selected]"))&&this.select.set("scrollTop",this.select.one("option[selected]").get("getX")),this.validate()},validate:function(){this.button.set("disabled",""===this.select.get("value"))},typed:function(){var t,e=this.input.get("value"),s=0,i=null;for(t in this.lastsearch&&this.lastsearch.set("value",e),this.select.all("option").remove(),this.selectoptions)0<=t.indexOf(e)&&(s++,i=this.selectoptions[t],this.select.append(this.selectoptions[t]));0===s?this.input.addClass("error"):(this.input.removeClass("error"),1===s&&i.set("selected",!0)),""!==e?this.cancel.removeClass("d-none"):this.cancel.addClass("d-none"),this.validate()}},{NAME:"tool_capability-search",ATTRS:{strsearch:{}}}),M.tool_capability=M.tool_capability||{},M.tool_capability.init_capability_search=function(t){new e(t)}},"@VERSION@",{requires:["base","node"]}); \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js.map b/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js.map index 0c6e79f2a59..634749e1d34 100644 --- a/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js.map +++ b/admin/tool/componentlibrary/amd/build/clipboardwrapper.min.js.map @@ -1 +1 @@ -{"version":3,"file":"clipboardwrapper.min.js","sources":["../src/clipboardwrapper.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Wrapper to ensure that all Hugo example snippets have a \"Copy to clipboard\" button.\n *\n * @module tool_componentlibrary/clipboardwrapper\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport 'core/copy_to_clipboard';\nimport selectors from 'tool_componentlibrary/selectors';\nimport Templates from 'core/templates';\n\nlet idCounter = 0;\n\n/**\n * Initialise the clipboard button on all reusable code.\n *\n * @method\n */\nexport const clipboardWrapper = async() => {\n document.querySelectorAll(selectors.clipboardcontent).forEach(element => {\n if (!element.id) {\n element.id = `tool_componentlibrary_content-${idCounter++}`;\n }\n Templates.renderForPromise('tool_componentlibrary/clipboardbutton', {clipboardtarget: `#${element.id} code`})\n .then(({html, js}) => {\n Templates.prependNodeContents(element, html, js);\n return;\n })\n .catch();\n });\n};\n"],"names":["idCounter","async","document","querySelectorAll","selectors","clipboardcontent","forEach","element","id","renderForPromise","clipboardtarget","then","_ref","html","js","prependNodeContents","catch"],"mappings":";;;;;;;8LA0BIA,UAAY,4BAOgBC,UAC5BC,SAASC,iBAAiBC,mBAAUC,kBAAkBC,SAAQC,UACrDA,QAAQC,KACTD,QAAQC,2CAAsCR,iCAExCS,iBAAiB,wCAAyC,CAACC,2BAAqBH,QAAQC,cACjGG,MAAKC,WAACC,KAACA,KAADC,GAAOA,4BACAC,oBAAoBR,QAASM,KAAMC,OAGhDE"} \ No newline at end of file +{"version":3,"file":"clipboardwrapper.min.js","sources":["../src/clipboardwrapper.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Wrapper to ensure that all Hugo example snippets have a \"Copy to clipboard\" button.\n *\n * @module tool_componentlibrary/clipboardwrapper\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport 'core/copy_to_clipboard';\nimport selectors from 'tool_componentlibrary/selectors';\nimport Templates from 'core/templates';\n\nlet idCounter = 0;\n\n/**\n * Initialise the clipboard button on all reusable code.\n *\n * @method\n */\nexport const clipboardWrapper = async() => {\n document.querySelectorAll(selectors.clipboardcontent).forEach(element => {\n if (!element.id) {\n element.id = `tool_componentlibrary_content-${idCounter++}`;\n }\n Templates.renderForPromise('tool_componentlibrary/clipboardbutton', {clipboardtarget: `#${element.id} code`})\n .then(({html, js}) => {\n Templates.prependNodeContents(element, html, js);\n return;\n })\n .catch();\n });\n};\n"],"names":["_interopRequireDefault","obj","__esModule","default","_selectors","_templates","idCounter","_exports","clipboardWrapper","async","document","querySelectorAll","selectors","clipboardcontent","forEach","element","id","concat","Templates","renderForPromise","clipboardtarget","then","_ref","html","js","prependNodeContents","catch"],"mappings":"qMAwBuC,SAAAA,uBAAAC,KAAAA,OAAAA,KAAAA,IAAAC,WAAAD,IAAAE,CAAAA,QAAAF,IAAA;;;;;;;8FADvCG,WAAAJ,uBAAAI,YACAC,WAAAL,uBAAAK,YAEA,IAAIC,UAAY,EAmBdC,SAAAC,iBAZ8BC,UAC5BC,SAASC,iBAAiBC,WAAST,QAACU,kBAAkBC,SAAQC,UACrDA,QAAQC,KACTD,QAAQC,GAAE,iCAAAC,OAAoCX,cAElDY,WAAAA,QAAUC,iBAAiB,wCAAyC,CAACC,gBAAeH,IAAAA,OAAMF,QAAQC,GAAE,WACnGK,MAAKC,OAAgB,IAAfC,KAACA,KAAIC,GAAEA,IAAGF,KACbJ,WAASf,QAACsB,oBAAoBV,QAASQ,KAAMC,GAC7C,IAEHE,OAAO,GACV,CACJ"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/jsrunner.min.js.map b/admin/tool/componentlibrary/amd/build/jsrunner.min.js.map index cba5b132059..959e62f072e 100644 --- a/admin/tool/componentlibrary/amd/build/jsrunner.min.js.map +++ b/admin/tool/componentlibrary/amd/build/jsrunner.min.js.map @@ -1 +1 @@ -{"version":3,"file":"jsrunner.min.js","sources":["../src/jsrunner.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Run the JS required for example code to work in the library.\n *\n * @module tool_componentlibrary/jsrunner\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport selectors from 'tool_componentlibrary/selectors';\n\n/**\n * The Hugo shortcodes changes the JavaScript in markdownfiles from\n * the Moodle mustache {{js}} code... {{/js}} syntax into a div with\n * attribute data-action='runjs'. See hugo/site/layouts/shortcodes/example.html.\n * This code fetches and runs the JavaScript content.\n *\n * @method\n */\nexport const jsRunner = () => {\n const compLib = document.querySelector(selectors.componentlibrary);\n compLib.querySelectorAll(selectors.jscode).forEach(runjs => {\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.innerHTML = runjs.textContent;\n document.head.appendChild(script);\n });\n};\n"],"names":["document","querySelector","selectors","componentlibrary","querySelectorAll","jscode","forEach","runjs","script","createElement","type","innerHTML","textContent","head","appendChild"],"mappings":";;;;;;;sKAiCwB,KACJA,SAASC,cAAcC,mBAAUC,kBACzCC,iBAAiBF,mBAAUG,QAAQC,SAAQC,cACzCC,OAASR,SAASS,cAAc,UACtCD,OAAOE,KAAO,kBACdF,OAAOG,UAAYJ,MAAMK,YACzBZ,SAASa,KAAKC,YAAYN"} \ No newline at end of file +{"version":3,"file":"jsrunner.min.js","sources":["../src/jsrunner.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Run the JS required for example code to work in the library.\n *\n * @module tool_componentlibrary/jsrunner\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport selectors from 'tool_componentlibrary/selectors';\n\n/**\n * The Hugo shortcodes changes the JavaScript in markdownfiles from\n * the Moodle mustache {{js}} code... {{/js}} syntax into a div with\n * attribute data-action='runjs'. See hugo/site/layouts/shortcodes/example.html.\n * This code fetches and runs the JavaScript content.\n *\n * @method\n */\nexport const jsRunner = () => {\n const compLib = document.querySelector(selectors.componentlibrary);\n compLib.querySelectorAll(selectors.jscode).forEach(runjs => {\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.innerHTML = runjs.textContent;\n document.head.appendChild(script);\n });\n};\n"],"names":["obj","_selectors","__esModule","default","_exports","jsRunner","document","querySelector","selectors","componentlibrary","querySelectorAll","jscode","forEach","runjs","script","createElement","type","innerHTML","textContent","head","appendChild"],"mappings":"qHAuBwD,IAAAA;;;;;;;sFAAxDC,YAAwDD,IAAxDC,aAAwDD,IAAAE,WAAAF,IAAAG,CAAAA,QAAAH,KAkBtDI,SAAAC,SARsBA,KACJC,SAASC,cAAcC,WAAAA,QAAUC,kBACzCC,iBAAiBF,WAASL,QAACQ,QAAQC,SAAQC,QAC/C,MAAMC,OAASR,SAASS,cAAc,UACtCD,OAAOE,KAAO,kBACdF,OAAOG,UAAYJ,MAAMK,YACzBZ,SAASa,KAAKC,YAAYN,OAAO,GACnC,CACJ"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/loader.min.js.map b/admin/tool/componentlibrary/amd/build/loader.min.js.map index cd8e5c606e5..9ddf25fcff5 100644 --- a/admin/tool/componentlibrary/amd/build/loader.min.js.map +++ b/admin/tool/componentlibrary/amd/build/loader.min.js.map @@ -1 +1 @@ -{"version":3,"file":"loader.min.js","sources":["../src/loader.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * This initialises the component library JS\n *\n * @module tool_componentlibrary/loader\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {mustache} from './mustache';\nimport {jsRunner} from './jsrunner';\nimport {clipboardWrapper} from './clipboardwrapper';\nimport {search} from './search';\n\n/**\n * Load all the component library JavaScript.\n *\n * @param {string} jsonFile Full path to the JSON file with the search DB.\n */\nexport const init = jsonFile => {\n mustache();\n jsRunner();\n clipboardWrapper();\n search(jsonFile);\n};\n"],"names":["jsonFile"],"mappings":"yQAiCoBA,yHAITA"} \ No newline at end of file +{"version":3,"file":"loader.min.js","sources":["../src/loader.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * This initialises the component library JS\n *\n * @module tool_componentlibrary/loader\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {mustache} from './mustache';\nimport {jsRunner} from './jsrunner';\nimport {clipboardWrapper} from './clipboardwrapper';\nimport {search} from './search';\n\n/**\n * Load all the component library JavaScript.\n *\n * @param {string} jsonFile Full path to the JSON file with the search DB.\n */\nexport const init = jsonFile => {\n mustache();\n jsRunner();\n clipboardWrapper();\n search(jsonFile);\n};\n"],"names":["_exports","init","jsonFile","mustache","jsRunner","clipboardWrapper","search"],"mappings":"2PAsCEA,SAAAC,KALkBC,YAChB,EAAAC,uBACA,EAAAC,uBACA,EAAAC,uCACA,EAAAC,QAAAA,QAAOJ,SAAS,CAClB"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/lunr.min.js b/admin/tool/componentlibrary/amd/build/lunr.min.js index 9273bde7c14..22497d81b86 100644 --- a/admin/tool/componentlibrary/amd/build/lunr.min.js +++ b/admin/tool/componentlibrary/amd/build/lunr.min.js @@ -3,6 +3,6 @@ * Copyright (C) 2020 Oliver Nightingale * @license MIT */ -!function(){var global,step2list,step3list,v,C,re_mgr0,re_mgr1,re_meq1,re_s_v,re_1a,re2_1a,re_1b,re2_1b,re_1b_2,re2_1b_2,re3_1b_2,re4_1b_2,re_1c,re_2,re_3,re_4,re2_4,re_5,re_5_1,re3_5,porterStemmer,root,factory,lunr=function(config){var builder=new lunr.Builder;return builder.pipeline.add(lunr.trimmer,lunr.stopWordFilter,lunr.stemmer),builder.searchPipeline.add(lunr.stemmer),config.call(builder,builder),builder.build()};lunr.version="2.3.9",lunr.utils={},lunr.utils.warn=(global=this,function(message){global.console&&console.warn&&console.warn(message)}),lunr.utils.asString=function(obj){return null==obj?"":obj.toString()},lunr.utils.clone=function(obj){if(null==obj)return obj;for(var clone=Object.create(null),keys=Object.keys(obj),i=0;i0){var tokenMetadata=lunr.utils.clone(metadata)||{};tokenMetadata.position=[sliceStart,sliceLength],tokenMetadata.index=tokens.length,tokens.push(new lunr.Token(str.slice(sliceStart,sliceEnd),tokenMetadata))}sliceStart=sliceEnd+1}}return tokens},lunr.tokenizer.separator=/[\s\-]+/,lunr.Pipeline=function(){this._stack=[]},lunr.Pipeline.registeredFunctions=Object.create(null),lunr.Pipeline.registerFunction=function(fn,label){label in this.registeredFunctions&&lunr.utils.warn("Overwriting existing registered function: "+label),fn.label=label,lunr.Pipeline.registeredFunctions[fn.label]=fn},lunr.Pipeline.warnIfFunctionNotRegistered=function(fn){fn.label&&fn.label in this.registeredFunctions||lunr.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",fn)},lunr.Pipeline.load=function(serialised){var pipeline=new lunr.Pipeline;return serialised.forEach((function(fnName){var fn=lunr.Pipeline.registeredFunctions[fnName];if(!fn)throw new Error("Cannot load unregistered function: "+fnName);pipeline.add(fn)})),pipeline},lunr.Pipeline.prototype.add=function(){var fns=Array.prototype.slice.call(arguments);fns.forEach((function(fn){lunr.Pipeline.warnIfFunctionNotRegistered(fn),this._stack.push(fn)}),this)},lunr.Pipeline.prototype.after=function(existingFn,newFn){lunr.Pipeline.warnIfFunctionNotRegistered(newFn);var pos=this._stack.indexOf(existingFn);if(-1==pos)throw new Error("Cannot find existingFn");pos+=1,this._stack.splice(pos,0,newFn)},lunr.Pipeline.prototype.before=function(existingFn,newFn){lunr.Pipeline.warnIfFunctionNotRegistered(newFn);var pos=this._stack.indexOf(existingFn);if(-1==pos)throw new Error("Cannot find existingFn");this._stack.splice(pos,0,newFn)},lunr.Pipeline.prototype.remove=function(fn){var pos=this._stack.indexOf(fn);-1!=pos&&this._stack.splice(pos,1)},lunr.Pipeline.prototype.run=function(tokens){for(var stackLength=this._stack.length,i=0;i1&&(pivotIndexindex&&(end=pivotPoint),pivotIndex!=index);)sliceLength=end-start,pivotPoint=start+Math.floor(sliceLength/2),pivotIndex=this.elements[2*pivotPoint];return pivotIndex==index||pivotIndex>index?2*pivotPoint:pivotIndexbVal?j+=2:aVal==bVal&&(dotProduct+=a[i+1]*b[j+1],i+=2,j+=2);return dotProduct},lunr.Vector.prototype.similarity=function(otherVector){return this.dot(otherVector)/this.magnitude()||0},lunr.Vector.prototype.toArray=function(){for(var output=new Array(this.elements.length/2),i=1,j=0;i0){var noEditNode,char=frame.str.charAt(0);char in frame.node.edges?noEditNode=frame.node.edges[char]:(noEditNode=new lunr.TokenSet,frame.node.edges[char]=noEditNode),1==frame.str.length&&(noEditNode.final=!0),stack.push({node:noEditNode,editsRemaining:frame.editsRemaining,str:frame.str.slice(1)})}if(0!=frame.editsRemaining){if("*"in frame.node.edges)var insertionNode=frame.node.edges["*"];else{insertionNode=new lunr.TokenSet;frame.node.edges["*"]=insertionNode}if(0==frame.str.length&&(insertionNode.final=!0),stack.push({node:insertionNode,editsRemaining:frame.editsRemaining-1,str:frame.str}),frame.str.length>1&&stack.push({node:frame.node,editsRemaining:frame.editsRemaining-1,str:frame.str.slice(1)}),1==frame.str.length&&(frame.node.final=!0),frame.str.length>=1){if("*"in frame.node.edges)var substitutionNode=frame.node.edges["*"];else{substitutionNode=new lunr.TokenSet;frame.node.edges["*"]=substitutionNode}1==frame.str.length&&(substitutionNode.final=!0),stack.push({node:substitutionNode,editsRemaining:frame.editsRemaining-1,str:frame.str.slice(1)})}if(frame.str.length>1){var transposeNode,charA=frame.str.charAt(0),charB=frame.str.charAt(1);charB in frame.node.edges?transposeNode=frame.node.edges[charB]:(transposeNode=new lunr.TokenSet,frame.node.edges[charB]=transposeNode),1==frame.str.length&&(transposeNode.final=!0),stack.push({node:transposeNode,editsRemaining:frame.editsRemaining-1,str:charA+frame.str.slice(2)})}}}return root},lunr.TokenSet.fromString=function(str){for(var node=new lunr.TokenSet,root=node,i=0,len=str.length;i=downTo;i--){var node=this.uncheckedNodes[i],childKey=node.child.toString();childKey in this.minimizedNodes?node.parent.edges[node.char]=this.minimizedNodes[childKey]:(node.child._str=childKey,this.minimizedNodes[childKey]=node.child),this.uncheckedNodes.pop()}},lunr.Index=function(attrs){this.invertedIndex=attrs.invertedIndex,this.fieldVectors=attrs.fieldVectors,this.tokenSet=attrs.tokenSet,this.fields=attrs.fields,this.pipeline=attrs.pipeline},lunr.Index.prototype.search=function(queryString){return this.query((function(query){new lunr.QueryParser(queryString,query).parse()}))},lunr.Index.prototype.query=function(fn){for(var query=new lunr.Query(this.fields),matchingFields=Object.create(null),queryVectors=Object.create(null),termFieldCache=Object.create(null),requiredMatches=Object.create(null),prohibitedMatches=Object.create(null),i=0;i1?1:number},lunr.Builder.prototype.k1=function(number){this._k1=number},lunr.Builder.prototype.add=function(doc,attributes){var docRef=doc[this._ref],fields=Object.keys(this._fields);this._documents[docRef]=attributes||{},this.documentCount+=1;for(var i=0;i=this.length)return lunr.QueryLexer.EOS;var char=this.str.charAt(this.pos);return this.pos+=1,char},lunr.QueryLexer.prototype.width=function(){return this.pos-this.start},lunr.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},lunr.QueryLexer.prototype.backup=function(){this.pos-=1},lunr.QueryLexer.prototype.acceptDigitRun=function(){var char,charCode;do{charCode=(char=this.next()).charCodeAt(0)}while(charCode>47&&charCode<58);char!=lunr.QueryLexer.EOS&&this.backup()},lunr.QueryLexer.prototype.more=function(){return this.pos1&&(lexer.backup(),lexer.emit(lunr.QueryLexer.TERM)),lexer.ignore(),lexer.more())return lunr.QueryLexer.lexText},lunr.QueryLexer.lexEditDistance=function(lexer){return lexer.ignore(),lexer.acceptDigitRun(),lexer.emit(lunr.QueryLexer.EDIT_DISTANCE),lunr.QueryLexer.lexText},lunr.QueryLexer.lexBoost=function(lexer){return lexer.ignore(),lexer.acceptDigitRun(),lexer.emit(lunr.QueryLexer.BOOST),lunr.QueryLexer.lexText},lunr.QueryLexer.lexEOS=function(lexer){lexer.width()>0&&lexer.emit(lunr.QueryLexer.TERM)},lunr.QueryLexer.termSeparator=lunr.tokenizer.separator,lunr.QueryLexer.lexText=function(lexer){for(;;){var char=lexer.next();if(char==lunr.QueryLexer.EOS)return lunr.QueryLexer.lexEOS;if(92!=char.charCodeAt(0)){if(":"==char)return lunr.QueryLexer.lexField;if("~"==char)return lexer.backup(),lexer.width()>0&&lexer.emit(lunr.QueryLexer.TERM),lunr.QueryLexer.lexEditDistance;if("^"==char)return lexer.backup(),lexer.width()>0&&lexer.emit(lunr.QueryLexer.TERM),lunr.QueryLexer.lexBoost;if("+"==char&&1===lexer.width())return lexer.emit(lunr.QueryLexer.PRESENCE),lunr.QueryLexer.lexText;if("-"==char&&1===lexer.width())return lexer.emit(lunr.QueryLexer.PRESENCE),lunr.QueryLexer.lexText;if(char.match(lunr.QueryLexer.termSeparator))return lunr.QueryLexer.lexTerm}else lexer.escapeCharacter()}},lunr.QueryParser=function(str,query){this.lexer=new lunr.QueryLexer(str),this.query=query,this.currentClause={},this.lexemeIdx=0},lunr.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var state=lunr.QueryParser.parseClause;state;)state=state(this);return this.query},lunr.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},lunr.QueryParser.prototype.consumeLexeme=function(){var lexeme=this.peekLexeme();return this.lexemeIdx+=1,lexeme},lunr.QueryParser.prototype.nextClause=function(){var completedClause=this.currentClause;this.query.clause(completedClause),this.currentClause={}},lunr.QueryParser.parseClause=function(parser){var lexeme=parser.peekLexeme();if(null!=lexeme)switch(lexeme.type){case lunr.QueryLexer.PRESENCE:return lunr.QueryParser.parsePresence;case lunr.QueryLexer.FIELD:return lunr.QueryParser.parseField;case lunr.QueryLexer.TERM:return lunr.QueryParser.parseTerm;default:var errorMessage="expected either a field or a term, found "+lexeme.type;throw lexeme.str.length>=1&&(errorMessage+=" with value '"+lexeme.str+"'"),new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}},lunr.QueryParser.parsePresence=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){switch(lexeme.str){case"-":parser.currentClause.presence=lunr.Query.presence.PROHIBITED;break;case"+":parser.currentClause.presence=lunr.Query.presence.REQUIRED;break;default:var errorMessage="unrecognised presence operator'"+lexeme.str+"'";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}var nextLexeme=parser.peekLexeme();if(null==nextLexeme){errorMessage="expecting term or field, found nothing";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}switch(nextLexeme.type){case lunr.QueryLexer.FIELD:return lunr.QueryParser.parseField;case lunr.QueryLexer.TERM:return lunr.QueryParser.parseTerm;default:errorMessage="expecting term or field, found '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}}},lunr.QueryParser.parseField=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){if(-1==parser.query.allFields.indexOf(lexeme.str)){var possibleFields=parser.query.allFields.map((function(f){return"'"+f+"'"})).join(", "),errorMessage="unrecognised field '"+lexeme.str+"', possible fields: "+possibleFields;throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.fields=[lexeme.str];var nextLexeme=parser.peekLexeme();if(null==nextLexeme){errorMessage="expecting term, found nothing";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}if(nextLexeme.type===lunr.QueryLexer.TERM)return lunr.QueryParser.parseTerm;errorMessage="expecting term, found '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}},lunr.QueryParser.parseTerm=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){parser.currentClause.term=lexeme.str.toLowerCase(),-1!=lexeme.str.indexOf("*")&&(parser.currentClause.usePipeline=!1);var nextLexeme=parser.peekLexeme();if(null!=nextLexeme)switch(nextLexeme.type){case lunr.QueryLexer.TERM:return parser.nextClause(),lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:return parser.nextClause(),lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;case lunr.QueryLexer.PRESENCE:return parser.nextClause(),lunr.QueryParser.parsePresence;default:var errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}else parser.nextClause()}},lunr.QueryParser.parseEditDistance=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){var editDistance=parseInt(lexeme.str,10);if(isNaN(editDistance)){var errorMessage="edit distance must be numeric";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.editDistance=editDistance;var nextLexeme=parser.peekLexeme();if(null!=nextLexeme)switch(nextLexeme.type){case lunr.QueryLexer.TERM:return parser.nextClause(),lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:return parser.nextClause(),lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;case lunr.QueryLexer.PRESENCE:return parser.nextClause(),lunr.QueryParser.parsePresence;default:errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}else parser.nextClause()}},lunr.QueryParser.parseBoost=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){var boost=parseInt(lexeme.str,10);if(isNaN(boost)){var errorMessage="boost must be numeric";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.boost=boost;var nextLexeme=parser.peekLexeme();if(null!=nextLexeme)switch(nextLexeme.type){case lunr.QueryLexer.TERM:return parser.nextClause(),lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:return parser.nextClause(),lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;case lunr.QueryLexer.PRESENCE:return parser.nextClause(),lunr.QueryParser.parsePresence;default:errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}else parser.nextClause()}},root=this,factory=function(){return lunr},"function"==typeof define&&define.amd?define("tool_componentlibrary/lunr",factory):"object"==typeof exports?module.exports=factory():root.lunr=factory()}(); +!function(){var global,step2list,step3list,v,C,V,meq1,mgr1,s_v,re_mgr0,re_mgr1,re_meq1,re_s_v,re_1a,re2_1a,re_1b,re2_1b,re_1b_2,re2_1b_2,re3_1b_2,re4_1b_2,re_1c,re_2,re_3,re_4,re2_4,re_5,re_5_1,re3_5,porterStemmer,root,factory,lunr=function(config){var builder=new lunr.Builder;return builder.pipeline.add(lunr.trimmer,lunr.stopWordFilter,lunr.stemmer),builder.searchPipeline.add(lunr.stemmer),config.call(builder,builder),builder.build()};lunr.version="2.3.9",lunr.utils={},lunr.utils.warn=(global=this,function(message){global.console&&console.warn&&console.warn(message)}),lunr.utils.asString=function(obj){return null==obj?"":obj.toString()},lunr.utils.clone=function(obj){if(null==obj)return obj;for(var clone=Object.create(null),keys=Object.keys(obj),i=0;i0){var tokenMetadata=lunr.utils.clone(metadata)||{};tokenMetadata.position=[sliceStart,sliceLength],tokenMetadata.index=tokens.length,tokens.push(new lunr.Token(str.slice(sliceStart,sliceEnd),tokenMetadata))}sliceStart=sliceEnd+1}}return tokens},lunr.tokenizer.separator=/[\s\-]+/,lunr.Pipeline=function(){this._stack=[]},lunr.Pipeline.registeredFunctions=Object.create(null),lunr.Pipeline.registerFunction=function(fn,label){label in this.registeredFunctions&&lunr.utils.warn("Overwriting existing registered function: "+label),fn.label=label,lunr.Pipeline.registeredFunctions[fn.label]=fn},lunr.Pipeline.warnIfFunctionNotRegistered=function(fn){fn.label&&fn.label in this.registeredFunctions||lunr.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",fn)},lunr.Pipeline.load=function(serialised){var pipeline=new lunr.Pipeline;return serialised.forEach((function(fnName){var fn=lunr.Pipeline.registeredFunctions[fnName];if(!fn)throw new Error("Cannot load unregistered function: "+fnName);pipeline.add(fn)})),pipeline},lunr.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach((function(fn){lunr.Pipeline.warnIfFunctionNotRegistered(fn),this._stack.push(fn)}),this)},lunr.Pipeline.prototype.after=function(existingFn,newFn){lunr.Pipeline.warnIfFunctionNotRegistered(newFn);var pos=this._stack.indexOf(existingFn);if(-1==pos)throw new Error("Cannot find existingFn");pos+=1,this._stack.splice(pos,0,newFn)},lunr.Pipeline.prototype.before=function(existingFn,newFn){lunr.Pipeline.warnIfFunctionNotRegistered(newFn);var pos=this._stack.indexOf(existingFn);if(-1==pos)throw new Error("Cannot find existingFn");this._stack.splice(pos,0,newFn)},lunr.Pipeline.prototype.remove=function(fn){var pos=this._stack.indexOf(fn);-1!=pos&&this._stack.splice(pos,1)},lunr.Pipeline.prototype.run=function(tokens){for(var stackLength=this._stack.length,i=0;i1&&(pivotIndexindex&&(end=pivotPoint),pivotIndex!=index);)sliceLength=end-start,pivotPoint=start+Math.floor(sliceLength/2),pivotIndex=this.elements[2*pivotPoint];return pivotIndex==index||pivotIndex>index?2*pivotPoint:pivotIndexbVal?j+=2:aVal==bVal&&(dotProduct+=a[i+1]*b[j+1],i+=2,j+=2);return dotProduct},lunr.Vector.prototype.similarity=function(otherVector){return this.dot(otherVector)/this.magnitude()||0},lunr.Vector.prototype.toArray=function(){for(var output=new Array(this.elements.length/2),i=1,j=0;i0){var noEditNode,char=frame.str.charAt(0);char in frame.node.edges?noEditNode=frame.node.edges[char]:(noEditNode=new lunr.TokenSet,frame.node.edges[char]=noEditNode),1==frame.str.length&&(noEditNode.final=!0),stack.push({node:noEditNode,editsRemaining:frame.editsRemaining,str:frame.str.slice(1)})}if(0!=frame.editsRemaining){if("*"in frame.node.edges)var insertionNode=frame.node.edges["*"];else{insertionNode=new lunr.TokenSet;frame.node.edges["*"]=insertionNode}if(0==frame.str.length&&(insertionNode.final=!0),stack.push({node:insertionNode,editsRemaining:frame.editsRemaining-1,str:frame.str}),frame.str.length>1&&stack.push({node:frame.node,editsRemaining:frame.editsRemaining-1,str:frame.str.slice(1)}),1==frame.str.length&&(frame.node.final=!0),frame.str.length>=1){if("*"in frame.node.edges)var substitutionNode=frame.node.edges["*"];else{substitutionNode=new lunr.TokenSet;frame.node.edges["*"]=substitutionNode}1==frame.str.length&&(substitutionNode.final=!0),stack.push({node:substitutionNode,editsRemaining:frame.editsRemaining-1,str:frame.str.slice(1)})}if(frame.str.length>1){var transposeNode,charA=frame.str.charAt(0),charB=frame.str.charAt(1);charB in frame.node.edges?transposeNode=frame.node.edges[charB]:(transposeNode=new lunr.TokenSet,frame.node.edges[charB]=transposeNode),1==frame.str.length&&(transposeNode.final=!0),stack.push({node:transposeNode,editsRemaining:frame.editsRemaining-1,str:charA+frame.str.slice(2)})}}}return root},lunr.TokenSet.fromString=function(str){for(var node=new lunr.TokenSet,root=node,i=0,len=str.length;i=downTo;i--){var node=this.uncheckedNodes[i],childKey=node.child.toString();childKey in this.minimizedNodes?node.parent.edges[node.char]=this.minimizedNodes[childKey]:(node.child._str=childKey,this.minimizedNodes[childKey]=node.child),this.uncheckedNodes.pop()}},lunr.Index=function(attrs){this.invertedIndex=attrs.invertedIndex,this.fieldVectors=attrs.fieldVectors,this.tokenSet=attrs.tokenSet,this.fields=attrs.fields,this.pipeline=attrs.pipeline},lunr.Index.prototype.search=function(queryString){return this.query((function(query){new lunr.QueryParser(queryString,query).parse()}))},lunr.Index.prototype.query=function(fn){for(var query=new lunr.Query(this.fields),matchingFields=Object.create(null),queryVectors=Object.create(null),termFieldCache=Object.create(null),requiredMatches=Object.create(null),prohibitedMatches=Object.create(null),i=0;i1?1:number},lunr.Builder.prototype.k1=function(number){this._k1=number},lunr.Builder.prototype.add=function(doc,attributes){var docRef=doc[this._ref],fields=Object.keys(this._fields);this._documents[docRef]=attributes||{},this.documentCount+=1;for(var i=0;i=this.length)return lunr.QueryLexer.EOS;var char=this.str.charAt(this.pos);return this.pos+=1,char},lunr.QueryLexer.prototype.width=function(){return this.pos-this.start},lunr.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},lunr.QueryLexer.prototype.backup=function(){this.pos-=1},lunr.QueryLexer.prototype.acceptDigitRun=function(){var char,charCode;do{charCode=(char=this.next()).charCodeAt(0)}while(charCode>47&&charCode<58);char!=lunr.QueryLexer.EOS&&this.backup()},lunr.QueryLexer.prototype.more=function(){return this.pos1&&(lexer.backup(),lexer.emit(lunr.QueryLexer.TERM)),lexer.ignore(),lexer.more())return lunr.QueryLexer.lexText},lunr.QueryLexer.lexEditDistance=function(lexer){return lexer.ignore(),lexer.acceptDigitRun(),lexer.emit(lunr.QueryLexer.EDIT_DISTANCE),lunr.QueryLexer.lexText},lunr.QueryLexer.lexBoost=function(lexer){return lexer.ignore(),lexer.acceptDigitRun(),lexer.emit(lunr.QueryLexer.BOOST),lunr.QueryLexer.lexText},lunr.QueryLexer.lexEOS=function(lexer){lexer.width()>0&&lexer.emit(lunr.QueryLexer.TERM)},lunr.QueryLexer.termSeparator=lunr.tokenizer.separator,lunr.QueryLexer.lexText=function(lexer){for(;;){var char=lexer.next();if(char==lunr.QueryLexer.EOS)return lunr.QueryLexer.lexEOS;if(92!=char.charCodeAt(0)){if(":"==char)return lunr.QueryLexer.lexField;if("~"==char)return lexer.backup(),lexer.width()>0&&lexer.emit(lunr.QueryLexer.TERM),lunr.QueryLexer.lexEditDistance;if("^"==char)return lexer.backup(),lexer.width()>0&&lexer.emit(lunr.QueryLexer.TERM),lunr.QueryLexer.lexBoost;if("+"==char&&1===lexer.width())return lexer.emit(lunr.QueryLexer.PRESENCE),lunr.QueryLexer.lexText;if("-"==char&&1===lexer.width())return lexer.emit(lunr.QueryLexer.PRESENCE),lunr.QueryLexer.lexText;if(char.match(lunr.QueryLexer.termSeparator))return lunr.QueryLexer.lexTerm}else lexer.escapeCharacter()}},lunr.QueryParser=function(str,query){this.lexer=new lunr.QueryLexer(str),this.query=query,this.currentClause={},this.lexemeIdx=0},lunr.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var state=lunr.QueryParser.parseClause;state;)state=state(this);return this.query},lunr.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},lunr.QueryParser.prototype.consumeLexeme=function(){var lexeme=this.peekLexeme();return this.lexemeIdx+=1,lexeme},lunr.QueryParser.prototype.nextClause=function(){var completedClause=this.currentClause;this.query.clause(completedClause),this.currentClause={}},lunr.QueryParser.parseClause=function(parser){var lexeme=parser.peekLexeme();if(null!=lexeme)switch(lexeme.type){case lunr.QueryLexer.PRESENCE:return lunr.QueryParser.parsePresence;case lunr.QueryLexer.FIELD:return lunr.QueryParser.parseField;case lunr.QueryLexer.TERM:return lunr.QueryParser.parseTerm;default:var errorMessage="expected either a field or a term, found "+lexeme.type;throw lexeme.str.length>=1&&(errorMessage+=" with value '"+lexeme.str+"'"),new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}},lunr.QueryParser.parsePresence=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){switch(lexeme.str){case"-":parser.currentClause.presence=lunr.Query.presence.PROHIBITED;break;case"+":parser.currentClause.presence=lunr.Query.presence.REQUIRED;break;default:var errorMessage="unrecognised presence operator'"+lexeme.str+"'";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}var nextLexeme=parser.peekLexeme();if(null==nextLexeme){errorMessage="expecting term or field, found nothing";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}switch(nextLexeme.type){case lunr.QueryLexer.FIELD:return lunr.QueryParser.parseField;case lunr.QueryLexer.TERM:return lunr.QueryParser.parseTerm;default:errorMessage="expecting term or field, found '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}}},lunr.QueryParser.parseField=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){if(-1==parser.query.allFields.indexOf(lexeme.str)){var possibleFields=parser.query.allFields.map((function(f){return"'"+f+"'"})).join(", "),errorMessage="unrecognised field '"+lexeme.str+"', possible fields: "+possibleFields;throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.fields=[lexeme.str];var nextLexeme=parser.peekLexeme();if(null==nextLexeme){errorMessage="expecting term, found nothing";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}if(nextLexeme.type===lunr.QueryLexer.TERM)return lunr.QueryParser.parseTerm;errorMessage="expecting term, found '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}},lunr.QueryParser.parseTerm=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){parser.currentClause.term=lexeme.str.toLowerCase(),-1!=lexeme.str.indexOf("*")&&(parser.currentClause.usePipeline=!1);var nextLexeme=parser.peekLexeme();if(null!=nextLexeme)switch(nextLexeme.type){case lunr.QueryLexer.TERM:return parser.nextClause(),lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:return parser.nextClause(),lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;case lunr.QueryLexer.PRESENCE:return parser.nextClause(),lunr.QueryParser.parsePresence;default:var errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}else parser.nextClause()}},lunr.QueryParser.parseEditDistance=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){var editDistance=parseInt(lexeme.str,10);if(isNaN(editDistance)){var errorMessage="edit distance must be numeric";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.editDistance=editDistance;var nextLexeme=parser.peekLexeme();if(null!=nextLexeme)switch(nextLexeme.type){case lunr.QueryLexer.TERM:return parser.nextClause(),lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:return parser.nextClause(),lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;case lunr.QueryLexer.PRESENCE:return parser.nextClause(),lunr.QueryParser.parsePresence;default:errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}else parser.nextClause()}},lunr.QueryParser.parseBoost=function(parser){var lexeme=parser.consumeLexeme();if(null!=lexeme){var boost=parseInt(lexeme.str,10);if(isNaN(boost)){var errorMessage="boost must be numeric";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.boost=boost;var nextLexeme=parser.peekLexeme();if(null!=nextLexeme)switch(nextLexeme.type){case lunr.QueryLexer.TERM:return parser.nextClause(),lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:return parser.nextClause(),lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;case lunr.QueryLexer.PRESENCE:return parser.nextClause(),lunr.QueryParser.parsePresence;default:errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}else parser.nextClause()}},root=this,factory=function(){return lunr},"function"==typeof define&&define.amd?define("tool_componentlibrary/lunr",factory):"object"==typeof exports?module.exports=factory():root.lunr=factory()}(); //# sourceMappingURL=lunr.min.js.map \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/lunr.min.js.map b/admin/tool/componentlibrary/amd/build/lunr.min.js.map index fb888b2a655..289794a2303 100644 --- a/admin/tool/componentlibrary/amd/build/lunr.min.js.map +++ b/admin/tool/componentlibrary/amd/build/lunr.min.js.map @@ -1 +1 @@ -{"version":3,"file":"lunr.min.js","sources":["../src/lunr.js"],"sourcesContent":["/**\n * moodle readme\n *\n * Lunrjs can be downloaded from https://github.com/olivernn/lunr.js. To update this library get the lunr.js file\n * from this project and replace the content below with the new content.\n */\n\n/**\n * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9\n * Copyright (C) 2020 Oliver Nightingale\n * @license MIT\n */\n\n;(function(){\n\n/**\n * A convenience function for configuring and constructing\n * a new lunr Index.\n *\n * A lunr.Builder instance is created and the pipeline setup\n * with a trimmer, stop word filter and stemmer.\n *\n * This builder object is yielded to the configuration function\n * that is passed as a parameter, allowing the list of fields\n * and other builder parameters to be customised.\n *\n * All documents _must_ be added within the passed config function.\n *\n * @example\n * var idx = lunr(function () {\n * this.field('title')\n * this.field('body')\n * this.ref('id')\n *\n * documents.forEach(function (doc) {\n * this.add(doc)\n * }, this)\n * })\n *\n * @see {@link lunr.Builder}\n * @see {@link lunr.Pipeline}\n * @see {@link lunr.trimmer}\n * @see {@link lunr.stopWordFilter}\n * @see {@link lunr.stemmer}\n * @namespace {function} lunr\n */\nvar lunr = function (config) {\n var builder = new lunr.Builder\n\n builder.pipeline.add(\n lunr.trimmer,\n lunr.stopWordFilter,\n lunr.stemmer\n )\n\n builder.searchPipeline.add(\n lunr.stemmer\n )\n\n config.call(builder, builder)\n return builder.build()\n}\n\nlunr.version = \"2.3.9\"\n/*!\n * lunr.utils\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A namespace containing utils for the rest of the lunr library\n * @namespace lunr.utils\n */\nlunr.utils = {}\n\n/**\n * Print a warning message to the console.\n *\n * @param {String} message The message to be printed.\n * @memberOf lunr.utils\n * @function\n */\nlunr.utils.warn = (function (global) {\n /* eslint-disable no-console */\n return function (message) {\n if (global.console && console.warn) {\n console.warn(message)\n }\n }\n /* eslint-enable no-console */\n})(this)\n\n/**\n * Convert an object to a string.\n *\n * In the case of `null` and `undefined` the function returns\n * the empty string, in all other cases the result of calling\n * `toString` on the passed object is returned.\n *\n * @param {Any} obj The object to convert to a string.\n * @return {String} string representation of the passed object.\n * @memberOf lunr.utils\n */\nlunr.utils.asString = function (obj) {\n if (obj === void 0 || obj === null) {\n return \"\"\n } else {\n return obj.toString()\n }\n}\n\n/**\n * Clones an object.\n *\n * Will create a copy of an existing object such that any mutations\n * on the copy cannot affect the original.\n *\n * Only shallow objects are supported, passing a nested object to this\n * function will cause a TypeError.\n *\n * Objects with primitives, and arrays of primitives are supported.\n *\n * @param {Object} obj The object to clone.\n * @return {Object} a clone of the passed object.\n * @throws {TypeError} when a nested object is passed.\n * @memberOf Utils\n */\nlunr.utils.clone = function (obj) {\n if (obj === null || obj === undefined) {\n return obj\n }\n\n var clone = Object.create(null),\n keys = Object.keys(obj)\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i],\n val = obj[key]\n\n if (Array.isArray(val)) {\n clone[key] = val.slice()\n continue\n }\n\n if (typeof val === 'string' ||\n typeof val === 'number' ||\n typeof val === 'boolean') {\n clone[key] = val\n continue\n }\n\n throw new TypeError(\"clone is not deep and does not support nested objects\")\n }\n\n return clone\n}\nlunr.FieldRef = function (docRef, fieldName, stringValue) {\n this.docRef = docRef\n this.fieldName = fieldName\n this._stringValue = stringValue\n}\n\nlunr.FieldRef.joiner = \"/\"\n\nlunr.FieldRef.fromString = function (s) {\n var n = s.indexOf(lunr.FieldRef.joiner)\n\n if (n === -1) {\n throw \"malformed field ref string\"\n }\n\n var fieldRef = s.slice(0, n),\n docRef = s.slice(n + 1)\n\n return new lunr.FieldRef (docRef, fieldRef, s)\n}\n\nlunr.FieldRef.prototype.toString = function () {\n if (this._stringValue == undefined) {\n this._stringValue = this.fieldName + lunr.FieldRef.joiner + this.docRef\n }\n\n return this._stringValue\n}\n/*!\n * lunr.Set\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A lunr set.\n *\n * @constructor\n */\nlunr.Set = function (elements) {\n this.elements = Object.create(null)\n\n if (elements) {\n this.length = elements.length\n\n for (var i = 0; i < this.length; i++) {\n this.elements[elements[i]] = true\n }\n } else {\n this.length = 0\n }\n}\n\n/**\n * A complete set that contains all elements.\n *\n * @static\n * @readonly\n * @type {lunr.Set}\n */\nlunr.Set.complete = {\n intersect: function (other) {\n return other\n },\n\n union: function () {\n return this\n },\n\n contains: function () {\n return true\n }\n}\n\n/**\n * An empty set that contains no elements.\n *\n * @static\n * @readonly\n * @type {lunr.Set}\n */\nlunr.Set.empty = {\n intersect: function () {\n return this\n },\n\n union: function (other) {\n return other\n },\n\n contains: function () {\n return false\n }\n}\n\n/**\n * Returns true if this set contains the specified object.\n *\n * @param {object} object - Object whose presence in this set is to be tested.\n * @returns {boolean} - True if this set contains the specified object.\n */\nlunr.Set.prototype.contains = function (object) {\n return !!this.elements[object]\n}\n\n/**\n * Returns a new set containing only the elements that are present in both\n * this set and the specified set.\n *\n * @param {lunr.Set} other - set to intersect with this set.\n * @returns {lunr.Set} a new set that is the intersection of this and the specified set.\n */\n\nlunr.Set.prototype.intersect = function (other) {\n var a, b, elements, intersection = []\n\n if (other === lunr.Set.complete) {\n return this\n }\n\n if (other === lunr.Set.empty) {\n return other\n }\n\n if (this.length < other.length) {\n a = this\n b = other\n } else {\n a = other\n b = this\n }\n\n elements = Object.keys(a.elements)\n\n for (var i = 0; i < elements.length; i++) {\n var element = elements[i]\n if (element in b.elements) {\n intersection.push(element)\n }\n }\n\n return new lunr.Set (intersection)\n}\n\n/**\n * Returns a new set combining the elements of this and the specified set.\n *\n * @param {lunr.Set} other - set to union with this set.\n * @return {lunr.Set} a new set that is the union of this and the specified set.\n */\n\nlunr.Set.prototype.union = function (other) {\n if (other === lunr.Set.complete) {\n return lunr.Set.complete\n }\n\n if (other === lunr.Set.empty) {\n return this\n }\n\n return new lunr.Set(Object.keys(this.elements).concat(Object.keys(other.elements)))\n}\n/**\n * A function to calculate the inverse document frequency for\n * a posting. This is shared between the builder and the index\n *\n * @private\n * @param {object} posting - The posting for a given term\n * @param {number} documentCount - The total number of documents.\n */\nlunr.idf = function (posting, documentCount) {\n var documentsWithTerm = 0\n\n for (var fieldName in posting) {\n if (fieldName == '_index') continue // Ignore the term index, its not a field\n documentsWithTerm += Object.keys(posting[fieldName]).length\n }\n\n var x = (documentCount - documentsWithTerm + 0.5) / (documentsWithTerm + 0.5)\n\n return Math.log(1 + Math.abs(x))\n}\n\n/**\n * A token wraps a string representation of a token\n * as it is passed through the text processing pipeline.\n *\n * @constructor\n * @param {string} [str=''] - The string token being wrapped.\n * @param {object} [metadata={}] - Metadata associated with this token.\n */\nlunr.Token = function (str, metadata) {\n this.str = str || \"\"\n this.metadata = metadata || {}\n}\n\n/**\n * Returns the token string that is being wrapped by this object.\n *\n * @returns {string}\n */\nlunr.Token.prototype.toString = function () {\n return this.str\n}\n\n/**\n * A token update function is used when updating or optionally\n * when cloning a token.\n *\n * @callback lunr.Token~updateFunction\n * @param {string} str - The string representation of the token.\n * @param {Object} metadata - All metadata associated with this token.\n */\n\n/**\n * Applies the given function to the wrapped string token.\n *\n * @example\n * token.update(function (str, metadata) {\n * return str.toUpperCase()\n * })\n *\n * @param {lunr.Token~updateFunction} fn - A function to apply to the token string.\n * @returns {lunr.Token}\n */\nlunr.Token.prototype.update = function (fn) {\n this.str = fn(this.str, this.metadata)\n return this\n}\n\n/**\n * Creates a clone of this token. Optionally a function can be\n * applied to the cloned token.\n *\n * @param {lunr.Token~updateFunction} [fn] - An optional function to apply to the cloned token.\n * @returns {lunr.Token}\n */\nlunr.Token.prototype.clone = function (fn) {\n fn = fn || function (s) { return s }\n return new lunr.Token (fn(this.str, this.metadata), this.metadata)\n}\n/*!\n * lunr.tokenizer\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A function for splitting a string into tokens ready to be inserted into\n * the search index. Uses `lunr.tokenizer.separator` to split strings, change\n * the value of this property to change how strings are split into tokens.\n *\n * This tokenizer will convert its parameter to a string by calling `toString` and\n * then will split this string on the character in `lunr.tokenizer.separator`.\n * Arrays will have their elements converted to strings and wrapped in a lunr.Token.\n *\n * Optional metadata can be passed to the tokenizer, this metadata will be cloned and\n * added as metadata to every token that is created from the object to be tokenized.\n *\n * @static\n * @param {?(string|object|object[])} obj - The object to convert into tokens\n * @param {?object} metadata - Optional metadata to associate with every token\n * @returns {lunr.Token[]}\n * @see {@link lunr.Pipeline}\n */\nlunr.tokenizer = function (obj, metadata) {\n if (obj == null || obj == undefined) {\n return []\n }\n\n if (Array.isArray(obj)) {\n return obj.map(function (t) {\n return new lunr.Token(\n lunr.utils.asString(t).toLowerCase(),\n lunr.utils.clone(metadata)\n )\n })\n }\n\n var str = obj.toString().toLowerCase(),\n len = str.length,\n tokens = []\n\n for (var sliceEnd = 0, sliceStart = 0; sliceEnd <= len; sliceEnd++) {\n var char = str.charAt(sliceEnd),\n sliceLength = sliceEnd - sliceStart\n\n if ((char.match(lunr.tokenizer.separator) || sliceEnd == len)) {\n\n if (sliceLength > 0) {\n var tokenMetadata = lunr.utils.clone(metadata) || {}\n tokenMetadata[\"position\"] = [sliceStart, sliceLength]\n tokenMetadata[\"index\"] = tokens.length\n\n tokens.push(\n new lunr.Token (\n str.slice(sliceStart, sliceEnd),\n tokenMetadata\n )\n )\n }\n\n sliceStart = sliceEnd + 1\n }\n\n }\n\n return tokens\n}\n\n/**\n * The separator used to split a string into tokens. Override this property to change the behaviour of\n * `lunr.tokenizer` behaviour when tokenizing strings. By default this splits on whitespace and hyphens.\n *\n * @static\n * @see lunr.tokenizer\n */\nlunr.tokenizer.separator = /[\\s\\-]+/\n/*!\n * lunr.Pipeline\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.Pipelines maintain an ordered list of functions to be applied to all\n * tokens in documents entering the search index and queries being ran against\n * the index.\n *\n * An instance of lunr.Index created with the lunr shortcut will contain a\n * pipeline with a stop word filter and an English language stemmer. Extra\n * functions can be added before or after either of these functions or these\n * default functions can be removed.\n *\n * When run the pipeline will call each function in turn, passing a token, the\n * index of that token in the original list of all tokens and finally a list of\n * all the original tokens.\n *\n * The output of functions in the pipeline will be passed to the next function\n * in the pipeline. To exclude a token from entering the index the function\n * should return undefined, the rest of the pipeline will not be called with\n * this token.\n *\n * For serialisation of pipelines to work, all functions used in an instance of\n * a pipeline should be registered with lunr.Pipeline. Registered functions can\n * then be loaded. If trying to load a serialised pipeline that uses functions\n * that are not registered an error will be thrown.\n *\n * If not planning on serialising the pipeline then registering pipeline functions\n * is not necessary.\n *\n * @constructor\n */\nlunr.Pipeline = function () {\n this._stack = []\n}\n\nlunr.Pipeline.registeredFunctions = Object.create(null)\n\n/**\n * A pipeline function maps lunr.Token to lunr.Token. A lunr.Token contains the token\n * string as well as all known metadata. A pipeline function can mutate the token string\n * or mutate (or add) metadata for a given token.\n *\n * A pipeline function can indicate that the passed token should be discarded by returning\n * null, undefined or an empty string. This token will not be passed to any downstream pipeline\n * functions and will not be added to the index.\n *\n * Multiple tokens can be returned by returning an array of tokens. Each token will be passed\n * to any downstream pipeline functions and all will returned tokens will be added to the index.\n *\n * Any number of pipeline functions may be chained together using a lunr.Pipeline.\n *\n * @interface lunr.PipelineFunction\n * @param {lunr.Token} token - A token from the document being processed.\n * @param {number} i - The index of this token in the complete list of tokens for this document/field.\n * @param {lunr.Token[]} tokens - All tokens for this document/field.\n * @returns {(?lunr.Token|lunr.Token[])}\n */\n\n/**\n * Register a function with the pipeline.\n *\n * Functions that are used in the pipeline should be registered if the pipeline\n * needs to be serialised, or a serialised pipeline needs to be loaded.\n *\n * Registering a function does not add it to a pipeline, functions must still be\n * added to instances of the pipeline for them to be used when running a pipeline.\n *\n * @param {lunr.PipelineFunction} fn - The function to check for.\n * @param {String} label - The label to register this function with\n */\nlunr.Pipeline.registerFunction = function (fn, label) {\n if (label in this.registeredFunctions) {\n lunr.utils.warn('Overwriting existing registered function: ' + label)\n }\n\n fn.label = label\n lunr.Pipeline.registeredFunctions[fn.label] = fn\n}\n\n/**\n * Warns if the function is not registered as a Pipeline function.\n *\n * @param {lunr.PipelineFunction} fn - The function to check for.\n * @private\n */\nlunr.Pipeline.warnIfFunctionNotRegistered = function (fn) {\n var isRegistered = fn.label && (fn.label in this.registeredFunctions)\n\n if (!isRegistered) {\n lunr.utils.warn('Function is not registered with pipeline. This may cause problems when serialising the index.\\n', fn)\n }\n}\n\n/**\n * Loads a previously serialised pipeline.\n *\n * All functions to be loaded must already be registered with lunr.Pipeline.\n * If any function from the serialised data has not been registered then an\n * error will be thrown.\n *\n * @param {Object} serialised - The serialised pipeline to load.\n * @returns {lunr.Pipeline}\n */\nlunr.Pipeline.load = function (serialised) {\n var pipeline = new lunr.Pipeline\n\n serialised.forEach(function (fnName) {\n var fn = lunr.Pipeline.registeredFunctions[fnName]\n\n if (fn) {\n pipeline.add(fn)\n } else {\n throw new Error('Cannot load unregistered function: ' + fnName)\n }\n })\n\n return pipeline\n}\n\n/**\n * Adds new functions to the end of the pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction[]} functions - Any number of functions to add to the pipeline.\n */\nlunr.Pipeline.prototype.add = function () {\n var fns = Array.prototype.slice.call(arguments)\n\n fns.forEach(function (fn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(fn)\n this._stack.push(fn)\n }, this)\n}\n\n/**\n * Adds a single function after a function that already exists in the\n * pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.\n * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.\n */\nlunr.Pipeline.prototype.after = function (existingFn, newFn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(newFn)\n\n var pos = this._stack.indexOf(existingFn)\n if (pos == -1) {\n throw new Error('Cannot find existingFn')\n }\n\n pos = pos + 1\n this._stack.splice(pos, 0, newFn)\n}\n\n/**\n * Adds a single function before a function that already exists in the\n * pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.\n * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.\n */\nlunr.Pipeline.prototype.before = function (existingFn, newFn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(newFn)\n\n var pos = this._stack.indexOf(existingFn)\n if (pos == -1) {\n throw new Error('Cannot find existingFn')\n }\n\n this._stack.splice(pos, 0, newFn)\n}\n\n/**\n * Removes a function from the pipeline.\n *\n * @param {lunr.PipelineFunction} fn The function to remove from the pipeline.\n */\nlunr.Pipeline.prototype.remove = function (fn) {\n var pos = this._stack.indexOf(fn)\n if (pos == -1) {\n return\n }\n\n this._stack.splice(pos, 1)\n}\n\n/**\n * Runs the current list of functions that make up the pipeline against the\n * passed tokens.\n *\n * @param {Array} tokens The tokens to run through the pipeline.\n * @returns {Array}\n */\nlunr.Pipeline.prototype.run = function (tokens) {\n var stackLength = this._stack.length\n\n for (var i = 0; i < stackLength; i++) {\n var fn = this._stack[i]\n var memo = []\n\n for (var j = 0; j < tokens.length; j++) {\n var result = fn(tokens[j], j, tokens)\n\n if (result === null || result === void 0 || result === '') continue\n\n if (Array.isArray(result)) {\n for (var k = 0; k < result.length; k++) {\n memo.push(result[k])\n }\n } else {\n memo.push(result)\n }\n }\n\n tokens = memo\n }\n\n return tokens\n}\n\n/**\n * Convenience method for passing a string through a pipeline and getting\n * strings out. This method takes care of wrapping the passed string in a\n * token and mapping the resulting tokens back to strings.\n *\n * @param {string} str - The string to pass through the pipeline.\n * @param {?object} metadata - Optional metadata to associate with the token\n * passed to the pipeline.\n * @returns {string[]}\n */\nlunr.Pipeline.prototype.runString = function (str, metadata) {\n var token = new lunr.Token (str, metadata)\n\n return this.run([token]).map(function (t) {\n return t.toString()\n })\n}\n\n/**\n * Resets the pipeline by removing any existing processors.\n *\n */\nlunr.Pipeline.prototype.reset = function () {\n this._stack = []\n}\n\n/**\n * Returns a representation of the pipeline ready for serialisation.\n *\n * Logs a warning if the function has not been registered.\n *\n * @returns {Array}\n */\nlunr.Pipeline.prototype.toJSON = function () {\n return this._stack.map(function (fn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(fn)\n\n return fn.label\n })\n}\n/*!\n * lunr.Vector\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A vector is used to construct the vector space of documents and queries. These\n * vectors support operations to determine the similarity between two documents or\n * a document and a query.\n *\n * Normally no parameters are required for initializing a vector, but in the case of\n * loading a previously dumped vector the raw elements can be provided to the constructor.\n *\n * For performance reasons vectors are implemented with a flat array, where an elements\n * index is immediately followed by its value. E.g. [index, value, index, value]. This\n * allows the underlying array to be as sparse as possible and still offer decent\n * performance when being used for vector calculations.\n *\n * @constructor\n * @param {Number[]} [elements] - The flat list of element index and element value pairs.\n */\nlunr.Vector = function (elements) {\n this._magnitude = 0\n this.elements = elements || []\n}\n\n\n/**\n * Calculates the position within the vector to insert a given index.\n *\n * This is used internally by insert and upsert. If there are duplicate indexes then\n * the position is returned as if the value for that index were to be updated, but it\n * is the callers responsibility to check whether there is a duplicate at that index\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @returns {Number}\n */\nlunr.Vector.prototype.positionForIndex = function (index) {\n // For an empty vector the tuple can be inserted at the beginning\n if (this.elements.length == 0) {\n return 0\n }\n\n var start = 0,\n end = this.elements.length / 2,\n sliceLength = end - start,\n pivotPoint = Math.floor(sliceLength / 2),\n pivotIndex = this.elements[pivotPoint * 2]\n\n while (sliceLength > 1) {\n if (pivotIndex < index) {\n start = pivotPoint\n }\n\n if (pivotIndex > index) {\n end = pivotPoint\n }\n\n if (pivotIndex == index) {\n break\n }\n\n sliceLength = end - start\n pivotPoint = start + Math.floor(sliceLength / 2)\n pivotIndex = this.elements[pivotPoint * 2]\n }\n\n if (pivotIndex == index) {\n return pivotPoint * 2\n }\n\n if (pivotIndex > index) {\n return pivotPoint * 2\n }\n\n if (pivotIndex < index) {\n return (pivotPoint + 1) * 2\n }\n}\n\n/**\n * Inserts an element at an index within the vector.\n *\n * Does not allow duplicates, will throw an error if there is already an entry\n * for this index.\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @param {Number} val - The value to be inserted into the vector.\n */\nlunr.Vector.prototype.insert = function (insertIdx, val) {\n this.upsert(insertIdx, val, function () {\n throw \"duplicate index\"\n })\n}\n\n/**\n * Inserts or updates an existing index within the vector.\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @param {Number} val - The value to be inserted into the vector.\n * @param {function} fn - A function that is called for updates, the existing value and the\n * requested value are passed as arguments\n */\nlunr.Vector.prototype.upsert = function (insertIdx, val, fn) {\n this._magnitude = 0\n var position = this.positionForIndex(insertIdx)\n\n if (this.elements[position] == insertIdx) {\n this.elements[position + 1] = fn(this.elements[position + 1], val)\n } else {\n this.elements.splice(position, 0, insertIdx, val)\n }\n}\n\n/**\n * Calculates the magnitude of this vector.\n *\n * @returns {Number}\n */\nlunr.Vector.prototype.magnitude = function () {\n if (this._magnitude) return this._magnitude\n\n var sumOfSquares = 0,\n elementsLength = this.elements.length\n\n for (var i = 1; i < elementsLength; i += 2) {\n var val = this.elements[i]\n sumOfSquares += val * val\n }\n\n return this._magnitude = Math.sqrt(sumOfSquares)\n}\n\n/**\n * Calculates the dot product of this vector and another vector.\n *\n * @param {lunr.Vector} otherVector - The vector to compute the dot product with.\n * @returns {Number}\n */\nlunr.Vector.prototype.dot = function (otherVector) {\n var dotProduct = 0,\n a = this.elements, b = otherVector.elements,\n aLen = a.length, bLen = b.length,\n aVal = 0, bVal = 0,\n i = 0, j = 0\n\n while (i < aLen && j < bLen) {\n aVal = a[i], bVal = b[j]\n if (aVal < bVal) {\n i += 2\n } else if (aVal > bVal) {\n j += 2\n } else if (aVal == bVal) {\n dotProduct += a[i + 1] * b[j + 1]\n i += 2\n j += 2\n }\n }\n\n return dotProduct\n}\n\n/**\n * Calculates the similarity between this vector and another vector.\n *\n * @param {lunr.Vector} otherVector - The other vector to calculate the\n * similarity with.\n * @returns {Number}\n */\nlunr.Vector.prototype.similarity = function (otherVector) {\n return this.dot(otherVector) / this.magnitude() || 0\n}\n\n/**\n * Converts the vector to an array of the elements within the vector.\n *\n * @returns {Number[]}\n */\nlunr.Vector.prototype.toArray = function () {\n var output = new Array (this.elements.length / 2)\n\n for (var i = 1, j = 0; i < this.elements.length; i += 2, j++) {\n output[j] = this.elements[i]\n }\n\n return output\n}\n\n/**\n * A JSON serializable representation of the vector.\n *\n * @returns {Number[]}\n */\nlunr.Vector.prototype.toJSON = function () {\n return this.elements\n}\n/* eslint-disable */\n/*!\n * lunr.stemmer\n * Copyright (C) 2020 Oliver Nightingale\n * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt\n */\n\n/**\n * lunr.stemmer is an english language stemmer, this is a JavaScript\n * implementation of the PorterStemmer taken from http://tartarus.org/~martin\n *\n * @static\n * @implements {lunr.PipelineFunction}\n * @param {lunr.Token} token - The string to stem\n * @returns {lunr.Token}\n * @see {@link lunr.Pipeline}\n * @function\n */\nlunr.stemmer = (function(){\n var step2list = {\n \"ational\" : \"ate\",\n \"tional\" : \"tion\",\n \"enci\" : \"ence\",\n \"anci\" : \"ance\",\n \"izer\" : \"ize\",\n \"bli\" : \"ble\",\n \"alli\" : \"al\",\n \"entli\" : \"ent\",\n \"eli\" : \"e\",\n \"ousli\" : \"ous\",\n \"ization\" : \"ize\",\n \"ation\" : \"ate\",\n \"ator\" : \"ate\",\n \"alism\" : \"al\",\n \"iveness\" : \"ive\",\n \"fulness\" : \"ful\",\n \"ousness\" : \"ous\",\n \"aliti\" : \"al\",\n \"iviti\" : \"ive\",\n \"biliti\" : \"ble\",\n \"logi\" : \"log\"\n },\n\n step3list = {\n \"icate\" : \"ic\",\n \"ative\" : \"\",\n \"alize\" : \"al\",\n \"iciti\" : \"ic\",\n \"ical\" : \"ic\",\n \"ful\" : \"\",\n \"ness\" : \"\"\n },\n\n c = \"[^aeiou]\", // consonant\n v = \"[aeiouy]\", // vowel\n C = c + \"[^aeiouy]*\", // consonant sequence\n V = v + \"[aeiou]*\", // vowel sequence\n\n mgr0 = \"^(\" + C + \")?\" + V + C, // [C]VC... is m>0\n meq1 = \"^(\" + C + \")?\" + V + C + \"(\" + V + \")?$\", // [C]VC[V] is m=1\n mgr1 = \"^(\" + C + \")?\" + V + C + V + C, // [C]VCVC... is m>1\n s_v = \"^(\" + C + \")?\" + v; // vowel in stem\n\n var re_mgr0 = new RegExp(mgr0);\n var re_mgr1 = new RegExp(mgr1);\n var re_meq1 = new RegExp(meq1);\n var re_s_v = new RegExp(s_v);\n\n var re_1a = /^(.+?)(ss|i)es$/;\n var re2_1a = /^(.+?)([^s])s$/;\n var re_1b = /^(.+?)eed$/;\n var re2_1b = /^(.+?)(ed|ing)$/;\n var re_1b_2 = /.$/;\n var re2_1b_2 = /(at|bl|iz)$/;\n var re3_1b_2 = new RegExp(\"([^aeiouylsz])\\\\1$\");\n var re4_1b_2 = new RegExp(\"^\" + C + v + \"[^aeiouwxy]$\");\n\n var re_1c = /^(.+?[^aeiou])y$/;\n var re_2 = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;\n\n var re_3 = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;\n\n var re_4 = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;\n var re2_4 = /^(.+?)(s|t)(ion)$/;\n\n var re_5 = /^(.+?)e$/;\n var re_5_1 = /ll$/;\n var re3_5 = new RegExp(\"^\" + C + v + \"[^aeiouwxy]$\");\n\n var porterStemmer = function porterStemmer(w) {\n var stem,\n suffix,\n firstch,\n re,\n re2,\n re3,\n re4;\n\n if (w.length < 3) { return w; }\n\n firstch = w.substr(0,1);\n if (firstch == \"y\") {\n w = firstch.toUpperCase() + w.substr(1);\n }\n\n // Step 1a\n re = re_1a\n re2 = re2_1a;\n\n if (re.test(w)) { w = w.replace(re,\"$1$2\"); }\n else if (re2.test(w)) { w = w.replace(re2,\"$1$2\"); }\n\n // Step 1b\n re = re_1b;\n re2 = re2_1b;\n if (re.test(w)) {\n var fp = re.exec(w);\n re = re_mgr0;\n if (re.test(fp[1])) {\n re = re_1b_2;\n w = w.replace(re,\"\");\n }\n } else if (re2.test(w)) {\n var fp = re2.exec(w);\n stem = fp[1];\n re2 = re_s_v;\n if (re2.test(stem)) {\n w = stem;\n re2 = re2_1b_2;\n re3 = re3_1b_2;\n re4 = re4_1b_2;\n if (re2.test(w)) { w = w + \"e\"; }\n else if (re3.test(w)) { re = re_1b_2; w = w.replace(re,\"\"); }\n else if (re4.test(w)) { w = w + \"e\"; }\n }\n }\n\n // Step 1c - replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say)\n re = re_1c;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n w = stem + \"i\";\n }\n\n // Step 2\n re = re_2;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n suffix = fp[2];\n re = re_mgr0;\n if (re.test(stem)) {\n w = stem + step2list[suffix];\n }\n }\n\n // Step 3\n re = re_3;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n suffix = fp[2];\n re = re_mgr0;\n if (re.test(stem)) {\n w = stem + step3list[suffix];\n }\n }\n\n // Step 4\n re = re_4;\n re2 = re2_4;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n re = re_mgr1;\n if (re.test(stem)) {\n w = stem;\n }\n } else if (re2.test(w)) {\n var fp = re2.exec(w);\n stem = fp[1] + fp[2];\n re2 = re_mgr1;\n if (re2.test(stem)) {\n w = stem;\n }\n }\n\n // Step 5\n re = re_5;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n re = re_mgr1;\n re2 = re_meq1;\n re3 = re3_5;\n if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) {\n w = stem;\n }\n }\n\n re = re_5_1;\n re2 = re_mgr1;\n if (re.test(w) && re2.test(w)) {\n re = re_1b_2;\n w = w.replace(re,\"\");\n }\n\n // and turn initial Y back to y\n\n if (firstch == \"y\") {\n w = firstch.toLowerCase() + w.substr(1);\n }\n\n return w;\n };\n\n return function (token) {\n return token.update(porterStemmer);\n }\n})();\n\nlunr.Pipeline.registerFunction(lunr.stemmer, 'stemmer')\n/*!\n * lunr.stopWordFilter\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.generateStopWordFilter builds a stopWordFilter function from the provided\n * list of stop words.\n *\n * The built in lunr.stopWordFilter is built using this generator and can be used\n * to generate custom stopWordFilters for applications or non English languages.\n *\n * @function\n * @param {Array} token The token to pass through the filter\n * @returns {lunr.PipelineFunction}\n * @see lunr.Pipeline\n * @see lunr.stopWordFilter\n */\nlunr.generateStopWordFilter = function (stopWords) {\n var words = stopWords.reduce(function (memo, stopWord) {\n memo[stopWord] = stopWord\n return memo\n }, {})\n\n return function (token) {\n if (token && words[token.toString()] !== token.toString()) return token\n }\n}\n\n/**\n * lunr.stopWordFilter is an English language stop word list filter, any words\n * contained in the list will not be passed through the filter.\n *\n * This is intended to be used in the Pipeline. If the token does not pass the\n * filter then undefined will be returned.\n *\n * @function\n * @implements {lunr.PipelineFunction}\n * @params {lunr.Token} token - A token to check for being a stop word.\n * @returns {lunr.Token}\n * @see {@link lunr.Pipeline}\n */\nlunr.stopWordFilter = lunr.generateStopWordFilter([\n 'a',\n 'able',\n 'about',\n 'across',\n 'after',\n 'all',\n 'almost',\n 'also',\n 'am',\n 'among',\n 'an',\n 'and',\n 'any',\n 'are',\n 'as',\n 'at',\n 'be',\n 'because',\n 'been',\n 'but',\n 'by',\n 'can',\n 'cannot',\n 'could',\n 'dear',\n 'did',\n 'do',\n 'does',\n 'either',\n 'else',\n 'ever',\n 'every',\n 'for',\n 'from',\n 'get',\n 'got',\n 'had',\n 'has',\n 'have',\n 'he',\n 'her',\n 'hers',\n 'him',\n 'his',\n 'how',\n 'however',\n 'i',\n 'if',\n 'in',\n 'into',\n 'is',\n 'it',\n 'its',\n 'just',\n 'least',\n 'let',\n 'like',\n 'likely',\n 'may',\n 'me',\n 'might',\n 'most',\n 'must',\n 'my',\n 'neither',\n 'no',\n 'nor',\n 'not',\n 'of',\n 'off',\n 'often',\n 'on',\n 'only',\n 'or',\n 'other',\n 'our',\n 'own',\n 'rather',\n 'said',\n 'say',\n 'says',\n 'she',\n 'should',\n 'since',\n 'so',\n 'some',\n 'than',\n 'that',\n 'the',\n 'their',\n 'them',\n 'then',\n 'there',\n 'these',\n 'they',\n 'this',\n 'tis',\n 'to',\n 'too',\n 'twas',\n 'us',\n 'wants',\n 'was',\n 'we',\n 'were',\n 'what',\n 'when',\n 'where',\n 'which',\n 'while',\n 'who',\n 'whom',\n 'why',\n 'will',\n 'with',\n 'would',\n 'yet',\n 'you',\n 'your'\n])\n\nlunr.Pipeline.registerFunction(lunr.stopWordFilter, 'stopWordFilter')\n/*!\n * lunr.trimmer\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.trimmer is a pipeline function for trimming non word\n * characters from the beginning and end of tokens before they\n * enter the index.\n *\n * This implementation may not work correctly for non latin\n * characters and should either be removed or adapted for use\n * with languages with non-latin characters.\n *\n * @static\n * @implements {lunr.PipelineFunction}\n * @param {lunr.Token} token The token to pass through the filter\n * @returns {lunr.Token}\n * @see lunr.Pipeline\n */\nlunr.trimmer = function (token) {\n return token.update(function (s) {\n return s.replace(/^\\W+/, '').replace(/\\W+$/, '')\n })\n}\n\nlunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer')\n/*!\n * lunr.TokenSet\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A token set is used to store the unique list of all tokens\n * within an index. Token sets are also used to represent an\n * incoming query to the index, this query token set and index\n * token set are then intersected to find which tokens to look\n * up in the inverted index.\n *\n * A token set can hold multiple tokens, as in the case of the\n * index token set, or it can hold a single token as in the\n * case of a simple query token set.\n *\n * Additionally token sets are used to perform wildcard matching.\n * Leading, contained and trailing wildcards are supported, and\n * from this edit distance matching can also be provided.\n *\n * Token sets are implemented as a minimal finite state automata,\n * where both common prefixes and suffixes are shared between tokens.\n * This helps to reduce the space used for storing the token set.\n *\n * @constructor\n */\nlunr.TokenSet = function () {\n this.final = false\n this.edges = {}\n this.id = lunr.TokenSet._nextId\n lunr.TokenSet._nextId += 1\n}\n\n/**\n * Keeps track of the next, auto increment, identifier to assign\n * to a new tokenSet.\n *\n * TokenSets require a unique identifier to be correctly minimised.\n *\n * @private\n */\nlunr.TokenSet._nextId = 1\n\n/**\n * Creates a TokenSet instance from the given sorted array of words.\n *\n * @param {String[]} arr - A sorted array of strings to create the set from.\n * @returns {lunr.TokenSet}\n * @throws Will throw an error if the input array is not sorted.\n */\nlunr.TokenSet.fromArray = function (arr) {\n var builder = new lunr.TokenSet.Builder\n\n for (var i = 0, len = arr.length; i < len; i++) {\n builder.insert(arr[i])\n }\n\n builder.finish()\n return builder.root\n}\n\n/**\n * Creates a token set from a query clause.\n *\n * @private\n * @param {Object} clause - A single clause from lunr.Query.\n * @param {string} clause.term - The query clause term.\n * @param {number} [clause.editDistance] - The optional edit distance for the term.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.fromClause = function (clause) {\n if ('editDistance' in clause) {\n return lunr.TokenSet.fromFuzzyString(clause.term, clause.editDistance)\n } else {\n return lunr.TokenSet.fromString(clause.term)\n }\n}\n\n/**\n * Creates a token set representing a single string with a specified\n * edit distance.\n *\n * Insertions, deletions, substitutions and transpositions are each\n * treated as an edit distance of 1.\n *\n * Increasing the allowed edit distance will have a dramatic impact\n * on the performance of both creating and intersecting these TokenSets.\n * It is advised to keep the edit distance less than 3.\n *\n * @param {string} str - The string to create the token set from.\n * @param {number} editDistance - The allowed edit distance to match.\n * @returns {lunr.Vector}\n */\nlunr.TokenSet.fromFuzzyString = function (str, editDistance) {\n var root = new lunr.TokenSet\n\n var stack = [{\n node: root,\n editsRemaining: editDistance,\n str: str\n }]\n\n while (stack.length) {\n var frame = stack.pop()\n\n // no edit\n if (frame.str.length > 0) {\n var char = frame.str.charAt(0),\n noEditNode\n\n if (char in frame.node.edges) {\n noEditNode = frame.node.edges[char]\n } else {\n noEditNode = new lunr.TokenSet\n frame.node.edges[char] = noEditNode\n }\n\n if (frame.str.length == 1) {\n noEditNode.final = true\n }\n\n stack.push({\n node: noEditNode,\n editsRemaining: frame.editsRemaining,\n str: frame.str.slice(1)\n })\n }\n\n if (frame.editsRemaining == 0) {\n continue\n }\n\n // insertion\n if (\"*\" in frame.node.edges) {\n var insertionNode = frame.node.edges[\"*\"]\n } else {\n var insertionNode = new lunr.TokenSet\n frame.node.edges[\"*\"] = insertionNode\n }\n\n if (frame.str.length == 0) {\n insertionNode.final = true\n }\n\n stack.push({\n node: insertionNode,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str\n })\n\n // deletion\n // can only do a deletion if we have enough edits remaining\n // and if there are characters left to delete in the string\n if (frame.str.length > 1) {\n stack.push({\n node: frame.node,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str.slice(1)\n })\n }\n\n // deletion\n // just removing the last character from the str\n if (frame.str.length == 1) {\n frame.node.final = true\n }\n\n // substitution\n // can only do a substitution if we have enough edits remaining\n // and if there are characters left to substitute\n if (frame.str.length >= 1) {\n if (\"*\" in frame.node.edges) {\n var substitutionNode = frame.node.edges[\"*\"]\n } else {\n var substitutionNode = new lunr.TokenSet\n frame.node.edges[\"*\"] = substitutionNode\n }\n\n if (frame.str.length == 1) {\n substitutionNode.final = true\n }\n\n stack.push({\n node: substitutionNode,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str.slice(1)\n })\n }\n\n // transposition\n // can only do a transposition if there are edits remaining\n // and there are enough characters to transpose\n if (frame.str.length > 1) {\n var charA = frame.str.charAt(0),\n charB = frame.str.charAt(1),\n transposeNode\n\n if (charB in frame.node.edges) {\n transposeNode = frame.node.edges[charB]\n } else {\n transposeNode = new lunr.TokenSet\n frame.node.edges[charB] = transposeNode\n }\n\n if (frame.str.length == 1) {\n transposeNode.final = true\n }\n\n stack.push({\n node: transposeNode,\n editsRemaining: frame.editsRemaining - 1,\n str: charA + frame.str.slice(2)\n })\n }\n }\n\n return root\n}\n\n/**\n * Creates a TokenSet from a string.\n *\n * The string may contain one or more wildcard characters (*)\n * that will allow wildcard matching when intersecting with\n * another TokenSet.\n *\n * @param {string} str - The string to create a TokenSet from.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.fromString = function (str) {\n var node = new lunr.TokenSet,\n root = node\n\n /*\n * Iterates through all characters within the passed string\n * appending a node for each character.\n *\n * When a wildcard character is found then a self\n * referencing edge is introduced to continually match\n * any number of any characters.\n */\n for (var i = 0, len = str.length; i < len; i++) {\n var char = str[i],\n final = (i == len - 1)\n\n if (char == \"*\") {\n node.edges[char] = node\n node.final = final\n\n } else {\n var next = new lunr.TokenSet\n next.final = final\n\n node.edges[char] = next\n node = next\n }\n }\n\n return root\n}\n\n/**\n * Converts this TokenSet into an array of strings\n * contained within the TokenSet.\n *\n * This is not intended to be used on a TokenSet that\n * contains wildcards, in these cases the results are\n * undefined and are likely to cause an infinite loop.\n *\n * @returns {string[]}\n */\nlunr.TokenSet.prototype.toArray = function () {\n var words = []\n\n var stack = [{\n prefix: \"\",\n node: this\n }]\n\n while (stack.length) {\n var frame = stack.pop(),\n edges = Object.keys(frame.node.edges),\n len = edges.length\n\n if (frame.node.final) {\n /* In Safari, at this point the prefix is sometimes corrupted, see:\n * https://github.com/olivernn/lunr.js/issues/279 Calling any\n * String.prototype method forces Safari to \"cast\" this string to what\n * it's supposed to be, fixing the bug. */\n frame.prefix.charAt(0)\n words.push(frame.prefix)\n }\n\n for (var i = 0; i < len; i++) {\n var edge = edges[i]\n\n stack.push({\n prefix: frame.prefix.concat(edge),\n node: frame.node.edges[edge]\n })\n }\n }\n\n return words\n}\n\n/**\n * Generates a string representation of a TokenSet.\n *\n * This is intended to allow TokenSets to be used as keys\n * in objects, largely to aid the construction and minimisation\n * of a TokenSet. As such it is not designed to be a human\n * friendly representation of the TokenSet.\n *\n * @returns {string}\n */\nlunr.TokenSet.prototype.toString = function () {\n // NOTE: Using Object.keys here as this.edges is very likely\n // to enter 'hash-mode' with many keys being added\n //\n // avoiding a for-in loop here as it leads to the function\n // being de-optimised (at least in V8). From some simple\n // benchmarks the performance is comparable, but allowing\n // V8 to optimize may mean easy performance wins in the future.\n\n if (this._str) {\n return this._str\n }\n\n var str = this.final ? '1' : '0',\n labels = Object.keys(this.edges).sort(),\n len = labels.length\n\n for (var i = 0; i < len; i++) {\n var label = labels[i],\n node = this.edges[label]\n\n str = str + label + node.id\n }\n\n return str\n}\n\n/**\n * Returns a new TokenSet that is the intersection of\n * this TokenSet and the passed TokenSet.\n *\n * This intersection will take into account any wildcards\n * contained within the TokenSet.\n *\n * @param {lunr.TokenSet} b - An other TokenSet to intersect with.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.prototype.intersect = function (b) {\n var output = new lunr.TokenSet,\n frame = undefined\n\n var stack = [{\n qNode: b,\n output: output,\n node: this\n }]\n\n while (stack.length) {\n frame = stack.pop()\n\n // NOTE: As with the #toString method, we are using\n // Object.keys and a for loop instead of a for-in loop\n // as both of these objects enter 'hash' mode, causing\n // the function to be de-optimised in V8\n var qEdges = Object.keys(frame.qNode.edges),\n qLen = qEdges.length,\n nEdges = Object.keys(frame.node.edges),\n nLen = nEdges.length\n\n for (var q = 0; q < qLen; q++) {\n var qEdge = qEdges[q]\n\n for (var n = 0; n < nLen; n++) {\n var nEdge = nEdges[n]\n\n if (nEdge == qEdge || qEdge == '*') {\n var node = frame.node.edges[nEdge],\n qNode = frame.qNode.edges[qEdge],\n final = node.final && qNode.final,\n next = undefined\n\n if (nEdge in frame.output.edges) {\n // an edge already exists for this character\n // no need to create a new node, just set the finality\n // bit unless this node is already final\n next = frame.output.edges[nEdge]\n next.final = next.final || final\n\n } else {\n // no edge exists yet, must create one\n // set the finality bit and insert it\n // into the output\n next = new lunr.TokenSet\n next.final = final\n frame.output.edges[nEdge] = next\n }\n\n stack.push({\n qNode: qNode,\n output: next,\n node: node\n })\n }\n }\n }\n }\n\n return output\n}\nlunr.TokenSet.Builder = function () {\n this.previousWord = \"\"\n this.root = new lunr.TokenSet\n this.uncheckedNodes = []\n this.minimizedNodes = {}\n}\n\nlunr.TokenSet.Builder.prototype.insert = function (word) {\n var node,\n commonPrefix = 0\n\n if (word < this.previousWord) {\n throw new Error (\"Out of order word insertion\")\n }\n\n for (var i = 0; i < word.length && i < this.previousWord.length; i++) {\n if (word[i] != this.previousWord[i]) break\n commonPrefix++\n }\n\n this.minimize(commonPrefix)\n\n if (this.uncheckedNodes.length == 0) {\n node = this.root\n } else {\n node = this.uncheckedNodes[this.uncheckedNodes.length - 1].child\n }\n\n for (var i = commonPrefix; i < word.length; i++) {\n var nextNode = new lunr.TokenSet,\n char = word[i]\n\n node.edges[char] = nextNode\n\n this.uncheckedNodes.push({\n parent: node,\n char: char,\n child: nextNode\n })\n\n node = nextNode\n }\n\n node.final = true\n this.previousWord = word\n}\n\nlunr.TokenSet.Builder.prototype.finish = function () {\n this.minimize(0)\n}\n\nlunr.TokenSet.Builder.prototype.minimize = function (downTo) {\n for (var i = this.uncheckedNodes.length - 1; i >= downTo; i--) {\n var node = this.uncheckedNodes[i],\n childKey = node.child.toString()\n\n if (childKey in this.minimizedNodes) {\n node.parent.edges[node.char] = this.minimizedNodes[childKey]\n } else {\n // Cache the key for this node since\n // we know it can't change anymore\n node.child._str = childKey\n\n this.minimizedNodes[childKey] = node.child\n }\n\n this.uncheckedNodes.pop()\n }\n}\n/*!\n * lunr.Index\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * An index contains the built index of all documents and provides a query interface\n * to the index.\n *\n * Usually instances of lunr.Index will not be created using this constructor, instead\n * lunr.Builder should be used to construct new indexes, or lunr.Index.load should be\n * used to load previously built and serialized indexes.\n *\n * @constructor\n * @param {Object} attrs - The attributes of the built search index.\n * @param {Object} attrs.invertedIndex - An index of term/field to document reference.\n * @param {Object} attrs.fieldVectors - Field vectors\n * @param {lunr.TokenSet} attrs.tokenSet - An set of all corpus tokens.\n * @param {string[]} attrs.fields - The names of indexed document fields.\n * @param {lunr.Pipeline} attrs.pipeline - The pipeline to use for search terms.\n */\nlunr.Index = function (attrs) {\n this.invertedIndex = attrs.invertedIndex\n this.fieldVectors = attrs.fieldVectors\n this.tokenSet = attrs.tokenSet\n this.fields = attrs.fields\n this.pipeline = attrs.pipeline\n}\n\n/**\n * A result contains details of a document matching a search query.\n * @typedef {Object} lunr.Index~Result\n * @property {string} ref - The reference of the document this result represents.\n * @property {number} score - A number between 0 and 1 representing how similar this document is to the query.\n * @property {lunr.MatchData} matchData - Contains metadata about this match including which term(s) caused the match.\n */\n\n/**\n * Although lunr provides the ability to create queries using lunr.Query, it also provides a simple\n * query language which itself is parsed into an instance of lunr.Query.\n *\n * For programmatically building queries it is advised to directly use lunr.Query, the query language\n * is best used for human entered text rather than program generated text.\n *\n * At its simplest queries can just be a single term, e.g. `hello`, multiple terms are also supported\n * and will be combined with OR, e.g `hello world` will match documents that contain either 'hello'\n * or 'world', though those that contain both will rank higher in the results.\n *\n * Wildcards can be included in terms to match one or more unspecified characters, these wildcards can\n * be inserted anywhere within the term, and more than one wildcard can exist in a single term. Adding\n * wildcards will increase the number of documents that will be found but can also have a negative\n * impact on query performance, especially with wildcards at the beginning of a term.\n *\n * Terms can be restricted to specific fields, e.g. `title:hello`, only documents with the term\n * hello in the title field will match this query. Using a field not present in the index will lead\n * to an error being thrown.\n *\n * Modifiers can also be added to terms, lunr supports edit distance and boost modifiers on terms. A term\n * boost will make documents matching that term score higher, e.g. `foo^5`. Edit distance is also supported\n * to provide fuzzy matching, e.g. 'hello~2' will match documents with hello with an edit distance of 2.\n * Avoid large values for edit distance to improve query performance.\n *\n * Each term also supports a presence modifier. By default a term's presence in document is optional, however\n * this can be changed to either required or prohibited. For a term's presence to be required in a document the\n * term should be prefixed with a '+', e.g. `+foo bar` is a search for documents that must contain 'foo' and\n * optionally contain 'bar'. Conversely a leading '-' sets the terms presence to prohibited, i.e. it must not\n * appear in a document, e.g. `-foo bar` is a search for documents that do not contain 'foo' but may contain 'bar'.\n *\n * To escape special characters the backslash character '\\' can be used, this allows searches to include\n * characters that would normally be considered modifiers, e.g. `foo\\~2` will search for a term \"foo~2\" instead\n * of attempting to apply a boost of 2 to the search term \"foo\".\n *\n * @typedef {string} lunr.Index~QueryString\n * @example Simple single term query\n * hello\n * @example Multiple term query\n * hello world\n * @example term scoped to a field\n * title:hello\n * @example term with a boost of 10\n * hello^10\n * @example term with an edit distance of 2\n * hello~2\n * @example terms with presence modifiers\n * -foo +bar baz\n */\n\n/**\n * Performs a search against the index using lunr query syntax.\n *\n * Results will be returned sorted by their score, the most relevant results\n * will be returned first. For details on how the score is calculated, please see\n * the {@link https://lunrjs.com/guides/searching.html#scoring|guide}.\n *\n * For more programmatic querying use lunr.Index#query.\n *\n * @param {lunr.Index~QueryString} queryString - A string containing a lunr query.\n * @throws {lunr.QueryParseError} If the passed query string cannot be parsed.\n * @returns {lunr.Index~Result[]}\n */\nlunr.Index.prototype.search = function (queryString) {\n return this.query(function (query) {\n var parser = new lunr.QueryParser(queryString, query)\n parser.parse()\n })\n}\n\n/**\n * A query builder callback provides a query object to be used to express\n * the query to perform on the index.\n *\n * @callback lunr.Index~queryBuilder\n * @param {lunr.Query} query - The query object to build up.\n * @this lunr.Query\n */\n\n/**\n * Performs a query against the index using the yielded lunr.Query object.\n *\n * If performing programmatic queries against the index, this method is preferred\n * over lunr.Index#search so as to avoid the additional query parsing overhead.\n *\n * A query object is yielded to the supplied function which should be used to\n * express the query to be run against the index.\n *\n * Note that although this function takes a callback parameter it is _not_ an\n * asynchronous operation, the callback is just yielded a query object to be\n * customized.\n *\n * @param {lunr.Index~queryBuilder} fn - A function that is used to build the query.\n * @returns {lunr.Index~Result[]}\n */\nlunr.Index.prototype.query = function (fn) {\n // for each query clause\n // * process terms\n // * expand terms from token set\n // * find matching documents and metadata\n // * get document vectors\n // * score documents\n\n var query = new lunr.Query(this.fields),\n matchingFields = Object.create(null),\n queryVectors = Object.create(null),\n termFieldCache = Object.create(null),\n requiredMatches = Object.create(null),\n prohibitedMatches = Object.create(null)\n\n /*\n * To support field level boosts a query vector is created per\n * field. An empty vector is eagerly created to support negated\n * queries.\n */\n for (var i = 0; i < this.fields.length; i++) {\n queryVectors[this.fields[i]] = new lunr.Vector\n }\n\n fn.call(query, query)\n\n for (var i = 0; i < query.clauses.length; i++) {\n /*\n * Unless the pipeline has been disabled for this term, which is\n * the case for terms with wildcards, we need to pass the clause\n * term through the search pipeline. A pipeline returns an array\n * of processed terms. Pipeline functions may expand the passed\n * term, which means we may end up performing multiple index lookups\n * for a single query term.\n */\n var clause = query.clauses[i],\n terms = null,\n clauseMatches = lunr.Set.empty\n\n if (clause.usePipeline) {\n terms = this.pipeline.runString(clause.term, {\n fields: clause.fields\n })\n } else {\n terms = [clause.term]\n }\n\n for (var m = 0; m < terms.length; m++) {\n var term = terms[m]\n\n /*\n * Each term returned from the pipeline needs to use the same query\n * clause object, e.g. the same boost and or edit distance. The\n * simplest way to do this is to re-use the clause object but mutate\n * its term property.\n */\n clause.term = term\n\n /*\n * From the term in the clause we create a token set which will then\n * be used to intersect the indexes token set to get a list of terms\n * to lookup in the inverted index\n */\n var termTokenSet = lunr.TokenSet.fromClause(clause),\n expandedTerms = this.tokenSet.intersect(termTokenSet).toArray()\n\n /*\n * If a term marked as required does not exist in the tokenSet it is\n * impossible for the search to return any matches. We set all the field\n * scoped required matches set to empty and stop examining any further\n * clauses.\n */\n if (expandedTerms.length === 0 && clause.presence === lunr.Query.presence.REQUIRED) {\n for (var k = 0; k < clause.fields.length; k++) {\n var field = clause.fields[k]\n requiredMatches[field] = lunr.Set.empty\n }\n\n break\n }\n\n for (var j = 0; j < expandedTerms.length; j++) {\n /*\n * For each term get the posting and termIndex, this is required for\n * building the query vector.\n */\n var expandedTerm = expandedTerms[j],\n posting = this.invertedIndex[expandedTerm],\n termIndex = posting._index\n\n for (var k = 0; k < clause.fields.length; k++) {\n /*\n * For each field that this query term is scoped by (by default\n * all fields are in scope) we need to get all the document refs\n * that have this term in that field.\n *\n * The posting is the entry in the invertedIndex for the matching\n * term from above.\n */\n var field = clause.fields[k],\n fieldPosting = posting[field],\n matchingDocumentRefs = Object.keys(fieldPosting),\n termField = expandedTerm + \"/\" + field,\n matchingDocumentsSet = new lunr.Set(matchingDocumentRefs)\n\n /*\n * if the presence of this term is required ensure that the matching\n * documents are added to the set of required matches for this clause.\n *\n */\n if (clause.presence == lunr.Query.presence.REQUIRED) {\n clauseMatches = clauseMatches.union(matchingDocumentsSet)\n\n if (requiredMatches[field] === undefined) {\n requiredMatches[field] = lunr.Set.complete\n }\n }\n\n /*\n * if the presence of this term is prohibited ensure that the matching\n * documents are added to the set of prohibited matches for this field,\n * creating that set if it does not yet exist.\n */\n if (clause.presence == lunr.Query.presence.PROHIBITED) {\n if (prohibitedMatches[field] === undefined) {\n prohibitedMatches[field] = lunr.Set.empty\n }\n\n prohibitedMatches[field] = prohibitedMatches[field].union(matchingDocumentsSet)\n\n /*\n * Prohibited matches should not be part of the query vector used for\n * similarity scoring and no metadata should be extracted so we continue\n * to the next field\n */\n continue\n }\n\n /*\n * The query field vector is populated using the termIndex found for\n * the term and a unit value with the appropriate boost applied.\n * Using upsert because there could already be an entry in the vector\n * for the term we are working with. In that case we just add the scores\n * together.\n */\n queryVectors[field].upsert(termIndex, clause.boost, function (a, b) { return a + b })\n\n /**\n * If we've already seen this term, field combo then we've already collected\n * the matching documents and metadata, no need to go through all that again\n */\n if (termFieldCache[termField]) {\n continue\n }\n\n for (var l = 0; l < matchingDocumentRefs.length; l++) {\n /*\n * All metadata for this term/field/document triple\n * are then extracted and collected into an instance\n * of lunr.MatchData ready to be returned in the query\n * results\n */\n var matchingDocumentRef = matchingDocumentRefs[l],\n matchingFieldRef = new lunr.FieldRef (matchingDocumentRef, field),\n metadata = fieldPosting[matchingDocumentRef],\n fieldMatch\n\n if ((fieldMatch = matchingFields[matchingFieldRef]) === undefined) {\n matchingFields[matchingFieldRef] = new lunr.MatchData (expandedTerm, field, metadata)\n } else {\n fieldMatch.add(expandedTerm, field, metadata)\n }\n\n }\n\n termFieldCache[termField] = true\n }\n }\n }\n\n /**\n * If the presence was required we need to update the requiredMatches field sets.\n * We do this after all fields for the term have collected their matches because\n * the clause terms presence is required in _any_ of the fields not _all_ of the\n * fields.\n */\n if (clause.presence === lunr.Query.presence.REQUIRED) {\n for (var k = 0; k < clause.fields.length; k++) {\n var field = clause.fields[k]\n requiredMatches[field] = requiredMatches[field].intersect(clauseMatches)\n }\n }\n }\n\n /**\n * Need to combine the field scoped required and prohibited\n * matching documents into a global set of required and prohibited\n * matches\n */\n var allRequiredMatches = lunr.Set.complete,\n allProhibitedMatches = lunr.Set.empty\n\n for (var i = 0; i < this.fields.length; i++) {\n var field = this.fields[i]\n\n if (requiredMatches[field]) {\n allRequiredMatches = allRequiredMatches.intersect(requiredMatches[field])\n }\n\n if (prohibitedMatches[field]) {\n allProhibitedMatches = allProhibitedMatches.union(prohibitedMatches[field])\n }\n }\n\n var matchingFieldRefs = Object.keys(matchingFields),\n results = [],\n matches = Object.create(null)\n\n /*\n * If the query is negated (contains only prohibited terms)\n * we need to get _all_ fieldRefs currently existing in the\n * index. This is only done when we know that the query is\n * entirely prohibited terms to avoid any cost of getting all\n * fieldRefs unnecessarily.\n *\n * Additionally, blank MatchData must be created to correctly\n * populate the results.\n */\n if (query.isNegated()) {\n matchingFieldRefs = Object.keys(this.fieldVectors)\n\n for (var i = 0; i < matchingFieldRefs.length; i++) {\n var matchingFieldRef = matchingFieldRefs[i]\n var fieldRef = lunr.FieldRef.fromString(matchingFieldRef)\n matchingFields[matchingFieldRef] = new lunr.MatchData\n }\n }\n\n for (var i = 0; i < matchingFieldRefs.length; i++) {\n /*\n * Currently we have document fields that match the query, but we\n * need to return documents. The matchData and scores are combined\n * from multiple fields belonging to the same document.\n *\n * Scores are calculated by field, using the query vectors created\n * above, and combined into a final document score using addition.\n */\n var fieldRef = lunr.FieldRef.fromString(matchingFieldRefs[i]),\n docRef = fieldRef.docRef\n\n if (!allRequiredMatches.contains(docRef)) {\n continue\n }\n\n if (allProhibitedMatches.contains(docRef)) {\n continue\n }\n\n var fieldVector = this.fieldVectors[fieldRef],\n score = queryVectors[fieldRef.fieldName].similarity(fieldVector),\n docMatch\n\n if ((docMatch = matches[docRef]) !== undefined) {\n docMatch.score += score\n docMatch.matchData.combine(matchingFields[fieldRef])\n } else {\n var match = {\n ref: docRef,\n score: score,\n matchData: matchingFields[fieldRef]\n }\n matches[docRef] = match\n results.push(match)\n }\n }\n\n /*\n * Sort the results objects by score, highest first.\n */\n return results.sort(function (a, b) {\n return b.score - a.score\n })\n}\n\n/**\n * Prepares the index for JSON serialization.\n *\n * The schema for this JSON blob will be described in a\n * separate JSON schema file.\n *\n * @returns {Object}\n */\nlunr.Index.prototype.toJSON = function () {\n var invertedIndex = Object.keys(this.invertedIndex)\n .sort()\n .map(function (term) {\n return [term, this.invertedIndex[term]]\n }, this)\n\n var fieldVectors = Object.keys(this.fieldVectors)\n .map(function (ref) {\n return [ref, this.fieldVectors[ref].toJSON()]\n }, this)\n\n return {\n version: lunr.version,\n fields: this.fields,\n fieldVectors: fieldVectors,\n invertedIndex: invertedIndex,\n pipeline: this.pipeline.toJSON()\n }\n}\n\n/**\n * Loads a previously serialized lunr.Index\n *\n * @param {Object} serializedIndex - A previously serialized lunr.Index\n * @returns {lunr.Index}\n */\nlunr.Index.load = function (serializedIndex) {\n var attrs = {},\n fieldVectors = {},\n serializedVectors = serializedIndex.fieldVectors,\n invertedIndex = Object.create(null),\n serializedInvertedIndex = serializedIndex.invertedIndex,\n tokenSetBuilder = new lunr.TokenSet.Builder,\n pipeline = lunr.Pipeline.load(serializedIndex.pipeline)\n\n if (serializedIndex.version != lunr.version) {\n lunr.utils.warn(\"Version mismatch when loading serialised index. Current version of lunr '\" + lunr.version + \"' does not match serialized index '\" + serializedIndex.version + \"'\")\n }\n\n for (var i = 0; i < serializedVectors.length; i++) {\n var tuple = serializedVectors[i],\n ref = tuple[0],\n elements = tuple[1]\n\n fieldVectors[ref] = new lunr.Vector(elements)\n }\n\n for (var i = 0; i < serializedInvertedIndex.length; i++) {\n var tuple = serializedInvertedIndex[i],\n term = tuple[0],\n posting = tuple[1]\n\n tokenSetBuilder.insert(term)\n invertedIndex[term] = posting\n }\n\n tokenSetBuilder.finish()\n\n attrs.fields = serializedIndex.fields\n\n attrs.fieldVectors = fieldVectors\n attrs.invertedIndex = invertedIndex\n attrs.tokenSet = tokenSetBuilder.root\n attrs.pipeline = pipeline\n\n return new lunr.Index(attrs)\n}\n/*!\n * lunr.Builder\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.Builder performs indexing on a set of documents and\n * returns instances of lunr.Index ready for querying.\n *\n * All configuration of the index is done via the builder, the\n * fields to index, the document reference, the text processing\n * pipeline and document scoring parameters are all set on the\n * builder before indexing.\n *\n * @constructor\n * @property {string} _ref - Internal reference to the document reference field.\n * @property {string[]} _fields - Internal reference to the document fields to index.\n * @property {object} invertedIndex - The inverted index maps terms to document fields.\n * @property {object} documentTermFrequencies - Keeps track of document term frequencies.\n * @property {object} documentLengths - Keeps track of the length of documents added to the index.\n * @property {lunr.tokenizer} tokenizer - Function for splitting strings into tokens for indexing.\n * @property {lunr.Pipeline} pipeline - The pipeline performs text processing on tokens before indexing.\n * @property {lunr.Pipeline} searchPipeline - A pipeline for processing search terms before querying the index.\n * @property {number} documentCount - Keeps track of the total number of documents indexed.\n * @property {number} _b - A parameter to control field length normalization, setting this to 0 disabled normalization, 1 fully normalizes field lengths, the default value is 0.75.\n * @property {number} _k1 - A parameter to control how quickly an increase in term frequency results in term frequency saturation, the default value is 1.2.\n * @property {number} termIndex - A counter incremented for each unique term, used to identify a terms position in the vector space.\n * @property {array} metadataWhitelist - A list of metadata keys that have been whitelisted for entry in the index.\n */\nlunr.Builder = function () {\n this._ref = \"id\"\n this._fields = Object.create(null)\n this._documents = Object.create(null)\n this.invertedIndex = Object.create(null)\n this.fieldTermFrequencies = {}\n this.fieldLengths = {}\n this.tokenizer = lunr.tokenizer\n this.pipeline = new lunr.Pipeline\n this.searchPipeline = new lunr.Pipeline\n this.documentCount = 0\n this._b = 0.75\n this._k1 = 1.2\n this.termIndex = 0\n this.metadataWhitelist = []\n}\n\n/**\n * Sets the document field used as the document reference. Every document must have this field.\n * The type of this field in the document should be a string, if it is not a string it will be\n * coerced into a string by calling toString.\n *\n * The default ref is 'id'.\n *\n * The ref should _not_ be changed during indexing, it should be set before any documents are\n * added to the index. Changing it during indexing can lead to inconsistent results.\n *\n * @param {string} ref - The name of the reference field in the document.\n */\nlunr.Builder.prototype.ref = function (ref) {\n this._ref = ref\n}\n\n/**\n * A function that is used to extract a field from a document.\n *\n * Lunr expects a field to be at the top level of a document, if however the field\n * is deeply nested within a document an extractor function can be used to extract\n * the right field for indexing.\n *\n * @callback fieldExtractor\n * @param {object} doc - The document being added to the index.\n * @returns {?(string|object|object[])} obj - The object that will be indexed for this field.\n * @example Extracting a nested field\n * function (doc) { return doc.nested.field }\n */\n\n/**\n * Adds a field to the list of document fields that will be indexed. Every document being\n * indexed should have this field. Null values for this field in indexed documents will\n * not cause errors but will limit the chance of that document being retrieved by searches.\n *\n * All fields should be added before adding documents to the index. Adding fields after\n * a document has been indexed will have no effect on already indexed documents.\n *\n * Fields can be boosted at build time. This allows terms within that field to have more\n * importance when ranking search results. Use a field boost to specify that matches within\n * one field are more important than other fields.\n *\n * @param {string} fieldName - The name of a field to index in all documents.\n * @param {object} attributes - Optional attributes associated with this field.\n * @param {number} [attributes.boost=1] - Boost applied to all terms within this field.\n * @param {fieldExtractor} [attributes.extractor] - Function to extract a field from a document.\n * @throws {RangeError} fieldName cannot contain unsupported characters '/'\n */\nlunr.Builder.prototype.field = function (fieldName, attributes) {\n if (/\\//.test(fieldName)) {\n throw new RangeError (\"Field '\" + fieldName + \"' contains illegal character '/'\")\n }\n\n this._fields[fieldName] = attributes || {}\n}\n\n/**\n * A parameter to tune the amount of field length normalisation that is applied when\n * calculating relevance scores. A value of 0 will completely disable any normalisation\n * and a value of 1 will fully normalise field lengths. The default is 0.75. Values of b\n * will be clamped to the range 0 - 1.\n *\n * @param {number} number - The value to set for this tuning parameter.\n */\nlunr.Builder.prototype.b = function (number) {\n if (number < 0) {\n this._b = 0\n } else if (number > 1) {\n this._b = 1\n } else {\n this._b = number\n }\n}\n\n/**\n * A parameter that controls the speed at which a rise in term frequency results in term\n * frequency saturation. The default value is 1.2. Setting this to a higher value will give\n * slower saturation levels, a lower value will result in quicker saturation.\n *\n * @param {number} number - The value to set for this tuning parameter.\n */\nlunr.Builder.prototype.k1 = function (number) {\n this._k1 = number\n}\n\n/**\n * Adds a document to the index.\n *\n * Before adding fields to the index the index should have been fully setup, with the document\n * ref and all fields to index already having been specified.\n *\n * The document must have a field name as specified by the ref (by default this is 'id') and\n * it should have all fields defined for indexing, though null or undefined values will not\n * cause errors.\n *\n * Entire documents can be boosted at build time. Applying a boost to a document indicates that\n * this document should rank higher in search results than other documents.\n *\n * @param {object} doc - The document to add to the index.\n * @param {object} attributes - Optional attributes associated with this document.\n * @param {number} [attributes.boost=1] - Boost applied to all terms within this document.\n */\nlunr.Builder.prototype.add = function (doc, attributes) {\n var docRef = doc[this._ref],\n fields = Object.keys(this._fields)\n\n this._documents[docRef] = attributes || {}\n this.documentCount += 1\n\n for (var i = 0; i < fields.length; i++) {\n var fieldName = fields[i],\n extractor = this._fields[fieldName].extractor,\n field = extractor ? extractor(doc) : doc[fieldName],\n tokens = this.tokenizer(field, {\n fields: [fieldName]\n }),\n terms = this.pipeline.run(tokens),\n fieldRef = new lunr.FieldRef (docRef, fieldName),\n fieldTerms = Object.create(null)\n\n this.fieldTermFrequencies[fieldRef] = fieldTerms\n this.fieldLengths[fieldRef] = 0\n\n // store the length of this field for this document\n this.fieldLengths[fieldRef] += terms.length\n\n // calculate term frequencies for this field\n for (var j = 0; j < terms.length; j++) {\n var term = terms[j]\n\n if (fieldTerms[term] == undefined) {\n fieldTerms[term] = 0\n }\n\n fieldTerms[term] += 1\n\n // add to inverted index\n // create an initial posting if one doesn't exist\n if (this.invertedIndex[term] == undefined) {\n var posting = Object.create(null)\n posting[\"_index\"] = this.termIndex\n this.termIndex += 1\n\n for (var k = 0; k < fields.length; k++) {\n posting[fields[k]] = Object.create(null)\n }\n\n this.invertedIndex[term] = posting\n }\n\n // add an entry for this term/fieldName/docRef to the invertedIndex\n if (this.invertedIndex[term][fieldName][docRef] == undefined) {\n this.invertedIndex[term][fieldName][docRef] = Object.create(null)\n }\n\n // store all whitelisted metadata about this token in the\n // inverted index\n for (var l = 0; l < this.metadataWhitelist.length; l++) {\n var metadataKey = this.metadataWhitelist[l],\n metadata = term.metadata[metadataKey]\n\n if (this.invertedIndex[term][fieldName][docRef][metadataKey] == undefined) {\n this.invertedIndex[term][fieldName][docRef][metadataKey] = []\n }\n\n this.invertedIndex[term][fieldName][docRef][metadataKey].push(metadata)\n }\n }\n\n }\n}\n\n/**\n * Calculates the average document length for this index\n *\n * @private\n */\nlunr.Builder.prototype.calculateAverageFieldLengths = function () {\n\n var fieldRefs = Object.keys(this.fieldLengths),\n numberOfFields = fieldRefs.length,\n accumulator = {},\n documentsWithField = {}\n\n for (var i = 0; i < numberOfFields; i++) {\n var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),\n field = fieldRef.fieldName\n\n documentsWithField[field] || (documentsWithField[field] = 0)\n documentsWithField[field] += 1\n\n accumulator[field] || (accumulator[field] = 0)\n accumulator[field] += this.fieldLengths[fieldRef]\n }\n\n var fields = Object.keys(this._fields)\n\n for (var i = 0; i < fields.length; i++) {\n var fieldName = fields[i]\n accumulator[fieldName] = accumulator[fieldName] / documentsWithField[fieldName]\n }\n\n this.averageFieldLength = accumulator\n}\n\n/**\n * Builds a vector space model of every document using lunr.Vector\n *\n * @private\n */\nlunr.Builder.prototype.createFieldVectors = function () {\n var fieldVectors = {},\n fieldRefs = Object.keys(this.fieldTermFrequencies),\n fieldRefsLength = fieldRefs.length,\n termIdfCache = Object.create(null)\n\n for (var i = 0; i < fieldRefsLength; i++) {\n var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),\n fieldName = fieldRef.fieldName,\n fieldLength = this.fieldLengths[fieldRef],\n fieldVector = new lunr.Vector,\n termFrequencies = this.fieldTermFrequencies[fieldRef],\n terms = Object.keys(termFrequencies),\n termsLength = terms.length\n\n\n var fieldBoost = this._fields[fieldName].boost || 1,\n docBoost = this._documents[fieldRef.docRef].boost || 1\n\n for (var j = 0; j < termsLength; j++) {\n var term = terms[j],\n tf = termFrequencies[term],\n termIndex = this.invertedIndex[term]._index,\n idf, score, scoreWithPrecision\n\n if (termIdfCache[term] === undefined) {\n idf = lunr.idf(this.invertedIndex[term], this.documentCount)\n termIdfCache[term] = idf\n } else {\n idf = termIdfCache[term]\n }\n\n score = idf * ((this._k1 + 1) * tf) / (this._k1 * (1 - this._b + this._b * (fieldLength / this.averageFieldLength[fieldName])) + tf)\n score *= fieldBoost\n score *= docBoost\n scoreWithPrecision = Math.round(score * 1000) / 1000\n // Converts 1.23456789 to 1.234.\n // Reducing the precision so that the vectors take up less\n // space when serialised. Doing it now so that they behave\n // the same before and after serialisation. Also, this is\n // the fastest approach to reducing a number's precision in\n // JavaScript.\n\n fieldVector.insert(termIndex, scoreWithPrecision)\n }\n\n fieldVectors[fieldRef] = fieldVector\n }\n\n this.fieldVectors = fieldVectors\n}\n\n/**\n * Creates a token set of all tokens in the index using lunr.TokenSet\n *\n * @private\n */\nlunr.Builder.prototype.createTokenSet = function () {\n this.tokenSet = lunr.TokenSet.fromArray(\n Object.keys(this.invertedIndex).sort()\n )\n}\n\n/**\n * Builds the index, creating an instance of lunr.Index.\n *\n * This completes the indexing process and should only be called\n * once all documents have been added to the index.\n *\n * @returns {lunr.Index}\n */\nlunr.Builder.prototype.build = function () {\n this.calculateAverageFieldLengths()\n this.createFieldVectors()\n this.createTokenSet()\n\n return new lunr.Index({\n invertedIndex: this.invertedIndex,\n fieldVectors: this.fieldVectors,\n tokenSet: this.tokenSet,\n fields: Object.keys(this._fields),\n pipeline: this.searchPipeline\n })\n}\n\n/**\n * Applies a plugin to the index builder.\n *\n * A plugin is a function that is called with the index builder as its context.\n * Plugins can be used to customise or extend the behaviour of the index\n * in some way. A plugin is just a function, that encapsulated the custom\n * behaviour that should be applied when building the index.\n *\n * The plugin function will be called with the index builder as its argument, additional\n * arguments can also be passed when calling use. The function will be called\n * with the index builder as its context.\n *\n * @param {Function} plugin The plugin to apply.\n */\nlunr.Builder.prototype.use = function (fn) {\n var args = Array.prototype.slice.call(arguments, 1)\n args.unshift(this)\n fn.apply(this, args)\n}\n/**\n * Contains and collects metadata about a matching document.\n * A single instance of lunr.MatchData is returned as part of every\n * lunr.Index~Result.\n *\n * @constructor\n * @param {string} term - The term this match data is associated with\n * @param {string} field - The field in which the term was found\n * @param {object} metadata - The metadata recorded about this term in this field\n * @property {object} metadata - A cloned collection of metadata associated with this document.\n * @see {@link lunr.Index~Result}\n */\nlunr.MatchData = function (term, field, metadata) {\n var clonedMetadata = Object.create(null),\n metadataKeys = Object.keys(metadata || {})\n\n // Cloning the metadata to prevent the original\n // being mutated during match data combination.\n // Metadata is kept in an array within the inverted\n // index so cloning the data can be done with\n // Array#slice\n for (var i = 0; i < metadataKeys.length; i++) {\n var key = metadataKeys[i]\n clonedMetadata[key] = metadata[key].slice()\n }\n\n this.metadata = Object.create(null)\n\n if (term !== undefined) {\n this.metadata[term] = Object.create(null)\n this.metadata[term][field] = clonedMetadata\n }\n}\n\n/**\n * An instance of lunr.MatchData will be created for every term that matches a\n * document. However only one instance is required in a lunr.Index~Result. This\n * method combines metadata from another instance of lunr.MatchData with this\n * objects metadata.\n *\n * @param {lunr.MatchData} otherMatchData - Another instance of match data to merge with this one.\n * @see {@link lunr.Index~Result}\n */\nlunr.MatchData.prototype.combine = function (otherMatchData) {\n var terms = Object.keys(otherMatchData.metadata)\n\n for (var i = 0; i < terms.length; i++) {\n var term = terms[i],\n fields = Object.keys(otherMatchData.metadata[term])\n\n if (this.metadata[term] == undefined) {\n this.metadata[term] = Object.create(null)\n }\n\n for (var j = 0; j < fields.length; j++) {\n var field = fields[j],\n keys = Object.keys(otherMatchData.metadata[term][field])\n\n if (this.metadata[term][field] == undefined) {\n this.metadata[term][field] = Object.create(null)\n }\n\n for (var k = 0; k < keys.length; k++) {\n var key = keys[k]\n\n if (this.metadata[term][field][key] == undefined) {\n this.metadata[term][field][key] = otherMatchData.metadata[term][field][key]\n } else {\n this.metadata[term][field][key] = this.metadata[term][field][key].concat(otherMatchData.metadata[term][field][key])\n }\n\n }\n }\n }\n}\n\n/**\n * Add metadata for a term/field pair to this instance of match data.\n *\n * @param {string} term - The term this match data is associated with\n * @param {string} field - The field in which the term was found\n * @param {object} metadata - The metadata recorded about this term in this field\n */\nlunr.MatchData.prototype.add = function (term, field, metadata) {\n if (!(term in this.metadata)) {\n this.metadata[term] = Object.create(null)\n this.metadata[term][field] = metadata\n return\n }\n\n if (!(field in this.metadata[term])) {\n this.metadata[term][field] = metadata\n return\n }\n\n var metadataKeys = Object.keys(metadata)\n\n for (var i = 0; i < metadataKeys.length; i++) {\n var key = metadataKeys[i]\n\n if (key in this.metadata[term][field]) {\n this.metadata[term][field][key] = this.metadata[term][field][key].concat(metadata[key])\n } else {\n this.metadata[term][field][key] = metadata[key]\n }\n }\n}\n/**\n * A lunr.Query provides a programmatic way of defining queries to be performed\n * against a {@link lunr.Index}.\n *\n * Prefer constructing a lunr.Query using the {@link lunr.Index#query} method\n * so the query object is pre-initialized with the right index fields.\n *\n * @constructor\n * @property {lunr.Query~Clause[]} clauses - An array of query clauses.\n * @property {string[]} allFields - An array of all available fields in a lunr.Index.\n */\nlunr.Query = function (allFields) {\n this.clauses = []\n this.allFields = allFields\n}\n\n/**\n * Constants for indicating what kind of automatic wildcard insertion will be used when constructing a query clause.\n *\n * This allows wildcards to be added to the beginning and end of a term without having to manually do any string\n * concatenation.\n *\n * The wildcard constants can be bitwise combined to select both leading and trailing wildcards.\n *\n * @constant\n * @default\n * @property {number} wildcard.NONE - The term will have no wildcards inserted, this is the default behaviour\n * @property {number} wildcard.LEADING - Prepend the term with a wildcard, unless a leading wildcard already exists\n * @property {number} wildcard.TRAILING - Append a wildcard to the term, unless a trailing wildcard already exists\n * @see lunr.Query~Clause\n * @see lunr.Query#clause\n * @see lunr.Query#term\n * @example query term with trailing wildcard\n * query.term('foo', { wildcard: lunr.Query.wildcard.TRAILING })\n * @example query term with leading and trailing wildcard\n * query.term('foo', {\n * wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING\n * })\n */\n\nlunr.Query.wildcard = new String (\"*\")\nlunr.Query.wildcard.NONE = 0\nlunr.Query.wildcard.LEADING = 1\nlunr.Query.wildcard.TRAILING = 2\n\n/**\n * Constants for indicating what kind of presence a term must have in matching documents.\n *\n * @constant\n * @enum {number}\n * @see lunr.Query~Clause\n * @see lunr.Query#clause\n * @see lunr.Query#term\n * @example query term with required presence\n * query.term('foo', { presence: lunr.Query.presence.REQUIRED })\n */\nlunr.Query.presence = {\n /**\n * Term's presence in a document is optional, this is the default value.\n */\n OPTIONAL: 1,\n\n /**\n * Term's presence in a document is required, documents that do not contain\n * this term will not be returned.\n */\n REQUIRED: 2,\n\n /**\n * Term's presence in a document is prohibited, documents that do contain\n * this term will not be returned.\n */\n PROHIBITED: 3\n}\n\n/**\n * A single clause in a {@link lunr.Query} contains a term and details on how to\n * match that term against a {@link lunr.Index}.\n *\n * @typedef {Object} lunr.Query~Clause\n * @property {string[]} fields - The fields in an index this clause should be matched against.\n * @property {number} [boost=1] - Any boost that should be applied when matching this clause.\n * @property {number} [editDistance] - Whether the term should have fuzzy matching applied, and how fuzzy the match should be.\n * @property {boolean} [usePipeline] - Whether the term should be passed through the search pipeline.\n * @property {number} [wildcard=lunr.Query.wildcard.NONE] - Whether the term should have wildcards appended or prepended.\n * @property {number} [presence=lunr.Query.presence.OPTIONAL] - The terms presence in any matching documents.\n */\n\n/**\n * Adds a {@link lunr.Query~Clause} to this query.\n *\n * Unless the clause contains the fields to be matched all fields will be matched. In addition\n * a default boost of 1 is applied to the clause.\n *\n * @param {lunr.Query~Clause} clause - The clause to add to this query.\n * @see lunr.Query~Clause\n * @returns {lunr.Query}\n */\nlunr.Query.prototype.clause = function (clause) {\n if (!('fields' in clause)) {\n clause.fields = this.allFields\n }\n\n if (!('boost' in clause)) {\n clause.boost = 1\n }\n\n if (!('usePipeline' in clause)) {\n clause.usePipeline = true\n }\n\n if (!('wildcard' in clause)) {\n clause.wildcard = lunr.Query.wildcard.NONE\n }\n\n if ((clause.wildcard & lunr.Query.wildcard.LEADING) && (clause.term.charAt(0) != lunr.Query.wildcard)) {\n clause.term = \"*\" + clause.term\n }\n\n if ((clause.wildcard & lunr.Query.wildcard.TRAILING) && (clause.term.slice(-1) != lunr.Query.wildcard)) {\n clause.term = \"\" + clause.term + \"*\"\n }\n\n if (!('presence' in clause)) {\n clause.presence = lunr.Query.presence.OPTIONAL\n }\n\n this.clauses.push(clause)\n\n return this\n}\n\n/**\n * A negated query is one in which every clause has a presence of\n * prohibited. These queries require some special processing to return\n * the expected results.\n *\n * @returns boolean\n */\nlunr.Query.prototype.isNegated = function () {\n for (var i = 0; i < this.clauses.length; i++) {\n if (this.clauses[i].presence != lunr.Query.presence.PROHIBITED) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Adds a term to the current query, under the covers this will create a {@link lunr.Query~Clause}\n * to the list of clauses that make up this query.\n *\n * The term is used as is, i.e. no tokenization will be performed by this method. Instead conversion\n * to a token or token-like string should be done before calling this method.\n *\n * The term will be converted to a string by calling `toString`. Multiple terms can be passed as an\n * array, each term in the array will share the same options.\n *\n * @param {object|object[]} term - The term(s) to add to the query.\n * @param {object} [options] - Any additional properties to add to the query clause.\n * @returns {lunr.Query}\n * @see lunr.Query#clause\n * @see lunr.Query~Clause\n * @example adding a single term to a query\n * query.term(\"foo\")\n * @example adding a single term to a query and specifying search fields, term boost and automatic trailing wildcard\n * query.term(\"foo\", {\n * fields: [\"title\"],\n * boost: 10,\n * wildcard: lunr.Query.wildcard.TRAILING\n * })\n * @example using lunr.tokenizer to convert a string to tokens before using them as terms\n * query.term(lunr.tokenizer(\"foo bar\"))\n */\nlunr.Query.prototype.term = function (term, options) {\n if (Array.isArray(term)) {\n term.forEach(function (t) { this.term(t, lunr.utils.clone(options)) }, this)\n return this\n }\n\n var clause = options || {}\n clause.term = term.toString()\n\n this.clause(clause)\n\n return this\n}\nlunr.QueryParseError = function (message, start, end) {\n this.name = \"QueryParseError\"\n this.message = message\n this.start = start\n this.end = end\n}\n\nlunr.QueryParseError.prototype = new Error\nlunr.QueryLexer = function (str) {\n this.lexemes = []\n this.str = str\n this.length = str.length\n this.pos = 0\n this.start = 0\n this.escapeCharPositions = []\n}\n\nlunr.QueryLexer.prototype.run = function () {\n var state = lunr.QueryLexer.lexText\n\n while (state) {\n state = state(this)\n }\n}\n\nlunr.QueryLexer.prototype.sliceString = function () {\n var subSlices = [],\n sliceStart = this.start,\n sliceEnd = this.pos\n\n for (var i = 0; i < this.escapeCharPositions.length; i++) {\n sliceEnd = this.escapeCharPositions[i]\n subSlices.push(this.str.slice(sliceStart, sliceEnd))\n sliceStart = sliceEnd + 1\n }\n\n subSlices.push(this.str.slice(sliceStart, this.pos))\n this.escapeCharPositions.length = 0\n\n return subSlices.join('')\n}\n\nlunr.QueryLexer.prototype.emit = function (type) {\n this.lexemes.push({\n type: type,\n str: this.sliceString(),\n start: this.start,\n end: this.pos\n })\n\n this.start = this.pos\n}\n\nlunr.QueryLexer.prototype.escapeCharacter = function () {\n this.escapeCharPositions.push(this.pos - 1)\n this.pos += 1\n}\n\nlunr.QueryLexer.prototype.next = function () {\n if (this.pos >= this.length) {\n return lunr.QueryLexer.EOS\n }\n\n var char = this.str.charAt(this.pos)\n this.pos += 1\n return char\n}\n\nlunr.QueryLexer.prototype.width = function () {\n return this.pos - this.start\n}\n\nlunr.QueryLexer.prototype.ignore = function () {\n if (this.start == this.pos) {\n this.pos += 1\n }\n\n this.start = this.pos\n}\n\nlunr.QueryLexer.prototype.backup = function () {\n this.pos -= 1\n}\n\nlunr.QueryLexer.prototype.acceptDigitRun = function () {\n var char, charCode\n\n do {\n char = this.next()\n charCode = char.charCodeAt(0)\n } while (charCode > 47 && charCode < 58)\n\n if (char != lunr.QueryLexer.EOS) {\n this.backup()\n }\n}\n\nlunr.QueryLexer.prototype.more = function () {\n return this.pos < this.length\n}\n\nlunr.QueryLexer.EOS = 'EOS'\nlunr.QueryLexer.FIELD = 'FIELD'\nlunr.QueryLexer.TERM = 'TERM'\nlunr.QueryLexer.EDIT_DISTANCE = 'EDIT_DISTANCE'\nlunr.QueryLexer.BOOST = 'BOOST'\nlunr.QueryLexer.PRESENCE = 'PRESENCE'\n\nlunr.QueryLexer.lexField = function (lexer) {\n lexer.backup()\n lexer.emit(lunr.QueryLexer.FIELD)\n lexer.ignore()\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexTerm = function (lexer) {\n if (lexer.width() > 1) {\n lexer.backup()\n lexer.emit(lunr.QueryLexer.TERM)\n }\n\n lexer.ignore()\n\n if (lexer.more()) {\n return lunr.QueryLexer.lexText\n }\n}\n\nlunr.QueryLexer.lexEditDistance = function (lexer) {\n lexer.ignore()\n lexer.acceptDigitRun()\n lexer.emit(lunr.QueryLexer.EDIT_DISTANCE)\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexBoost = function (lexer) {\n lexer.ignore()\n lexer.acceptDigitRun()\n lexer.emit(lunr.QueryLexer.BOOST)\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexEOS = function (lexer) {\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n}\n\n// This matches the separator used when tokenising fields\n// within a document. These should match otherwise it is\n// not possible to search for some tokens within a document.\n//\n// It is possible for the user to change the separator on the\n// tokenizer so it _might_ clash with any other of the special\n// characters already used within the search string, e.g. :.\n//\n// This means that it is possible to change the separator in\n// such a way that makes some words unsearchable using a search\n// string.\nlunr.QueryLexer.termSeparator = lunr.tokenizer.separator\n\nlunr.QueryLexer.lexText = function (lexer) {\n while (true) {\n var char = lexer.next()\n\n if (char == lunr.QueryLexer.EOS) {\n return lunr.QueryLexer.lexEOS\n }\n\n // Escape character is '\\'\n if (char.charCodeAt(0) == 92) {\n lexer.escapeCharacter()\n continue\n }\n\n if (char == \":\") {\n return lunr.QueryLexer.lexField\n }\n\n if (char == \"~\") {\n lexer.backup()\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n return lunr.QueryLexer.lexEditDistance\n }\n\n if (char == \"^\") {\n lexer.backup()\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n return lunr.QueryLexer.lexBoost\n }\n\n // \"+\" indicates term presence is required\n // checking for length to ensure that only\n // leading \"+\" are considered\n if (char == \"+\" && lexer.width() === 1) {\n lexer.emit(lunr.QueryLexer.PRESENCE)\n return lunr.QueryLexer.lexText\n }\n\n // \"-\" indicates term presence is prohibited\n // checking for length to ensure that only\n // leading \"-\" are considered\n if (char == \"-\" && lexer.width() === 1) {\n lexer.emit(lunr.QueryLexer.PRESENCE)\n return lunr.QueryLexer.lexText\n }\n\n if (char.match(lunr.QueryLexer.termSeparator)) {\n return lunr.QueryLexer.lexTerm\n }\n }\n}\n\nlunr.QueryParser = function (str, query) {\n this.lexer = new lunr.QueryLexer (str)\n this.query = query\n this.currentClause = {}\n this.lexemeIdx = 0\n}\n\nlunr.QueryParser.prototype.parse = function () {\n this.lexer.run()\n this.lexemes = this.lexer.lexemes\n\n var state = lunr.QueryParser.parseClause\n\n while (state) {\n state = state(this)\n }\n\n return this.query\n}\n\nlunr.QueryParser.prototype.peekLexeme = function () {\n return this.lexemes[this.lexemeIdx]\n}\n\nlunr.QueryParser.prototype.consumeLexeme = function () {\n var lexeme = this.peekLexeme()\n this.lexemeIdx += 1\n return lexeme\n}\n\nlunr.QueryParser.prototype.nextClause = function () {\n var completedClause = this.currentClause\n this.query.clause(completedClause)\n this.currentClause = {}\n}\n\nlunr.QueryParser.parseClause = function (parser) {\n var lexeme = parser.peekLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n switch (lexeme.type) {\n case lunr.QueryLexer.PRESENCE:\n return lunr.QueryParser.parsePresence\n case lunr.QueryLexer.FIELD:\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expected either a field or a term, found \" + lexeme.type\n\n if (lexeme.str.length >= 1) {\n errorMessage += \" with value '\" + lexeme.str + \"'\"\n }\n\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n}\n\nlunr.QueryParser.parsePresence = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n switch (lexeme.str) {\n case \"-\":\n parser.currentClause.presence = lunr.Query.presence.PROHIBITED\n break\n case \"+\":\n parser.currentClause.presence = lunr.Query.presence.REQUIRED\n break\n default:\n var errorMessage = \"unrecognised presence operator'\" + lexeme.str + \"'\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n var errorMessage = \"expecting term or field, found nothing\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.FIELD:\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expecting term or field, found '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseField = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n if (parser.query.allFields.indexOf(lexeme.str) == -1) {\n var possibleFields = parser.query.allFields.map(function (f) { return \"'\" + f + \"'\" }).join(', '),\n errorMessage = \"unrecognised field '\" + lexeme.str + \"', possible fields: \" + possibleFields\n\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.fields = [lexeme.str]\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n var errorMessage = \"expecting term, found nothing\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expecting term, found '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseTerm = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n parser.currentClause.term = lexeme.str.toLowerCase()\n\n if (lexeme.str.indexOf(\"*\") != -1) {\n parser.currentClause.usePipeline = false\n }\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseEditDistance = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n var editDistance = parseInt(lexeme.str, 10)\n\n if (isNaN(editDistance)) {\n var errorMessage = \"edit distance must be numeric\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.editDistance = editDistance\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseBoost = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n var boost = parseInt(lexeme.str, 10)\n\n if (isNaN(boost)) {\n var errorMessage = \"boost must be numeric\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.boost = boost\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\n /**\n * export the module via AMD, CommonJS or as a browser global\n * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js\n */\n ;(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(factory)\n } else if (typeof exports === 'object') {\n /**\n * Node. Does not work with strict CommonJS, but\n * only CommonJS-like enviroments that support module.exports,\n * like Node.\n */\n module.exports = factory()\n } else {\n // Browser globals (root is window)\n root.lunr = factory()\n }\n }(this, function () {\n /**\n * Just return a value to define the module export.\n * This example returns an object, but the module\n * can return a function as the exported value.\n */\n return lunr\n }))\n})();\n"],"names":["global","step2list","step3list","v","C","re_mgr0","re_mgr1","re_meq1","re_s_v","re_1a","re2_1a","re_1b","re2_1b","re_1b_2","re2_1b_2","re3_1b_2","re4_1b_2","re_1c","re_2","re_3","re_4","re2_4","re_5","re_5_1","re3_5","porterStemmer","root","factory","lunr","config","builder","Builder","pipeline","add","trimmer","stopWordFilter","stemmer","searchPipeline","call","build","version","utils","warn","this","message","console","asString","obj","toString","clone","Object","create","keys","i","length","key","val","Array","isArray","slice","TypeError","FieldRef","docRef","fieldName","stringValue","_stringValue","joiner","fromString","s","n","indexOf","fieldRef","prototype","undefined","Set","elements","complete","intersect","other","union","contains","empty","object","a","b","intersection","element","push","concat","idf","posting","documentCount","documentsWithTerm","x","Math","log","abs","Token","str","metadata","update","fn","tokenizer","map","t","toLowerCase","len","tokens","sliceEnd","sliceStart","sliceLength","charAt","match","separator","tokenMetadata","Pipeline","_stack","registeredFunctions","registerFunction","label","warnIfFunctionNotRegistered","load","serialised","forEach","fnName","Error","fns","arguments","after","existingFn","newFn","pos","splice","before","remove","run","stackLength","memo","j","result","k","runString","token","reset","toJSON","Vector","_magnitude","positionForIndex","index","start","end","pivotPoint","floor","pivotIndex","insert","insertIdx","upsert","position","magnitude","sumOfSquares","elementsLength","sqrt","dot","otherVector","dotProduct","aLen","bLen","aVal","bVal","similarity","toArray","output","c","RegExp","w","stem","suffix","firstch","re","re2","re3","re4","substr","toUpperCase","test","replace","fp","exec","generateStopWordFilter","stopWords","words","reduce","stopWord","TokenSet","final","edges","id","_nextId","fromArray","arr","finish","fromClause","clause","fromFuzzyString","term","editDistance","stack","node","editsRemaining","frame","pop","noEditNode","char","insertionNode","substitutionNode","transposeNode","charA","charB","next","prefix","edge","_str","labels","sort","qNode","qEdges","qLen","nEdges","nLen","q","qEdge","nEdge","previousWord","uncheckedNodes","minimizedNodes","word","commonPrefix","minimize","child","nextNode","parent","downTo","childKey","Index","attrs","invertedIndex","fieldVectors","tokenSet","fields","search","queryString","query","QueryParser","parse","Query","matchingFields","queryVectors","termFieldCache","requiredMatches","prohibitedMatches","clauses","terms","clauseMatches","usePipeline","m","termTokenSet","expandedTerms","presence","REQUIRED","field","expandedTerm","termIndex","_index","fieldPosting","matchingDocumentRefs","termField","matchingDocumentsSet","PROHIBITED","boost","l","fieldMatch","matchingDocumentRef","matchingFieldRef","MatchData","allRequiredMatches","allProhibitedMatches","matchingFieldRefs","results","matches","isNegated","docMatch","fieldVector","score","matchData","combine","ref","serializedIndex","serializedVectors","serializedInvertedIndex","tokenSetBuilder","tuple","_ref","_fields","_documents","fieldTermFrequencies","fieldLengths","_b","_k1","metadataWhitelist","attributes","RangeError","number","k1","doc","extractor","fieldTerms","metadataKey","calculateAverageFieldLengths","fieldRefs","numberOfFields","accumulator","documentsWithField","averageFieldLength","createFieldVectors","fieldRefsLength","termIdfCache","fieldLength","termFrequencies","termsLength","fieldBoost","docBoost","scoreWithPrecision","tf","round","createTokenSet","use","args","unshift","apply","clonedMetadata","metadataKeys","otherMatchData","allFields","wildcard","String","NONE","LEADING","TRAILING","OPTIONAL","options","QueryParseError","name","QueryLexer","lexemes","escapeCharPositions","state","lexText","sliceString","subSlices","join","emit","type","escapeCharacter","EOS","width","ignore","backup","acceptDigitRun","charCode","charCodeAt","more","FIELD","TERM","EDIT_DISTANCE","BOOST","PRESENCE","lexField","lexer","lexTerm","lexEditDistance","lexBoost","lexEOS","termSeparator","currentClause","lexemeIdx","parseClause","peekLexeme","consumeLexeme","lexeme","nextClause","completedClause","parser","parsePresence","parseField","parseTerm","errorMessage","nextLexeme","possibleFields","f","parseEditDistance","parseBoost","parseInt","isNaN","define","amd","exports","module"],"mappings":";;;;;CAaC,eAqE4BA,OAw2BvBC,UAwBFC,UAWAC,EACAC,EAQEC,QACAC,QACAC,QACAC,OAEAC,MACAC,OACAC,MACAC,OACAC,QACAC,SACAC,SACAC,SAEAC,MACAC,KAEAC,KAEAC,KACAC,MAEAC,KACAC,OACAC,MAEAC,cAk4EQC,KAAMC,QAp1GhBC,KAAO,SAAUC,YACfC,QAAU,IAAIF,KAAKG,eAEvBD,QAAQE,SAASC,IACfL,KAAKM,QACLN,KAAKO,eACLP,KAAKQ,SAGPN,QAAQO,eAAeJ,IACrBL,KAAKQ,SAGPP,OAAOS,KAAKR,QAASA,SACdA,QAAQS,SAGjBX,KAAKY,QAAU,QAUfZ,KAAKa,MAAQ,GASbb,KAAKa,MAAMC,MAAkB1C,OAQ1B2C,KANM,SAAUC,SACX5C,OAAO6C,SAAWA,QAAQH,MAC5BG,QAAQH,KAAKE,WAiBnBhB,KAAKa,MAAMK,SAAW,SAAUC,YAC1BA,MAAAA,IACK,GAEAA,IAAIC,YAoBfpB,KAAKa,MAAMQ,MAAQ,SAAUF,QACvBA,MAAAA,WACKA,YAGLE,MAAQC,OAAOC,OAAO,MACtBC,KAAOF,OAAOE,KAAKL,KAEdM,EAAI,EAAGA,EAAID,KAAKE,OAAQD,IAAK,KAChCE,IAAMH,KAAKC,GACXG,IAAMT,IAAIQ,QAEVE,MAAMC,QAAQF,KAChBP,MAAMM,KAAOC,IAAIG,gBAIA,iBAARH,KACQ,iBAARA,KACQ,kBAARA,UAKL,IAAII,UAAU,yDAJlBX,MAAMM,KAAOC,YAOVP,OAETrB,KAAKiC,SAAW,SAAUC,OAAQC,UAAWC,kBACtCF,OAASA,YACTC,UAAYA,eACZE,aAAeD,aAGtBpC,KAAKiC,SAASK,OAAS,IAEvBtC,KAAKiC,SAASM,WAAa,SAAUC,OAC/BC,EAAID,EAAEE,QAAQ1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AAKoU,WAAWsB,aACZ1V,KAAKgO,YAAYoJ,gBACrBpX,KAAKoU,WAAWuB,gBACnBgB,OAAOF,aACAzW,KAAKgO,YAAY4I,sBAEpBG,aAAe,2BAA6BC,WAAWnC,KAAO,UAC5D,IAAI7U,KAAKkU,gBAAiB6C,aAAcC,WAAWvP,MAAOuP,WAAWtP,UApB7EiP,OAAOF,eAwBXzW,KAAKgO,YAAYoJ,WAAa,SAAUT,YAClCH,OAASG,OAAOJ,mBAEN1T,MAAV2T,YAIA9G,MAAQ2H,SAASb,OAAOlS,IAAK,OAE7BgT,MAAM5H,OAAQ,KACZqH,aAAe,8BACb,IAAI/W,KAAKkU,gBAAiB6C,aAAcP,OAAO/O,MAAO+O,OAAO9O,KAGrEiP,OAAOR,cAAczG,MAAQA,UAEzBsH,WAAaL,OAAOL,gBAENzT,MAAdmU,kBAKIA,WAAWnC,WACZ7U,KAAKoU,WAAWoB,YACnBmB,OAAOF,aACAzW,KAAKgO,YAAY8I,eACrB9W,KAAKoU,WAAWmB,aACnBoB,OAAOF,aACAzW,KAAKgO,YAAY6I,gBACrB7W,KAAKoU,WAAWqB,qBACZzV,KAAKgO,YAAYmJ,uBACrBnX,KAAKoU,WAAWsB,aACZ1V,KAAKgO,YAAYoJ,gBACrBpX,KAAKoU,WAAWuB,gBACnBgB,OAAOF,aACAzW,KAAKgO,YAAY4I,sBAEpBG,aAAe,2BAA6BC,WAAWnC,KAAO,UAC5D,IAAI7U,KAAKkU,gBAAiB6C,aAAcC,WAAWvP,MAAOuP,WAAWtP,UApB7EiP,OAAOF,eA4BG3W,KAeViB,KAfgBhB,QAeV,kBAMCC,MApBe,mBAAXuX,QAAyBA,OAAOC,IAEzCD,oCAAOxX,SACqB,iBAAZ0X,QAMhBC,OAAOD,QAAU1X,UAGjBD,KAAKE,KAAOD,UAl4GjB"} \ No newline at end of file +{"version":3,"file":"lunr.min.js","sources":["../src/lunr.js"],"sourcesContent":["/**\n * moodle readme\n *\n * Lunrjs can be downloaded from https://github.com/olivernn/lunr.js. To update this library get the lunr.js file\n * from this project and replace the content below with the new content.\n */\n\n/**\n * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9\n * Copyright (C) 2020 Oliver Nightingale\n * @license MIT\n */\n\n;(function(){\n\n/**\n * A convenience function for configuring and constructing\n * a new lunr Index.\n *\n * A lunr.Builder instance is created and the pipeline setup\n * with a trimmer, stop word filter and stemmer.\n *\n * This builder object is yielded to the configuration function\n * that is passed as a parameter, allowing the list of fields\n * and other builder parameters to be customised.\n *\n * All documents _must_ be added within the passed config function.\n *\n * @example\n * var idx = lunr(function () {\n * this.field('title')\n * this.field('body')\n * this.ref('id')\n *\n * documents.forEach(function (doc) {\n * this.add(doc)\n * }, this)\n * })\n *\n * @see {@link lunr.Builder}\n * @see {@link lunr.Pipeline}\n * @see {@link lunr.trimmer}\n * @see {@link lunr.stopWordFilter}\n * @see {@link lunr.stemmer}\n * @namespace {function} lunr\n */\nvar lunr = function (config) {\n var builder = new lunr.Builder\n\n builder.pipeline.add(\n lunr.trimmer,\n lunr.stopWordFilter,\n lunr.stemmer\n )\n\n builder.searchPipeline.add(\n lunr.stemmer\n )\n\n config.call(builder, builder)\n return builder.build()\n}\n\nlunr.version = \"2.3.9\"\n/*!\n * lunr.utils\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A namespace containing utils for the rest of the lunr library\n * @namespace lunr.utils\n */\nlunr.utils = {}\n\n/**\n * Print a warning message to the console.\n *\n * @param {String} message The message to be printed.\n * @memberOf lunr.utils\n * @function\n */\nlunr.utils.warn = (function (global) {\n /* eslint-disable no-console */\n return function (message) {\n if (global.console && console.warn) {\n console.warn(message)\n }\n }\n /* eslint-enable no-console */\n})(this)\n\n/**\n * Convert an object to a string.\n *\n * In the case of `null` and `undefined` the function returns\n * the empty string, in all other cases the result of calling\n * `toString` on the passed object is returned.\n *\n * @param {Any} obj The object to convert to a string.\n * @return {String} string representation of the passed object.\n * @memberOf lunr.utils\n */\nlunr.utils.asString = function (obj) {\n if (obj === void 0 || obj === null) {\n return \"\"\n } else {\n return obj.toString()\n }\n}\n\n/**\n * Clones an object.\n *\n * Will create a copy of an existing object such that any mutations\n * on the copy cannot affect the original.\n *\n * Only shallow objects are supported, passing a nested object to this\n * function will cause a TypeError.\n *\n * Objects with primitives, and arrays of primitives are supported.\n *\n * @param {Object} obj The object to clone.\n * @return {Object} a clone of the passed object.\n * @throws {TypeError} when a nested object is passed.\n * @memberOf Utils\n */\nlunr.utils.clone = function (obj) {\n if (obj === null || obj === undefined) {\n return obj\n }\n\n var clone = Object.create(null),\n keys = Object.keys(obj)\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i],\n val = obj[key]\n\n if (Array.isArray(val)) {\n clone[key] = val.slice()\n continue\n }\n\n if (typeof val === 'string' ||\n typeof val === 'number' ||\n typeof val === 'boolean') {\n clone[key] = val\n continue\n }\n\n throw new TypeError(\"clone is not deep and does not support nested objects\")\n }\n\n return clone\n}\nlunr.FieldRef = function (docRef, fieldName, stringValue) {\n this.docRef = docRef\n this.fieldName = fieldName\n this._stringValue = stringValue\n}\n\nlunr.FieldRef.joiner = \"/\"\n\nlunr.FieldRef.fromString = function (s) {\n var n = s.indexOf(lunr.FieldRef.joiner)\n\n if (n === -1) {\n throw \"malformed field ref string\"\n }\n\n var fieldRef = s.slice(0, n),\n docRef = s.slice(n + 1)\n\n return new lunr.FieldRef (docRef, fieldRef, s)\n}\n\nlunr.FieldRef.prototype.toString = function () {\n if (this._stringValue == undefined) {\n this._stringValue = this.fieldName + lunr.FieldRef.joiner + this.docRef\n }\n\n return this._stringValue\n}\n/*!\n * lunr.Set\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A lunr set.\n *\n * @constructor\n */\nlunr.Set = function (elements) {\n this.elements = Object.create(null)\n\n if (elements) {\n this.length = elements.length\n\n for (var i = 0; i < this.length; i++) {\n this.elements[elements[i]] = true\n }\n } else {\n this.length = 0\n }\n}\n\n/**\n * A complete set that contains all elements.\n *\n * @static\n * @readonly\n * @type {lunr.Set}\n */\nlunr.Set.complete = {\n intersect: function (other) {\n return other\n },\n\n union: function () {\n return this\n },\n\n contains: function () {\n return true\n }\n}\n\n/**\n * An empty set that contains no elements.\n *\n * @static\n * @readonly\n * @type {lunr.Set}\n */\nlunr.Set.empty = {\n intersect: function () {\n return this\n },\n\n union: function (other) {\n return other\n },\n\n contains: function () {\n return false\n }\n}\n\n/**\n * Returns true if this set contains the specified object.\n *\n * @param {object} object - Object whose presence in this set is to be tested.\n * @returns {boolean} - True if this set contains the specified object.\n */\nlunr.Set.prototype.contains = function (object) {\n return !!this.elements[object]\n}\n\n/**\n * Returns a new set containing only the elements that are present in both\n * this set and the specified set.\n *\n * @param {lunr.Set} other - set to intersect with this set.\n * @returns {lunr.Set} a new set that is the intersection of this and the specified set.\n */\n\nlunr.Set.prototype.intersect = function (other) {\n var a, b, elements, intersection = []\n\n if (other === lunr.Set.complete) {\n return this\n }\n\n if (other === lunr.Set.empty) {\n return other\n }\n\n if (this.length < other.length) {\n a = this\n b = other\n } else {\n a = other\n b = this\n }\n\n elements = Object.keys(a.elements)\n\n for (var i = 0; i < elements.length; i++) {\n var element = elements[i]\n if (element in b.elements) {\n intersection.push(element)\n }\n }\n\n return new lunr.Set (intersection)\n}\n\n/**\n * Returns a new set combining the elements of this and the specified set.\n *\n * @param {lunr.Set} other - set to union with this set.\n * @return {lunr.Set} a new set that is the union of this and the specified set.\n */\n\nlunr.Set.prototype.union = function (other) {\n if (other === lunr.Set.complete) {\n return lunr.Set.complete\n }\n\n if (other === lunr.Set.empty) {\n return this\n }\n\n return new lunr.Set(Object.keys(this.elements).concat(Object.keys(other.elements)))\n}\n/**\n * A function to calculate the inverse document frequency for\n * a posting. This is shared between the builder and the index\n *\n * @private\n * @param {object} posting - The posting for a given term\n * @param {number} documentCount - The total number of documents.\n */\nlunr.idf = function (posting, documentCount) {\n var documentsWithTerm = 0\n\n for (var fieldName in posting) {\n if (fieldName == '_index') continue // Ignore the term index, its not a field\n documentsWithTerm += Object.keys(posting[fieldName]).length\n }\n\n var x = (documentCount - documentsWithTerm + 0.5) / (documentsWithTerm + 0.5)\n\n return Math.log(1 + Math.abs(x))\n}\n\n/**\n * A token wraps a string representation of a token\n * as it is passed through the text processing pipeline.\n *\n * @constructor\n * @param {string} [str=''] - The string token being wrapped.\n * @param {object} [metadata={}] - Metadata associated with this token.\n */\nlunr.Token = function (str, metadata) {\n this.str = str || \"\"\n this.metadata = metadata || {}\n}\n\n/**\n * Returns the token string that is being wrapped by this object.\n *\n * @returns {string}\n */\nlunr.Token.prototype.toString = function () {\n return this.str\n}\n\n/**\n * A token update function is used when updating or optionally\n * when cloning a token.\n *\n * @callback lunr.Token~updateFunction\n * @param {string} str - The string representation of the token.\n * @param {Object} metadata - All metadata associated with this token.\n */\n\n/**\n * Applies the given function to the wrapped string token.\n *\n * @example\n * token.update(function (str, metadata) {\n * return str.toUpperCase()\n * })\n *\n * @param {lunr.Token~updateFunction} fn - A function to apply to the token string.\n * @returns {lunr.Token}\n */\nlunr.Token.prototype.update = function (fn) {\n this.str = fn(this.str, this.metadata)\n return this\n}\n\n/**\n * Creates a clone of this token. Optionally a function can be\n * applied to the cloned token.\n *\n * @param {lunr.Token~updateFunction} [fn] - An optional function to apply to the cloned token.\n * @returns {lunr.Token}\n */\nlunr.Token.prototype.clone = function (fn) {\n fn = fn || function (s) { return s }\n return new lunr.Token (fn(this.str, this.metadata), this.metadata)\n}\n/*!\n * lunr.tokenizer\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A function for splitting a string into tokens ready to be inserted into\n * the search index. Uses `lunr.tokenizer.separator` to split strings, change\n * the value of this property to change how strings are split into tokens.\n *\n * This tokenizer will convert its parameter to a string by calling `toString` and\n * then will split this string on the character in `lunr.tokenizer.separator`.\n * Arrays will have their elements converted to strings and wrapped in a lunr.Token.\n *\n * Optional metadata can be passed to the tokenizer, this metadata will be cloned and\n * added as metadata to every token that is created from the object to be tokenized.\n *\n * @static\n * @param {?(string|object|object[])} obj - The object to convert into tokens\n * @param {?object} metadata - Optional metadata to associate with every token\n * @returns {lunr.Token[]}\n * @see {@link lunr.Pipeline}\n */\nlunr.tokenizer = function (obj, metadata) {\n if (obj == null || obj == undefined) {\n return []\n }\n\n if (Array.isArray(obj)) {\n return obj.map(function (t) {\n return new lunr.Token(\n lunr.utils.asString(t).toLowerCase(),\n lunr.utils.clone(metadata)\n )\n })\n }\n\n var str = obj.toString().toLowerCase(),\n len = str.length,\n tokens = []\n\n for (var sliceEnd = 0, sliceStart = 0; sliceEnd <= len; sliceEnd++) {\n var char = str.charAt(sliceEnd),\n sliceLength = sliceEnd - sliceStart\n\n if ((char.match(lunr.tokenizer.separator) || sliceEnd == len)) {\n\n if (sliceLength > 0) {\n var tokenMetadata = lunr.utils.clone(metadata) || {}\n tokenMetadata[\"position\"] = [sliceStart, sliceLength]\n tokenMetadata[\"index\"] = tokens.length\n\n tokens.push(\n new lunr.Token (\n str.slice(sliceStart, sliceEnd),\n tokenMetadata\n )\n )\n }\n\n sliceStart = sliceEnd + 1\n }\n\n }\n\n return tokens\n}\n\n/**\n * The separator used to split a string into tokens. Override this property to change the behaviour of\n * `lunr.tokenizer` behaviour when tokenizing strings. By default this splits on whitespace and hyphens.\n *\n * @static\n * @see lunr.tokenizer\n */\nlunr.tokenizer.separator = /[\\s\\-]+/\n/*!\n * lunr.Pipeline\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.Pipelines maintain an ordered list of functions to be applied to all\n * tokens in documents entering the search index and queries being ran against\n * the index.\n *\n * An instance of lunr.Index created with the lunr shortcut will contain a\n * pipeline with a stop word filter and an English language stemmer. Extra\n * functions can be added before or after either of these functions or these\n * default functions can be removed.\n *\n * When run the pipeline will call each function in turn, passing a token, the\n * index of that token in the original list of all tokens and finally a list of\n * all the original tokens.\n *\n * The output of functions in the pipeline will be passed to the next function\n * in the pipeline. To exclude a token from entering the index the function\n * should return undefined, the rest of the pipeline will not be called with\n * this token.\n *\n * For serialisation of pipelines to work, all functions used in an instance of\n * a pipeline should be registered with lunr.Pipeline. Registered functions can\n * then be loaded. If trying to load a serialised pipeline that uses functions\n * that are not registered an error will be thrown.\n *\n * If not planning on serialising the pipeline then registering pipeline functions\n * is not necessary.\n *\n * @constructor\n */\nlunr.Pipeline = function () {\n this._stack = []\n}\n\nlunr.Pipeline.registeredFunctions = Object.create(null)\n\n/**\n * A pipeline function maps lunr.Token to lunr.Token. A lunr.Token contains the token\n * string as well as all known metadata. A pipeline function can mutate the token string\n * or mutate (or add) metadata for a given token.\n *\n * A pipeline function can indicate that the passed token should be discarded by returning\n * null, undefined or an empty string. This token will not be passed to any downstream pipeline\n * functions and will not be added to the index.\n *\n * Multiple tokens can be returned by returning an array of tokens. Each token will be passed\n * to any downstream pipeline functions and all will returned tokens will be added to the index.\n *\n * Any number of pipeline functions may be chained together using a lunr.Pipeline.\n *\n * @interface lunr.PipelineFunction\n * @param {lunr.Token} token - A token from the document being processed.\n * @param {number} i - The index of this token in the complete list of tokens for this document/field.\n * @param {lunr.Token[]} tokens - All tokens for this document/field.\n * @returns {(?lunr.Token|lunr.Token[])}\n */\n\n/**\n * Register a function with the pipeline.\n *\n * Functions that are used in the pipeline should be registered if the pipeline\n * needs to be serialised, or a serialised pipeline needs to be loaded.\n *\n * Registering a function does not add it to a pipeline, functions must still be\n * added to instances of the pipeline for them to be used when running a pipeline.\n *\n * @param {lunr.PipelineFunction} fn - The function to check for.\n * @param {String} label - The label to register this function with\n */\nlunr.Pipeline.registerFunction = function (fn, label) {\n if (label in this.registeredFunctions) {\n lunr.utils.warn('Overwriting existing registered function: ' + label)\n }\n\n fn.label = label\n lunr.Pipeline.registeredFunctions[fn.label] = fn\n}\n\n/**\n * Warns if the function is not registered as a Pipeline function.\n *\n * @param {lunr.PipelineFunction} fn - The function to check for.\n * @private\n */\nlunr.Pipeline.warnIfFunctionNotRegistered = function (fn) {\n var isRegistered = fn.label && (fn.label in this.registeredFunctions)\n\n if (!isRegistered) {\n lunr.utils.warn('Function is not registered with pipeline. This may cause problems when serialising the index.\\n', fn)\n }\n}\n\n/**\n * Loads a previously serialised pipeline.\n *\n * All functions to be loaded must already be registered with lunr.Pipeline.\n * If any function from the serialised data has not been registered then an\n * error will be thrown.\n *\n * @param {Object} serialised - The serialised pipeline to load.\n * @returns {lunr.Pipeline}\n */\nlunr.Pipeline.load = function (serialised) {\n var pipeline = new lunr.Pipeline\n\n serialised.forEach(function (fnName) {\n var fn = lunr.Pipeline.registeredFunctions[fnName]\n\n if (fn) {\n pipeline.add(fn)\n } else {\n throw new Error('Cannot load unregistered function: ' + fnName)\n }\n })\n\n return pipeline\n}\n\n/**\n * Adds new functions to the end of the pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction[]} functions - Any number of functions to add to the pipeline.\n */\nlunr.Pipeline.prototype.add = function () {\n var fns = Array.prototype.slice.call(arguments)\n\n fns.forEach(function (fn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(fn)\n this._stack.push(fn)\n }, this)\n}\n\n/**\n * Adds a single function after a function that already exists in the\n * pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.\n * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.\n */\nlunr.Pipeline.prototype.after = function (existingFn, newFn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(newFn)\n\n var pos = this._stack.indexOf(existingFn)\n if (pos == -1) {\n throw new Error('Cannot find existingFn')\n }\n\n pos = pos + 1\n this._stack.splice(pos, 0, newFn)\n}\n\n/**\n * Adds a single function before a function that already exists in the\n * pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.\n * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.\n */\nlunr.Pipeline.prototype.before = function (existingFn, newFn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(newFn)\n\n var pos = this._stack.indexOf(existingFn)\n if (pos == -1) {\n throw new Error('Cannot find existingFn')\n }\n\n this._stack.splice(pos, 0, newFn)\n}\n\n/**\n * Removes a function from the pipeline.\n *\n * @param {lunr.PipelineFunction} fn The function to remove from the pipeline.\n */\nlunr.Pipeline.prototype.remove = function (fn) {\n var pos = this._stack.indexOf(fn)\n if (pos == -1) {\n return\n }\n\n this._stack.splice(pos, 1)\n}\n\n/**\n * Runs the current list of functions that make up the pipeline against the\n * passed tokens.\n *\n * @param {Array} tokens The tokens to run through the pipeline.\n * @returns {Array}\n */\nlunr.Pipeline.prototype.run = function (tokens) {\n var stackLength = this._stack.length\n\n for (var i = 0; i < stackLength; i++) {\n var fn = this._stack[i]\n var memo = []\n\n for (var j = 0; j < tokens.length; j++) {\n var result = fn(tokens[j], j, tokens)\n\n if (result === null || result === void 0 || result === '') continue\n\n if (Array.isArray(result)) {\n for (var k = 0; k < result.length; k++) {\n memo.push(result[k])\n }\n } else {\n memo.push(result)\n }\n }\n\n tokens = memo\n }\n\n return tokens\n}\n\n/**\n * Convenience method for passing a string through a pipeline and getting\n * strings out. This method takes care of wrapping the passed string in a\n * token and mapping the resulting tokens back to strings.\n *\n * @param {string} str - The string to pass through the pipeline.\n * @param {?object} metadata - Optional metadata to associate with the token\n * passed to the pipeline.\n * @returns {string[]}\n */\nlunr.Pipeline.prototype.runString = function (str, metadata) {\n var token = new lunr.Token (str, metadata)\n\n return this.run([token]).map(function (t) {\n return t.toString()\n })\n}\n\n/**\n * Resets the pipeline by removing any existing processors.\n *\n */\nlunr.Pipeline.prototype.reset = function () {\n this._stack = []\n}\n\n/**\n * Returns a representation of the pipeline ready for serialisation.\n *\n * Logs a warning if the function has not been registered.\n *\n * @returns {Array}\n */\nlunr.Pipeline.prototype.toJSON = function () {\n return this._stack.map(function (fn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(fn)\n\n return fn.label\n })\n}\n/*!\n * lunr.Vector\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A vector is used to construct the vector space of documents and queries. These\n * vectors support operations to determine the similarity between two documents or\n * a document and a query.\n *\n * Normally no parameters are required for initializing a vector, but in the case of\n * loading a previously dumped vector the raw elements can be provided to the constructor.\n *\n * For performance reasons vectors are implemented with a flat array, where an elements\n * index is immediately followed by its value. E.g. [index, value, index, value]. This\n * allows the underlying array to be as sparse as possible and still offer decent\n * performance when being used for vector calculations.\n *\n * @constructor\n * @param {Number[]} [elements] - The flat list of element index and element value pairs.\n */\nlunr.Vector = function (elements) {\n this._magnitude = 0\n this.elements = elements || []\n}\n\n\n/**\n * Calculates the position within the vector to insert a given index.\n *\n * This is used internally by insert and upsert. If there are duplicate indexes then\n * the position is returned as if the value for that index were to be updated, but it\n * is the callers responsibility to check whether there is a duplicate at that index\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @returns {Number}\n */\nlunr.Vector.prototype.positionForIndex = function (index) {\n // For an empty vector the tuple can be inserted at the beginning\n if (this.elements.length == 0) {\n return 0\n }\n\n var start = 0,\n end = this.elements.length / 2,\n sliceLength = end - start,\n pivotPoint = Math.floor(sliceLength / 2),\n pivotIndex = this.elements[pivotPoint * 2]\n\n while (sliceLength > 1) {\n if (pivotIndex < index) {\n start = pivotPoint\n }\n\n if (pivotIndex > index) {\n end = pivotPoint\n }\n\n if (pivotIndex == index) {\n break\n }\n\n sliceLength = end - start\n pivotPoint = start + Math.floor(sliceLength / 2)\n pivotIndex = this.elements[pivotPoint * 2]\n }\n\n if (pivotIndex == index) {\n return pivotPoint * 2\n }\n\n if (pivotIndex > index) {\n return pivotPoint * 2\n }\n\n if (pivotIndex < index) {\n return (pivotPoint + 1) * 2\n }\n}\n\n/**\n * Inserts an element at an index within the vector.\n *\n * Does not allow duplicates, will throw an error if there is already an entry\n * for this index.\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @param {Number} val - The value to be inserted into the vector.\n */\nlunr.Vector.prototype.insert = function (insertIdx, val) {\n this.upsert(insertIdx, val, function () {\n throw \"duplicate index\"\n })\n}\n\n/**\n * Inserts or updates an existing index within the vector.\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @param {Number} val - The value to be inserted into the vector.\n * @param {function} fn - A function that is called for updates, the existing value and the\n * requested value are passed as arguments\n */\nlunr.Vector.prototype.upsert = function (insertIdx, val, fn) {\n this._magnitude = 0\n var position = this.positionForIndex(insertIdx)\n\n if (this.elements[position] == insertIdx) {\n this.elements[position + 1] = fn(this.elements[position + 1], val)\n } else {\n this.elements.splice(position, 0, insertIdx, val)\n }\n}\n\n/**\n * Calculates the magnitude of this vector.\n *\n * @returns {Number}\n */\nlunr.Vector.prototype.magnitude = function () {\n if (this._magnitude) return this._magnitude\n\n var sumOfSquares = 0,\n elementsLength = this.elements.length\n\n for (var i = 1; i < elementsLength; i += 2) {\n var val = this.elements[i]\n sumOfSquares += val * val\n }\n\n return this._magnitude = Math.sqrt(sumOfSquares)\n}\n\n/**\n * Calculates the dot product of this vector and another vector.\n *\n * @param {lunr.Vector} otherVector - The vector to compute the dot product with.\n * @returns {Number}\n */\nlunr.Vector.prototype.dot = function (otherVector) {\n var dotProduct = 0,\n a = this.elements, b = otherVector.elements,\n aLen = a.length, bLen = b.length,\n aVal = 0, bVal = 0,\n i = 0, j = 0\n\n while (i < aLen && j < bLen) {\n aVal = a[i], bVal = b[j]\n if (aVal < bVal) {\n i += 2\n } else if (aVal > bVal) {\n j += 2\n } else if (aVal == bVal) {\n dotProduct += a[i + 1] * b[j + 1]\n i += 2\n j += 2\n }\n }\n\n return dotProduct\n}\n\n/**\n * Calculates the similarity between this vector and another vector.\n *\n * @param {lunr.Vector} otherVector - The other vector to calculate the\n * similarity with.\n * @returns {Number}\n */\nlunr.Vector.prototype.similarity = function (otherVector) {\n return this.dot(otherVector) / this.magnitude() || 0\n}\n\n/**\n * Converts the vector to an array of the elements within the vector.\n *\n * @returns {Number[]}\n */\nlunr.Vector.prototype.toArray = function () {\n var output = new Array (this.elements.length / 2)\n\n for (var i = 1, j = 0; i < this.elements.length; i += 2, j++) {\n output[j] = this.elements[i]\n }\n\n return output\n}\n\n/**\n * A JSON serializable representation of the vector.\n *\n * @returns {Number[]}\n */\nlunr.Vector.prototype.toJSON = function () {\n return this.elements\n}\n/* eslint-disable */\n/*!\n * lunr.stemmer\n * Copyright (C) 2020 Oliver Nightingale\n * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt\n */\n\n/**\n * lunr.stemmer is an english language stemmer, this is a JavaScript\n * implementation of the PorterStemmer taken from http://tartarus.org/~martin\n *\n * @static\n * @implements {lunr.PipelineFunction}\n * @param {lunr.Token} token - The string to stem\n * @returns {lunr.Token}\n * @see {@link lunr.Pipeline}\n * @function\n */\nlunr.stemmer = (function(){\n var step2list = {\n \"ational\" : \"ate\",\n \"tional\" : \"tion\",\n \"enci\" : \"ence\",\n \"anci\" : \"ance\",\n \"izer\" : \"ize\",\n \"bli\" : \"ble\",\n \"alli\" : \"al\",\n \"entli\" : \"ent\",\n \"eli\" : \"e\",\n \"ousli\" : \"ous\",\n \"ization\" : \"ize\",\n \"ation\" : \"ate\",\n \"ator\" : \"ate\",\n \"alism\" : \"al\",\n \"iveness\" : \"ive\",\n \"fulness\" : \"ful\",\n \"ousness\" : \"ous\",\n \"aliti\" : \"al\",\n \"iviti\" : \"ive\",\n \"biliti\" : \"ble\",\n \"logi\" : \"log\"\n },\n\n step3list = {\n \"icate\" : \"ic\",\n \"ative\" : \"\",\n \"alize\" : \"al\",\n \"iciti\" : \"ic\",\n \"ical\" : \"ic\",\n \"ful\" : \"\",\n \"ness\" : \"\"\n },\n\n c = \"[^aeiou]\", // consonant\n v = \"[aeiouy]\", // vowel\n C = c + \"[^aeiouy]*\", // consonant sequence\n V = v + \"[aeiou]*\", // vowel sequence\n\n mgr0 = \"^(\" + C + \")?\" + V + C, // [C]VC... is m>0\n meq1 = \"^(\" + C + \")?\" + V + C + \"(\" + V + \")?$\", // [C]VC[V] is m=1\n mgr1 = \"^(\" + C + \")?\" + V + C + V + C, // [C]VCVC... is m>1\n s_v = \"^(\" + C + \")?\" + v; // vowel in stem\n\n var re_mgr0 = new RegExp(mgr0);\n var re_mgr1 = new RegExp(mgr1);\n var re_meq1 = new RegExp(meq1);\n var re_s_v = new RegExp(s_v);\n\n var re_1a = /^(.+?)(ss|i)es$/;\n var re2_1a = /^(.+?)([^s])s$/;\n var re_1b = /^(.+?)eed$/;\n var re2_1b = /^(.+?)(ed|ing)$/;\n var re_1b_2 = /.$/;\n var re2_1b_2 = /(at|bl|iz)$/;\n var re3_1b_2 = new RegExp(\"([^aeiouylsz])\\\\1$\");\n var re4_1b_2 = new RegExp(\"^\" + C + v + \"[^aeiouwxy]$\");\n\n var re_1c = /^(.+?[^aeiou])y$/;\n var re_2 = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;\n\n var re_3 = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;\n\n var re_4 = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;\n var re2_4 = /^(.+?)(s|t)(ion)$/;\n\n var re_5 = /^(.+?)e$/;\n var re_5_1 = /ll$/;\n var re3_5 = new RegExp(\"^\" + C + v + \"[^aeiouwxy]$\");\n\n var porterStemmer = function porterStemmer(w) {\n var stem,\n suffix,\n firstch,\n re,\n re2,\n re3,\n re4;\n\n if (w.length < 3) { return w; }\n\n firstch = w.substr(0,1);\n if (firstch == \"y\") {\n w = firstch.toUpperCase() + w.substr(1);\n }\n\n // Step 1a\n re = re_1a\n re2 = re2_1a;\n\n if (re.test(w)) { w = w.replace(re,\"$1$2\"); }\n else if (re2.test(w)) { w = w.replace(re2,\"$1$2\"); }\n\n // Step 1b\n re = re_1b;\n re2 = re2_1b;\n if (re.test(w)) {\n var fp = re.exec(w);\n re = re_mgr0;\n if (re.test(fp[1])) {\n re = re_1b_2;\n w = w.replace(re,\"\");\n }\n } else if (re2.test(w)) {\n var fp = re2.exec(w);\n stem = fp[1];\n re2 = re_s_v;\n if (re2.test(stem)) {\n w = stem;\n re2 = re2_1b_2;\n re3 = re3_1b_2;\n re4 = re4_1b_2;\n if (re2.test(w)) { w = w + \"e\"; }\n else if (re3.test(w)) { re = re_1b_2; w = w.replace(re,\"\"); }\n else if (re4.test(w)) { w = w + \"e\"; }\n }\n }\n\n // Step 1c - replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say)\n re = re_1c;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n w = stem + \"i\";\n }\n\n // Step 2\n re = re_2;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n suffix = fp[2];\n re = re_mgr0;\n if (re.test(stem)) {\n w = stem + step2list[suffix];\n }\n }\n\n // Step 3\n re = re_3;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n suffix = fp[2];\n re = re_mgr0;\n if (re.test(stem)) {\n w = stem + step3list[suffix];\n }\n }\n\n // Step 4\n re = re_4;\n re2 = re2_4;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n re = re_mgr1;\n if (re.test(stem)) {\n w = stem;\n }\n } else if (re2.test(w)) {\n var fp = re2.exec(w);\n stem = fp[1] + fp[2];\n re2 = re_mgr1;\n if (re2.test(stem)) {\n w = stem;\n }\n }\n\n // Step 5\n re = re_5;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n re = re_mgr1;\n re2 = re_meq1;\n re3 = re3_5;\n if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) {\n w = stem;\n }\n }\n\n re = re_5_1;\n re2 = re_mgr1;\n if (re.test(w) && re2.test(w)) {\n re = re_1b_2;\n w = w.replace(re,\"\");\n }\n\n // and turn initial Y back to y\n\n if (firstch == \"y\") {\n w = firstch.toLowerCase() + w.substr(1);\n }\n\n return w;\n };\n\n return function (token) {\n return token.update(porterStemmer);\n }\n})();\n\nlunr.Pipeline.registerFunction(lunr.stemmer, 'stemmer')\n/*!\n * lunr.stopWordFilter\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.generateStopWordFilter builds a stopWordFilter function from the provided\n * list of stop words.\n *\n * The built in lunr.stopWordFilter is built using this generator and can be used\n * to generate custom stopWordFilters for applications or non English languages.\n *\n * @function\n * @param {Array} token The token to pass through the filter\n * @returns {lunr.PipelineFunction}\n * @see lunr.Pipeline\n * @see lunr.stopWordFilter\n */\nlunr.generateStopWordFilter = function (stopWords) {\n var words = stopWords.reduce(function (memo, stopWord) {\n memo[stopWord] = stopWord\n return memo\n }, {})\n\n return function (token) {\n if (token && words[token.toString()] !== token.toString()) return token\n }\n}\n\n/**\n * lunr.stopWordFilter is an English language stop word list filter, any words\n * contained in the list will not be passed through the filter.\n *\n * This is intended to be used in the Pipeline. If the token does not pass the\n * filter then undefined will be returned.\n *\n * @function\n * @implements {lunr.PipelineFunction}\n * @params {lunr.Token} token - A token to check for being a stop word.\n * @returns {lunr.Token}\n * @see {@link lunr.Pipeline}\n */\nlunr.stopWordFilter = lunr.generateStopWordFilter([\n 'a',\n 'able',\n 'about',\n 'across',\n 'after',\n 'all',\n 'almost',\n 'also',\n 'am',\n 'among',\n 'an',\n 'and',\n 'any',\n 'are',\n 'as',\n 'at',\n 'be',\n 'because',\n 'been',\n 'but',\n 'by',\n 'can',\n 'cannot',\n 'could',\n 'dear',\n 'did',\n 'do',\n 'does',\n 'either',\n 'else',\n 'ever',\n 'every',\n 'for',\n 'from',\n 'get',\n 'got',\n 'had',\n 'has',\n 'have',\n 'he',\n 'her',\n 'hers',\n 'him',\n 'his',\n 'how',\n 'however',\n 'i',\n 'if',\n 'in',\n 'into',\n 'is',\n 'it',\n 'its',\n 'just',\n 'least',\n 'let',\n 'like',\n 'likely',\n 'may',\n 'me',\n 'might',\n 'most',\n 'must',\n 'my',\n 'neither',\n 'no',\n 'nor',\n 'not',\n 'of',\n 'off',\n 'often',\n 'on',\n 'only',\n 'or',\n 'other',\n 'our',\n 'own',\n 'rather',\n 'said',\n 'say',\n 'says',\n 'she',\n 'should',\n 'since',\n 'so',\n 'some',\n 'than',\n 'that',\n 'the',\n 'their',\n 'them',\n 'then',\n 'there',\n 'these',\n 'they',\n 'this',\n 'tis',\n 'to',\n 'too',\n 'twas',\n 'us',\n 'wants',\n 'was',\n 'we',\n 'were',\n 'what',\n 'when',\n 'where',\n 'which',\n 'while',\n 'who',\n 'whom',\n 'why',\n 'will',\n 'with',\n 'would',\n 'yet',\n 'you',\n 'your'\n])\n\nlunr.Pipeline.registerFunction(lunr.stopWordFilter, 'stopWordFilter')\n/*!\n * lunr.trimmer\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.trimmer is a pipeline function for trimming non word\n * characters from the beginning and end of tokens before they\n * enter the index.\n *\n * This implementation may not work correctly for non latin\n * characters and should either be removed or adapted for use\n * with languages with non-latin characters.\n *\n * @static\n * @implements {lunr.PipelineFunction}\n * @param {lunr.Token} token The token to pass through the filter\n * @returns {lunr.Token}\n * @see lunr.Pipeline\n */\nlunr.trimmer = function (token) {\n return token.update(function (s) {\n return s.replace(/^\\W+/, '').replace(/\\W+$/, '')\n })\n}\n\nlunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer')\n/*!\n * lunr.TokenSet\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * A token set is used to store the unique list of all tokens\n * within an index. Token sets are also used to represent an\n * incoming query to the index, this query token set and index\n * token set are then intersected to find which tokens to look\n * up in the inverted index.\n *\n * A token set can hold multiple tokens, as in the case of the\n * index token set, or it can hold a single token as in the\n * case of a simple query token set.\n *\n * Additionally token sets are used to perform wildcard matching.\n * Leading, contained and trailing wildcards are supported, and\n * from this edit distance matching can also be provided.\n *\n * Token sets are implemented as a minimal finite state automata,\n * where both common prefixes and suffixes are shared between tokens.\n * This helps to reduce the space used for storing the token set.\n *\n * @constructor\n */\nlunr.TokenSet = function () {\n this.final = false\n this.edges = {}\n this.id = lunr.TokenSet._nextId\n lunr.TokenSet._nextId += 1\n}\n\n/**\n * Keeps track of the next, auto increment, identifier to assign\n * to a new tokenSet.\n *\n * TokenSets require a unique identifier to be correctly minimised.\n *\n * @private\n */\nlunr.TokenSet._nextId = 1\n\n/**\n * Creates a TokenSet instance from the given sorted array of words.\n *\n * @param {String[]} arr - A sorted array of strings to create the set from.\n * @returns {lunr.TokenSet}\n * @throws Will throw an error if the input array is not sorted.\n */\nlunr.TokenSet.fromArray = function (arr) {\n var builder = new lunr.TokenSet.Builder\n\n for (var i = 0, len = arr.length; i < len; i++) {\n builder.insert(arr[i])\n }\n\n builder.finish()\n return builder.root\n}\n\n/**\n * Creates a token set from a query clause.\n *\n * @private\n * @param {Object} clause - A single clause from lunr.Query.\n * @param {string} clause.term - The query clause term.\n * @param {number} [clause.editDistance] - The optional edit distance for the term.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.fromClause = function (clause) {\n if ('editDistance' in clause) {\n return lunr.TokenSet.fromFuzzyString(clause.term, clause.editDistance)\n } else {\n return lunr.TokenSet.fromString(clause.term)\n }\n}\n\n/**\n * Creates a token set representing a single string with a specified\n * edit distance.\n *\n * Insertions, deletions, substitutions and transpositions are each\n * treated as an edit distance of 1.\n *\n * Increasing the allowed edit distance will have a dramatic impact\n * on the performance of both creating and intersecting these TokenSets.\n * It is advised to keep the edit distance less than 3.\n *\n * @param {string} str - The string to create the token set from.\n * @param {number} editDistance - The allowed edit distance to match.\n * @returns {lunr.Vector}\n */\nlunr.TokenSet.fromFuzzyString = function (str, editDistance) {\n var root = new lunr.TokenSet\n\n var stack = [{\n node: root,\n editsRemaining: editDistance,\n str: str\n }]\n\n while (stack.length) {\n var frame = stack.pop()\n\n // no edit\n if (frame.str.length > 0) {\n var char = frame.str.charAt(0),\n noEditNode\n\n if (char in frame.node.edges) {\n noEditNode = frame.node.edges[char]\n } else {\n noEditNode = new lunr.TokenSet\n frame.node.edges[char] = noEditNode\n }\n\n if (frame.str.length == 1) {\n noEditNode.final = true\n }\n\n stack.push({\n node: noEditNode,\n editsRemaining: frame.editsRemaining,\n str: frame.str.slice(1)\n })\n }\n\n if (frame.editsRemaining == 0) {\n continue\n }\n\n // insertion\n if (\"*\" in frame.node.edges) {\n var insertionNode = frame.node.edges[\"*\"]\n } else {\n var insertionNode = new lunr.TokenSet\n frame.node.edges[\"*\"] = insertionNode\n }\n\n if (frame.str.length == 0) {\n insertionNode.final = true\n }\n\n stack.push({\n node: insertionNode,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str\n })\n\n // deletion\n // can only do a deletion if we have enough edits remaining\n // and if there are characters left to delete in the string\n if (frame.str.length > 1) {\n stack.push({\n node: frame.node,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str.slice(1)\n })\n }\n\n // deletion\n // just removing the last character from the str\n if (frame.str.length == 1) {\n frame.node.final = true\n }\n\n // substitution\n // can only do a substitution if we have enough edits remaining\n // and if there are characters left to substitute\n if (frame.str.length >= 1) {\n if (\"*\" in frame.node.edges) {\n var substitutionNode = frame.node.edges[\"*\"]\n } else {\n var substitutionNode = new lunr.TokenSet\n frame.node.edges[\"*\"] = substitutionNode\n }\n\n if (frame.str.length == 1) {\n substitutionNode.final = true\n }\n\n stack.push({\n node: substitutionNode,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str.slice(1)\n })\n }\n\n // transposition\n // can only do a transposition if there are edits remaining\n // and there are enough characters to transpose\n if (frame.str.length > 1) {\n var charA = frame.str.charAt(0),\n charB = frame.str.charAt(1),\n transposeNode\n\n if (charB in frame.node.edges) {\n transposeNode = frame.node.edges[charB]\n } else {\n transposeNode = new lunr.TokenSet\n frame.node.edges[charB] = transposeNode\n }\n\n if (frame.str.length == 1) {\n transposeNode.final = true\n }\n\n stack.push({\n node: transposeNode,\n editsRemaining: frame.editsRemaining - 1,\n str: charA + frame.str.slice(2)\n })\n }\n }\n\n return root\n}\n\n/**\n * Creates a TokenSet from a string.\n *\n * The string may contain one or more wildcard characters (*)\n * that will allow wildcard matching when intersecting with\n * another TokenSet.\n *\n * @param {string} str - The string to create a TokenSet from.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.fromString = function (str) {\n var node = new lunr.TokenSet,\n root = node\n\n /*\n * Iterates through all characters within the passed string\n * appending a node for each character.\n *\n * When a wildcard character is found then a self\n * referencing edge is introduced to continually match\n * any number of any characters.\n */\n for (var i = 0, len = str.length; i < len; i++) {\n var char = str[i],\n final = (i == len - 1)\n\n if (char == \"*\") {\n node.edges[char] = node\n node.final = final\n\n } else {\n var next = new lunr.TokenSet\n next.final = final\n\n node.edges[char] = next\n node = next\n }\n }\n\n return root\n}\n\n/**\n * Converts this TokenSet into an array of strings\n * contained within the TokenSet.\n *\n * This is not intended to be used on a TokenSet that\n * contains wildcards, in these cases the results are\n * undefined and are likely to cause an infinite loop.\n *\n * @returns {string[]}\n */\nlunr.TokenSet.prototype.toArray = function () {\n var words = []\n\n var stack = [{\n prefix: \"\",\n node: this\n }]\n\n while (stack.length) {\n var frame = stack.pop(),\n edges = Object.keys(frame.node.edges),\n len = edges.length\n\n if (frame.node.final) {\n /* In Safari, at this point the prefix is sometimes corrupted, see:\n * https://github.com/olivernn/lunr.js/issues/279 Calling any\n * String.prototype method forces Safari to \"cast\" this string to what\n * it's supposed to be, fixing the bug. */\n frame.prefix.charAt(0)\n words.push(frame.prefix)\n }\n\n for (var i = 0; i < len; i++) {\n var edge = edges[i]\n\n stack.push({\n prefix: frame.prefix.concat(edge),\n node: frame.node.edges[edge]\n })\n }\n }\n\n return words\n}\n\n/**\n * Generates a string representation of a TokenSet.\n *\n * This is intended to allow TokenSets to be used as keys\n * in objects, largely to aid the construction and minimisation\n * of a TokenSet. As such it is not designed to be a human\n * friendly representation of the TokenSet.\n *\n * @returns {string}\n */\nlunr.TokenSet.prototype.toString = function () {\n // NOTE: Using Object.keys here as this.edges is very likely\n // to enter 'hash-mode' with many keys being added\n //\n // avoiding a for-in loop here as it leads to the function\n // being de-optimised (at least in V8). From some simple\n // benchmarks the performance is comparable, but allowing\n // V8 to optimize may mean easy performance wins in the future.\n\n if (this._str) {\n return this._str\n }\n\n var str = this.final ? '1' : '0',\n labels = Object.keys(this.edges).sort(),\n len = labels.length\n\n for (var i = 0; i < len; i++) {\n var label = labels[i],\n node = this.edges[label]\n\n str = str + label + node.id\n }\n\n return str\n}\n\n/**\n * Returns a new TokenSet that is the intersection of\n * this TokenSet and the passed TokenSet.\n *\n * This intersection will take into account any wildcards\n * contained within the TokenSet.\n *\n * @param {lunr.TokenSet} b - An other TokenSet to intersect with.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.prototype.intersect = function (b) {\n var output = new lunr.TokenSet,\n frame = undefined\n\n var stack = [{\n qNode: b,\n output: output,\n node: this\n }]\n\n while (stack.length) {\n frame = stack.pop()\n\n // NOTE: As with the #toString method, we are using\n // Object.keys and a for loop instead of a for-in loop\n // as both of these objects enter 'hash' mode, causing\n // the function to be de-optimised in V8\n var qEdges = Object.keys(frame.qNode.edges),\n qLen = qEdges.length,\n nEdges = Object.keys(frame.node.edges),\n nLen = nEdges.length\n\n for (var q = 0; q < qLen; q++) {\n var qEdge = qEdges[q]\n\n for (var n = 0; n < nLen; n++) {\n var nEdge = nEdges[n]\n\n if (nEdge == qEdge || qEdge == '*') {\n var node = frame.node.edges[nEdge],\n qNode = frame.qNode.edges[qEdge],\n final = node.final && qNode.final,\n next = undefined\n\n if (nEdge in frame.output.edges) {\n // an edge already exists for this character\n // no need to create a new node, just set the finality\n // bit unless this node is already final\n next = frame.output.edges[nEdge]\n next.final = next.final || final\n\n } else {\n // no edge exists yet, must create one\n // set the finality bit and insert it\n // into the output\n next = new lunr.TokenSet\n next.final = final\n frame.output.edges[nEdge] = next\n }\n\n stack.push({\n qNode: qNode,\n output: next,\n node: node\n })\n }\n }\n }\n }\n\n return output\n}\nlunr.TokenSet.Builder = function () {\n this.previousWord = \"\"\n this.root = new lunr.TokenSet\n this.uncheckedNodes = []\n this.minimizedNodes = {}\n}\n\nlunr.TokenSet.Builder.prototype.insert = function (word) {\n var node,\n commonPrefix = 0\n\n if (word < this.previousWord) {\n throw new Error (\"Out of order word insertion\")\n }\n\n for (var i = 0; i < word.length && i < this.previousWord.length; i++) {\n if (word[i] != this.previousWord[i]) break\n commonPrefix++\n }\n\n this.minimize(commonPrefix)\n\n if (this.uncheckedNodes.length == 0) {\n node = this.root\n } else {\n node = this.uncheckedNodes[this.uncheckedNodes.length - 1].child\n }\n\n for (var i = commonPrefix; i < word.length; i++) {\n var nextNode = new lunr.TokenSet,\n char = word[i]\n\n node.edges[char] = nextNode\n\n this.uncheckedNodes.push({\n parent: node,\n char: char,\n child: nextNode\n })\n\n node = nextNode\n }\n\n node.final = true\n this.previousWord = word\n}\n\nlunr.TokenSet.Builder.prototype.finish = function () {\n this.minimize(0)\n}\n\nlunr.TokenSet.Builder.prototype.minimize = function (downTo) {\n for (var i = this.uncheckedNodes.length - 1; i >= downTo; i--) {\n var node = this.uncheckedNodes[i],\n childKey = node.child.toString()\n\n if (childKey in this.minimizedNodes) {\n node.parent.edges[node.char] = this.minimizedNodes[childKey]\n } else {\n // Cache the key for this node since\n // we know it can't change anymore\n node.child._str = childKey\n\n this.minimizedNodes[childKey] = node.child\n }\n\n this.uncheckedNodes.pop()\n }\n}\n/*!\n * lunr.Index\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * An index contains the built index of all documents and provides a query interface\n * to the index.\n *\n * Usually instances of lunr.Index will not be created using this constructor, instead\n * lunr.Builder should be used to construct new indexes, or lunr.Index.load should be\n * used to load previously built and serialized indexes.\n *\n * @constructor\n * @param {Object} attrs - The attributes of the built search index.\n * @param {Object} attrs.invertedIndex - An index of term/field to document reference.\n * @param {Object} attrs.fieldVectors - Field vectors\n * @param {lunr.TokenSet} attrs.tokenSet - An set of all corpus tokens.\n * @param {string[]} attrs.fields - The names of indexed document fields.\n * @param {lunr.Pipeline} attrs.pipeline - The pipeline to use for search terms.\n */\nlunr.Index = function (attrs) {\n this.invertedIndex = attrs.invertedIndex\n this.fieldVectors = attrs.fieldVectors\n this.tokenSet = attrs.tokenSet\n this.fields = attrs.fields\n this.pipeline = attrs.pipeline\n}\n\n/**\n * A result contains details of a document matching a search query.\n * @typedef {Object} lunr.Index~Result\n * @property {string} ref - The reference of the document this result represents.\n * @property {number} score - A number between 0 and 1 representing how similar this document is to the query.\n * @property {lunr.MatchData} matchData - Contains metadata about this match including which term(s) caused the match.\n */\n\n/**\n * Although lunr provides the ability to create queries using lunr.Query, it also provides a simple\n * query language which itself is parsed into an instance of lunr.Query.\n *\n * For programmatically building queries it is advised to directly use lunr.Query, the query language\n * is best used for human entered text rather than program generated text.\n *\n * At its simplest queries can just be a single term, e.g. `hello`, multiple terms are also supported\n * and will be combined with OR, e.g `hello world` will match documents that contain either 'hello'\n * or 'world', though those that contain both will rank higher in the results.\n *\n * Wildcards can be included in terms to match one or more unspecified characters, these wildcards can\n * be inserted anywhere within the term, and more than one wildcard can exist in a single term. Adding\n * wildcards will increase the number of documents that will be found but can also have a negative\n * impact on query performance, especially with wildcards at the beginning of a term.\n *\n * Terms can be restricted to specific fields, e.g. `title:hello`, only documents with the term\n * hello in the title field will match this query. Using a field not present in the index will lead\n * to an error being thrown.\n *\n * Modifiers can also be added to terms, lunr supports edit distance and boost modifiers on terms. A term\n * boost will make documents matching that term score higher, e.g. `foo^5`. Edit distance is also supported\n * to provide fuzzy matching, e.g. 'hello~2' will match documents with hello with an edit distance of 2.\n * Avoid large values for edit distance to improve query performance.\n *\n * Each term also supports a presence modifier. By default a term's presence in document is optional, however\n * this can be changed to either required or prohibited. For a term's presence to be required in a document the\n * term should be prefixed with a '+', e.g. `+foo bar` is a search for documents that must contain 'foo' and\n * optionally contain 'bar'. Conversely a leading '-' sets the terms presence to prohibited, i.e. it must not\n * appear in a document, e.g. `-foo bar` is a search for documents that do not contain 'foo' but may contain 'bar'.\n *\n * To escape special characters the backslash character '\\' can be used, this allows searches to include\n * characters that would normally be considered modifiers, e.g. `foo\\~2` will search for a term \"foo~2\" instead\n * of attempting to apply a boost of 2 to the search term \"foo\".\n *\n * @typedef {string} lunr.Index~QueryString\n * @example Simple single term query\n * hello\n * @example Multiple term query\n * hello world\n * @example term scoped to a field\n * title:hello\n * @example term with a boost of 10\n * hello^10\n * @example term with an edit distance of 2\n * hello~2\n * @example terms with presence modifiers\n * -foo +bar baz\n */\n\n/**\n * Performs a search against the index using lunr query syntax.\n *\n * Results will be returned sorted by their score, the most relevant results\n * will be returned first. For details on how the score is calculated, please see\n * the {@link https://lunrjs.com/guides/searching.html#scoring|guide}.\n *\n * For more programmatic querying use lunr.Index#query.\n *\n * @param {lunr.Index~QueryString} queryString - A string containing a lunr query.\n * @throws {lunr.QueryParseError} If the passed query string cannot be parsed.\n * @returns {lunr.Index~Result[]}\n */\nlunr.Index.prototype.search = function (queryString) {\n return this.query(function (query) {\n var parser = new lunr.QueryParser(queryString, query)\n parser.parse()\n })\n}\n\n/**\n * A query builder callback provides a query object to be used to express\n * the query to perform on the index.\n *\n * @callback lunr.Index~queryBuilder\n * @param {lunr.Query} query - The query object to build up.\n * @this lunr.Query\n */\n\n/**\n * Performs a query against the index using the yielded lunr.Query object.\n *\n * If performing programmatic queries against the index, this method is preferred\n * over lunr.Index#search so as to avoid the additional query parsing overhead.\n *\n * A query object is yielded to the supplied function which should be used to\n * express the query to be run against the index.\n *\n * Note that although this function takes a callback parameter it is _not_ an\n * asynchronous operation, the callback is just yielded a query object to be\n * customized.\n *\n * @param {lunr.Index~queryBuilder} fn - A function that is used to build the query.\n * @returns {lunr.Index~Result[]}\n */\nlunr.Index.prototype.query = function (fn) {\n // for each query clause\n // * process terms\n // * expand terms from token set\n // * find matching documents and metadata\n // * get document vectors\n // * score documents\n\n var query = new lunr.Query(this.fields),\n matchingFields = Object.create(null),\n queryVectors = Object.create(null),\n termFieldCache = Object.create(null),\n requiredMatches = Object.create(null),\n prohibitedMatches = Object.create(null)\n\n /*\n * To support field level boosts a query vector is created per\n * field. An empty vector is eagerly created to support negated\n * queries.\n */\n for (var i = 0; i < this.fields.length; i++) {\n queryVectors[this.fields[i]] = new lunr.Vector\n }\n\n fn.call(query, query)\n\n for (var i = 0; i < query.clauses.length; i++) {\n /*\n * Unless the pipeline has been disabled for this term, which is\n * the case for terms with wildcards, we need to pass the clause\n * term through the search pipeline. A pipeline returns an array\n * of processed terms. Pipeline functions may expand the passed\n * term, which means we may end up performing multiple index lookups\n * for a single query term.\n */\n var clause = query.clauses[i],\n terms = null,\n clauseMatches = lunr.Set.empty\n\n if (clause.usePipeline) {\n terms = this.pipeline.runString(clause.term, {\n fields: clause.fields\n })\n } else {\n terms = [clause.term]\n }\n\n for (var m = 0; m < terms.length; m++) {\n var term = terms[m]\n\n /*\n * Each term returned from the pipeline needs to use the same query\n * clause object, e.g. the same boost and or edit distance. The\n * simplest way to do this is to re-use the clause object but mutate\n * its term property.\n */\n clause.term = term\n\n /*\n * From the term in the clause we create a token set which will then\n * be used to intersect the indexes token set to get a list of terms\n * to lookup in the inverted index\n */\n var termTokenSet = lunr.TokenSet.fromClause(clause),\n expandedTerms = this.tokenSet.intersect(termTokenSet).toArray()\n\n /*\n * If a term marked as required does not exist in the tokenSet it is\n * impossible for the search to return any matches. We set all the field\n * scoped required matches set to empty and stop examining any further\n * clauses.\n */\n if (expandedTerms.length === 0 && clause.presence === lunr.Query.presence.REQUIRED) {\n for (var k = 0; k < clause.fields.length; k++) {\n var field = clause.fields[k]\n requiredMatches[field] = lunr.Set.empty\n }\n\n break\n }\n\n for (var j = 0; j < expandedTerms.length; j++) {\n /*\n * For each term get the posting and termIndex, this is required for\n * building the query vector.\n */\n var expandedTerm = expandedTerms[j],\n posting = this.invertedIndex[expandedTerm],\n termIndex = posting._index\n\n for (var k = 0; k < clause.fields.length; k++) {\n /*\n * For each field that this query term is scoped by (by default\n * all fields are in scope) we need to get all the document refs\n * that have this term in that field.\n *\n * The posting is the entry in the invertedIndex for the matching\n * term from above.\n */\n var field = clause.fields[k],\n fieldPosting = posting[field],\n matchingDocumentRefs = Object.keys(fieldPosting),\n termField = expandedTerm + \"/\" + field,\n matchingDocumentsSet = new lunr.Set(matchingDocumentRefs)\n\n /*\n * if the presence of this term is required ensure that the matching\n * documents are added to the set of required matches for this clause.\n *\n */\n if (clause.presence == lunr.Query.presence.REQUIRED) {\n clauseMatches = clauseMatches.union(matchingDocumentsSet)\n\n if (requiredMatches[field] === undefined) {\n requiredMatches[field] = lunr.Set.complete\n }\n }\n\n /*\n * if the presence of this term is prohibited ensure that the matching\n * documents are added to the set of prohibited matches for this field,\n * creating that set if it does not yet exist.\n */\n if (clause.presence == lunr.Query.presence.PROHIBITED) {\n if (prohibitedMatches[field] === undefined) {\n prohibitedMatches[field] = lunr.Set.empty\n }\n\n prohibitedMatches[field] = prohibitedMatches[field].union(matchingDocumentsSet)\n\n /*\n * Prohibited matches should not be part of the query vector used for\n * similarity scoring and no metadata should be extracted so we continue\n * to the next field\n */\n continue\n }\n\n /*\n * The query field vector is populated using the termIndex found for\n * the term and a unit value with the appropriate boost applied.\n * Using upsert because there could already be an entry in the vector\n * for the term we are working with. In that case we just add the scores\n * together.\n */\n queryVectors[field].upsert(termIndex, clause.boost, function (a, b) { return a + b })\n\n /**\n * If we've already seen this term, field combo then we've already collected\n * the matching documents and metadata, no need to go through all that again\n */\n if (termFieldCache[termField]) {\n continue\n }\n\n for (var l = 0; l < matchingDocumentRefs.length; l++) {\n /*\n * All metadata for this term/field/document triple\n * are then extracted and collected into an instance\n * of lunr.MatchData ready to be returned in the query\n * results\n */\n var matchingDocumentRef = matchingDocumentRefs[l],\n matchingFieldRef = new lunr.FieldRef (matchingDocumentRef, field),\n metadata = fieldPosting[matchingDocumentRef],\n fieldMatch\n\n if ((fieldMatch = matchingFields[matchingFieldRef]) === undefined) {\n matchingFields[matchingFieldRef] = new lunr.MatchData (expandedTerm, field, metadata)\n } else {\n fieldMatch.add(expandedTerm, field, metadata)\n }\n\n }\n\n termFieldCache[termField] = true\n }\n }\n }\n\n /**\n * If the presence was required we need to update the requiredMatches field sets.\n * We do this after all fields for the term have collected their matches because\n * the clause terms presence is required in _any_ of the fields not _all_ of the\n * fields.\n */\n if (clause.presence === lunr.Query.presence.REQUIRED) {\n for (var k = 0; k < clause.fields.length; k++) {\n var field = clause.fields[k]\n requiredMatches[field] = requiredMatches[field].intersect(clauseMatches)\n }\n }\n }\n\n /**\n * Need to combine the field scoped required and prohibited\n * matching documents into a global set of required and prohibited\n * matches\n */\n var allRequiredMatches = lunr.Set.complete,\n allProhibitedMatches = lunr.Set.empty\n\n for (var i = 0; i < this.fields.length; i++) {\n var field = this.fields[i]\n\n if (requiredMatches[field]) {\n allRequiredMatches = allRequiredMatches.intersect(requiredMatches[field])\n }\n\n if (prohibitedMatches[field]) {\n allProhibitedMatches = allProhibitedMatches.union(prohibitedMatches[field])\n }\n }\n\n var matchingFieldRefs = Object.keys(matchingFields),\n results = [],\n matches = Object.create(null)\n\n /*\n * If the query is negated (contains only prohibited terms)\n * we need to get _all_ fieldRefs currently existing in the\n * index. This is only done when we know that the query is\n * entirely prohibited terms to avoid any cost of getting all\n * fieldRefs unnecessarily.\n *\n * Additionally, blank MatchData must be created to correctly\n * populate the results.\n */\n if (query.isNegated()) {\n matchingFieldRefs = Object.keys(this.fieldVectors)\n\n for (var i = 0; i < matchingFieldRefs.length; i++) {\n var matchingFieldRef = matchingFieldRefs[i]\n var fieldRef = lunr.FieldRef.fromString(matchingFieldRef)\n matchingFields[matchingFieldRef] = new lunr.MatchData\n }\n }\n\n for (var i = 0; i < matchingFieldRefs.length; i++) {\n /*\n * Currently we have document fields that match the query, but we\n * need to return documents. The matchData and scores are combined\n * from multiple fields belonging to the same document.\n *\n * Scores are calculated by field, using the query vectors created\n * above, and combined into a final document score using addition.\n */\n var fieldRef = lunr.FieldRef.fromString(matchingFieldRefs[i]),\n docRef = fieldRef.docRef\n\n if (!allRequiredMatches.contains(docRef)) {\n continue\n }\n\n if (allProhibitedMatches.contains(docRef)) {\n continue\n }\n\n var fieldVector = this.fieldVectors[fieldRef],\n score = queryVectors[fieldRef.fieldName].similarity(fieldVector),\n docMatch\n\n if ((docMatch = matches[docRef]) !== undefined) {\n docMatch.score += score\n docMatch.matchData.combine(matchingFields[fieldRef])\n } else {\n var match = {\n ref: docRef,\n score: score,\n matchData: matchingFields[fieldRef]\n }\n matches[docRef] = match\n results.push(match)\n }\n }\n\n /*\n * Sort the results objects by score, highest first.\n */\n return results.sort(function (a, b) {\n return b.score - a.score\n })\n}\n\n/**\n * Prepares the index for JSON serialization.\n *\n * The schema for this JSON blob will be described in a\n * separate JSON schema file.\n *\n * @returns {Object}\n */\nlunr.Index.prototype.toJSON = function () {\n var invertedIndex = Object.keys(this.invertedIndex)\n .sort()\n .map(function (term) {\n return [term, this.invertedIndex[term]]\n }, this)\n\n var fieldVectors = Object.keys(this.fieldVectors)\n .map(function (ref) {\n return [ref, this.fieldVectors[ref].toJSON()]\n }, this)\n\n return {\n version: lunr.version,\n fields: this.fields,\n fieldVectors: fieldVectors,\n invertedIndex: invertedIndex,\n pipeline: this.pipeline.toJSON()\n }\n}\n\n/**\n * Loads a previously serialized lunr.Index\n *\n * @param {Object} serializedIndex - A previously serialized lunr.Index\n * @returns {lunr.Index}\n */\nlunr.Index.load = function (serializedIndex) {\n var attrs = {},\n fieldVectors = {},\n serializedVectors = serializedIndex.fieldVectors,\n invertedIndex = Object.create(null),\n serializedInvertedIndex = serializedIndex.invertedIndex,\n tokenSetBuilder = new lunr.TokenSet.Builder,\n pipeline = lunr.Pipeline.load(serializedIndex.pipeline)\n\n if (serializedIndex.version != lunr.version) {\n lunr.utils.warn(\"Version mismatch when loading serialised index. Current version of lunr '\" + lunr.version + \"' does not match serialized index '\" + serializedIndex.version + \"'\")\n }\n\n for (var i = 0; i < serializedVectors.length; i++) {\n var tuple = serializedVectors[i],\n ref = tuple[0],\n elements = tuple[1]\n\n fieldVectors[ref] = new lunr.Vector(elements)\n }\n\n for (var i = 0; i < serializedInvertedIndex.length; i++) {\n var tuple = serializedInvertedIndex[i],\n term = tuple[0],\n posting = tuple[1]\n\n tokenSetBuilder.insert(term)\n invertedIndex[term] = posting\n }\n\n tokenSetBuilder.finish()\n\n attrs.fields = serializedIndex.fields\n\n attrs.fieldVectors = fieldVectors\n attrs.invertedIndex = invertedIndex\n attrs.tokenSet = tokenSetBuilder.root\n attrs.pipeline = pipeline\n\n return new lunr.Index(attrs)\n}\n/*!\n * lunr.Builder\n * Copyright (C) 2020 Oliver Nightingale\n */\n\n/**\n * lunr.Builder performs indexing on a set of documents and\n * returns instances of lunr.Index ready for querying.\n *\n * All configuration of the index is done via the builder, the\n * fields to index, the document reference, the text processing\n * pipeline and document scoring parameters are all set on the\n * builder before indexing.\n *\n * @constructor\n * @property {string} _ref - Internal reference to the document reference field.\n * @property {string[]} _fields - Internal reference to the document fields to index.\n * @property {object} invertedIndex - The inverted index maps terms to document fields.\n * @property {object} documentTermFrequencies - Keeps track of document term frequencies.\n * @property {object} documentLengths - Keeps track of the length of documents added to the index.\n * @property {lunr.tokenizer} tokenizer - Function for splitting strings into tokens for indexing.\n * @property {lunr.Pipeline} pipeline - The pipeline performs text processing on tokens before indexing.\n * @property {lunr.Pipeline} searchPipeline - A pipeline for processing search terms before querying the index.\n * @property {number} documentCount - Keeps track of the total number of documents indexed.\n * @property {number} _b - A parameter to control field length normalization, setting this to 0 disabled normalization, 1 fully normalizes field lengths, the default value is 0.75.\n * @property {number} _k1 - A parameter to control how quickly an increase in term frequency results in term frequency saturation, the default value is 1.2.\n * @property {number} termIndex - A counter incremented for each unique term, used to identify a terms position in the vector space.\n * @property {array} metadataWhitelist - A list of metadata keys that have been whitelisted for entry in the index.\n */\nlunr.Builder = function () {\n this._ref = \"id\"\n this._fields = Object.create(null)\n this._documents = Object.create(null)\n this.invertedIndex = Object.create(null)\n this.fieldTermFrequencies = {}\n this.fieldLengths = {}\n this.tokenizer = lunr.tokenizer\n this.pipeline = new lunr.Pipeline\n this.searchPipeline = new lunr.Pipeline\n this.documentCount = 0\n this._b = 0.75\n this._k1 = 1.2\n this.termIndex = 0\n this.metadataWhitelist = []\n}\n\n/**\n * Sets the document field used as the document reference. Every document must have this field.\n * The type of this field in the document should be a string, if it is not a string it will be\n * coerced into a string by calling toString.\n *\n * The default ref is 'id'.\n *\n * The ref should _not_ be changed during indexing, it should be set before any documents are\n * added to the index. Changing it during indexing can lead to inconsistent results.\n *\n * @param {string} ref - The name of the reference field in the document.\n */\nlunr.Builder.prototype.ref = function (ref) {\n this._ref = ref\n}\n\n/**\n * A function that is used to extract a field from a document.\n *\n * Lunr expects a field to be at the top level of a document, if however the field\n * is deeply nested within a document an extractor function can be used to extract\n * the right field for indexing.\n *\n * @callback fieldExtractor\n * @param {object} doc - The document being added to the index.\n * @returns {?(string|object|object[])} obj - The object that will be indexed for this field.\n * @example Extracting a nested field\n * function (doc) { return doc.nested.field }\n */\n\n/**\n * Adds a field to the list of document fields that will be indexed. Every document being\n * indexed should have this field. Null values for this field in indexed documents will\n * not cause errors but will limit the chance of that document being retrieved by searches.\n *\n * All fields should be added before adding documents to the index. Adding fields after\n * a document has been indexed will have no effect on already indexed documents.\n *\n * Fields can be boosted at build time. This allows terms within that field to have more\n * importance when ranking search results. Use a field boost to specify that matches within\n * one field are more important than other fields.\n *\n * @param {string} fieldName - The name of a field to index in all documents.\n * @param {object} attributes - Optional attributes associated with this field.\n * @param {number} [attributes.boost=1] - Boost applied to all terms within this field.\n * @param {fieldExtractor} [attributes.extractor] - Function to extract a field from a document.\n * @throws {RangeError} fieldName cannot contain unsupported characters '/'\n */\nlunr.Builder.prototype.field = function (fieldName, attributes) {\n if (/\\//.test(fieldName)) {\n throw new RangeError (\"Field '\" + fieldName + \"' contains illegal character '/'\")\n }\n\n this._fields[fieldName] = attributes || {}\n}\n\n/**\n * A parameter to tune the amount of field length normalisation that is applied when\n * calculating relevance scores. A value of 0 will completely disable any normalisation\n * and a value of 1 will fully normalise field lengths. The default is 0.75. Values of b\n * will be clamped to the range 0 - 1.\n *\n * @param {number} number - The value to set for this tuning parameter.\n */\nlunr.Builder.prototype.b = function (number) {\n if (number < 0) {\n this._b = 0\n } else if (number > 1) {\n this._b = 1\n } else {\n this._b = number\n }\n}\n\n/**\n * A parameter that controls the speed at which a rise in term frequency results in term\n * frequency saturation. The default value is 1.2. Setting this to a higher value will give\n * slower saturation levels, a lower value will result in quicker saturation.\n *\n * @param {number} number - The value to set for this tuning parameter.\n */\nlunr.Builder.prototype.k1 = function (number) {\n this._k1 = number\n}\n\n/**\n * Adds a document to the index.\n *\n * Before adding fields to the index the index should have been fully setup, with the document\n * ref and all fields to index already having been specified.\n *\n * The document must have a field name as specified by the ref (by default this is 'id') and\n * it should have all fields defined for indexing, though null or undefined values will not\n * cause errors.\n *\n * Entire documents can be boosted at build time. Applying a boost to a document indicates that\n * this document should rank higher in search results than other documents.\n *\n * @param {object} doc - The document to add to the index.\n * @param {object} attributes - Optional attributes associated with this document.\n * @param {number} [attributes.boost=1] - Boost applied to all terms within this document.\n */\nlunr.Builder.prototype.add = function (doc, attributes) {\n var docRef = doc[this._ref],\n fields = Object.keys(this._fields)\n\n this._documents[docRef] = attributes || {}\n this.documentCount += 1\n\n for (var i = 0; i < fields.length; i++) {\n var fieldName = fields[i],\n extractor = this._fields[fieldName].extractor,\n field = extractor ? extractor(doc) : doc[fieldName],\n tokens = this.tokenizer(field, {\n fields: [fieldName]\n }),\n terms = this.pipeline.run(tokens),\n fieldRef = new lunr.FieldRef (docRef, fieldName),\n fieldTerms = Object.create(null)\n\n this.fieldTermFrequencies[fieldRef] = fieldTerms\n this.fieldLengths[fieldRef] = 0\n\n // store the length of this field for this document\n this.fieldLengths[fieldRef] += terms.length\n\n // calculate term frequencies for this field\n for (var j = 0; j < terms.length; j++) {\n var term = terms[j]\n\n if (fieldTerms[term] == undefined) {\n fieldTerms[term] = 0\n }\n\n fieldTerms[term] += 1\n\n // add to inverted index\n // create an initial posting if one doesn't exist\n if (this.invertedIndex[term] == undefined) {\n var posting = Object.create(null)\n posting[\"_index\"] = this.termIndex\n this.termIndex += 1\n\n for (var k = 0; k < fields.length; k++) {\n posting[fields[k]] = Object.create(null)\n }\n\n this.invertedIndex[term] = posting\n }\n\n // add an entry for this term/fieldName/docRef to the invertedIndex\n if (this.invertedIndex[term][fieldName][docRef] == undefined) {\n this.invertedIndex[term][fieldName][docRef] = Object.create(null)\n }\n\n // store all whitelisted metadata about this token in the\n // inverted index\n for (var l = 0; l < this.metadataWhitelist.length; l++) {\n var metadataKey = this.metadataWhitelist[l],\n metadata = term.metadata[metadataKey]\n\n if (this.invertedIndex[term][fieldName][docRef][metadataKey] == undefined) {\n this.invertedIndex[term][fieldName][docRef][metadataKey] = []\n }\n\n this.invertedIndex[term][fieldName][docRef][metadataKey].push(metadata)\n }\n }\n\n }\n}\n\n/**\n * Calculates the average document length for this index\n *\n * @private\n */\nlunr.Builder.prototype.calculateAverageFieldLengths = function () {\n\n var fieldRefs = Object.keys(this.fieldLengths),\n numberOfFields = fieldRefs.length,\n accumulator = {},\n documentsWithField = {}\n\n for (var i = 0; i < numberOfFields; i++) {\n var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),\n field = fieldRef.fieldName\n\n documentsWithField[field] || (documentsWithField[field] = 0)\n documentsWithField[field] += 1\n\n accumulator[field] || (accumulator[field] = 0)\n accumulator[field] += this.fieldLengths[fieldRef]\n }\n\n var fields = Object.keys(this._fields)\n\n for (var i = 0; i < fields.length; i++) {\n var fieldName = fields[i]\n accumulator[fieldName] = accumulator[fieldName] / documentsWithField[fieldName]\n }\n\n this.averageFieldLength = accumulator\n}\n\n/**\n * Builds a vector space model of every document using lunr.Vector\n *\n * @private\n */\nlunr.Builder.prototype.createFieldVectors = function () {\n var fieldVectors = {},\n fieldRefs = Object.keys(this.fieldTermFrequencies),\n fieldRefsLength = fieldRefs.length,\n termIdfCache = Object.create(null)\n\n for (var i = 0; i < fieldRefsLength; i++) {\n var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),\n fieldName = fieldRef.fieldName,\n fieldLength = this.fieldLengths[fieldRef],\n fieldVector = new lunr.Vector,\n termFrequencies = this.fieldTermFrequencies[fieldRef],\n terms = Object.keys(termFrequencies),\n termsLength = terms.length\n\n\n var fieldBoost = this._fields[fieldName].boost || 1,\n docBoost = this._documents[fieldRef.docRef].boost || 1\n\n for (var j = 0; j < termsLength; j++) {\n var term = terms[j],\n tf = termFrequencies[term],\n termIndex = this.invertedIndex[term]._index,\n idf, score, scoreWithPrecision\n\n if (termIdfCache[term] === undefined) {\n idf = lunr.idf(this.invertedIndex[term], this.documentCount)\n termIdfCache[term] = idf\n } else {\n idf = termIdfCache[term]\n }\n\n score = idf * ((this._k1 + 1) * tf) / (this._k1 * (1 - this._b + this._b * (fieldLength / this.averageFieldLength[fieldName])) + tf)\n score *= fieldBoost\n score *= docBoost\n scoreWithPrecision = Math.round(score * 1000) / 1000\n // Converts 1.23456789 to 1.234.\n // Reducing the precision so that the vectors take up less\n // space when serialised. Doing it now so that they behave\n // the same before and after serialisation. Also, this is\n // the fastest approach to reducing a number's precision in\n // JavaScript.\n\n fieldVector.insert(termIndex, scoreWithPrecision)\n }\n\n fieldVectors[fieldRef] = fieldVector\n }\n\n this.fieldVectors = fieldVectors\n}\n\n/**\n * Creates a token set of all tokens in the index using lunr.TokenSet\n *\n * @private\n */\nlunr.Builder.prototype.createTokenSet = function () {\n this.tokenSet = lunr.TokenSet.fromArray(\n Object.keys(this.invertedIndex).sort()\n )\n}\n\n/**\n * Builds the index, creating an instance of lunr.Index.\n *\n * This completes the indexing process and should only be called\n * once all documents have been added to the index.\n *\n * @returns {lunr.Index}\n */\nlunr.Builder.prototype.build = function () {\n this.calculateAverageFieldLengths()\n this.createFieldVectors()\n this.createTokenSet()\n\n return new lunr.Index({\n invertedIndex: this.invertedIndex,\n fieldVectors: this.fieldVectors,\n tokenSet: this.tokenSet,\n fields: Object.keys(this._fields),\n pipeline: this.searchPipeline\n })\n}\n\n/**\n * Applies a plugin to the index builder.\n *\n * A plugin is a function that is called with the index builder as its context.\n * Plugins can be used to customise or extend the behaviour of the index\n * in some way. A plugin is just a function, that encapsulated the custom\n * behaviour that should be applied when building the index.\n *\n * The plugin function will be called with the index builder as its argument, additional\n * arguments can also be passed when calling use. The function will be called\n * with the index builder as its context.\n *\n * @param {Function} plugin The plugin to apply.\n */\nlunr.Builder.prototype.use = function (fn) {\n var args = Array.prototype.slice.call(arguments, 1)\n args.unshift(this)\n fn.apply(this, args)\n}\n/**\n * Contains and collects metadata about a matching document.\n * A single instance of lunr.MatchData is returned as part of every\n * lunr.Index~Result.\n *\n * @constructor\n * @param {string} term - The term this match data is associated with\n * @param {string} field - The field in which the term was found\n * @param {object} metadata - The metadata recorded about this term in this field\n * @property {object} metadata - A cloned collection of metadata associated with this document.\n * @see {@link lunr.Index~Result}\n */\nlunr.MatchData = function (term, field, metadata) {\n var clonedMetadata = Object.create(null),\n metadataKeys = Object.keys(metadata || {})\n\n // Cloning the metadata to prevent the original\n // being mutated during match data combination.\n // Metadata is kept in an array within the inverted\n // index so cloning the data can be done with\n // Array#slice\n for (var i = 0; i < metadataKeys.length; i++) {\n var key = metadataKeys[i]\n clonedMetadata[key] = metadata[key].slice()\n }\n\n this.metadata = Object.create(null)\n\n if (term !== undefined) {\n this.metadata[term] = Object.create(null)\n this.metadata[term][field] = clonedMetadata\n }\n}\n\n/**\n * An instance of lunr.MatchData will be created for every term that matches a\n * document. However only one instance is required in a lunr.Index~Result. This\n * method combines metadata from another instance of lunr.MatchData with this\n * objects metadata.\n *\n * @param {lunr.MatchData} otherMatchData - Another instance of match data to merge with this one.\n * @see {@link lunr.Index~Result}\n */\nlunr.MatchData.prototype.combine = function (otherMatchData) {\n var terms = Object.keys(otherMatchData.metadata)\n\n for (var i = 0; i < terms.length; i++) {\n var term = terms[i],\n fields = Object.keys(otherMatchData.metadata[term])\n\n if (this.metadata[term] == undefined) {\n this.metadata[term] = Object.create(null)\n }\n\n for (var j = 0; j < fields.length; j++) {\n var field = fields[j],\n keys = Object.keys(otherMatchData.metadata[term][field])\n\n if (this.metadata[term][field] == undefined) {\n this.metadata[term][field] = Object.create(null)\n }\n\n for (var k = 0; k < keys.length; k++) {\n var key = keys[k]\n\n if (this.metadata[term][field][key] == undefined) {\n this.metadata[term][field][key] = otherMatchData.metadata[term][field][key]\n } else {\n this.metadata[term][field][key] = this.metadata[term][field][key].concat(otherMatchData.metadata[term][field][key])\n }\n\n }\n }\n }\n}\n\n/**\n * Add metadata for a term/field pair to this instance of match data.\n *\n * @param {string} term - The term this match data is associated with\n * @param {string} field - The field in which the term was found\n * @param {object} metadata - The metadata recorded about this term in this field\n */\nlunr.MatchData.prototype.add = function (term, field, metadata) {\n if (!(term in this.metadata)) {\n this.metadata[term] = Object.create(null)\n this.metadata[term][field] = metadata\n return\n }\n\n if (!(field in this.metadata[term])) {\n this.metadata[term][field] = metadata\n return\n }\n\n var metadataKeys = Object.keys(metadata)\n\n for (var i = 0; i < metadataKeys.length; i++) {\n var key = metadataKeys[i]\n\n if (key in this.metadata[term][field]) {\n this.metadata[term][field][key] = this.metadata[term][field][key].concat(metadata[key])\n } else {\n this.metadata[term][field][key] = metadata[key]\n }\n }\n}\n/**\n * A lunr.Query provides a programmatic way of defining queries to be performed\n * against a {@link lunr.Index}.\n *\n * Prefer constructing a lunr.Query using the {@link lunr.Index#query} method\n * so the query object is pre-initialized with the right index fields.\n *\n * @constructor\n * @property {lunr.Query~Clause[]} clauses - An array of query clauses.\n * @property {string[]} allFields - An array of all available fields in a lunr.Index.\n */\nlunr.Query = function (allFields) {\n this.clauses = []\n this.allFields = allFields\n}\n\n/**\n * Constants for indicating what kind of automatic wildcard insertion will be used when constructing a query clause.\n *\n * This allows wildcards to be added to the beginning and end of a term without having to manually do any string\n * concatenation.\n *\n * The wildcard constants can be bitwise combined to select both leading and trailing wildcards.\n *\n * @constant\n * @default\n * @property {number} wildcard.NONE - The term will have no wildcards inserted, this is the default behaviour\n * @property {number} wildcard.LEADING - Prepend the term with a wildcard, unless a leading wildcard already exists\n * @property {number} wildcard.TRAILING - Append a wildcard to the term, unless a trailing wildcard already exists\n * @see lunr.Query~Clause\n * @see lunr.Query#clause\n * @see lunr.Query#term\n * @example query term with trailing wildcard\n * query.term('foo', { wildcard: lunr.Query.wildcard.TRAILING })\n * @example query term with leading and trailing wildcard\n * query.term('foo', {\n * wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING\n * })\n */\n\nlunr.Query.wildcard = new String (\"*\")\nlunr.Query.wildcard.NONE = 0\nlunr.Query.wildcard.LEADING = 1\nlunr.Query.wildcard.TRAILING = 2\n\n/**\n * Constants for indicating what kind of presence a term must have in matching documents.\n *\n * @constant\n * @enum {number}\n * @see lunr.Query~Clause\n * @see lunr.Query#clause\n * @see lunr.Query#term\n * @example query term with required presence\n * query.term('foo', { presence: lunr.Query.presence.REQUIRED })\n */\nlunr.Query.presence = {\n /**\n * Term's presence in a document is optional, this is the default value.\n */\n OPTIONAL: 1,\n\n /**\n * Term's presence in a document is required, documents that do not contain\n * this term will not be returned.\n */\n REQUIRED: 2,\n\n /**\n * Term's presence in a document is prohibited, documents that do contain\n * this term will not be returned.\n */\n PROHIBITED: 3\n}\n\n/**\n * A single clause in a {@link lunr.Query} contains a term and details on how to\n * match that term against a {@link lunr.Index}.\n *\n * @typedef {Object} lunr.Query~Clause\n * @property {string[]} fields - The fields in an index this clause should be matched against.\n * @property {number} [boost=1] - Any boost that should be applied when matching this clause.\n * @property {number} [editDistance] - Whether the term should have fuzzy matching applied, and how fuzzy the match should be.\n * @property {boolean} [usePipeline] - Whether the term should be passed through the search pipeline.\n * @property {number} [wildcard=lunr.Query.wildcard.NONE] - Whether the term should have wildcards appended or prepended.\n * @property {number} [presence=lunr.Query.presence.OPTIONAL] - The terms presence in any matching documents.\n */\n\n/**\n * Adds a {@link lunr.Query~Clause} to this query.\n *\n * Unless the clause contains the fields to be matched all fields will be matched. In addition\n * a default boost of 1 is applied to the clause.\n *\n * @param {lunr.Query~Clause} clause - The clause to add to this query.\n * @see lunr.Query~Clause\n * @returns {lunr.Query}\n */\nlunr.Query.prototype.clause = function (clause) {\n if (!('fields' in clause)) {\n clause.fields = this.allFields\n }\n\n if (!('boost' in clause)) {\n clause.boost = 1\n }\n\n if (!('usePipeline' in clause)) {\n clause.usePipeline = true\n }\n\n if (!('wildcard' in clause)) {\n clause.wildcard = lunr.Query.wildcard.NONE\n }\n\n if ((clause.wildcard & lunr.Query.wildcard.LEADING) && (clause.term.charAt(0) != lunr.Query.wildcard)) {\n clause.term = \"*\" + clause.term\n }\n\n if ((clause.wildcard & lunr.Query.wildcard.TRAILING) && (clause.term.slice(-1) != lunr.Query.wildcard)) {\n clause.term = \"\" + clause.term + \"*\"\n }\n\n if (!('presence' in clause)) {\n clause.presence = lunr.Query.presence.OPTIONAL\n }\n\n this.clauses.push(clause)\n\n return this\n}\n\n/**\n * A negated query is one in which every clause has a presence of\n * prohibited. These queries require some special processing to return\n * the expected results.\n *\n * @returns boolean\n */\nlunr.Query.prototype.isNegated = function () {\n for (var i = 0; i < this.clauses.length; i++) {\n if (this.clauses[i].presence != lunr.Query.presence.PROHIBITED) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Adds a term to the current query, under the covers this will create a {@link lunr.Query~Clause}\n * to the list of clauses that make up this query.\n *\n * The term is used as is, i.e. no tokenization will be performed by this method. Instead conversion\n * to a token or token-like string should be done before calling this method.\n *\n * The term will be converted to a string by calling `toString`. Multiple terms can be passed as an\n * array, each term in the array will share the same options.\n *\n * @param {object|object[]} term - The term(s) to add to the query.\n * @param {object} [options] - Any additional properties to add to the query clause.\n * @returns {lunr.Query}\n * @see lunr.Query#clause\n * @see lunr.Query~Clause\n * @example adding a single term to a query\n * query.term(\"foo\")\n * @example adding a single term to a query and specifying search fields, term boost and automatic trailing wildcard\n * query.term(\"foo\", {\n * fields: [\"title\"],\n * boost: 10,\n * wildcard: lunr.Query.wildcard.TRAILING\n * })\n * @example using lunr.tokenizer to convert a string to tokens before using them as terms\n * query.term(lunr.tokenizer(\"foo bar\"))\n */\nlunr.Query.prototype.term = function (term, options) {\n if (Array.isArray(term)) {\n term.forEach(function (t) { this.term(t, lunr.utils.clone(options)) }, this)\n return this\n }\n\n var clause = options || {}\n clause.term = term.toString()\n\n this.clause(clause)\n\n return this\n}\nlunr.QueryParseError = function (message, start, end) {\n this.name = \"QueryParseError\"\n this.message = message\n this.start = start\n this.end = end\n}\n\nlunr.QueryParseError.prototype = new Error\nlunr.QueryLexer = function (str) {\n this.lexemes = []\n this.str = str\n this.length = str.length\n this.pos = 0\n this.start = 0\n this.escapeCharPositions = []\n}\n\nlunr.QueryLexer.prototype.run = function () {\n var state = lunr.QueryLexer.lexText\n\n while (state) {\n state = state(this)\n }\n}\n\nlunr.QueryLexer.prototype.sliceString = function () {\n var subSlices = [],\n sliceStart = this.start,\n sliceEnd = this.pos\n\n for (var i = 0; i < this.escapeCharPositions.length; i++) {\n sliceEnd = this.escapeCharPositions[i]\n subSlices.push(this.str.slice(sliceStart, sliceEnd))\n sliceStart = sliceEnd + 1\n }\n\n subSlices.push(this.str.slice(sliceStart, this.pos))\n this.escapeCharPositions.length = 0\n\n return subSlices.join('')\n}\n\nlunr.QueryLexer.prototype.emit = function (type) {\n this.lexemes.push({\n type: type,\n str: this.sliceString(),\n start: this.start,\n end: this.pos\n })\n\n this.start = this.pos\n}\n\nlunr.QueryLexer.prototype.escapeCharacter = function () {\n this.escapeCharPositions.push(this.pos - 1)\n this.pos += 1\n}\n\nlunr.QueryLexer.prototype.next = function () {\n if (this.pos >= this.length) {\n return lunr.QueryLexer.EOS\n }\n\n var char = this.str.charAt(this.pos)\n this.pos += 1\n return char\n}\n\nlunr.QueryLexer.prototype.width = function () {\n return this.pos - this.start\n}\n\nlunr.QueryLexer.prototype.ignore = function () {\n if (this.start == this.pos) {\n this.pos += 1\n }\n\n this.start = this.pos\n}\n\nlunr.QueryLexer.prototype.backup = function () {\n this.pos -= 1\n}\n\nlunr.QueryLexer.prototype.acceptDigitRun = function () {\n var char, charCode\n\n do {\n char = this.next()\n charCode = char.charCodeAt(0)\n } while (charCode > 47 && charCode < 58)\n\n if (char != lunr.QueryLexer.EOS) {\n this.backup()\n }\n}\n\nlunr.QueryLexer.prototype.more = function () {\n return this.pos < this.length\n}\n\nlunr.QueryLexer.EOS = 'EOS'\nlunr.QueryLexer.FIELD = 'FIELD'\nlunr.QueryLexer.TERM = 'TERM'\nlunr.QueryLexer.EDIT_DISTANCE = 'EDIT_DISTANCE'\nlunr.QueryLexer.BOOST = 'BOOST'\nlunr.QueryLexer.PRESENCE = 'PRESENCE'\n\nlunr.QueryLexer.lexField = function (lexer) {\n lexer.backup()\n lexer.emit(lunr.QueryLexer.FIELD)\n lexer.ignore()\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexTerm = function (lexer) {\n if (lexer.width() > 1) {\n lexer.backup()\n lexer.emit(lunr.QueryLexer.TERM)\n }\n\n lexer.ignore()\n\n if (lexer.more()) {\n return lunr.QueryLexer.lexText\n }\n}\n\nlunr.QueryLexer.lexEditDistance = function (lexer) {\n lexer.ignore()\n lexer.acceptDigitRun()\n lexer.emit(lunr.QueryLexer.EDIT_DISTANCE)\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexBoost = function (lexer) {\n lexer.ignore()\n lexer.acceptDigitRun()\n lexer.emit(lunr.QueryLexer.BOOST)\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexEOS = function (lexer) {\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n}\n\n// This matches the separator used when tokenising fields\n// within a document. These should match otherwise it is\n// not possible to search for some tokens within a document.\n//\n// It is possible for the user to change the separator on the\n// tokenizer so it _might_ clash with any other of the special\n// characters already used within the search string, e.g. :.\n//\n// This means that it is possible to change the separator in\n// such a way that makes some words unsearchable using a search\n// string.\nlunr.QueryLexer.termSeparator = lunr.tokenizer.separator\n\nlunr.QueryLexer.lexText = function (lexer) {\n while (true) {\n var char = lexer.next()\n\n if (char == lunr.QueryLexer.EOS) {\n return lunr.QueryLexer.lexEOS\n }\n\n // Escape character is '\\'\n if (char.charCodeAt(0) == 92) {\n lexer.escapeCharacter()\n continue\n }\n\n if (char == \":\") {\n return lunr.QueryLexer.lexField\n }\n\n if (char == \"~\") {\n lexer.backup()\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n return lunr.QueryLexer.lexEditDistance\n }\n\n if (char == \"^\") {\n lexer.backup()\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n return lunr.QueryLexer.lexBoost\n }\n\n // \"+\" indicates term presence is required\n // checking for length to ensure that only\n // leading \"+\" are considered\n if (char == \"+\" && lexer.width() === 1) {\n lexer.emit(lunr.QueryLexer.PRESENCE)\n return lunr.QueryLexer.lexText\n }\n\n // \"-\" indicates term presence is prohibited\n // checking for length to ensure that only\n // leading \"-\" are considered\n if (char == \"-\" && lexer.width() === 1) {\n lexer.emit(lunr.QueryLexer.PRESENCE)\n return lunr.QueryLexer.lexText\n }\n\n if (char.match(lunr.QueryLexer.termSeparator)) {\n return lunr.QueryLexer.lexTerm\n }\n }\n}\n\nlunr.QueryParser = function (str, query) {\n this.lexer = new lunr.QueryLexer (str)\n this.query = query\n this.currentClause = {}\n this.lexemeIdx = 0\n}\n\nlunr.QueryParser.prototype.parse = function () {\n this.lexer.run()\n this.lexemes = this.lexer.lexemes\n\n var state = lunr.QueryParser.parseClause\n\n while (state) {\n state = state(this)\n }\n\n return this.query\n}\n\nlunr.QueryParser.prototype.peekLexeme = function () {\n return this.lexemes[this.lexemeIdx]\n}\n\nlunr.QueryParser.prototype.consumeLexeme = function () {\n var lexeme = this.peekLexeme()\n this.lexemeIdx += 1\n return lexeme\n}\n\nlunr.QueryParser.prototype.nextClause = function () {\n var completedClause = this.currentClause\n this.query.clause(completedClause)\n this.currentClause = {}\n}\n\nlunr.QueryParser.parseClause = function (parser) {\n var lexeme = parser.peekLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n switch (lexeme.type) {\n case lunr.QueryLexer.PRESENCE:\n return lunr.QueryParser.parsePresence\n case lunr.QueryLexer.FIELD:\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expected either a field or a term, found \" + lexeme.type\n\n if (lexeme.str.length >= 1) {\n errorMessage += \" with value '\" + lexeme.str + \"'\"\n }\n\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n}\n\nlunr.QueryParser.parsePresence = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n switch (lexeme.str) {\n case \"-\":\n parser.currentClause.presence = lunr.Query.presence.PROHIBITED\n break\n case \"+\":\n parser.currentClause.presence = lunr.Query.presence.REQUIRED\n break\n default:\n var errorMessage = \"unrecognised presence operator'\" + lexeme.str + \"'\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n var errorMessage = \"expecting term or field, found nothing\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.FIELD:\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expecting term or field, found '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseField = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n if (parser.query.allFields.indexOf(lexeme.str) == -1) {\n var possibleFields = parser.query.allFields.map(function (f) { return \"'\" + f + \"'\" }).join(', '),\n errorMessage = \"unrecognised field '\" + lexeme.str + \"', possible fields: \" + possibleFields\n\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.fields = [lexeme.str]\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n var errorMessage = \"expecting term, found nothing\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expecting term, found '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseTerm = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n parser.currentClause.term = lexeme.str.toLowerCase()\n\n if (lexeme.str.indexOf(\"*\") != -1) {\n parser.currentClause.usePipeline = false\n }\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseEditDistance = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n var editDistance = parseInt(lexeme.str, 10)\n\n if (isNaN(editDistance)) {\n var errorMessage = \"edit distance must be numeric\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.editDistance = editDistance\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseBoost = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n var boost = parseInt(lexeme.str, 10)\n\n if (isNaN(boost)) {\n var errorMessage = \"boost must be numeric\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.boost = boost\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\n /**\n * export the module via AMD, CommonJS or as a browser global\n * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js\n */\n ;(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(factory)\n } else if (typeof exports === 'object') {\n /**\n * Node. Does not work with strict CommonJS, but\n * only CommonJS-like enviroments that support module.exports,\n * like Node.\n */\n module.exports = factory()\n } else {\n // Browser globals (root is window)\n root.lunr = factory()\n }\n }(this, function () {\n /**\n * Just return a value to define the module export.\n * This example returns an object, but the module\n * can return a function as the exported value.\n */\n return lunr\n }))\n})();\n"],"names":["global","step2list","step3list","v","C","V","meq1","mgr1","s_v","re_mgr0","re_mgr1","re_meq1","re_s_v","re_1a","re2_1a","re_1b","re2_1b","re_1b_2","re2_1b_2","re3_1b_2","re4_1b_2","re_1c","re_2","re_3","re_4","re2_4","re_5","re_5_1","re3_5","porterStemmer","root","factory","lunr","config","builder","Builder","pipeline","add","trimmer","stopWordFilter","stemmer","searchPipeline","call","build","version","utils","warn","this","message","console","asString","obj","toString","clone","Object","create","keys","i","length","key","val","Array","isArray","slice","TypeError","FieldRef","docRef","fieldName","stringValue","_stringValue","joiner","fromString","s","n","indexOf","fieldRef","prototype","undefined","Set","elements","complete","intersect","other","union","contains","empty","object","a","b","intersection","element","push","concat","idf","posting","documentCount","documentsWithTerm","x","Math","log","abs","Token","str","metadata","update","fn","tokenizer","map","t","toLowerCase","len","tokens","sliceEnd","sliceStart","sliceLength","charAt","match","separator","tokenMetadata","Pipeline","_stack","registeredFunctions","registerFunction","label","warnIfFunctionNotRegistered","load","serialised","forEach","fnName","Error","arguments","after","existingFn","newFn","pos","splice","before","remove","run","stackLength","memo","j","result","k","runString","token","reset","toJSON","Vector","_magnitude","positionForIndex","index","start","end","pivotPoint","floor","pivotIndex","insert","insertIdx","upsert","position","magnitude","sumOfSquares","elementsLength","sqrt","dot","otherVector","dotProduct","aLen","bLen","aVal","bVal","similarity","toArray","output","ational","tional","enci","anci","izer","bli","alli","entli","eli","ousli","ization","ation","ator","alism","iveness","fulness","ousness","aliti","iviti","biliti","logi","icate","ative","alize","iciti","ical","ful","ness","c","RegExp","w","stem","suffix","firstch","re","re2","re3","re4","substr","toUpperCase","test","replace","fp","exec","generateStopWordFilter","stopWords","words","reduce","stopWord","TokenSet","final","edges","id","_nextId","fromArray","arr","finish","fromClause","clause","fromFuzzyString","term","editDistance","stack","node","editsRemaining","frame","pop","noEditNode","char","insertionNode","substitutionNode","transposeNode","charA","charB","next","prefix","edge","_str","labels","sort","qNode","qEdges","qLen","nEdges","nLen","q","qEdge","nEdge","previousWord","uncheckedNodes","minimizedNodes","word","commonPrefix","minimize","child","nextNode","parent","downTo","childKey","Index","attrs","invertedIndex","fieldVectors","tokenSet","fields","search","queryString","query","QueryParser","parse","Query","matchingFields","queryVectors","termFieldCache","requiredMatches","prohibitedMatches","clauses","terms","clauseMatches","usePipeline","m","termTokenSet","expandedTerms","presence","REQUIRED","field","expandedTerm","termIndex","_index","fieldPosting","matchingDocumentRefs","termField","matchingDocumentsSet","PROHIBITED","boost","l","fieldMatch","matchingDocumentRef","matchingFieldRef","MatchData","allRequiredMatches","allProhibitedMatches","matchingFieldRefs","results","matches","isNegated","docMatch","fieldVector","score","matchData","combine","ref","serializedIndex","serializedVectors","serializedInvertedIndex","tokenSetBuilder","tuple","_ref","_fields","_documents","fieldTermFrequencies","fieldLengths","_b","_k1","metadataWhitelist","attributes","RangeError","number","k1","doc","extractor","fieldTerms","metadataKey","calculateAverageFieldLengths","fieldRefs","numberOfFields","accumulator","documentsWithField","averageFieldLength","createFieldVectors","fieldRefsLength","termIdfCache","fieldLength","termFrequencies","termsLength","fieldBoost","docBoost","scoreWithPrecision","tf","round","createTokenSet","use","args","unshift","apply","clonedMetadata","metadataKeys","otherMatchData","allFields","wildcard","String","NONE","LEADING","TRAILING","OPTIONAL","options","QueryParseError","name","QueryLexer","lexemes","escapeCharPositions","state","lexText","sliceString","subSlices","join","emit","type","escapeCharacter","EOS","width","ignore","backup","acceptDigitRun","charCode","charCodeAt","more","FIELD","TERM","EDIT_DISTANCE","BOOST","PRESENCE","lexField","lexer","lexTerm","lexEditDistance","lexBoost","lexEOS","termSeparator","currentClause","lexemeIdx","parseClause","peekLexeme","consumeLexeme","lexeme","nextClause","completedClause","parser","parsePresence","parseField","parseTerm","errorMessage","nextLexeme","possibleFields","f","parseEditDistance","parseBoost","parseInt","isNaN","define","amd","exports","module"],"mappings":";;;;;CAaC,WAiCD,IAoC6BA,OAw2BvBC,UAwBFC,UAWAC,EACAC,EACAC,EAGAC,KACAC,KACAC,IAEEC,QACAC,QACAC,QACAC,OAEAC,MACAC,OACAC,MACAC,OACAC,QACAC,SACAC,SACAC,SAEAC,MACAC,KAEAC,KAEAC,KACAC,MAEAC,KACAC,OACAC,MAEAC,cAk4EQC,KAAMC,QAp1GhBC,KAAO,SAAUC,QACnB,IAAIC,QAAU,IAAIF,KAAKG,QAavB,OAXAD,QAAQE,SAASC,IACfL,KAAKM,QACLN,KAAKO,eACLP,KAAKQ,SAGPN,QAAQO,eAAeJ,IACrBL,KAAKQ,SAGPP,OAAOS,KAAKR,QAASA,SACdA,QAAQS,SAGjBX,KAAKY,QAAU,QAUfZ,KAAKa,MAAQ,GASbb,KAAKa,MAAMC,MAAkB9C,OAQ1B+C,KANM,SAAUC,SACXhD,OAAOiD,SAAWA,QAAQH,MAC5BG,QAAQH,KAAKE,WAiBnBhB,KAAKa,MAAMK,SAAW,SAAUC,KAC9B,OAAIA,UACK,GAEAA,IAAIC,YAoBfpB,KAAKa,MAAMQ,MAAQ,SAAUF,KAC3B,GAAIA,UACF,OAAOA,IAMT,IAHA,IAAIE,MAAQC,OAAOC,OAAO,MACtBC,KAAOF,OAAOE,KAAKL,KAEdM,EAAI,EAAGA,EAAID,KAAKE,OAAQD,IAAK,CACpC,IAAIE,IAAMH,KAAKC,GACXG,IAAMT,IAAIQ,KAEd,GAAIE,MAAMC,QAAQF,KAChBP,MAAMM,KAAOC,IAAIG,YADnB,CAKA,GAAmB,iBAARH,KACQ,iBAARA,KACQ,kBAARA,IAKX,MAAM,IAAII,UAAU,yDAJlBX,MAAMM,KAAOC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R,GAAE,CAAE,GAEL,OAAO,SAAUK,OACf,GAAIA,OAAS4E,MAAM5E,MAAM7F,cAAgB6F,MAAM7F,WAAY,OAAO6F,QAiBtEjH,KAAKO,eAAiBP,KAAK2L,uBAAuB,CAChD,IACA,OACA,QACA,SACA,QACA,MACA,SACA,OACA,KACA,QACA,KACA,MACA,MACA,MACA,KACA,KACA,KACA,UACA,OACA,MACA,KACA,MACA,SACA,QACA,OACA,MACA,KACA,OACA,SACA,OACA,OACA,QACA,MACA,OACA,MACA,MACA,MACA,MACA,OACA,KACA,MACA,OACA,MACA,MACA,MACA,UACA,IACA,KACA,KACA,OACA,KACA,KACA,MACA,OACA,QACA,MACA,OACA,SACA,MACA,KACA,QACA,OACA,OACA,KACA,UACA,KACA,MACA,MACA,KACA,MACA,QACA,KACA,OACA,KACA,QACA,MACA,MACA,SACA,OACA,MACA,OACA,MACA,SACA,QACA,KACA,OACA,OACA,OACA,MACA,QACA,OACA,OACA,QACA,QACA,OACA,OACA,MACA,KACA,MACA,OACA,KACA,QACA,MACA,KACA,OACA,OACA,OACA,QACA,QACA,QACA,MACA,OACA,MACA,OACA,OACA,QACA,MACA,MACA,SAGF3L,KAAKuF,SAASG,iBAAiB1F,KAAKO,eAAgB,kBAqBpDP,KAAKM,QAAU,SAAU2G,OACvB,OAAOA,MAAMzC,QAAO,SAAUhC,GAC5B,OAAOA,EAAEgJ,QAAQ,OAAQ,IAAIA,QAAQ,OAAQ,GAC/C,KAGFxL,KAAKuF,SAASG,iBAAiB1F,KAAKM,QAAS,WA2B7CN,KAAKgM,SAAW,WACdjL,KAAKkL,OAAQ,EACblL,KAAKmL,MAAQ,GACbnL,KAAKoL,GAAKnM,KAAKgM,SAASI,QACxBpM,KAAKgM,SAASI,SAAW,GAW3BpM,KAAKgM,SAASI,QAAU,EASxBpM,KAAKgM,SAASK,UAAY,SAAUC,KAGlC,IAFA,IAAIpM,QAAU,IAAIF,KAAKgM,SAAS7L,QAEvBsB,EAAI,EAAGqD,IA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,OAAQ,CAChB,IAAIqH,aAAe,wBACnB,MAAM,IAAI1Y,KAAK6V,gBAAiB6C,aAAcP,OAAO3Q,MAAO2Q,OAAO1Q,IACrE,CAEA6Q,OAAOR,cAAczG,MAAQA,MAE7B,IAAIsH,WAAaL,OAAOL,aAExB,GAAkBpV,MAAd8V,WAKJ,OAAQA,WAAWnC,MACjB,KAAKxW,KAAK+V,WAAWoB,KAEnB,OADAmB,OAAOF,aACApY,KAAK2P,YAAY8I,UAC1B,KAAKzY,KAAK+V,WAAWmB,MAEnB,OADAoB,OAAOF,aACApY,KAAK2P,YAAY6I,WAC1B,KAAKxY,KAAK+V,WAAWqB,cACnB,OAAOpX,KAAK2P,YAAYmJ,kBAC1B,KAAK9Y,KAAK+V,WAAWsB,MACnB,OAAOrX,KAAK2P,YAAYoJ,WAC1B,KAAK/Y,KAAK+V,WAAWuB,SAEnB,OADAgB,OAAOF,aACApY,KAAK2P,YAAY4I,cAC1B,QACMG,aAAe,2BAA6BC,WAAWnC,KAAO,IAClE,MAAM,IAAIxW,KAAK6V,gBAAiB6C,aAAcC,WAAWnR,MAAOmR,WAAWlR,UApB7E6Q,OAAOF,YAdT,GA0CYtY,KAeViB,KAfgBhB,QAeV,WAMN,OAAOC,IACT,EArBwB,mBAAXkZ,QAAyBA,OAAOC,IAEzCD,OAAM,6BAACnZ,SACqB,iBAAZqZ,QAMhBC,OAAOD,QAAUrZ,UAGjBD,KAAKE,KAAOD,SAUjB,CA54GA"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/mustache.min.js.map b/admin/tool/componentlibrary/amd/build/mustache.min.js.map index 3e3fa85e215..54ed48f7789 100644 --- a/admin/tool/componentlibrary/amd/build/mustache.min.js.map +++ b/admin/tool/componentlibrary/amd/build/mustache.min.js.map @@ -1 +1 @@ -{"version":3,"file":"mustache.min.js","sources":["../src/mustache.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Render mustache template examples within the component library.\n *\n * @module tool_componentlibrary/mustache\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport selectors from 'tool_componentlibrary/selectors';\nimport Ajax from 'core/ajax';\nimport Config from 'core/config';\nimport Templates from 'core/templates';\nimport Log from 'core/log';\nimport Notification from 'core/notification';\n\n/**\n * Handle a template loaded response.\n *\n * @method\n * @private\n * @param {String} container The template container\n * @param {String} templateName The template name\n * @param {String} context Data for the template.\n */\nconst renderTemplate = async(container, templateName, context) => {\n try {\n context = JSON.parse(context);\n } catch (e) {\n Log.debug('Could not parse json example context for template.');\n Log.debug(e);\n }\n\n const {html, js} = await Templates.renderForPromise(templateName, context);\n\n const rendercontainer = container.querySelector(selectors.mustacherendered);\n\n // Load the rendered content in the renderer tab.\n await Templates.replaceNodeContents(rendercontainer, html, js);\n};\n\n/**\n * Load the a template source from Moodle.\n *\n * @method\n * @private\n * @param {String} container The template container\n */\nconst loadTemplate = container => {\n const sourcecontainer = container.querySelector(selectors.mustachesource);\n const contextcontainer = container.querySelector(selectors.mustachecontext);\n const templateName = container.dataset.template;\n let context = container.querySelector(selectors.mustacherawcontext).textContent;\n\n const parts = templateName.split('/');\n const component = parts.shift();\n const name = parts.join('/');\n\n const request = {\n methodname: 'core_output_load_template',\n args: {\n component: component,\n template: name,\n themename: Config.theme,\n includecomments: true\n }\n };\n\n Ajax.call([request])[0]\n .done((source) => {\n // Load the source template in Template tab.\n sourcecontainer.textContent = source;\n if (!context) {\n const example = source.match(/Example context \\(json\\):([\\s\\S]+?)(}})/);\n context = example[1];\n // Load the variables in the Variables tab.\n const precontainer = document.createElement(\"pre\");\n precontainer.innerHTML = JSON.stringify(JSON.parse(context), null, 4);\n contextcontainer.parentNode.appendChild(precontainer);\n contextcontainer.classList.add('d-none');\n }\n renderTemplate(container, templateName, context);\n })\n .fail(Notification.exception);\n};\n\n/**\n * Initialize the module.\n *\n * @method\n */\nexport const mustache = () => {\n document.querySelectorAll(selectors.mustachecode).forEach((container) => {\n loadTemplate(container);\n });\n};\n"],"names":["loadTemplate","container","sourcecontainer","querySelector","selectors","mustachesource","contextcontainer","mustachecontext","templateName","dataset","template","context","mustacherawcontext","textContent","parts","split","request","methodname","args","component","shift","join","themename","Config","theme","includecomments","call","done","source","example","match","precontainer","document","createElement","innerHTML","JSON","stringify","parse","parentNode","appendChild","classList","add","async","e","debug","html","js","Templates","renderForPromise","rendercontainer","mustacherendered","replaceNodeContents","renderTemplate","fail","Notification","exception","querySelectorAll","mustachecode","forEach"],"mappings":";;;;;;;0VA8DMA,aAAeC,kBACPC,gBAAkBD,UAAUE,cAAcC,mBAAUC,gBACpDC,iBAAmBL,UAAUE,cAAcC,mBAAUG,iBACrDC,aAAeP,UAAUQ,QAAQC,aACnCC,QAAUV,UAAUE,cAAcC,mBAAUQ,oBAAoBC,kBAE9DC,MAAQN,aAAaO,MAAM,KAI3BC,QAAU,CACZC,WAAY,4BACZC,KAAM,CACFC,UANUL,MAAMM,QAOhBV,SANKI,MAAMO,KAAK,KAOhBC,UAAWC,gBAAOC,MAClBC,iBAAiB,kBAIpBC,KAAK,CAACV,UAAU,GAChBW,MAAMC,YAEH1B,gBAAgBW,YAAce,QACzBjB,QAAS,OACJkB,QAAUD,OAAOE,MAAM,2CAC7BnB,QAAUkB,QAAQ,SAEZE,aAAeC,SAASC,cAAc,OAC5CF,aAAaG,UAAYC,KAAKC,UAAUD,KAAKE,MAAM1B,SAAU,KAAM,GACnEL,iBAAiBgC,WAAWC,YAAYR,cACxCzB,iBAAiBkC,UAAUC,IAAI,UAtD5BC,OAAMzC,UAAWO,aAAcG,eAE9CA,QAAUwB,KAAKE,MAAM1B,SACvB,MAAOgC,gBACDC,MAAM,mEACNA,MAAMD,SAGRE,KAACA,KAADC,GAAOA,UAAYC,mBAAUC,iBAAiBxC,aAAcG,SAE5DsC,gBAAkBhD,UAAUE,cAAcC,mBAAU8C,wBAGpDH,mBAAUI,oBAAoBF,gBAAiBJ,KAAMC,KA2C/CM,CAAenD,UAAWO,aAAcG,YAE3C0C,KAAKC,sBAAaC,8BAQP,KACpBvB,SAASwB,iBAAiBpD,mBAAUqD,cAAcC,SAASzD,YACvDD,aAAaC"} \ No newline at end of file +{"version":3,"file":"mustache.min.js","sources":["../src/mustache.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Render mustache template examples within the component library.\n *\n * @module tool_componentlibrary/mustache\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport selectors from 'tool_componentlibrary/selectors';\nimport Ajax from 'core/ajax';\nimport Config from 'core/config';\nimport Templates from 'core/templates';\nimport Log from 'core/log';\nimport Notification from 'core/notification';\n\n/**\n * Handle a template loaded response.\n *\n * @method\n * @private\n * @param {String} container The template container\n * @param {String} templateName The template name\n * @param {String} context Data for the template.\n */\nconst renderTemplate = async(container, templateName, context) => {\n try {\n context = JSON.parse(context);\n } catch (e) {\n Log.debug('Could not parse json example context for template.');\n Log.debug(e);\n }\n\n const {html, js} = await Templates.renderForPromise(templateName, context);\n\n const rendercontainer = container.querySelector(selectors.mustacherendered);\n\n // Load the rendered content in the renderer tab.\n await Templates.replaceNodeContents(rendercontainer, html, js);\n};\n\n/**\n * Load the a template source from Moodle.\n *\n * @method\n * @private\n * @param {String} container The template container\n */\nconst loadTemplate = container => {\n const sourcecontainer = container.querySelector(selectors.mustachesource);\n const contextcontainer = container.querySelector(selectors.mustachecontext);\n const templateName = container.dataset.template;\n let context = container.querySelector(selectors.mustacherawcontext).textContent;\n\n const parts = templateName.split('/');\n const component = parts.shift();\n const name = parts.join('/');\n\n const request = {\n methodname: 'core_output_load_template',\n args: {\n component: component,\n template: name,\n themename: Config.theme,\n includecomments: true\n }\n };\n\n Ajax.call([request])[0]\n .done((source) => {\n // Load the source template in Template tab.\n sourcecontainer.textContent = source;\n if (!context) {\n const example = source.match(/Example context \\(json\\):([\\s\\S]+?)(}})/);\n context = example[1];\n // Load the variables in the Variables tab.\n const precontainer = document.createElement(\"pre\");\n precontainer.innerHTML = JSON.stringify(JSON.parse(context), null, 4);\n contextcontainer.parentNode.appendChild(precontainer);\n contextcontainer.classList.add('d-none');\n }\n renderTemplate(container, templateName, context);\n })\n .fail(Notification.exception);\n};\n\n/**\n * Initialize the module.\n *\n * @method\n */\nexport const mustache = () => {\n document.querySelectorAll(selectors.mustachecode).forEach((container) => {\n loadTemplate(container);\n });\n};\n"],"names":["_interopRequireDefault","obj","__esModule","default","_selectors","_ajax","_config","_templates","_log","_notification","loadTemplate","container","sourcecontainer","querySelector","selectors","mustachesource","contextcontainer","mustachecontext","templateName","dataset","template","context","mustacherawcontext","textContent","parts","split","request","methodname","args","component","shift","join","themename","Config","theme","includecomments","Ajax","call","done","source","example","match","precontainer","document","createElement","innerHTML","JSON","stringify","parse","parentNode","appendChild","classList","add","async","e","Log","debug","html","js","Templates","renderForPromise","rendercontainer","mustacherendered","replaceNodeContents","renderTemplate","fail","Notification","exception","_exports","mustache","querySelectorAll","mustachecode","forEach"],"mappings":"2OA4B6C,SAAAA,uBAAAC,KAAAA,OAAAA,KAAAA,IAAA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erD,UAAWO,aAAcG,QAAQ,IAEnD4C,KAAKC,cAAY/D,QAACgE,UAAU,EAYvCC,SAAAC,SAJsBA,KACpB1B,SAAS2B,iBAAiBxD,WAASX,QAACoE,cAAcC,SAAS7D,YACvDD,aAAaC,UAAU,GACzB,CACJ"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/search.min.js.map b/admin/tool/componentlibrary/amd/build/search.min.js.map index 82b9e5a4a44..17522e84591 100644 --- a/admin/tool/componentlibrary/amd/build/search.min.js.map +++ b/admin/tool/componentlibrary/amd/build/search.min.js.map @@ -1 +1 @@ -{"version":3,"file":"search.min.js","sources":["../src/search.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Interface to the Lunr search engines.\n *\n * @module tool_componentlibrary/search\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport lunrJs from 'tool_componentlibrary/lunr';\nimport selectors from 'tool_componentlibrary/selectors';\nimport Log from 'core/log';\nimport Notification from 'core/notification';\nimport {enter, escape} from 'core/key_codes';\n\nlet lunrIndex = null;\nlet pagesIndex = null;\n\n/**\n * Get the jsonFile that is generated when the component library is build.\n *\n * @method\n * @private\n * @param {String} jsonFile the URL to the json file.\n * @return {Object}\n */\nconst fetchJson = async(jsonFile) => {\n const response = await fetch(jsonFile);\n\n if (!response.ok) {\n Log.debug(`Error getting Hugo index file: ${response.status}`);\n }\n\n return await response.json();\n};\n\n/**\n * Initiate lunr on the data in the jsonFile and add the jsondata to the pagesIndex\n *\n * @method\n * @private\n * @param {String} jsonFile the URL to the json file.\n */\nconst initLunr = jsonFile => {\n fetchJson(jsonFile).then(jsondata => {\n pagesIndex = jsondata;\n // Using an arrow function here will break lunr on compile.\n lunrIndex = lunrJs(function() {\n this.ref('uri');\n this.field('title', {boost: 10});\n this.field('content');\n this.field('tags', {boost: 5});\n jsondata.forEach(p => {\n this.add(p);\n });\n });\n return null;\n }).catch(Notification.exception);\n};\n\n/**\n * Setup the eventlistener to listen on user input on the search field.\n *\n * @method\n * @private\n */\nconst initUI = () => {\n const searchInput = document.querySelector(selectors.searchinput);\n searchInput.addEventListener('keyup', e => {\n const query = e.currentTarget.value;\n if (query.length < 2) {\n document.querySelector(selectors.dropdownmenu).classList.remove('show');\n return;\n }\n renderResults(searchIndex(query));\n });\n searchInput.addEventListener('keydown', e => {\n if (e.keyCode === enter) {\n e.preventDefault();\n }\n if (e.keyCode === escape) {\n searchInput.value = '';\n }\n });\n};\n\n/**\n * Trigger a search in lunr and transform the result.\n *\n * @method\n * @private\n * @param {String} query\n * @return {Array} results\n */\nconst searchIndex = query => {\n // Find the item in our index corresponding to the lunr one to have more info\n // Lunr result:\n // {ref: \"/section/page1\", score: 0.2725657778206127}\n // Our result:\n // {title:\"Page1\", href:\"/section/page1\", ...}\n\n return lunrIndex.search(query + ' ' + query + '*').map(result => {\n return pagesIndex.filter(page => {\n return page.uri === result.ref;\n })[0];\n });\n};\n\n/**\n * Display the 10 first results\n *\n * @method\n * @private\n * @param {Array} results to display\n */\nconst renderResults = results => {\n const dropdownMenu = document.querySelector(selectors.dropdownmenu);\n if (!results.length) {\n dropdownMenu.classList.remove('show');\n return;\n }\n\n // Clear out the results.\n dropdownMenu.innerHTML = '';\n\n const baseUrl = M.cfg.wwwroot + '/admin/tool/componentlibrary/docspage.php';\n\n // Only show the ten first results\n results.slice(0, 10).forEach(function(result) {\n const link = document.createElement(\"a\");\n const chapter = result.uri.split('/')[1];\n link.appendChild(document.createTextNode(`${chapter} > ${result.title}`));\n link.classList.add('dropdown-item');\n link.href = baseUrl + result.uri;\n\n dropdownMenu.appendChild(link);\n });\n\n dropdownMenu.classList.add('show');\n};\n\n/**\n * Initialize module.\n *\n * @method\n * @param {String} jsonFile Full path to the search DB json file.\n */\nexport const search = jsonFile => {\n initLunr(jsonFile);\n initUI();\n};\n"],"names":["lunrIndex","pagesIndex","initLunr","jsonFile","async","response","fetch","ok","debug","status","json","fetchJson","then","jsondata","ref","field","boost","forEach","p","add","catch","Notification","exception","searchIndex","query","search","map","result","filter","page","uri","renderResults","results","dropdownMenu","document","querySelector","selectors","dropdownmenu","length","classList","remove","innerHTML","baseUrl","M","cfg","wwwroot","slice","link","createElement","chapter","split","appendChild","createTextNode","title","href","searchInput","searchinput","addEventListener","e","currentTarget","value","keyCode","enter","preventDefault","escape","initUI"],"mappings":";;;;;;;gQA6BIA,UAAY,KACZC,WAAa,WA2BXC,SAAWC,WAjBCC,OAAAA,iBACRC,eAAiBC,MAAMH,iBAExBE,SAASE,iBACNC,+CAAwCH,SAASI,eAG5CJ,SAASK,QAWtBC,CAAUR,UAAUS,MAAKC,WACrBZ,WAAaY,SAEbb,WAAY,kBAAO,gBACVc,IAAI,YACJC,MAAM,QAAS,CAACC,MAAO,UACvBD,MAAM,gBACNA,MAAM,OAAQ,CAACC,MAAO,IAC3BH,SAASI,SAAQC,SACRC,IAAID,SAGV,QACRE,MAAMC,sBAAaC,YAqCpBC,YAAcC,OAOTxB,UAAUyB,OAAOD,MAAQ,IAAMA,MAAQ,KAAKE,KAAIC,QAC5C1B,WAAW2B,QAAOC,MACdA,KAAKC,MAAQH,OAAOb,MAC5B,KAWLiB,cAAgBC,gBACZC,aAAeC,SAASC,cAAcC,mBAAUC,kBACjDL,QAAQM,mBACTL,aAAaM,UAAUC,OAAO,QAKlCP,aAAaQ,UAAY,SAEnBC,QAAUC,EAAEC,IAAIC,QAAU,4CAGhCb,QAAQc,MAAM,EAAG,IAAI7B,SAAQ,SAASU,cAC5BoB,KAAOb,SAASc,cAAc,KAC9BC,QAAUtB,OAAOG,IAAIoB,MAAM,KAAK,GACtCH,KAAKI,YAAYjB,SAASkB,yBAAkBH,sBAAatB,OAAO0B,SAChEN,KAAKR,UAAUpB,IAAI,iBACnB4B,KAAKO,KAAOZ,QAAUf,OAAOG,IAE7BG,aAAakB,YAAYJ,SAG7Bd,aAAaM,UAAUpB,IAAI,yBASThB,WAClBD,SAASC,UAlFE,YACLoD,YAAcrB,SAASC,cAAcC,mBAAUoB,aACrDD,YAAYE,iBAAiB,SAASC,UAC5BlC,MAAQkC,EAAEC,cAAcC,MAC1BpC,MAAMc,OAAS,EACfJ,SAASC,cAAcC,mBAAUC,cAAcE,UAAUC,OAAO,QAGpET,cAAcR,YAAYC,WAE9B+B,YAAYE,iBAAiB,WAAWC,IAChCA,EAAEG,UAAYC,kBACdJ,EAAEK,iBAEFL,EAAEG,UAAYG,oBACdT,YAAYK,MAAQ,QAoE5BK"} \ No newline at end of file +{"version":3,"file":"search.min.js","sources":["../src/search.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Interface to the Lunr search engines.\n *\n * @module tool_componentlibrary/search\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport lunrJs from 'tool_componentlibrary/lunr';\nimport selectors from 'tool_componentlibrary/selectors';\nimport Log from 'core/log';\nimport Notification from 'core/notification';\nimport {enter, escape} from 'core/key_codes';\n\nlet lunrIndex = null;\nlet pagesIndex = null;\n\n/**\n * Get the jsonFile that is generated when the component library is build.\n *\n * @method\n * @private\n * @param {String} jsonFile the URL to the json file.\n * @return {Object}\n */\nconst fetchJson = async(jsonFile) => {\n const response = await fetch(jsonFile);\n\n if (!response.ok) {\n Log.debug(`Error getting Hugo index file: ${response.status}`);\n }\n\n return await response.json();\n};\n\n/**\n * Initiate lunr on the data in the jsonFile and add the jsondata to the pagesIndex\n *\n * @method\n * @private\n * @param {String} jsonFile the URL to the json file.\n */\nconst initLunr = jsonFile => {\n fetchJson(jsonFile).then(jsondata => {\n pagesIndex = jsondata;\n // Using an arrow function here will break lunr on compile.\n lunrIndex = lunrJs(function() {\n this.ref('uri');\n this.field('title', {boost: 10});\n this.field('content');\n this.field('tags', {boost: 5});\n jsondata.forEach(p => {\n this.add(p);\n });\n });\n return null;\n }).catch(Notification.exception);\n};\n\n/**\n * Setup the eventlistener to listen on user input on the search field.\n *\n * @method\n * @private\n */\nconst initUI = () => {\n const searchInput = document.querySelector(selectors.searchinput);\n searchInput.addEventListener('keyup', e => {\n const query = e.currentTarget.value;\n if (query.length < 2) {\n document.querySelector(selectors.dropdownmenu).classList.remove('show');\n return;\n }\n renderResults(searchIndex(query));\n });\n searchInput.addEventListener('keydown', e => {\n if (e.keyCode === enter) {\n e.preventDefault();\n }\n if (e.keyCode === escape) {\n searchInput.value = '';\n }\n });\n};\n\n/**\n * Trigger a search in lunr and transform the result.\n *\n * @method\n * @private\n * @param {String} query\n * @return {Array} results\n */\nconst searchIndex = query => {\n // Find the item in our index corresponding to the lunr one to have more info\n // Lunr result:\n // {ref: \"/section/page1\", score: 0.2725657778206127}\n // Our result:\n // {title:\"Page1\", href:\"/section/page1\", ...}\n\n return lunrIndex.search(query + ' ' + query + '*').map(result => {\n return pagesIndex.filter(page => {\n return page.uri === result.ref;\n })[0];\n });\n};\n\n/**\n * Display the 10 first results\n *\n * @method\n * @private\n * @param {Array} results to display\n */\nconst renderResults = results => {\n const dropdownMenu = document.querySelector(selectors.dropdownmenu);\n if (!results.length) {\n dropdownMenu.classList.remove('show');\n return;\n }\n\n // Clear out the results.\n dropdownMenu.innerHTML = '';\n\n const baseUrl = M.cfg.wwwroot + '/admin/tool/componentlibrary/docspage.php';\n\n // Only show the ten first results\n results.slice(0, 10).forEach(function(result) {\n const link = document.createElement(\"a\");\n const chapter = result.uri.split('/')[1];\n link.appendChild(document.createTextNode(`${chapter} > ${result.title}`));\n link.classList.add('dropdown-item');\n link.href = baseUrl + result.uri;\n\n dropdownMenu.appendChild(link);\n });\n\n dropdownMenu.classList.add('show');\n};\n\n/**\n * Initialize module.\n *\n * @method\n * @param {String} jsonFile Full path to the search DB json file.\n */\nexport const search = jsonFile => {\n initLunr(jsonFile);\n initUI();\n};\n"],"names":["_interopRequireDefault","obj","__esModule","default","_lunr","_selectors","_log","_notification","lunrIndex","pagesIndex","initLunr","jsonFile","async","response","fetch","ok","Log","debug","concat","status","json","fetchJson","then","jsondata","lunrJs","this","ref","field","boost","forEach","p","add","catch","Notification","exception","searchIndex","query","search","map","result","filter","page","uri","renderResults","results","dropdownMenu","document","querySelector","selectors","dropdownmenu","length","classList","remove","innerHTML","baseUrl","M","cfg","wwwroot","slice","link","createElement","chapter","split","appendChild","createTextNode","title","href","_exports","initUI","searchInput","searchinput","addEventListener","e","currentTarget","value","keyCode","enter","preventDefault","escape"],"mappings":"oOA0B6C,SAAAA,uBAAAC,KAAAA,OAAAA,KAAAA,IAAAC,WAAAD,IAAAE,CAAAA,QAAAF,IAAA;;;;;;;oFAH7CG,MAAAJ,uBAAAI,OACAC,WAAAL,uBAAAK,YACAC,KAAAN,uBAAAM,MACAC,cAAAP,uBAAAO,eAGA,IAAIC,UAAY,KACZC,WAAa,KAUjB,MAiBMC,SAAWC,WAjBCC,kBACd,MAAMC,eAAiBC,MAAMH,UAM7B,OAJKE,SAASE,IACVC,KAAGb,QAACc,MAAKC,kCAAAA,OAAmCL,SAASM,eAG5CN,SAASO,MAAM,EAW5BC,CAAUV,UAAUW,MAAKC,WACrBd,WAAac,SAEbf,WAAY,E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AEK,iBAEFL,EAAEG,UAAYG,oBACdT,YAAYK,MAAQ,GACxB,GACF,EAkEFN,EAAQ,CACV"} \ No newline at end of file diff --git a/admin/tool/componentlibrary/amd/build/selectors.min.js.map b/admin/tool/componentlibrary/amd/build/selectors.min.js.map index 3f14335b2e2..ff89c1dacad 100644 --- a/admin/tool/componentlibrary/amd/build/selectors.min.js.map +++ b/admin/tool/componentlibrary/amd/build/selectors.min.js.map @@ -1 +1 @@ -{"version":3,"file":"selectors.min.js","sources":["../src/selectors.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Selectors for the component library\n *\n * @module tool_componentlibrary/selectors\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n /**\n * A selector relating to the 'Copy to clipboard' button.\n *\n * @type {string}\n */\n clipboardbutton: '.btn-clipboard',\n\n /**\n * A selector relating to the content copied by the 'Copy to clipboard' button.\n *\n * @type {string}\n */\n clipboardcontent: 'figure.highlight, div.highlight',\n\n /**\n * A selector relating to the 'Search' text input.\n *\n * @type {string}\n */\n searchinput: '[data-region=\"docsearch\"] input',\n\n /**\n * A selector relating to the 'Search' submit btton.\n *\n * @type {string}\n */\n searchsubmit: '[data-region=\"docsearch\"] .btn-submit',\n\n /**\n * A selector relating to the search dropdown menu.\n *\n * @type {string}\n */\n dropdownmenu: '[data-region=\"docsearch\"] .dropdown-menu',\n\n /**\n * A selector relating to the entire Component Library content region.\n *\n * @type {string}\n */\n componentlibrary: '[data-region=\"componentlibrary\"]',\n\n /**\n * A selector relating to JS Code which is to be run for examples to function.\n *\n * @type {string}\n */\n jscode: '[data-action=\"runjs\"]',\n\n /**\n * A selector relating to Mustache Template code regions.\n *\n * @type {string}\n */\n mustachecode: '[data-region=\"mustachecode\"]',\n\n /**\n * A selector relating to raw Mustache content regions.\n *\n * @type {string}\n */\n mustacherawcontext: '[data-region=\"rawcontext\"]',\n\n /**\n * A selector relating to rendered Mustache content regions.\n *\n * @type {string}\n */\n mustacherendered: '[data-region=\"mustacherendered\"]',\n\n /**\n * A selector relating to Mustache source code regions.\n *\n * @type {string}\n */\n mustachesource: '[data-region=\"mustachesource\"]',\n\n /**\n * A selector relating to Mustache context regions.\n *\n * @type {string}\n */\n mustachecontext: '[data-region=\"mustachecontext\"]',\n};\n"],"names":["clipboardbutton","clipboardcontent","searchinput","searchsubmit","dropdownmenu","componentlibrary","jscode","mustachecode","mustacherawcontext","mustacherendered","mustachesource","mustachecontext"],"mappings":"iLAsBe,CAMXA,gBAAiB,iBAOjBC,iBAAkB,kCAOlBC,YAAa,kCAObC,aAAc,wCAOdC,aAAc,2CAOdC,iBAAkB,mCAOlBC,OAAQ,wBAORC,aAAc,+BAOdC,mBAAoB,6BAOpBC,iBAAkB,mCAOlBC,eAAgB,iCAOhBC,gBAAiB"} \ No newline at end of file +{"version":3,"file":"selectors.min.js","sources":["../src/selectors.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Selectors for the component library\n *\n * @module tool_componentlibrary/selectors\n * @copyright 2021 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n /**\n * A selector relating to the 'Copy to clipboard' button.\n *\n * @type {string}\n */\n clipboardbutton: '.btn-clipboard',\n\n /**\n * A selector relating to the content copied by the 'Copy to clipboard' button.\n *\n * @type {string}\n */\n clipboardcontent: 'figure.highlight, div.highlight',\n\n /**\n * A selector relating to the 'Search' text input.\n *\n * @type {string}\n */\n searchinput: '[data-region=\"docsearch\"] input',\n\n /**\n * A selector relating to the 'Search' submit btton.\n *\n * @type {string}\n */\n searchsubmit: '[data-region=\"docsearch\"] .btn-submit',\n\n /**\n * A selector relating to the search dropdown menu.\n *\n * @type {string}\n */\n dropdownmenu: '[data-region=\"docsearch\"] .dropdown-menu',\n\n /**\n * A selector relating to the entire Component Library content region.\n *\n * @type {string}\n */\n componentlibrary: '[data-region=\"componentlibrary\"]',\n\n /**\n * A selector relating to JS Code which is to be run for examples to function.\n *\n * @type {string}\n */\n jscode: '[data-action=\"runjs\"]',\n\n /**\n * A selector relating to Mustache Template code regions.\n *\n * @type {string}\n */\n mustachecode: '[data-region=\"mustachecode\"]',\n\n /**\n * A selector relating to raw Mustache content regions.\n *\n * @type {string}\n */\n mustacherawcontext: '[data-region=\"rawcontext\"]',\n\n /**\n * A selector relating to rendered Mustache content regions.\n *\n * @type {string}\n */\n mustacherendered: '[data-region=\"mustacherendered\"]',\n\n /**\n * A selector relating to Mustache source code regions.\n *\n * @type {string}\n */\n mustachesource: '[data-region=\"mustachesource\"]',\n\n /**\n * A selector relating to Mustache context regions.\n *\n * @type {string}\n */\n mustachecontext: '[data-region=\"mustachecontext\"]',\n};\n"],"names":["_exports","default","clipboardbutton","clipboardcontent","searchinput","searchsubmit","dropdownmenu","componentlibrary","jscode","mustachecode","mustacherawcontext","mustacherendered","mustachesource","mustachecontext"],"mappings":"yJA0GC,OAAAA,SAAAC,QApFc,CAMXC,gBAAiB,iBAOjBC,iBAAkB,kCAOlBC,YAAa,kCAObC,aAAc,wCAOdC,aAAc,2CAOdC,iBAAkB,mCAOlBC,OAAQ,wBAORC,aAAc,+BAOdC,mBAAoB,6BAOpBC,iBAAkB,mCAOlBC,eAAgB,iCAOhBC,gBAAiB,mCACpBb,SAAAC,OAAA"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/add_category.min.js.map b/admin/tool/dataprivacy/amd/build/add_category.min.js.map index 2ee9d89dc99..cef834a5efd 100644 --- a/admin/tool/dataprivacy/amd/build/add_category.min.js.map +++ b/admin/tool/dataprivacy/amd/build/add_category.min.js.map @@ -1 +1 @@ -{"version":3,"file":"add_category.min.js","sources":["../src/add_category.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to add categories.\n *\n * @module tool_dataprivacy/add_category\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/ajax',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/fragment',\n 'core_form/changechecker',\n], function(\n $,\n Str,\n Ajax,\n Notification,\n ModalFactory,\n ModalEvents,\n Fragment,\n FormChangeChecker\n) {\n\n var SELECTORS = {\n CATEGORY_LINK: '[data-add-element=\"category\"]',\n };\n\n var AddCategory = function(contextId) {\n this.contextId = contextId;\n\n var stringKeys = [\n {\n key: 'addcategory',\n component: 'tool_dataprivacy'\n },\n {\n key: 'save',\n component: 'admin'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n };\n\n /**\n * @var {int} contextId\n * @private\n */\n AddCategory.prototype.contextId = 0;\n\n /**\n * @var {Promise}\n * @private\n */\n AddCategory.prototype.strings = 0;\n\n AddCategory.prototype.registerEventListeners = function() {\n\n var trigger = $(SELECTORS.CATEGORY_LINK);\n trigger.on('click', function() {\n return this.strings.then(function(strings) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: strings[0],\n body: '',\n }, trigger).done(function(modal) {\n this.setupFormModal(modal, strings[1]);\n }.bind(this));\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this));\n\n };\n\n /**\n * @method getBody\n * @param {Object} formdata\n * @private\n * @return {Promise}\n */\n AddCategory.prototype.getBody = function(formdata) {\n\n var params = null;\n if (typeof formdata !== \"undefined\") {\n params = {jsonformdata: JSON.stringify(formdata)};\n }\n // Get the content of the modal.\n return Fragment.loadFragment('tool_dataprivacy', 'addcategory_form', this.contextId, params);\n };\n\n AddCategory.prototype.setupFormModal = function(modal, saveText) {\n modal.setLarge();\n\n modal.setSaveButtonText(saveText);\n\n // We want to reset the form every time it is opened.\n modal.getRoot().on(ModalEvents.hidden, this.destroy.bind(this));\n\n modal.setBody(this.getBody());\n\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n\n this.modal = modal;\n\n modal.show();\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n AddCategory.prototype.submitForm = function(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n AddCategory.prototype.submitFormAjax = function(e) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = this.modal.getRoot().find('form').serialize();\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_create_category_form',\n args: {jsonformdata: JSON.stringify(formData)},\n done: function(data) {\n if (data.validationerrors) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.close();\n }\n }.bind(this),\n fail: Notification.exception\n }]);\n };\n\n AddCategory.prototype.close = function() {\n this.destroy();\n document.location.reload();\n };\n\n AddCategory.prototype.destroy = function() {\n FormChangeChecker.resetAllFormDirtyStates();\n this.modal.destroy();\n };\n\n AddCategory.prototype.removeListeners = function() {\n $(SELECTORS.CATEGORY_LINK).off('click');\n };\n\n return /** @alias module:tool_dataprivacy/add_category */ {\n getInstance: function(contextId) {\n return new AddCategory(contextId);\n }\n };\n }\n);\n\n"],"names":["define","$","Str","Ajax","Notification","ModalFactory","ModalEvents","Fragment","FormChangeChecker","SELECTORS","AddCategory","contextId","strings","get_strings","key","component","registerEventListeners","prototype","trigger","on","this","then","create","type","types","SAVE_CANCEL","title","body","done","modal","setupFormModal","bind","fail","exception","getBody","formdata","params","jsonformdata","JSON","stringify","loadFragment","saveText","setLarge","setSaveButtonText","getRoot","hidden","destroy","setBody","save","submitForm","submitFormAjax","show","e","preventDefault","find","submit","formData","serialize","call","methodname","args","data","validationerrors","close","document","location","reload","resetAllFormDirtyStates","removeListeners","off","getInstance"],"mappings":";;;;;;;AAsBAA,uCAAO,CACH,SACA,WACA,YACA,oBACA,qBACA,oBACA,gBACA,4BACD,SACCC,EACAC,IACAC,KACAC,aACAC,aACAC,YACAC,SACAC,uBAGQC,wBACe,gCAGfC,YAAc,SAASC,gBAClBA,UAAYA,eAYZC,QAAUV,IAAIW,YAVF,CACb,CACIC,IAAK,cACLC,UAAW,oBAEf,CACID,IAAK,OACLC,UAAW,gBAKdC,iCAOTN,YAAYO,UAAUN,UAAY,EAMlCD,YAAYO,UAAUL,QAAU,EAEhCF,YAAYO,UAAUD,uBAAyB,eAEvCE,QAAUjB,EAAEQ,yBAChBS,QAAQC,GAAG,QAAS,kBACTC,KAAKR,QAAQS,KAAK,SAAST,SAC9BP,aAAaiB,OAAO,CAChBC,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fpC,YAAYO,UAAUmD,gBAAkB,WACpCnE,EAAEQ,yBAAyB4D,IAAI,UAGuB,CACtDC,YAAa,SAAS3D,kBACX,IAAID,YAAYC"} \ No newline at end of file +{"version":3,"file":"add_category.min.js","sources":["../src/add_category.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to add categories.\n *\n * @module tool_dataprivacy/add_category\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/ajax',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/fragment',\n 'core_form/changechecker',\n], function(\n $,\n Str,\n Ajax,\n Notification,\n ModalFactory,\n ModalEvents,\n Fragment,\n FormChangeChecker\n) {\n\n var SELECTORS = {\n CATEGORY_LINK: '[data-add-element=\"category\"]',\n };\n\n var AddCategory = function(contextId) {\n this.contextId = contextId;\n\n var stringKeys = [\n {\n key: 'addcategory',\n component: 'tool_dataprivacy'\n },\n {\n key: 'save',\n component: 'admin'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n };\n\n /**\n * @var {int} contextId\n * @private\n */\n AddCategory.prototype.contextId = 0;\n\n /**\n * @var {Promise}\n * @private\n */\n AddCategory.prototype.strings = 0;\n\n AddCategory.prototype.registerEventListeners = function() {\n\n var trigger = $(SELECTORS.CATEGORY_LINK);\n trigger.on('click', function() {\n return this.strings.then(function(strings) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: strings[0],\n body: '',\n }, trigger).done(function(modal) {\n this.setupFormModal(modal, strings[1]);\n }.bind(this));\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this));\n\n };\n\n /**\n * @method getBody\n * @param {Object} formdata\n * @private\n * @return {Promise}\n */\n AddCategory.prototype.getBody = function(formdata) {\n\n var params = null;\n if (typeof formdata !== \"undefined\") {\n params = {jsonformdata: JSON.stringify(formdata)};\n }\n // Get the content of the modal.\n return Fragment.loadFragment('tool_dataprivacy', 'addcategory_form', this.contextId, params);\n };\n\n AddCategory.prototype.setupFormModal = function(modal, saveText) {\n modal.setLarge();\n\n modal.setSaveButtonText(saveText);\n\n // We want to reset the form every time it is opened.\n modal.getRoot().on(ModalEvents.hidden, this.destroy.bind(this));\n\n modal.setBody(this.getBody());\n\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n\n this.modal = modal;\n\n modal.show();\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n AddCategory.prototype.submitForm = function(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n AddCategory.prototype.submitFormAjax = function(e) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = this.modal.getRoot().find('form').serialize();\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_create_category_form',\n args: {jsonformdata: JSON.stringify(formData)},\n done: function(data) {\n if (data.validationerrors) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.close();\n }\n }.bind(this),\n fail: Notification.exception\n }]);\n };\n\n AddCategory.prototype.close = function() {\n this.destroy();\n document.location.reload();\n };\n\n AddCategory.prototype.destroy = function() {\n FormChangeChecker.resetAllFormDirtyStates();\n this.modal.destroy();\n };\n\n AddCategory.prototype.removeListeners = function() {\n $(SELECTORS.CATEGORY_LINK).off('click');\n };\n\n return /** @alias module:tool_dataprivacy/add_category */ {\n getInstance: function(contextId) {\n return new AddCategory(contextId);\n }\n };\n }\n);\n\n"],"names":["define","$","Str","Ajax","Notification","ModalFactory","ModalEvents","Fragment","FormChangeChecker","SELECTORS","AddCategory","contextId","this","strings","get_strings","key","component","registerEventListeners","prototype","trigger","on","then","create","type","types","SAVE_CANCEL","title","body","done","modal","setupFormModal","bind","fail","exception","getBody","formdata","params","jsonformdata","JSON","stringify","loadFragment","saveText","setLarge","setSaveButtonText","getRoot","hidden","destroy","setBody","save","submitForm","submitFormAjax","show","e","preventDefault","find","submit","formData","serialize","call","methodname","args","data","validationerrors","close","document","location","reload","resetAllFormDirtyStates","removeListeners","off","getInstance"],"mappings":";;;;;;;AAsBAA,OAAO,gCAAA,CACH,SACA,WACA,YACA,oBACA,qBACA,oBACA,gBACA,4BACD,SACCC,EACAC,IACAC,KACAC,aACAC,aACAC,YACAC,SACAC,mBAGI,IAAIC,wBACe,gCAGfC,YAAc,SAASC,WACvBC,KAAKD,UAAYA,UAYjBC,KAAKC,QAAUX,IAAIY,YAVF,CACb,CACIC,IAAK,cACLC,UAAW,oBAEf,CACID,IAAK,OACLC,UAAW,WAKnBJ,KAAKK,0BAqHT,OA9GAP,YAAYQ,UAAUP,UAAY,EAMlCD,YAAYQ,UAAUL,QAAU,EAEhCH,YAAYQ,UAAUD,uBAAyB,WAE3C,IAAIE,QAAUlB,EAAEQ,yBAChBU,QAAQC,GAAG,QAAS,WAChB,OAAOR,KAAKC,QAAQQ,KAAK,SAASR,SAC9BR,aAAaiB,OAAO,CAChBC,KAAMlB,aAAamB,MAAMC,YACzBC,MAAOb,QAAQ,GACfc,KAAM,IACPR,SAASS,KAAK,SAASC,OACtBjB,KAAKkB,eAAeD,MAAOhB,QAAQ,GACvC,EAAEkB,KAAKnB,MACX,EAAEmB,KA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pCnE,EAAEQ,yBAAyB4D,IAAI,UAGuB,CACtDC,YAAa,SAAS3D,WAClB,OAAO,IAAID,YAAYC,UAC3B,EAER"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/add_purpose.min.js.map b/admin/tool/dataprivacy/amd/build/add_purpose.min.js.map index 6b9b9f5b460..4169faa6e5c 100644 --- a/admin/tool/dataprivacy/amd/build/add_purpose.min.js.map +++ b/admin/tool/dataprivacy/amd/build/add_purpose.min.js.map @@ -1 +1 @@ -{"version":3,"file":"add_purpose.min.js","sources":["../src/add_purpose.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to add purposes.\n *\n * @module tool_dataprivacy/add_purpose\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/ajax',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/fragment',\n 'core_form/changechecker',\n], function(\n $,\n Str,\n Ajax,\n Notification,\n ModalFactory,\n ModalEvents,\n Fragment,\n FormChangeChecker\n) {\n\n var SELECTORS = {\n PURPOSE_LINK: '[data-add-element=\"purpose\"]',\n };\n\n var AddPurpose = function(contextId) {\n this.contextId = contextId;\n\n var stringKeys = [\n {\n key: 'addpurpose',\n component: 'tool_dataprivacy'\n },\n {\n key: 'save',\n component: 'admin'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n };\n\n /**\n * @var {int} contextId\n * @private\n */\n AddPurpose.prototype.contextId = 0;\n\n /**\n * @var {Promise}\n * @private\n */\n AddPurpose.prototype.strings = 0;\n\n AddPurpose.prototype.registerEventListeners = function() {\n\n var trigger = $(SELECTORS.PURPOSE_LINK);\n trigger.on('click', function() {\n return this.strings.then(function(strings) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: strings[0],\n body: '',\n }, trigger).done(function(modal) {\n this.setupFormModal(modal, strings[1]);\n }.bind(this));\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this));\n\n };\n\n /**\n * @method getBody\n * @param {Object} formdata\n * @private\n * @return {Promise}\n */\n AddPurpose.prototype.getBody = function(formdata) {\n\n var params = null;\n if (typeof formdata !== \"undefined\") {\n params = {jsonformdata: JSON.stringify(formdata)};\n }\n // Get the content of the modal.\n return Fragment.loadFragment('tool_dataprivacy', 'addpurpose_form', this.contextId, params);\n };\n\n AddPurpose.prototype.setupFormModal = function(modal, saveText) {\n modal.setLarge();\n\n modal.setSaveButtonText(saveText);\n\n // We want to reset the form every time it is opened.\n modal.getRoot().on(ModalEvents.hidden, this.destroy.bind(this));\n\n modal.setBody(this.getBody());\n\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n\n this.modal = modal;\n\n modal.show();\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n AddPurpose.prototype.submitForm = function(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n AddPurpose.prototype.submitFormAjax = function(e) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = this.modal.getRoot().find('form').serialize();\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_create_purpose_form',\n args: {jsonformdata: JSON.stringify(formData)},\n done: function(data) {\n if (data.validationerrors) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.close();\n }\n }.bind(this),\n\n fail: Notification.exception\n }]);\n };\n\n AddPurpose.prototype.close = function() {\n this.destroy();\n document.location.reload();\n };\n\n AddPurpose.prototype.destroy = function() {\n FormChangeChecker.resetAllFormDirtyStates();\n this.modal.destroy();\n };\n\n AddPurpose.prototype.removeListeners = function() {\n $(SELECTORS.PURPOSE_LINK).off('click');\n };\n\n return /** @alias module:tool_dataprivacy/add_purpose */ {\n getInstance: function(contextId) {\n return new AddPurpose(contextId);\n }\n };\n }\n);\n\n"],"names":["define","$","Str","Ajax","Notification","ModalFactory","ModalEvents","Fragment","FormChangeChecker","SELECTORS","AddPurpose","contextId","strings","get_strings","key","component","registerEventListeners","prototype","trigger","on","this","then","create","type","types","SAVE_CANCEL","title","body","done","modal","setupFormModal","bind","fail","exception","getBody","formdata","params","jsonformdata","JSON","stringify","loadFragment","saveText","setLarge","setSaveButtonText","getRoot","hidden","destroy","setBody","save","submitForm","submitFormAjax","show","e","preventDefault","find","submit","formData","serialize","call","methodname","args","data","validationerrors","close","document","location","reload","resetAllFormDirtyStates","removeListeners","off","getInstance"],"mappings":";;;;;;;AAsBAA,sCAAO,CACH,SACA,WACA,YACA,oBACA,qBACA,oBACA,gBACA,4BACD,SACCC,EACAC,IACAC,KACAC,aACAC,aACAC,YACAC,SACAC,uBAGQC,uBACc,+BAGdC,WAAa,SAASC,gBACjBA,UAAYA,eAYZC,QAAUV,IAAIW,YAVF,CACb,CACIC,IAAK,aACLC,UAAW,oBAEf,CACID,IAAK,OACLC,UAAW,gBAKdC,iCAOTN,WAAWO,UAAUN,UAAY,EAMjCD,WAAWO,UAAUL,QAAU,EAE/BF,WAAWO,UAAUD,uBAAyB,eAEtCE,QAAUjB,EAAEQ,wBAChBS,QAAQC,GAAG,QAAS,kBACTC,KAAKR,QAAQS,KAAK,SAAST,SAC9BP,aAAaiB,OAAO,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MiB,WAGfpC,WAAWO,UAAUmD,gBAAkB,WACnCnE,EAAEQ,wBAAwB4D,IAAI,UAGuB,CACrDC,YAAa,SAAS3D,kBACX,IAAID,WAAWC"} \ No newline at end of file +{"version":3,"file":"add_purpose.min.js","sources":["../src/add_purpose.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to add purposes.\n *\n * @module tool_dataprivacy/add_purpose\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/ajax',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/fragment',\n 'core_form/changechecker',\n], function(\n $,\n Str,\n Ajax,\n Notification,\n ModalFactory,\n ModalEvents,\n Fragment,\n FormChangeChecker\n) {\n\n var SELECTORS = {\n PURPOSE_LINK: '[data-add-element=\"purpose\"]',\n };\n\n var AddPurpose = function(contextId) {\n this.contextId = contextId;\n\n var stringKeys = [\n {\n key: 'addpurpose',\n component: 'tool_dataprivacy'\n },\n {\n key: 'save',\n component: 'admin'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n };\n\n /**\n * @var {int} contextId\n * @private\n */\n AddPurpose.prototype.contextId = 0;\n\n /**\n * @var {Promise}\n * @private\n */\n AddPurpose.prototype.strings = 0;\n\n AddPurpose.prototype.registerEventListeners = function() {\n\n var trigger = $(SELECTORS.PURPOSE_LINK);\n trigger.on('click', function() {\n return this.strings.then(function(strings) {\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: strings[0],\n body: '',\n }, trigger).done(function(modal) {\n this.setupFormModal(modal, strings[1]);\n }.bind(this));\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this));\n\n };\n\n /**\n * @method getBody\n * @param {Object} formdata\n * @private\n * @return {Promise}\n */\n AddPurpose.prototype.getBody = function(formdata) {\n\n var params = null;\n if (typeof formdata !== \"undefined\") {\n params = {jsonformdata: JSON.stringify(formdata)};\n }\n // Get the content of the modal.\n return Fragment.loadFragment('tool_dataprivacy', 'addpurpose_form', this.contextId, params);\n };\n\n AddPurpose.prototype.setupFormModal = function(modal, saveText) {\n modal.setLarge();\n\n modal.setSaveButtonText(saveText);\n\n // We want to reset the form every time it is opened.\n modal.getRoot().on(ModalEvents.hidden, this.destroy.bind(this));\n\n modal.setBody(this.getBody());\n\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n\n this.modal = modal;\n\n modal.show();\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n AddPurpose.prototype.submitForm = function(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n AddPurpose.prototype.submitFormAjax = function(e) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = this.modal.getRoot().find('form').serialize();\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_create_purpose_form',\n args: {jsonformdata: JSON.stringify(formData)},\n done: function(data) {\n if (data.validationerrors) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.close();\n }\n }.bind(this),\n\n fail: Notification.exception\n }]);\n };\n\n AddPurpose.prototype.close = function() {\n this.destroy();\n document.location.reload();\n };\n\n AddPurpose.prototype.destroy = function() {\n FormChangeChecker.resetAllFormDirtyStates();\n this.modal.destroy();\n };\n\n AddPurpose.prototype.removeListeners = function() {\n $(SELECTORS.PURPOSE_LINK).off('click');\n };\n\n return /** @alias module:tool_dataprivacy/add_purpose */ {\n getInstance: function(contextId) {\n return new AddPurpose(contextId);\n }\n };\n }\n);\n\n"],"names":["define","$","Str","Ajax","Notification","ModalFactory","ModalEvents","Fragment","FormChangeChecker","SELECTORS","AddPurpose","contextId","this","strings","get_strings","key","component","registerEventListeners","prototype","trigger","on","then","create","type","types","SAVE_CANCEL","title","body","done","modal","setupFormModal","bind","fail","exception","getBody","formdata","params","jsonformdata","JSON","stringify","loadFragment","saveText","setLarge","setSaveButtonText","getRoot","hidden","destroy","setBody","save","submitForm","submitFormAjax","show","e","preventDefault","find","submit","formData","serialize","call","methodname","args","data","validationerrors","close","document","location","reload","resetAllFormDirtyStates","removeListeners","off","getInstance"],"mappings":";;;;;;;AAsBAA,OAAO,+BAAA,CACH,SACA,WACA,YACA,oBACA,qBACA,oBACA,gBACA,4BACD,SACCC,EACAC,IACAC,KACAC,aACAC,aACAC,YACAC,SACAC,mBAGI,IAAIC,uBACc,+BAGdC,WAAa,SAASC,WACtBC,KAAKD,UAAYA,UAYjBC,KAAKC,QAAUX,IAAIY,YAVF,CACb,CACIC,IAAK,aACLC,UAAW,oBAEf,CACID,IAAK,OACLC,UAAW,WAKnBJ,KAAKK,0BAsHT,OA/GAP,WAAWQ,UAAUP,UAAY,EAMjCD,WAAWQ,UAAUL,QAAU,EAE/BH,WAAWQ,UAAUD,uBAAyB,WAE1C,IAAIE,QAAUlB,EAAEQ,wBAChBU,QAAQC,GAAG,QAAS,WAChB,OAAOR,KAAKC,QAAQQ,KAAK,SAASR,SAC9BR,aAAaiB,OAAO,CAChBC,KAAMlB,aAAamB,MAAMC,YACzBC,MAAOb,QAAQ,GACfc,KAAM,IACPR,SAASS,KAAK,SAASC,OACtBjB,KAAKkB,eAAeD,MAAOhB,Q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,MAAMiB,WAGfpC,WAAWQ,UAAUkD,gBAAkB,WACnCnE,EAAEQ,wBAAwB4D,IAAI,UAGuB,CACrDC,YAAa,SAAS3D,WAClB,OAAO,IAAID,WAAWC,UAC1B,EAER"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/categoriesactions.min.js.map b/admin/tool/dataprivacy/amd/build/categoriesactions.min.js.map index 683666ec3bb..4b3d57ffe59 100644 --- a/admin/tool/dataprivacy/amd/build/categoriesactions.min.js.map +++ b/admin/tool/dataprivacy/amd/build/categoriesactions.min.js.map @@ -1 +1 @@ -{"version":3,"file":"categoriesactions.min.js","sources":["../src/categoriesactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * AMD module for categories actions.\n *\n * @module tool_dataprivacy/categoriesactions\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{DELETE: string}}\n */\n var ACTIONS = {\n DELETE: '[data-action=\"deletecategory\"]',\n };\n\n /**\n * CategoriesActions class.\n */\n var CategoriesActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n CategoriesActions.prototype.registerEvents = function() {\n $(ACTIONS.DELETE).click(function(e) {\n e.preventDefault();\n\n var id = $(this).data('id');\n var categoryname = $(this).data('name');\n var stringkeys = [\n {\n key: 'deletecategory',\n component: 'tool_dataprivacy'\n },\n {\n key: 'deletecategorytext',\n component: 'tool_dataprivacy',\n param: categoryname\n },\n {\n key: 'delete'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langStrings) {\n var title = langStrings[0];\n var confirmMessage = langStrings[1];\n var buttonText = langStrings[2];\n return ModalFactory.create({\n title: title,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n }).then(function(modal) {\n modal.setSaveButtonText(buttonText);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n\n var request = {\n methodname: 'tool_dataprivacy_delete_category',\n args: {'id': id}\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n $('tr[data-categoryid=\"' + id + '\"]').remove();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n });\n }).done(function(modal) {\n modal.show();\n\n }).fail(Notification.exception);\n });\n };\n\n return /** @alias module:tool_dataprivacy/categoriesactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {CategoriesActions}\n */\n 'init': function() {\n return new CategoriesActions();\n }\n };\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","CategoriesActions","registerEvents","prototype","click","e","preventDefault","id","this","data","stringkeys","key","component","param","get_strings","then","langStrings","title","confirmMessage","buttonText","create","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","request","methodname","args","call","done","result","remove","addNotification","message","warnings","fail","exception","hidden","destroy","show"],"mappings":";;;;;;;AAsBAA,4CAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,sBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,iBAO3CC,eACQ,iCAMRC,kBAAoB,gBACfC,yBAMTD,kBAAkBE,UAAUD,eAAiB,WACzCR,EAAEM,gBAAgBI,OAAM,SAASC,GAC7BA,EAAEC,qBAEEC,GAAKb,EAAEc,MAAMC,KAAK,MAElBC,WAAa,CACb,CACIC,IAAK,iBACLC,UAAW,oBAEf,CACID,IAAK,qBACLC,UAAW,mBACXC,MATWnB,EAAEc,MAAMC,KAAK,SAW5B,CACIE,IAAK,WAIbd,IAAIiB,YAAYJ,YAAYK,MAAK,SAASC,iBAClCC,MAAQD,YAAY,GACpBE,eAAiBF,YAAY,GAC7BG,WAAaH,YAAY,UACtBlB,aAAasB,OAAO,CACvBH,MAAOA,MACPI,KAAMH,eACNI,KAAMxB,aAAayB,MAAMC,cAC1BT,MAAK,SAASU,cACbA,MAAMC,kBAAkBP,YAGxBM,MAAME,UAAUC,GAAG7B,YAAY8B,MAAM,eAE7BC,QAAU,CACVC,WAAY,mCACZC,KAAM,IAAOzB,KAGjBZ,KAAKsC,KAAK,CAACH,UAAU,GAAGI,MAAK,SAASzB,MAC9BA,KAAK0B,OACLzC,EAAE,uBAAyBa,GAAK,MAAM6B,SAEtCxC,aAAayC,gBAAgB,CACzBC,QAAS7B,KAAK8B,SAAS,GAAGD,QAC1BhB,KAAM,aAGfkB,KAAK5C,aAAa6C,cAIzBhB,MAAME,UAAUC,GAAG7B,YAAY2C,QAAQ,WAEnCjB,MAAMkB,aAGHlB,YAEZS,MAAK,SAAST,OACbA,MAAMmB,UAEPJ,KAAK5C,aAAa6C,eAIkC,MASnD,kBACG,IAAIxC"} \ No newline at end of file +{"version":3,"file":"categoriesactions.min.js","sources":["../src/categoriesactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * AMD module for categories actions.\n *\n * @module tool_dataprivacy/categoriesactions\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{DELETE: string}}\n */\n var ACTIONS = {\n DELETE: '[data-action=\"deletecategory\"]',\n };\n\n /**\n * CategoriesActions class.\n */\n var CategoriesActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n CategoriesActions.prototype.registerEvents = function() {\n $(ACTIONS.DELETE).click(function(e) {\n e.preventDefault();\n\n var id = $(this).data('id');\n var categoryname = $(this).data('name');\n var stringkeys = [\n {\n key: 'deletecategory',\n component: 'tool_dataprivacy'\n },\n {\n key: 'deletecategorytext',\n component: 'tool_dataprivacy',\n param: categoryname\n },\n {\n key: 'delete'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langStrings) {\n var title = langStrings[0];\n var confirmMessage = langStrings[1];\n var buttonText = langStrings[2];\n return ModalFactory.create({\n title: title,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n }).then(function(modal) {\n modal.setSaveButtonText(buttonText);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n\n var request = {\n methodname: 'tool_dataprivacy_delete_category',\n args: {'id': id}\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n $('tr[data-categoryid=\"' + id + '\"]').remove();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n });\n }).done(function(modal) {\n modal.show();\n\n }).fail(Notification.exception);\n });\n };\n\n return /** @alias module:tool_dataprivacy/categoriesactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {CategoriesActions}\n */\n 'init': function() {\n return new CategoriesActions();\n }\n };\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","CategoriesActions","this","registerEvents","prototype","click","e","preventDefault","id","data","stringkeys","key","component","param","get_strings","then","langStrings","title","confirmMessage","buttonText","create","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","request","methodname","args","call","done","result","remove","addNotification","message","warnings","fail","exception","hidden","destroy","show","init"],"mappings":";;;;;;;AAsBAA,OAAM,qCAAC,CACH,SACA,YACA,oBACA,WACA,qBACA,sBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,aAO/C,IAAIC,eACQ,iCAMRC,kBAAoB,WACpBC,KAAKC,kBAyET,OAnEAF,kBAAkBG,UAAUD,eAAiB,WACzCT,EAAEM,gBAAgBK,OAAM,SAASC,GAC7BA,EAAEC,iBAEF,IAAIC,GAAKd,EAAEQ,MAAMO,KAAK,MAElBC,WAAa,CACb,CACIC,IAAK,iBACLC,UAAW,oBAEf,CACID,IAAK,qBACLC,UAAW,mBACXC,MATWnB,EAAEQ,MAAMO,KAAK,SAW5B,CACIE,IAAK,WAIbd,IAAIiB,YAAYJ,YAAYK,MAAK,SAASC,aACtC,IAAIC,MAAQD,YAAY,GACpBE,eAAiBF,YAAY,GAC7BG,WAAaH,YAAY,GAC7B,OAAOlB,aAAasB,OAAO,CACvBH,MAAOA,MACPI,KAAMH,eACNI,KAAMxB,aAAayB,MAAMC,cAC1BT,MAAK,SAASU,OA6Bb,OA5BAA,MAAMC,kBAAkBP,YAGxBM,MAAME,UAAUC,GAAG7B,YAAY8B,MAAM,WAEjC,IAAIC,QAAU,CACVC,WAAY,mCACZC,KAAM,CAACxB,GAAMA,KAGjBb,KAAKsC,KAAK,CAACH,UAAU,GAAGI,MAAK,SAASzB,MAC9BA,KAAK0B,OACLzC,EAAE,uBAAyBc,GAAK,MAAM4B,SAEtCxC,aAAayC,gBAAgB,CACzBC,QAAS7B,KAAK8B,SAAS,GAAGD,QAC1BhB,KAAM,SAGjB,IAAEkB,KAAK5C,aAAa6C,UACzB,IAGAhB,MAAME,UAAUC,GAAG7B,YAAY2C,QAAQ,WAEnCjB,MAAMkB,SACV,IAEOlB,KACX,GACJ,IAAGS,MAAK,SAAST,OACbA,MAAMmB,MAET,IAAEJ,KAAK5C,aAAa6C,UACzB,KAG2D,CAS3DI,KAAQ,WACJ,OAAO,IAAI5C,iBACf,EAER"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/contactdpo.min.js.map b/admin/tool/dataprivacy/amd/build/contactdpo.min.js.map index 680d7bb355d..1d68f9e367f 100644 --- a/admin/tool/dataprivacy/amd/build/contactdpo.min.js.map +++ b/admin/tool/dataprivacy/amd/build/contactdpo.min.js.map @@ -1 +1 @@ -{"version":3,"file":"contactdpo.min.js","sources":["../src/contactdpo.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Javascript module for contacting the site DPO\n *\n * @module tool_dataprivacy/contactdpo\n * @copyright 2021 Paul Holden \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalForm from 'core_form/modalform';\nimport Notification from 'core/notification';\nimport {get_string as getString} from 'core/str';\nimport {add as addToast} from 'core/toast';\n\nconst SELECTORS = {\n CONTACT_DPO: '[data-action=\"contactdpo\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n const triggerElement = document.querySelector(SELECTORS.CONTACT_DPO);\n\n triggerElement.addEventListener('click', event => {\n event.preventDefault();\n\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('contactdataprotectionofficer', 'tool_dataprivacy'),\n },\n formClass: 'tool_dataprivacy\\\\form\\\\contactdpo',\n saveButtonText: getString('send', 'tool_dataprivacy'),\n returnFocus: triggerElement,\n });\n\n // Show a toast notification when the form is submitted.\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {\n if (event.detail.result) {\n getString('requestsubmitted', 'tool_dataprivacy').then(addToast).catch();\n } else {\n const warningMessages = event.detail.warnings.map(warning => warning.message);\n Notification.addNotification({\n type: 'error',\n message: warningMessages.join('
')\n });\n }\n });\n\n modalForm.show();\n });\n};\n"],"names":["SELECTORS","triggerElement","document","querySelector","addEventListener","event","preventDefault","modalForm","ModalForm","modalConfig","title","formClass","saveButtonText","returnFocus","events","FORM_SUBMITTED","detail","result","then","addToast","catch","warningMessages","warnings","map","warning","message","addNotification","type","join","show"],"mappings":";;;;;;;0LA4BMA,sBACW,2CAMG,WACVC,eAAiBC,SAASC,cAAcH,uBAE9CC,eAAeG,iBAAiB,SAASC,QACrCA,MAAMC,uBAEAC,UAAY,IAAIC,mBAAU,CAC5BC,YAAa,CACTC,OAAO,mBAAU,+BAAgC,qBAErDC,UAAW,qCACXC,gBAAgB,mBAAU,OAAQ,oBAClCC,YAAaZ,iBAIjBM,UAAUH,iBAAiBG,UAAUO,OAAOC,gBAAgBV,WACpDA,MAAMW,OAAOC,2BACH,mBAAoB,oBAAoBC,KAAKC,YAAUC,YAC9D,OACGC,gBAAkBhB,MAAMW,OAAOM,SAASC,KAAIC,SAAWA,QAAQC,gCACxDC,gBAAgB,CACzBC,KAAM,QACNF,QAASJ,gBAAgBO,KAAK,cAK1CrB,UAAUsB"} \ No newline at end of file +{"version":3,"file":"contactdpo.min.js","sources":["../src/contactdpo.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Javascript module for contacting the site DPO\n *\n * @module tool_dataprivacy/contactdpo\n * @copyright 2021 Paul Holden \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalForm from 'core_form/modalform';\nimport Notification from 'core/notification';\nimport {get_string as getString} from 'core/str';\nimport {add as addToast} from 'core/toast';\n\nconst SELECTORS = {\n CONTACT_DPO: '[data-action=\"contactdpo\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n const triggerElement = document.querySelector(SELECTORS.CONTACT_DPO);\n\n triggerElement.addEventListener('click', event => {\n event.preventDefault();\n\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('contactdataprotectionofficer', 'tool_dataprivacy'),\n },\n formClass: 'tool_dataprivacy\\\\form\\\\contactdpo',\n saveButtonText: getString('send', 'tool_dataprivacy'),\n returnFocus: triggerElement,\n });\n\n // Show a toast notification when the form is submitted.\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {\n if (event.detail.result) {\n getString('requestsubmitted', 'tool_dataprivacy').then(addToast).catch();\n } else {\n const warningMessages = event.detail.warnings.map(warning => warning.message);\n Notification.addNotification({\n type: 'error',\n message: warningMessages.join('
')\n });\n }\n });\n\n modalForm.show();\n });\n};\n"],"names":["_interopRequireDefault","obj","__esModule","default","_modalform","_notification","SELECTORS","_exports","init","triggerElement","document","querySelector","addEventListener","event","preventDefault","modalForm","ModalForm","modalConfig","title","getString","formClass","saveButtonText","returnFocus","events","FORM_SUBMITTED","detail","result","get_string","then","addToast","catch","warningMessages","warnings","map","warning","message","Notification","addNotification","type","join","show"],"mappings":"4KAwB6C,SAAAA,uBAAAC,KAAAA,OAAAA,KAAAA,IAAAC,WAAAD,IAAAE,CAAAA,QAAAF,IAAA;;;;;;;kFAD7CG,WAAAJ,uBAAAI,YACAC,cAAAL,uBAAAK,eAIA,MAAMC,sBACW,6BAoCfC,SAAAC,KA9BkBA,KAChB,MAAMC,eAAiBC,SAASC,cAAcL,uBAE9CG,eAAeG,iBAAiB,SAASC,QACrCA,MAAMC,iBAEN,MAAMC,UAAY,IAAIC,WAAAA,QAAU,CAC5BC,YAAa,CACTC,OAAO,EAAAC,KAAAA,YAAU,+BAAgC,qBAErDC,UAAW,qCACXC,gBAAgB,EAAAF,KAAAA,YAAU,OAAQ,oBAClCG,YAAab,iBAIjBM,UAAUH,iBAAiBG,UAAUQ,OAAOC,gBAAgBX,QACxD,GAAIA,MAAMY,OAAOC,QACb,EAAAP,KAASQ,YAAC,mBAAoB,oBAAoBC,KAAKC,OAAAA,KAAUC,YAC9D,CACH,MAAMC,gBAAkBlB,MAAMY,OAAOO,SAASC,KAAIC,SAAWA,QAAQC,UACrEC,cAAYjC,QAACkC,gBAAgB,CACzBC,KAAM,QACNH,QAASJ,gBAAgBQ,KAAK,SAEtC,KAGJxB,UAAUyB,MAAM,GAClB,CACJ"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/data_deletion.min.js.map b/admin/tool/dataprivacy/amd/build/data_deletion.min.js.map index 79fec21d7e6..0d6cefaf7c0 100644 --- a/admin/tool/dataprivacy/amd/build/data_deletion.min.js.map +++ b/admin/tool/dataprivacy/amd/build/data_deletion.min.js.map @@ -1 +1 @@ -{"version":3,"file":"data_deletion.min.js","sources":["../src/data_deletion.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Request actions.\n *\n * @module tool_dataprivacy/data_deletion\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{MARK_FOR_DELETION: string}}\n * @type {{SELECT_ALL: string}}\n */\n var ACTIONS = {\n MARK_FOR_DELETION: '[data-action=\"markfordeletion\"]',\n SELECT_ALL: '[data-action=\"selectall\"]',\n };\n\n /**\n * List of selectors.\n *\n * @type {{SELECTCONTEXT: string}}\n */\n var SELECTORS = {\n SELECTCONTEXT: '.selectcontext',\n };\n\n /**\n * DataDeletionActions class.\n */\n var DataDeletionActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n DataDeletionActions.prototype.registerEvents = function() {\n $(ACTIONS.MARK_FOR_DELETION).click(function(e) {\n e.preventDefault();\n\n var selectedIds = [];\n $(SELECTORS.SELECTCONTEXT).each(function() {\n var checkbox = $(this);\n if (checkbox.is(':checked')) {\n selectedIds.push(checkbox.val());\n }\n });\n showConfirmation(selectedIds);\n });\n\n $(ACTIONS.SELECT_ALL).change(function(e) {\n e.preventDefault();\n\n var selectallnone = $(this);\n if (selectallnone.is(':checked')) {\n $(SELECTORS.SELECTCONTEXT).attr('checked', 'checked');\n } else {\n $(SELECTORS.SELECTCONTEXT).removeAttr('checked');\n }\n });\n };\n\n /**\n * Show the confirmation dialogue.\n *\n * @param {Array} ids The array of expired context record IDs.\n */\n function showConfirmation(ids) {\n var keys = [\n {\n key: 'confirm',\n component: 'moodle'\n },\n {\n key: 'confirmcontextdeletion',\n component: 'tool_dataprivacy'\n }\n ];\n var wsfunction = 'tool_dataprivacy_confirm_contexts_for_deletion';\n\n var modalTitle = '';\n Str.get_strings(keys).then(function(langStrings) {\n modalTitle = langStrings[0];\n var confirmMessage = langStrings[1];\n return ModalFactory.create({\n title: modalTitle,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n });\n }).then(function(modal) {\n modal.setSaveButtonText(modalTitle);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n // Confirm the request.\n var params = {\n 'ids': ids\n };\n\n var request = {\n methodname: wsfunction,\n args: params\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n window.location.reload();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n }).done(function(modal) {\n modal.show();\n }).fail(Notification.exception);\n }\n\n return DataDeletionActions;\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","SELECTORS","DataDeletionActions","registerEvents","prototype","click","e","preventDefault","ids","keys","wsfunction","modalTitle","selectedIds","each","checkbox","this","is","push","val","key","component","get_strings","then","langStrings","confirmMessage","create","title","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","request","methodname","args","call","done","data","result","window","location","reload","addNotification","message","warnings","fail","exception","hidden","destroy","show","change","attr","removeAttr"],"mappings":";;;;;;;AAsBAA,wCAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,sBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,iBAQ3CC,0BACmB,kCADnBA,mBAEY,4BAQZC,wBACe,iBAMfC,oBAAsB,gBACjBC,yBAMTD,oBAAoBE,UAAUD,eAAiB,WAC3CT,EAAEM,2BAA2BK,OAAM,SAASC,GACxCA,EAAEC,qBA6BgBC,IAClBC,KAUAC,WAEAC,WAxCIC,YAAc,GAClBlB,EAAEO,yBAAyBY,MAAK,eACxBC,SAAWpB,EAAEqB,MACbD,SAASE,GAAG,aACZJ,YAAYK,KAAKH,SAASI,UAuBhBV,IApBDI,YAqBjBH,KAAO,CACP,CACIU,IAAK,UACLC,UAAW,UAEf,CACID,IAAK,yBACLC,UAAW,qBAGfV,WAAa,iDAEbC,WAAa,GACjBd,IAAIwB,YAAYZ,MAAMa,MAAK,SAASC,aAChCZ,WAAaY,YAAY,OACrBC,eAAiBD,YAAY,UAC1BzB,aAAa2B,OAAO,CACvBC,MAAOf,WACPgB,KAAMH,eACNI,KAAM9B,aAAa+B,MAAMC,iBAE9BR,MAAK,SAASS,cACbA,MAAMC,kBAAkBrB,YAGxBoB,MAAME,UAAUC,GAAGnC,YAAYoC,MAAM,eAM7BC,QAAU,CACVC,WAAY3B,WACZ4B,KANS,KACF9B,MAQXb,KAAK4C,KAAK,CAACH,UAAU,GAAGI,MAAK,SAASC,MAC9BA,KAAKC,OACLC,OAAOC,SAASC,SAEhBjD,aAAakD,gBAAgB,CACzBC,QAASN,KAAKO,SAAS,GAAGD,QAC1BnB,KAAM,aAGfqB,KAAKrD,aAAasD,cAIzBnB,MAAME,UAAUC,GAAGnC,YAAYoD,QAAQ,WAEnCpB,MAAMqB,aAGHrB,SACRS,MAAK,SAAST,OACbA,MAAMsB,UACPJ,KAAKrD,aAAasD,cA3ErBxD,EAAEM,oBAAoBsD,QAAO,SAAShD,GAClCA,EAAEC,iBAEkBb,EAAEqB,MACJC,GAAG,YACjBtB,EAAEO,yBAAyBsD,KAAK,UAAW,WAE3C7D,EAAEO,yBAAyBuD,WAAW,eAuE3CtD"} \ No newline at end of file +{"version":3,"file":"data_deletion.min.js","sources":["../src/data_deletion.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Request actions.\n *\n * @module tool_dataprivacy/data_deletion\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{MARK_FOR_DELETION: string}}\n * @type {{SELECT_ALL: string}}\n */\n var ACTIONS = {\n MARK_FOR_DELETION: '[data-action=\"markfordeletion\"]',\n SELECT_ALL: '[data-action=\"selectall\"]',\n };\n\n /**\n * List of selectors.\n *\n * @type {{SELECTCONTEXT: string}}\n */\n var SELECTORS = {\n SELECTCONTEXT: '.selectcontext',\n };\n\n /**\n * DataDeletionActions class.\n */\n var DataDeletionActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n DataDeletionActions.prototype.registerEvents = function() {\n $(ACTIONS.MARK_FOR_DELETION).click(function(e) {\n e.preventDefault();\n\n var selectedIds = [];\n $(SELECTORS.SELECTCONTEXT).each(function() {\n var checkbox = $(this);\n if (checkbox.is(':checked')) {\n selectedIds.push(checkbox.val());\n }\n });\n showConfirmation(selectedIds);\n });\n\n $(ACTIONS.SELECT_ALL).change(function(e) {\n e.preventDefault();\n\n var selectallnone = $(this);\n if (selectallnone.is(':checked')) {\n $(SELECTORS.SELECTCONTEXT).attr('checked', 'checked');\n } else {\n $(SELECTORS.SELECTCONTEXT).removeAttr('checked');\n }\n });\n };\n\n /**\n * Show the confirmation dialogue.\n *\n * @param {Array} ids The array of expired context record IDs.\n */\n function showConfirmation(ids) {\n var keys = [\n {\n key: 'confirm',\n component: 'moodle'\n },\n {\n key: 'confirmcontextdeletion',\n component: 'tool_dataprivacy'\n }\n ];\n var wsfunction = 'tool_dataprivacy_confirm_contexts_for_deletion';\n\n var modalTitle = '';\n Str.get_strings(keys).then(function(langStrings) {\n modalTitle = langStrings[0];\n var confirmMessage = langStrings[1];\n return ModalFactory.create({\n title: modalTitle,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n });\n }).then(function(modal) {\n modal.setSaveButtonText(modalTitle);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n // Confirm the request.\n var params = {\n 'ids': ids\n };\n\n var request = {\n methodname: wsfunction,\n args: params\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n window.location.reload();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n }).done(function(modal) {\n modal.show();\n }).fail(Notification.exception);\n }\n\n return DataDeletionActions;\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","SELECTORS","DataDeletionActions","this","registerEvents","prototype","click","e","preventDefault","ids","keys","wsfunction","modalTitle","selectedIds","each","checkbox","is","push","val","key","component","get_strings","then","langStrings","confirmMessage","create","title","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","request","methodname","args","call","done","data","result","window","location","reload","addNotification","message","warnings","fail","exception","hidden","destroy","show","change","attr","removeAttr"],"mappings":";;;;;;;AAsBAA,OAAM,iCAAC,CACH,SACA,YACA,oBACA,WACA,qBACA,sBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,aAQ/C,IAAIC,0BACmB,kCADnBA,mBAEY,4BAQZC,wBACe,iBAMfC,oBAAsB,WACtBC,K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AW,UAE9C,KAqEGtD,mBACX"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/data_registry.min.js.map b/admin/tool/dataprivacy/amd/build/data_registry.min.js.map index 235aef226ce..a7b5903fc9c 100644 --- a/admin/tool/dataprivacy/amd/build/data_registry.min.js.map +++ b/admin/tool/dataprivacy/amd/build/data_registry.min.js.map @@ -1 +1 @@ -{"version":3,"file":"data_registry.min.js","sources":["../src/data_registry.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Request actions.\n *\n * @module tool_dataprivacy/data_registry\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/templates', 'core/modal_factory',\n 'core/modal_events', 'core/fragment', 'tool_dataprivacy/add_purpose', 'tool_dataprivacy/add_category'],\n function($, Str, Ajax, Notification, Templates, ModalFactory, ModalEvents, Fragment, AddPurpose, AddCategory) {\n\n var SELECTORS = {\n TREE_NODES: '[data-context-tree-node=1]',\n FORM_CONTAINER: '#context-form-container',\n };\n\n var DataRegistry = function(systemContextId, initContextLevel, initContextId) {\n this.systemContextId = systemContextId;\n this.currentContextLevel = initContextLevel;\n this.currentContextId = initContextId;\n this.init();\n };\n\n /**\n * @var {int} systemContextId\n * @private\n */\n DataRegistry.prototype.systemContextId = 0;\n\n /**\n * @var {int} currentContextLevel\n * @private\n */\n DataRegistry.prototype.currentContextLevel = 0;\n\n /**\n * @var {int} currentContextId\n * @private\n */\n DataRegistry.prototype.currentContextId = 0;\n\n /**\n * @var {AddPurpose} addpurpose\n * @private\n */\n DataRegistry.prototype.addpurpose = null;\n\n /**\n * @var {AddCategory} addcategory\n * @private\n */\n DataRegistry.prototype.addcategory = null;\n\n DataRegistry.prototype.init = function() {\n // Add purpose and category modals always at system context.\n this.addpurpose = AddPurpose.getInstance(this.systemContextId);\n this.addcategory = AddCategory.getInstance(this.systemContextId);\n\n var stringKeys = [\n {\n key: 'changessaved',\n component: 'moodle'\n }, {\n key: 'contextpurposecategorysaved',\n component: 'tool_dataprivacy'\n }, {\n key: 'noblockstoload',\n component: 'tool_dataprivacy'\n }, {\n key: 'noactivitiestoload',\n component: 'tool_dataprivacy'\n }, {\n key: 'nocoursestoload',\n component: 'tool_dataprivacy'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n\n // Load the default context level form.\n if (this.currentContextId) {\n this.loadForm('context_form', [this.currentContextId], this.submitContextFormAjax.bind(this));\n } else {\n this.loadForm('contextlevel_form', [this.currentContextLevel], this.submitContextLevelFormAjax.bind(this));\n }\n };\n\n DataRegistry.prototype.registerEventListeners = function() {\n $(SELECTORS.TREE_NODES).on('click', function(ev) {\n ev.preventDefault();\n\n var trigger = $(ev.currentTarget);\n\n // Active node.\n $(SELECTORS.TREE_NODES).removeClass('active');\n trigger.addClass('active');\n\n var contextLevel = trigger.data('contextlevel');\n var contextId = trigger.data('contextid');\n if (contextLevel) {\n // Context level level.\n\n window.history.pushState({}, null, '?contextlevel=' + contextLevel);\n\n // Remove previous add purpose and category listeners to avoid memory leaks.\n this.addpurpose.removeListeners();\n this.addcategory.removeListeners();\n\n // Load the context level form.\n this.currentContextLevel = contextLevel;\n this.loadForm('contextlevel_form', [this.currentContextLevel], this.submitContextLevelFormAjax.bind(this));\n } else if (contextId) {\n // Context instance level.\n\n window.history.pushState({}, null, '?contextid=' + contextId);\n\n // Remove previous add purpose and category listeners to avoid memory leaks.\n this.addpurpose.removeListeners();\n this.addcategory.removeListeners();\n\n // Load the context level form.\n this.currentContextId = contextId;\n this.loadForm('context_form', [this.currentContextId], this.submitContextFormAjax.bind(this));\n } else {\n // Expandable nodes.\n\n var expandContextId = trigger.data('expandcontextid');\n var expandElement = trigger.data('expandelement');\n var expanded = trigger.data('expanded');\n\n // Extra checking that there is an expandElement because we remove it after loading 0 branches.\n if (expandElement) {\n\n if (!expanded) {\n if (trigger.data('loaded') || !expandContextId || !expandElement) {\n this.expand(trigger);\n } else {\n\n trigger.find('> i').removeClass('fa-plus');\n trigger.find('> i').addClass('fa-circle-o-notch fa-spin');\n this.loadExtra(trigger, expandContextId, expandElement);\n }\n } else {\n this.collapse(trigger);\n }\n }\n }\n\n }.bind(this));\n };\n\n DataRegistry.prototype.removeListeners = function() {\n $(SELECTORS.TREE_NODES).off('click');\n };\n\n DataRegistry.prototype.loadForm = function(fragmentName, fragmentArgs, formSubmitCallback) {\n\n this.clearForm();\n\n var fragment = Fragment.loadFragment('tool_dataprivacy', fragmentName, this.systemContextId, fragmentArgs);\n fragment.done(function(html, js) {\n\n $(SELECTORS.FORM_CONTAINER).html(html);\n Templates.runTemplateJS(js);\n\n this.addpurpose.registerEventListeners();\n this.addcategory.registerEventListeners();\n\n // We also catch the form submit event and use it to submit the form with ajax.\n $(SELECTORS.FORM_CONTAINER).on('submit', 'form', formSubmitCallback);\n\n }.bind(this)).fail(Notification.exception);\n };\n\n DataRegistry.prototype.clearForm = function() {\n // Remove previous listeners.\n $(SELECTORS.FORM_CONTAINER).off('submit', 'form');\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n DataRegistry.prototype.submitForm = function(e) {\n e.preventDefault();\n $(SELECTORS.FORM_CONTAINER).find('form').submit();\n };\n\n DataRegistry.prototype.submitContextLevelFormAjax = function(e) {\n this.submitFormAjax(e, 'tool_dataprivacy_set_contextlevel_form');\n };\n\n DataRegistry.prototype.submitContextFormAjax = function(e) {\n this.submitFormAjax(e, 'tool_dataprivacy_set_context_form');\n };\n\n DataRegistry.prototype.submitFormAjax = function(e, saveMethodName) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = $(SELECTORS.FORM_CONTAINER).find('form').serialize();\n return this.strings.then(function(strings) {\n Ajax.call([{\n methodname: saveMethodName,\n args: {jsonformdata: JSON.stringify(formData)},\n done: function() {\n Notification.alert(strings[0], strings[1]);\n },\n fail: Notification.exception\n }]);\n return;\n }).catch(Notification.exception);\n\n };\n\n DataRegistry.prototype.loadExtra = function(parentNode, expandContextId, expandElement) {\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_tree_extra_branches',\n args: {\n contextid: expandContextId,\n element: expandElement,\n },\n done: function(data) {\n if (data.branches.length == 0) {\n this.noElements(parentNode, expandElement);\n return;\n }\n Templates.render('tool_dataprivacy/context_tree_branches', data)\n .then(function(html) {\n parentNode.after(html);\n this.removeListeners();\n this.registerEventListeners();\n this.expand(parentNode);\n parentNode.data('loaded', 1);\n return;\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this),\n fail: Notification.exception\n }]);\n };\n\n DataRegistry.prototype.noElements = function(node, expandElement) {\n node.data('expandcontextid', '');\n node.data('expandelement', '');\n this.strings.then(function(strings) {\n\n // 2 = blocks, 3 = activities, 4 = courses (although courses is not likely really).\n var key = 2;\n if (expandElement == 'module') {\n key = 3;\n } else if (expandElement == 'course') {\n key = 4;\n }\n node.text(strings[key]);\n return;\n }).fail(Notification.exception);\n };\n\n DataRegistry.prototype.collapse = function(node) {\n node.data('expanded', 0);\n node.siblings('nav').addClass('hidden');\n node.find('> i').removeClass('fa-minus');\n node.find('> i').addClass('fa-plus');\n };\n\n DataRegistry.prototype.expand = function(node) {\n node.data('expanded', 1);\n node.siblings('nav').removeClass('hidden');\n node.find('> i').removeClass('fa-plus');\n // Also remove the spinning one if data was just loaded.\n node.find('> i').removeClass('fa-circle-o-notch fa-spin');\n node.find('> i').addClass('fa-minus');\n };\n return /** @alias module:tool_dataprivacy/data_registry */ {\n\n /**\n * Initialise the page.\n *\n * @param {Number} systemContextId\n * @param {Number} initContextLevel\n * @param {Number} initContextId\n * @return {DataRegistry}\n */\n init: function(systemContextId, initContextLevel, initContextId) {\n return new DataRegistry(systemContextId, initContextLevel, initContextId);\n }\n };\n }\n);\n\n"],"names":["define","$","Str","Ajax","Notification","Templates","ModalFactory","ModalEvents","Fragment","AddPurpose","AddCategory","SELECTORS","DataRegistry","systemContextId","initContextLevel","initContextId","currentContextLevel","currentContextId","init","prototype","addpurpose","addcategory","getInstance","this","strings","get_strings","key","component","registerEventListeners","loadForm","submitContextFormAjax","bind","submitContextLevelFormAjax","on","ev","preventDefault","trigger","currentTarget","removeClass","addClass","contextLevel","data","contextId","window","history","pushState","removeListeners","expandContextId","expandElement","expanded","collapse","find","loadExtra","expand","off","fragmentName","fragmentArgs","formSubmitCallback","clearForm","loadFragment","done","html","js","runTemplateJS","fail","exception","submitForm","e","submit","submitFormAjax","saveMethodName","formData","serialize","then","call","methodname","args","jsonformdata","JSON","stringify","alert","catch","parentNode","contextid","element","branches","length","render","after","noElements","node","text","siblings"],"mappings":";;;;;;;AAsBAA,wCAAO,CAAC,SAAU,WAAY,YAAa,oBAAqB,iBAAkB,qBAC9E,oBAAqB,gBAAiB,+BAAgC,kCACtE,SAASC,EAAGC,IAAKC,KAAMC,aAAcC,UAAWC,aAAcC,YAAaC,SAAUC,WAAYC,iBAEzFC,qBACY,6BADZA,yBAEgB,0BAGhBC,aAAe,SAASC,gBAAiBC,iBAAkBC,oBACtDF,gBAAkBA,qBAClBG,oBAAsBF,sBACtBG,iBAAmBF,mBACnBG,eAOTN,aAAaO,UAAUN,gBAAkB,EAMzCD,aAAaO,UAAUH,oBAAsB,EAM7CJ,aAAaO,UAAUF,iBAAmB,EAM1CL,aAAaO,UAAUC,WAAa,KAMpCR,aAAaO,UAAUE,YAAc,KAErCT,aAAaO,UAAUD,KAAO,gBAErBE,WAAa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AAM,CACFO,UAAWpC,gBACXqC,QAASpC,eAEbY,KAAM,SAASnB,MACiB,GAAxBA,KAAK4C,SAASC,OAIlBjF,UAAUkF,OAAO,yCAA0C9C,MACtDgC,KAAK,SAASZ,MACXqB,WAAWM,MAAM3B,WACZf,uBACAlB,8BACAyB,OAAO6B,YACZA,WAAWzC,KAAK,SAAU,IAE5BV,KAAKR,OACNyC,KAAK5D,aAAa6D,gBAZdwB,WAAWP,WAAYlC,gBAalCjB,KAAKR,MACPyC,KAAM5D,aAAa6D,cAI3BrD,aAAaO,UAAUsE,WAAa,SAASC,KAAM1C,eAC/C0C,KAAKjD,KAAK,kBAAmB,IAC7BiD,KAAKjD,KAAK,gBAAiB,SACtBjB,QAAQiD,MAAK,SAASjD,aAGnBE,IAAM,EACW,UAAjBsB,cACAtB,IAAM,EACkB,UAAjBsB,gBACPtB,IAAM,GAEVgE,KAAKC,KAAKnE,QAAQE,SAEnBsC,KAAK5D,aAAa6D,YAGzBrD,aAAaO,UAAU+B,SAAW,SAASwC,MACvCA,KAAKjD,KAAK,WAAY,GACtBiD,KAAKE,SAAS,OAAOrD,SAAS,UAC9BmD,KAAKvC,KAAK,OAAOb,YAAY,YAC7BoD,KAAKvC,KAAK,OAAOZ,SAAS,YAG9B3B,aAAaO,UAAUkC,OAAS,SAASqC,MACrCA,KAAKjD,KAAK,WAAY,GACtBiD,KAAKE,SAAS,OAAOtD,YAAY,UACjCoD,KAAKvC,KAAK,OAAOb,YAAY,WAE7BoD,KAAKvC,KAAK,OAAOb,YAAY,6BAC7BoD,KAAKvC,KAAK,OAAOZ,SAAS,aAE6B,CAUvDrB,KAAM,SAASL,gBAAiBC,iBAAkBC,sBACvC,IAAIH,aAAaC,gBAAiBC,iBAAkBC"} \ No newline at end of file +{"version":3,"file":"data_registry.min.js","sources":["../src/data_registry.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Request actions.\n *\n * @module tool_dataprivacy/data_registry\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/templates', 'core/modal_factory',\n 'core/modal_events', 'core/fragment', 'tool_dataprivacy/add_purpose', 'tool_dataprivacy/add_category'],\n function($, Str, Ajax, Notification, Templates, ModalFactory, ModalEvents, Fragment, AddPurpose, AddCategory) {\n\n var SELECTORS = {\n TREE_NODES: '[data-context-tree-node=1]',\n FORM_CONTAINER: '#context-form-container',\n };\n\n var DataRegistry = function(systemContextId, initContextLevel, initContextId) {\n this.systemContextId = systemContextId;\n this.currentContextLevel = initContextLevel;\n this.currentContextId = initContextId;\n this.init();\n };\n\n /**\n * @var {int} systemContextId\n * @private\n */\n DataRegistry.prototype.systemContextId = 0;\n\n /**\n * @var {int} currentContextLevel\n * @private\n */\n DataRegistry.prototype.currentContextLevel = 0;\n\n /**\n * @var {int} currentContextId\n * @private\n */\n DataRegistry.prototype.currentContextId = 0;\n\n /**\n * @var {AddPurpose} addpurpose\n * @private\n */\n DataRegistry.prototype.addpurpose = null;\n\n /**\n * @var {AddCategory} addcategory\n * @private\n */\n DataRegistry.prototype.addcategory = null;\n\n DataRegistry.prototype.init = function() {\n // Add purpose and category modals always at system context.\n this.addpurpose = AddPurpose.getInstance(this.systemContextId);\n this.addcategory = AddCategory.getInstance(this.systemContextId);\n\n var stringKeys = [\n {\n key: 'changessaved',\n component: 'moodle'\n }, {\n key: 'contextpurposecategorysaved',\n component: 'tool_dataprivacy'\n }, {\n key: 'noblockstoload',\n component: 'tool_dataprivacy'\n }, {\n key: 'noactivitiestoload',\n component: 'tool_dataprivacy'\n }, {\n key: 'nocoursestoload',\n component: 'tool_dataprivacy'\n }\n ];\n this.strings = Str.get_strings(stringKeys);\n\n this.registerEventListeners();\n\n // Load the default context level form.\n if (this.currentContextId) {\n this.loadForm('context_form', [this.currentContextId], this.submitContextFormAjax.bind(this));\n } else {\n this.loadForm('contextlevel_form', [this.currentContextLevel], this.submitContextLevelFormAjax.bind(this));\n }\n };\n\n DataRegistry.prototype.registerEventListeners = function() {\n $(SELECTORS.TREE_NODES).on('click', function(ev) {\n ev.preventDefault();\n\n var trigger = $(ev.currentTarget);\n\n // Active node.\n $(SELECTORS.TREE_NODES).removeClass('active');\n trigger.addClass('active');\n\n var contextLevel = trigger.data('contextlevel');\n var contextId = trigger.data('contextid');\n if (contextLevel) {\n // Context level level.\n\n window.history.pushState({}, null, '?contextlevel=' + contextLevel);\n\n // Remove previous add purpose and category listeners to avoid memory leaks.\n this.addpurpose.removeListeners();\n this.addcategory.removeListeners();\n\n // Load the context level form.\n this.currentContextLevel = contextLevel;\n this.loadForm('contextlevel_form', [this.currentContextLevel], this.submitContextLevelFormAjax.bind(this));\n } else if (contextId) {\n // Context instance level.\n\n window.history.pushState({}, null, '?contextid=' + contextId);\n\n // Remove previous add purpose and category listeners to avoid memory leaks.\n this.addpurpose.removeListeners();\n this.addcategory.removeListeners();\n\n // Load the context level form.\n this.currentContextId = contextId;\n this.loadForm('context_form', [this.currentContextId], this.submitContextFormAjax.bind(this));\n } else {\n // Expandable nodes.\n\n var expandContextId = trigger.data('expandcontextid');\n var expandElement = trigger.data('expandelement');\n var expanded = trigger.data('expanded');\n\n // Extra checking that there is an expandElement because we remove it after loading 0 branches.\n if (expandElement) {\n\n if (!expanded) {\n if (trigger.data('loaded') || !expandContextId || !expandElement) {\n this.expand(trigger);\n } else {\n\n trigger.find('> i').removeClass('fa-plus');\n trigger.find('> i').addClass('fa-circle-o-notch fa-spin');\n this.loadExtra(trigger, expandContextId, expandElement);\n }\n } else {\n this.collapse(trigger);\n }\n }\n }\n\n }.bind(this));\n };\n\n DataRegistry.prototype.removeListeners = function() {\n $(SELECTORS.TREE_NODES).off('click');\n };\n\n DataRegistry.prototype.loadForm = function(fragmentName, fragmentArgs, formSubmitCallback) {\n\n this.clearForm();\n\n var fragment = Fragment.loadFragment('tool_dataprivacy', fragmentName, this.systemContextId, fragmentArgs);\n fragment.done(function(html, js) {\n\n $(SELECTORS.FORM_CONTAINER).html(html);\n Templates.runTemplateJS(js);\n\n this.addpurpose.registerEventListeners();\n this.addcategory.registerEventListeners();\n\n // We also catch the form submit event and use it to submit the form with ajax.\n $(SELECTORS.FORM_CONTAINER).on('submit', 'form', formSubmitCallback);\n\n }.bind(this)).fail(Notification.exception);\n };\n\n DataRegistry.prototype.clearForm = function() {\n // Remove previous listeners.\n $(SELECTORS.FORM_CONTAINER).off('submit', 'form');\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n DataRegistry.prototype.submitForm = function(e) {\n e.preventDefault();\n $(SELECTORS.FORM_CONTAINER).find('form').submit();\n };\n\n DataRegistry.prototype.submitContextLevelFormAjax = function(e) {\n this.submitFormAjax(e, 'tool_dataprivacy_set_contextlevel_form');\n };\n\n DataRegistry.prototype.submitContextFormAjax = function(e) {\n this.submitFormAjax(e, 'tool_dataprivacy_set_context_form');\n };\n\n DataRegistry.prototype.submitFormAjax = function(e, saveMethodName) {\n // We don't want to do a real form submission.\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n var formData = $(SELECTORS.FORM_CONTAINER).find('form').serialize();\n return this.strings.then(function(strings) {\n Ajax.call([{\n methodname: saveMethodName,\n args: {jsonformdata: JSON.stringify(formData)},\n done: function() {\n Notification.alert(strings[0], strings[1]);\n },\n fail: Notification.exception\n }]);\n return;\n }).catch(Notification.exception);\n\n };\n\n DataRegistry.prototype.loadExtra = function(parentNode, expandContextId, expandElement) {\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_tree_extra_branches',\n args: {\n contextid: expandContextId,\n element: expandElement,\n },\n done: function(data) {\n if (data.branches.length == 0) {\n this.noElements(parentNode, expandElement);\n return;\n }\n Templates.render('tool_dataprivacy/context_tree_branches', data)\n .then(function(html) {\n parentNode.after(html);\n this.removeListeners();\n this.registerEventListeners();\n this.expand(parentNode);\n parentNode.data('loaded', 1);\n return;\n }.bind(this))\n .fail(Notification.exception);\n }.bind(this),\n fail: Notification.exception\n }]);\n };\n\n DataRegistry.prototype.noElements = function(node, expandElement) {\n node.data('expandcontextid', '');\n node.data('expandelement', '');\n this.strings.then(function(strings) {\n\n // 2 = blocks, 3 = activities, 4 = courses (although courses is not likely really).\n var key = 2;\n if (expandElement == 'module') {\n key = 3;\n } else if (expandElement == 'course') {\n key = 4;\n }\n node.text(strings[key]);\n return;\n }).fail(Notification.exception);\n };\n\n DataRegistry.prototype.collapse = function(node) {\n node.data('expanded', 0);\n node.siblings('nav').addClass('hidden');\n node.find('> i').removeClass('fa-minus');\n node.find('> i').addClass('fa-plus');\n };\n\n DataRegistry.prototype.expand = function(node) {\n node.data('expanded', 1);\n node.siblings('nav').removeClass('hidden');\n node.find('> i').removeClass('fa-plus');\n // Also remove the spinning one if data was just loaded.\n node.find('> i').removeClass('fa-circle-o-notch fa-spin');\n node.find('> i').addClass('fa-minus');\n };\n return /** @alias module:tool_dataprivacy/data_registry */ {\n\n /**\n * Initialise the page.\n *\n * @param {Number} systemContextId\n * @param {Number} initContextLevel\n * @param {Number} initContextId\n * @return {DataRegistry}\n */\n init: function(systemContextId, initContextLevel, initContextId) {\n return new DataRegistry(systemContextId, initContextLevel, initContextId);\n }\n };\n }\n);\n\n"],"names":["define","$","Str","Ajax","Notification","Templates","ModalFactory","ModalEvents","Fragment","AddPurpose","AddCategory","SELECTORS","DataRegistry","systemContextId","initContextLevel","initContextId","this","currentContextLevel","currentContextId","init","prototype","addpurpose","addcategory","getInstance","strings","get_strings","key","component","registerEventListeners","loadForm","submitContextFormAjax","bind","submitContextLevelFormAjax","on","ev","preventDefault","trigger","currentTarget","removeClass","addClass","contextLevel","data","contextId","window","history","pushState","removeListeners","expandContextId","expandElement","expanded","collapse","find","loadExtra","expand","off","fragmentName","fragmentArgs","formSubmitCallback","clearForm","loadFragment","done","html","js","runTemplateJS","fail","exception","submitForm","e","submit","submitFormAjax","saveMethodName","formData","serialize","then","call","methodname","args","jsonformdata","JSON","stringify","alert","catch","parentNode","contextid","element","branches","length","render","after","noElements","node","text","siblings"],"mappings":";;;;;;;AAsBAA,wCAAO,CAAC,SAAU,WAAY,YAAa,oBAAqB,iBAAkB,qBAC9E,oBAAqB,gBAAiB,+BAAgC,kCACtE,SAASC,EAAGC,IAAKC,KAAMC,aAAcC,UAAWC,aAAcC,YAAaC,SAAUC,WAAYC,aAE7F,IAAIC,qBACY,6BADZA,yBAEgB,0BAGhBC,aAAe,SAASC,gBAAiBC,iBAAkBC,eAC3DC,KAAKH,gBAAkBA,gBACvBG,KAAKC,oBAAsBH,iBAC3BE,KAAKE,iBAAmBH,cACxBC,KAAKG,QAoQT,OA7PAP,aAAaQ,UAAUP,gBAAkB,EAMzCD,aAAaQ,UAAUH,oBAAsB,EAM7CL,aAAaQ,UAAUF,iBAAmB,EAM1CN,aAAaQ,UAAUC,WAAa,KAMpCT,aAAaQ,UAAUE,YAAc,KAErCV,aAAaQ,UAAUD,KAAO,WAE1BH,KAAKK,WAAaZ,WAAWc,YAAYP,KAAKH,iBAC9CG,KAAKM,YAAcZ,YAAYa,YAAYP,KAAKH,iBAoBhDG,KAAKQ,QAAUtB,IAAIuB,YAlBF,CACb,CACIC,IAAK,eACLC,UAAW,UACZ,CACCD,IAAK,8BACLC,UAAW,oBACZ,CACCD,IAAK,iBACLC,UAAW,oBACZ,CACCD,IAAK,qBACLC,UAAW,oBACZ,CACCD,IAAK,kBACLC,UAAW,sBAKnBX,KAAKY,yBAGDZ,KAAKE,iBACLF,KAAK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,SAASnB,MACiB,GAAxBA,KAAK4C,SAASC,OAIlBjF,UAAUkF,OAAO,yCAA0C9C,MACtDgC,KAAK,SAASZ,MACXqB,WAAWM,MAAM3B,MACjB7C,KAAK8B,kBACL9B,KAAKY,yBACLZ,KAAKqC,OAAO6B,YACZA,WAAWzC,KAAK,SAAU,EAE9B,EAAEV,KAAKf,OACNgD,KAAK5D,aAAa6D,WAZnBjD,KAAKyE,WAAWP,WAAYlC,cAapC,EAAEjB,KAAKf,MACPgD,KAAM5D,aAAa6D,cAI3BrD,aAAaQ,UAAUqE,WAAa,SAASC,KAAM1C,eAC/C0C,KAAKjD,KAAK,kBAAmB,IAC7BiD,KAAKjD,KAAK,gBAAiB,IAC3BzB,KAAKQ,QAAQiD,MAAK,SAASjD,SAGvB,IAAIE,IAAM,EACW,UAAjBsB,cACAtB,IAAM,EACkB,UAAjBsB,gBACPtB,IAAM,GAEVgE,KAAKC,KAAKnE,QAAQE,KAErB,IAAEsC,KAAK5D,aAAa6D,YAGzBrD,aAAaQ,UAAU8B,SAAW,SAASwC,MACvCA,KAAKjD,KAAK,WAAY,GACtBiD,KAAKE,SAAS,OAAOrD,SAAS,UAC9BmD,KAAKvC,KAAK,OAAOb,YAAY,YAC7BoD,KAAKvC,KAAK,OAAOZ,SAAS,YAG9B3B,aAAaQ,UAAUiC,OAAS,SAASqC,MACrCA,KAAKjD,KAAK,WAAY,GACtBiD,KAAKE,SAAS,OAAOtD,YAAY,UACjCoD,KAAKvC,KAAK,OAAOb,YAAY,WAE7BoD,KAAKvC,KAAK,OAAOb,YAAY,6BAC7BoD,KAAKvC,KAAK,OAAOZ,SAAS,aAE6B,CAUvDpB,KAAM,SAASN,gBAAiBC,iBAAkBC,eAC9C,OAAO,IAAIH,aAAaC,gBAAiBC,iBAAkBC,cAC/D,EAER"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map b/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map index ef4fbb7deda..ece5de5201d 100644 --- a/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map +++ b/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map @@ -1 +1 @@ -{"version":3,"file":"data_request_modal.min.js","sources":["../src/data_request_modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Request actions.\n *\n * @module tool_dataprivacy/data_request_modal\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/modal', 'core/modal_registry',\n 'tool_dataprivacy/events'],\n function($, Notification, CustomEvents, Modal, ModalRegistry, DataPrivacyEvents) {\n\n var registered = false;\n var SELECTORS = {\n APPROVE_BUTTON: '[data-action=\"approve\"]',\n DENY_BUTTON: '[data-action=\"deny\"]',\n COMPLETE_BUTTON: '[data-action=\"complete\"]'\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalDataRequest = function(root) {\n Modal.call(this, root);\n };\n\n ModalDataRequest.TYPE = 'tool_dataprivacy-data_request';\n ModalDataRequest.prototype = Object.create(Modal.prototype);\n ModalDataRequest.prototype.constructor = ModalDataRequest;\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalDataRequest.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.APPROVE_BUTTON, function(e, data) {\n var approveEvent = $.Event(DataPrivacyEvents.approve);\n this.getRoot().trigger(approveEvent, this);\n\n if (!approveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DENY_BUTTON, function(e, data) {\n var denyEvent = $.Event(DataPrivacyEvents.deny);\n this.getRoot().trigger(denyEvent, this);\n\n if (!denyEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.COMPLETE_BUTTON, function(e, data) {\n var completeEvent = $.Event(DataPrivacyEvents.complete);\n this.getRoot().trigger(completeEvent, this);\n\n if (!completeEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalDataRequest.TYPE, ModalDataRequest, 'tool_dataprivacy/data_request_modal');\n registered = true;\n }\n\n return ModalDataRequest;\n });"],"names":["define","$","Notification","CustomEvents","Modal","ModalRegistry","DataPrivacyEvents","registered","SELECTORS","ModalDataRequest","root","call","this","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","e","data","approveEvent","Event","approve","getRoot","trigger","isDefaultPrevented","hide","originalEvent","preventDefault","bind","denyEvent","deny","completeEvent","complete","register"],"mappings":";;;;;;;AAsBAA,6CAAO,CAAC,SAAU,oBAAqB,iCAAkC,aAAc,sBAC/E,4BACJ,SAASC,EAAGC,aAAcC,aAAcC,MAAOC,cAAeC,uBAEtDC,YAAa,EACbC,yBACgB,0BADhBA,sBAEa,uBAFbA,0BAGiB,2BAQjBC,iBAAmB,SAASC,MAC5BN,MAAMO,KAAKC,KAAMF,cAGrBD,iBAAiBI,KAAO,iCACxBJ,iBAAiBK,UAAYC,OAAOC,OAAOZ,MAAMU,YACtBG,YAAcR,iBAOzCA,iBAAiBK,UAAUI,uBAAyB,WAEhDd,MAAMU,UAAUI,uBAAuBP,KAAKC,WAEvCO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,yBAA0B,SAASe,EAAGC,UAC/EC,aAAexB,EAAEyB,MAAMpB,kBAAkBqB,cACxCC,UAAUC,QAAQJ,aAAcb,MAEhCa,aAAaK,4BACTC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKtB,YAEFO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,sBAAuB,SAASe,EAAGC,UAC5EW,UAAYlC,EAAEyB,MAAMpB,kBAAkB8B,WACrCR,UAAUC,QAAQM,UAAWvB,MAE7BuB,UAAUL,4BACNC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKtB,YAEFO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,0BAA2B,SAASe,EAAGC,UAChFa,cAAgBpC,EAAEyB,MAAMpB,kBAAkBgC,eACzCV,UAAUC,QAAQQ,cAAezB,MAEjCyB,cAAcP,4BACVC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKtB,QAKNL,aACDF,cAAckC,SAAS9B,iBAAiBI,KAAMJ,iBAAkB,uCAChEF,YAAa,GAGVE"} \ No newline at end of file +{"version":3,"file":"data_request_modal.min.js","sources":["../src/data_request_modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Request actions.\n *\n * @module tool_dataprivacy/data_request_modal\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/modal', 'core/modal_registry',\n 'tool_dataprivacy/events'],\n function($, Notification, CustomEvents, Modal, ModalRegistry, DataPrivacyEvents) {\n\n var registered = false;\n var SELECTORS = {\n APPROVE_BUTTON: '[data-action=\"approve\"]',\n DENY_BUTTON: '[data-action=\"deny\"]',\n COMPLETE_BUTTON: '[data-action=\"complete\"]'\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalDataRequest = function(root) {\n Modal.call(this, root);\n };\n\n ModalDataRequest.TYPE = 'tool_dataprivacy-data_request';\n ModalDataRequest.prototype = Object.create(Modal.prototype);\n ModalDataRequest.prototype.constructor = ModalDataRequest;\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalDataRequest.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.APPROVE_BUTTON, function(e, data) {\n var approveEvent = $.Event(DataPrivacyEvents.approve);\n this.getRoot().trigger(approveEvent, this);\n\n if (!approveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DENY_BUTTON, function(e, data) {\n var denyEvent = $.Event(DataPrivacyEvents.deny);\n this.getRoot().trigger(denyEvent, this);\n\n if (!denyEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.COMPLETE_BUTTON, function(e, data) {\n var completeEvent = $.Event(DataPrivacyEvents.complete);\n this.getRoot().trigger(completeEvent, this);\n\n if (!completeEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalDataRequest.TYPE, ModalDataRequest, 'tool_dataprivacy/data_request_modal');\n registered = true;\n }\n\n return ModalDataRequest;\n });"],"names":["define","$","Notification","CustomEvents","Modal","ModalRegistry","DataPrivacyEvents","registered","SELECTORS","ModalDataRequest","root","call","this","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","e","data","approveEvent","Event","approve","getRoot","trigger","isDefaultPrevented","hide","originalEvent","preventDefault","bind","denyEvent","deny","completeEvent","complete","register"],"mappings":";;;;;;;AAsBAA,OAAM,sCAAC,CAAC,SAAU,oBAAqB,iCAAkC,aAAc,sBAC/E,4BACJ,SAASC,EAAGC,aAAcC,aAAcC,MAAOC,cAAeC,mBAE1D,IAAIC,YAAa,EACbC,yBACgB,0BADhBA,sBAEa,uBAFbA,0BAGiB,2BAQjBC,iBAAmB,SAASC,MAC5BN,MAAMO,KAAKC,KAAMF,OAsDrB,OAnDAD,iBAAiBI,KAAO,iCACxBJ,iBAAiBK,UAAYC,OAAOC,OAAOZ,MAAMU,YACtBG,YAAcR,iBAOzCA,iBAAiBK,UAAUI,uBAAyB,WAEhDd,MAAMU,UAAUI,uBAAuBP,KAAKC,MAE5CA,KAAKO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,yBAA0B,SAASe,EAAGC,MACnF,IAAIC,aAAexB,EAAEyB,MAAMpB,kBAAkBqB,SAC7Cf,KAAKgB,UAAUC,QAAQJ,aAAcb,MAEhCa,aAAaK,uBACdlB,KAAKmB,OACLP,KAAKQ,cAAcC,iBAE3B,EAAEC,KAAKtB,OAEPA,KAAKO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,sBAAuB,SAASe,EAAGC,MAChF,IAAIW,UAAYlC,EAAEyB,MAAMpB,kBAAkB8B,MAC1CxB,KAAKgB,UAAUC,QAAQM,UAAWvB,MAE7BuB,UAAUL,uBACXlB,KAAKmB,OACLP,KAAKQ,cAAcC,iBAE3B,EAAEC,KAAKtB,OAEPA,KAAKO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,0BAA2B,SAASe,EAAGC,MACpF,IAAIa,cAAgBpC,EAAEyB,MAAMpB,kBAAkBgC,UAC9C1B,KAAKgB,UAAUC,QAAQQ,cAAezB,MAEjCyB,cAAcP,uBACflB,KAAKmB,OACLP,KAAKQ,cAAcC,iBAE3B,EAAEC,KAAKtB,QAKNL,aACDF,cAAckC,SAAS9B,iBAAiBI,KAAMJ,iBAAkB,uCAChEF,YAAa,GAGVE,gBACX"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/defaultsactions.min.js.map b/admin/tool/dataprivacy/amd/build/defaultsactions.min.js.map index 50b7d083a24..7301cd7f014 100644 --- a/admin/tool/dataprivacy/amd/build/defaultsactions.min.js.map +++ b/admin/tool/dataprivacy/amd/build/defaultsactions.min.js.map @@ -1 +1 @@ -{"version":3,"file":"defaultsactions.min.js","sources":["../src/defaultsactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * AMD module for data registry defaults actions.\n *\n * @module tool_dataprivacy/defaultsactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/templates'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates) {\n\n /**\n * List of action selectors.\n *\n * @type {{EDIT_LEVEL_DEFAULTS: string}}\n * @type {{NEW_ACTIVITY_DEFAULTS: string}}\n * @type {{EDIT_ACTIVITY_DEFAULTS: string}}\n * @type {{DELETE_ACTIVITY_DEFAULTS: string}}\n */\n var ACTIONS = {\n EDIT_LEVEL_DEFAULTS: '[data-action=\"edit-level-defaults\"]',\n NEW_ACTIVITY_DEFAULTS: '[data-action=\"new-activity-defaults\"]',\n EDIT_ACTIVITY_DEFAULTS: '[data-action=\"edit-activity-defaults\"]',\n DELETE_ACTIVITY_DEFAULTS: '[data-action=\"delete-activity-defaults\"]'\n };\n\n /** @type {{INHERIT: Number}} **/\n var INHERIT = -1;\n\n /**\n * DefaultsActions class.\n */\n var DefaultsActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n DefaultsActions.prototype.registerEvents = function() {\n $(ACTIONS.EDIT_LEVEL_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var category = button.data('category');\n var purpose = button.data('purpose');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('editdefaults', 'tool_dataprivacy', $('#defaults-header').text());\n $.when(promises[0], promises[1], titlePromise).then(function(categoryResponse, purposeResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n showDefaultsFormModal(title, contextLevel, category, purpose, null, categories, purposes, null);\n\n return true;\n }).catch(Notification.exception);\n });\n\n $(ACTIONS.NEW_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}},\n {methodname: 'tool_dataprivacy_get_activity_options', args: {'nodefaults': true}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('addnewdefaults', 'tool_dataprivacy');\n\n $.when(promises[0], promises[1], promises[2], titlePromise).then(\n function(categoryResponse, purposeResponse, activityResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n var activities = activityResponse.options;\n\n showDefaultsFormModal(title, contextLevel, null, null, null, categories, purposes, activities);\n\n return true;\n\n }).catch(Notification.exception);\n }\n );\n\n $(ACTIONS.EDIT_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var category = button.data('category');\n var purpose = button.data('purpose');\n var activity = button.data('activityname');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}},\n {methodname: 'tool_dataprivacy_get_activity_options', args: {}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('editmoduledefaults', 'tool_dataprivacy');\n\n $.when(promises[0], promises[1], promises[2], titlePromise).then(\n function(categoryResponse, purposeResponse, activityResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n var activities = activityResponse.options;\n\n showDefaultsFormModal(title, contextLevel, category, purpose, activity, categories, purposes, activities);\n\n return true;\n\n }).catch(Notification.exception);\n }\n );\n\n $(ACTIONS.DELETE_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var activity = button.data('activityname');\n var activityDisplayName = button.data('activitydisplayname');\n // Set category and purpose to inherit (-1).\n var category = INHERIT;\n var purpose = INHERIT;\n\n ModalFactory.create({\n title: Str.get_string('deletedefaults', 'tool_dataprivacy', activityDisplayName),\n body: Templates.render('tool_dataprivacy/delete_activity_defaults', {\"activityname\": activityDisplayName}),\n type: ModalFactory.types.SAVE_CANCEL,\n large: true\n }).then(function(modal) {\n modal.setSaveButtonText(Str.get_string('delete'));\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n setContextDefaults(contextLevel, category, purpose, activity, false);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return true;\n }).catch(Notification.exception);\n });\n };\n\n /**\n * Prepares and renders the modal for setting the defaults for the given context level/plugin.\n *\n * @param {String} title The modal's title.\n * @param {Number} contextLevel The context level to set defaults for.\n * @param {Number} category The current category ID.\n * @param {Number} purpose The current purpose ID.\n * @param {String} activity The plugin name of the activity. Optional.\n * @param {Array} categoryOptions The list of category options.\n * @param {Array} purposeOptions The list of purpose options.\n * @param {Array} activityOptions The list of activity options. Optional.\n */\n function showDefaultsFormModal(title, contextLevel, category, purpose, activity,\n categoryOptions, purposeOptions, activityOptions) {\n\n if (category !== null) {\n categoryOptions.forEach(function(currentValue) {\n if (currentValue.id === category) {\n currentValue.selected = true;\n }\n });\n }\n\n if (purpose !== null) {\n purposeOptions.forEach(function(currentValue) {\n if (currentValue.id === purpose) {\n currentValue.selected = true;\n }\n });\n }\n\n var templateContext = {\n \"contextlevel\": contextLevel,\n \"categoryoptions\": categoryOptions,\n \"purposeoptions\": purposeOptions\n };\n\n // Check the activityOptions parameter that was passed.\n if (activityOptions !== null && activityOptions.length) {\n // Check the activity parameter that was passed.\n if (activity === null) {\n // We're setting a new defaults for a module.\n templateContext.newactivitydefaults = true;\n\n } else {\n // Edit mode. Set selection.\n activityOptions.forEach(function(currentValue) {\n if (activity === currentValue.name) {\n currentValue.selected = true;\n }\n });\n }\n\n templateContext.modemodule = true;\n templateContext.activityoptions = activityOptions;\n }\n\n ModalFactory.create({\n title: title,\n body: Templates.render('tool_dataprivacy/category_purpose_form', templateContext),\n type: ModalFactory.types.SAVE_CANCEL,\n large: true\n }).then(function(modal) {\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n var activity = $('#activity');\n var activityVal = typeof activity !== 'undefined' ? activity.val() : null;\n var override = $('#override');\n var overrideVal = typeof override !== 'undefined' ? override.is(':checked') : false;\n\n setContextDefaults($('#contextlevel').val(), $('#category').val(), $('#purpose').val(), activityVal, overrideVal);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return modal;\n }).catch(Notification.exception);\n }\n\n /**\n * Calls a the tool_dataprivacy_set_context_defaults WS function.\n *\n * @param {Number} contextLevel The context level.\n * @param {Number} category The category ID.\n * @param {Number} purpose The purpose ID.\n * @param {String} activity The plugin name of the activity module.\n * @param {Boolean} override Whether to override custom instances.\n */\n function setContextDefaults(contextLevel, category, purpose, activity, override) {\n var request = {\n methodname: 'tool_dataprivacy_set_context_defaults',\n args: {\n 'contextlevel': contextLevel,\n 'category': category,\n 'purpose': purpose,\n 'override': override,\n 'activity': activity\n }\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n window.location.reload();\n }\n });\n }\n\n return /** @alias module:tool_dataprivacy/defaultsactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {DefaultsActions}\n */\n 'init': function() {\n return new DefaultsActions();\n }\n };\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","Templates","ACTIONS","DefaultsActions","registerEvents","showDefaultsFormModal","title","contextLevel","category","purpose","activity","categoryOptions","purposeOptions","activityOptions","forEach","currentValue","id","selected","templateContext","length","newactivitydefaults","name","modemodule","activityoptions","create","body","render","type","types","SAVE_CANCEL","large","then","modal","getRoot","on","save","activityVal","val","override","overrideVal","is","setContextDefaults","hidden","destroy","show","catch","exception","request","methodname","args","call","done","data","result","window","location","reload","prototype","click","e","preventDefault","button","this","promises","titlePromise","get_string","text","when","categoryResponse","purposeResponse","categories","options","purposes","activityResponse","activities","activityDisplayName","setSaveButtonText"],"mappings":";;;;;;;AAsBAA,0CAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,oBACA,mBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,YAAaC,eAUxDC,4BACqB,sCADrBA,8BAEuB,wCAFvBA,+BAGwB,yCAHxBA,iCAI0B,2CA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,IAAI3C"} \ No newline at end of file +{"version":3,"file":"defaultsactions.min.js","sources":["../src/defaultsactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * AMD module for data registry defaults actions.\n *\n * @module tool_dataprivacy/defaultsactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/templates'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates) {\n\n /**\n * List of action selectors.\n *\n * @type {{EDIT_LEVEL_DEFAULTS: string}}\n * @type {{NEW_ACTIVITY_DEFAULTS: string}}\n * @type {{EDIT_ACTIVITY_DEFAULTS: string}}\n * @type {{DELETE_ACTIVITY_DEFAULTS: string}}\n */\n var ACTIONS = {\n EDIT_LEVEL_DEFAULTS: '[data-action=\"edit-level-defaults\"]',\n NEW_ACTIVITY_DEFAULTS: '[data-action=\"new-activity-defaults\"]',\n EDIT_ACTIVITY_DEFAULTS: '[data-action=\"edit-activity-defaults\"]',\n DELETE_ACTIVITY_DEFAULTS: '[data-action=\"delete-activity-defaults\"]'\n };\n\n /** @type {{INHERIT: Number}} **/\n var INHERIT = -1;\n\n /**\n * DefaultsActions class.\n */\n var DefaultsActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n DefaultsActions.prototype.registerEvents = function() {\n $(ACTIONS.EDIT_LEVEL_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var category = button.data('category');\n var purpose = button.data('purpose');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('editdefaults', 'tool_dataprivacy', $('#defaults-header').text());\n $.when(promises[0], promises[1], titlePromise).then(function(categoryResponse, purposeResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n showDefaultsFormModal(title, contextLevel, category, purpose, null, categories, purposes, null);\n\n return true;\n }).catch(Notification.exception);\n });\n\n $(ACTIONS.NEW_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}},\n {methodname: 'tool_dataprivacy_get_activity_options', args: {'nodefaults': true}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('addnewdefaults', 'tool_dataprivacy');\n\n $.when(promises[0], promises[1], promises[2], titlePromise).then(\n function(categoryResponse, purposeResponse, activityResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n var activities = activityResponse.options;\n\n showDefaultsFormModal(title, contextLevel, null, null, null, categories, purposes, activities);\n\n return true;\n\n }).catch(Notification.exception);\n }\n );\n\n $(ACTIONS.EDIT_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var category = button.data('category');\n var purpose = button.data('purpose');\n var activity = button.data('activityname');\n\n // Get options.\n var requests = [\n {methodname: 'tool_dataprivacy_get_category_options', args: {}},\n {methodname: 'tool_dataprivacy_get_purpose_options', args: {}},\n {methodname: 'tool_dataprivacy_get_activity_options', args: {}}\n ];\n\n var promises = Ajax.call(requests);\n var titlePromise = Str.get_string('editmoduledefaults', 'tool_dataprivacy');\n\n $.when(promises[0], promises[1], promises[2], titlePromise).then(\n function(categoryResponse, purposeResponse, activityResponse, title) {\n var categories = categoryResponse.options;\n var purposes = purposeResponse.options;\n var activities = activityResponse.options;\n\n showDefaultsFormModal(title, contextLevel, category, purpose, activity, categories, purposes, activities);\n\n return true;\n\n }).catch(Notification.exception);\n }\n );\n\n $(ACTIONS.DELETE_ACTIVITY_DEFAULTS).click(function(e) {\n e.preventDefault();\n\n var button = $(this);\n var contextLevel = button.data('contextlevel');\n var activity = button.data('activityname');\n var activityDisplayName = button.data('activitydisplayname');\n // Set category and purpose to inherit (-1).\n var category = INHERIT;\n var purpose = INHERIT;\n\n ModalFactory.create({\n title: Str.get_string('deletedefaults', 'tool_dataprivacy', activityDisplayName),\n body: Templates.render('tool_dataprivacy/delete_activity_defaults', {\"activityname\": activityDisplayName}),\n type: ModalFactory.types.SAVE_CANCEL,\n large: true\n }).then(function(modal) {\n modal.setSaveButtonText(Str.get_string('delete'));\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n setContextDefaults(contextLevel, category, purpose, activity, false);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return true;\n }).catch(Notification.exception);\n });\n };\n\n /**\n * Prepares and renders the modal for setting the defaults for the given context level/plugin.\n *\n * @param {String} title The modal's title.\n * @param {Number} contextLevel The context level to set defaults for.\n * @param {Number} category The current category ID.\n * @param {Number} purpose The current purpose ID.\n * @param {String} activity The plugin name of the activity. Optional.\n * @param {Array} categoryOptions The list of category options.\n * @param {Array} purposeOptions The list of purpose options.\n * @param {Array} activityOptions The list of activity options. Optional.\n */\n function showDefaultsFormModal(title, contextLevel, category, purpose, activity,\n categoryOptions, purposeOptions, activityOptions) {\n\n if (category !== null) {\n categoryOptions.forEach(function(currentValue) {\n if (currentValue.id === category) {\n currentValue.selected = true;\n }\n });\n }\n\n if (purpose !== null) {\n purposeOptions.forEach(function(currentValue) {\n if (currentValue.id === purpose) {\n currentValue.selected = true;\n }\n });\n }\n\n var templateContext = {\n \"contextlevel\": contextLevel,\n \"categoryoptions\": categoryOptions,\n \"purposeoptions\": purposeOptions\n };\n\n // Check the activityOptions parameter that was passed.\n if (activityOptions !== null && activityOptions.length) {\n // Check the activity parameter that was passed.\n if (activity === null) {\n // We're setting a new defaults for a module.\n templateContext.newactivitydefaults = true;\n\n } else {\n // Edit mode. Set selection.\n activityOptions.forEach(function(currentValue) {\n if (activity === currentValue.name) {\n currentValue.selected = true;\n }\n });\n }\n\n templateContext.modemodule = true;\n templateContext.activityoptions = activityOptions;\n }\n\n ModalFactory.create({\n title: title,\n body: Templates.render('tool_dataprivacy/category_purpose_form', templateContext),\n type: ModalFactory.types.SAVE_CANCEL,\n large: true\n }).then(function(modal) {\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n var activity = $('#activity');\n var activityVal = typeof activity !== 'undefined' ? activity.val() : null;\n var override = $('#override');\n var overrideVal = typeof override !== 'undefined' ? override.is(':checked') : false;\n\n setContextDefaults($('#contextlevel').val(), $('#category').val(), $('#purpose').val(), activityVal, overrideVal);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return modal;\n }).catch(Notification.exception);\n }\n\n /**\n * Calls a the tool_dataprivacy_set_context_defaults WS function.\n *\n * @param {Number} contextLevel The context level.\n * @param {Number} category The category ID.\n * @param {Number} purpose The purpose ID.\n * @param {String} activity The plugin name of the activity module.\n * @param {Boolean} override Whether to override custom instances.\n */\n function setContextDefaults(contextLevel, category, purpose, activity, override) {\n var request = {\n methodname: 'tool_dataprivacy_set_context_defaults',\n args: {\n 'contextlevel': contextLevel,\n 'category': category,\n 'purpose': purpose,\n 'override': override,\n 'activity': activity\n }\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n window.location.reload();\n }\n });\n }\n\n return /** @alias module:tool_dataprivacy/defaultsactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {DefaultsActions}\n */\n 'init': function() {\n return new DefaultsActions();\n }\n };\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","Templates","ACTIONS","DefaultsActions","this","registerEvents","showDefaultsFormModal","title","contextLevel","category","purpose","activity","categoryOptions","purposeOptions","activityOptions","forEach","currentValue","id","selected","templateContext","contextlevel","categoryoptions","purposeoptions","length","newactivitydefaults","name","modemodule","activityoptions","create","body","render","type","types","SAVE_CANCEL","large","then","modal","getRoot","on","save","activityVal","val","override","overrideVal","is","setContextDefaults","hidden","destroy","show","catch","exception","request","methodname","args","call","done","data","result","window","location","reload","prototype","click","e","preventDefault","button","promises","titlePromise","get_string","text","when","categoryResponse","purposeResponse","categories","options","purposes","nodefaults","activityResponse","activities","activityDisplayName","activityname","setSaveButtonText","init"],"mappings":";;;;;;;AAsBAA,OAAO,mCAAA,CACH,SACA,YACA,oBACA,WACA,qBACA,oBACA,mBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,YAAaC,WAU5D,IAAIC,4BACqB,sCADrBA,8BAEuB,wCAFvBA,+BAGwB,yCAHxBA,iCAI0B,2CAS1BC,gBAAkB,WAClBC,KAAKC,kBAgJT,SAASC,sBAAsBC,MAAOC,aAAcC,SAAUC,QAASC,SACxCC,gBAAiBC,eAAgBC,iBAE3C,OAAbL,UACAG,gBAAgBG,SAAQ,SAASC,cACzBA,aAAaC,KAAOR,WACpBO,aAAaE,UAAW,EAEhC,IAGY,OAAZR,SACAG,eAAeE,SAAQ,SAASC,cACxBA,aAAaC,KAAOP,UACpBM,aAAaE,UAAW,EAEhC,IAGJ,IAAIC,gBAAkB,CAClBC,aAAgBZ,aAChBa,gBAAmBT,gBACnBU,eAAkBT,gBAIE,OAApBC,iBAA4BA,gBAAgBS,SAE3B,OAAbZ,SAEAQ,gBAA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_retention_period.min.js.map b/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js.map index ac590ba9ea6..5440248c910 100644 --- a/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js.map +++ b/admin/tool/dataprivacy/amd/build/effective_retention_period.min.js.map @@ -1 +1 @@ -{"version":3,"file":"effective_retention_period.min.js","sources":["../src/effective_retention_period.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to update the displayed retention period.\n *\n * @module tool_dataprivacy/effective_retention_period\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'],\n function($) {\n\n var SELECTORS = {\n PURPOSE_SELECT: '#id_purposeid',\n RETENTION_FIELD: '#fitem_id_retention_current [data-fieldtype=static]',\n };\n\n /**\n * Constructor for the retention period display.\n *\n * @param {Array} purposeRetentionPeriods Associative array of purposeids with effective retention period at this context\n */\n var EffectiveRetentionPeriod = function(purposeRetentionPeriods) {\n this.purposeRetentionPeriods = purposeRetentionPeriods;\n this.registerEventListeners();\n };\n\n /**\n * Removes the current 'change' listeners.\n *\n * Useful when a new form is loaded.\n */\n var removeListeners = function() {\n $(SELECTORS.PURPOSE_SELECT).off('change');\n };\n\n /**\n * @var {Array} purposeRetentionPeriods\n * @private\n */\n EffectiveRetentionPeriod.prototype.purposeRetentionPeriods = [];\n\n /**\n * Add purpose change listeners.\n *\n * @method registerEventListeners\n */\n EffectiveRetentionPeriod.prototype.registerEventListeners = function() {\n\n $(SELECTORS.PURPOSE_SELECT).on('change', function(ev) {\n var selected = $(ev.currentTarget).val();\n var selectedPurpose = this.purposeRetentionPeriods[selected];\n $(SELECTORS.RETENTION_FIELD).text(selectedPurpose);\n }.bind(this));\n };\n\n return /** @alias module:tool_dataprivacy/effective_retention_period */ {\n init: function(purposeRetentionPeriods) {\n // Remove previously attached listeners.\n removeListeners();\n return new EffectiveRetentionPeriod(purposeRetentionPeriods);\n }\n };\n }\n);\n\n"],"names":["define","$","SELECTORS","EffectiveRetentionPeriod","purposeRetentionPeriods","registerEventListeners","prototype","on","ev","selected","currentTarget","val","selectedPurpose","this","text","bind","init","off"],"mappings":";;;;;;;AAsBAA,qDAAO,CAAC,WACJ,SAASC,OAEDC,yBACgB,gBADhBA,0BAEiB,sDAQjBC,yBAA2B,SAASC,8BAC/BA,wBAA0BA,6BAC1BC,iCAgBTF,yBAAyBG,UAAUF,wBAA0B,GAO7DD,yBAAyBG,UAAUD,uBAAyB,WAExDJ,EAAEC,0BAA0BK,GAAG,SAAU,SAASC,QAC1CC,SAAWR,EAAEO,GAAGE,eAAeC,MAC/BC,gBAAkBC,KAAKT,wBAAwBK,UACnDR,EAAEC,2BAA2BY,KAAKF,kBACpCG,KAAKF,QAG6D,CACpEG,KAAM,SAASZ,gCAxBfH,EAAEC,0BAA0Be,IAAI,UA2BrB,IAAId,yBAAyBC"} \ No newline at end of file +{"version":3,"file":"effective_retention_period.min.js","sources":["../src/effective_retention_period.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to update the displayed retention period.\n *\n * @module tool_dataprivacy/effective_retention_period\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'],\n function($) {\n\n var SELECTORS = {\n PURPOSE_SELECT: '#id_purposeid',\n RETENTION_FIELD: '#fitem_id_retention_current [data-fieldtype=static]',\n };\n\n /**\n * Constructor for the retention period display.\n *\n * @param {Array} purposeRetentionPeriods Associative array of purposeids with effective retention period at this context\n */\n var EffectiveRetentionPeriod = function(purposeRetentionPeriods) {\n this.purposeRetentionPeriods = purposeRetentionPeriods;\n this.registerEventListeners();\n };\n\n /**\n * Removes the current 'change' listeners.\n *\n * Useful when a new form is loaded.\n */\n var removeListeners = function() {\n $(SELECTORS.PURPOSE_SELECT).off('change');\n };\n\n /**\n * @var {Array} purposeRetentionPeriods\n * @private\n */\n EffectiveRetentionPeriod.prototype.purposeRetentionPeriods = [];\n\n /**\n * Add purpose change listeners.\n *\n * @method registerEventListeners\n */\n EffectiveRetentionPeriod.prototype.registerEventListeners = function() {\n\n $(SELECTORS.PURPOSE_SELECT).on('change', function(ev) {\n var selected = $(ev.currentTarget).val();\n var selectedPurpose = this.purposeRetentionPeriods[selected];\n $(SELECTORS.RETENTION_FIELD).text(selectedPurpose);\n }.bind(this));\n };\n\n return /** @alias module:tool_dataprivacy/effective_retention_period */ {\n init: function(purposeRetentionPeriods) {\n // Remove previously attached listeners.\n removeListeners();\n return new EffectiveRetentionPeriod(purposeRetentionPeriods);\n }\n };\n }\n);\n\n"],"names":["define","$","SELECTORS","EffectiveRetentionPeriod","purposeRetentionPeriods","this","registerEventListeners","prototype","on","ev","selected","currentTarget","val","selectedPurpose","text","bind","init","off"],"mappings":";;;;;;;AAsBAA,qDAAO,CAAC,WACJ,SAASC,GAEL,IAAIC,yBACgB,gBADhBA,0BAEiB,sDAQjBC,yBAA2B,SAASC,yBACpCC,KAAKD,wBAA0BA,wBAC/BC,KAAKC,0BAgCT,OAhBAH,yBAAyBI,UAAUH,wBAA0B,GAO7DD,yBAAyBI,UAAUD,uBAAyB,WAExDL,EAAEC,0BAA0BM,GAAG,SAAU,SAASC,IAC9C,IAAIC,SAAWT,EAAEQ,GAAGE,eAAeC,MAC/BC,gBAAkBR,KAAKD,wBAAwBM,UACnDT,EAAEC,2BAA2BY,KAAKD,gBACtC,EAAEE,KAAKV,QAG6D,CACpEW,KAAM,SAASZ,yBAGX,OA3BJH,EAAEC,0BAA0Be,IAAI,UA2BrB,IAAId,yBAAyBC,wBACxC,EAER"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/events.min.js.map b/admin/tool/dataprivacy/amd/build/events.min.js.map index 287e52800b6..57aa7a662fd 100644 --- a/admin/tool/dataprivacy/amd/build/events.min.js.map +++ b/admin/tool/dataprivacy/amd/build/events.min.js.map @@ -1 +1 @@ -{"version":3,"file":"events.min.js","sources":["../src/events.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the events the data privacy tool can fire.\n *\n * @module tool_dataprivacy/events\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n approve: 'tool_dataprivacy-data_request:approve',\n bulkApprove: 'tool_dataprivacy-data_request:bulk_approve',\n deny: 'tool_dataprivacy-data_request:deny',\n bulkDeny: 'tool_dataprivacy-data_request:bulk_deny',\n complete: 'tool_dataprivacy-data_request:complete'\n };\n});\n"],"names":["define","approve","bulkApprove","deny","bulkDeny","complete"],"mappings":";;;;;;;AAsBAA,iCAAO,IAAI,iBACA,CACHC,QAAS,wCACTC,YAAa,6CACbC,KAAM,qCACNC,SAAU,0CACVC,SAAU"} \ No newline at end of file +{"version":3,"file":"events.min.js","sources":["../src/events.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the events the data privacy tool can fire.\n *\n * @module tool_dataprivacy/events\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n approve: 'tool_dataprivacy-data_request:approve',\n bulkApprove: 'tool_dataprivacy-data_request:bulk_approve',\n deny: 'tool_dataprivacy-data_request:deny',\n bulkDeny: 'tool_dataprivacy-data_request:bulk_deny',\n complete: 'tool_dataprivacy-data_request:complete'\n };\n});\n"],"names":["define","approve","bulkApprove","deny","bulkDeny","complete"],"mappings":";;;;;;;AAsBAA,OAAM,0BAAC,IAAI,WACP,MAAO,CACHC,QAAS,wCACTC,YAAa,6CACbC,KAAM,qCACNC,SAAU,0CACVC,SAAU,yCAElB"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/expand_contract.min.js.map b/admin/tool/dataprivacy/amd/build/expand_contract.min.js.map index 2be5226c3af..5b7fb580f0e 100644 --- a/admin/tool/dataprivacy/amd/build/expand_contract.min.js.map +++ b/admin/tool/dataprivacy/amd/build/expand_contract.min.js.map @@ -1 +1 @@ -{"version":3,"file":"expand_contract.min.js","sources":["../src/expand_contract.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Potential user selector module.\n *\n * @module tool_dataprivacy/expand_contract\n * @copyright 2018 Adrian Greeve\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/url', 'core/str', 'core/notification'], function($, url, str, Notification) {\n\n var expandedImage = $('\"\"');\n var collapsedImage = $('\"\"');\n\n /*\n * Class names to apply when expanding/collapsing nodes.\n */\n var CLASSES = {\n EXPAND: 'fa-caret-right',\n COLLAPSE: 'fa-caret-down'\n };\n\n return /** @alias module:tool_dataprivacy/expand-collapse */ {\n /**\n * Expand or collapse a selected node.\n *\n * @param {object} targetnode The node that we want to expand / collapse\n * @param {object} thisnode The node that was clicked.\n */\n expandCollapse: function(targetnode, thisnode) {\n if (targetnode.hasClass('hide')) {\n targetnode.removeClass('hide');\n targetnode.addClass('visible');\n targetnode.attr('aria-expanded', true);\n thisnode.find(':header i.fa').removeClass(CLASSES.EXPAND);\n thisnode.find(':header i.fa').addClass(CLASSES.COLLAPSE);\n thisnode.find(':header img.icon').attr('src', expandedImage.attr('src'));\n } else {\n targetnode.removeClass('visible');\n targetnode.addClass('hide');\n targetnode.attr('aria-expanded', false);\n thisnode.find(':header i.fa').removeClass(CLASSES.COLLAPSE);\n thisnode.find(':header i.fa').addClass(CLASSES.EXPAND);\n thisnode.find(':header img.icon').attr('src', collapsedImage.attr('src'));\n }\n },\n\n /**\n * Expand or collapse all nodes on this page.\n *\n * @param {string} nextstate The next state to change to.\n */\n expandCollapseAll: function(nextstate) {\n var currentstate = (nextstate == 'visible') ? 'hide' : 'visible';\n var ariaexpandedstate = (nextstate == 'visible') ? true : false;\n var iconclassnow = (nextstate == 'visible') ? CLASSES.EXPAND : CLASSES.COLLAPSE;\n var iconclassnext = (nextstate == 'visible') ? CLASSES.COLLAPSE : CLASSES.EXPAND;\n var imagenow = (nextstate == 'visible') ? expandedImage.attr('src') : collapsedImage.attr('src');\n $('.' + currentstate).each(function() {\n $(this).removeClass(currentstate);\n $(this).addClass(nextstate);\n $(this).attr('aria-expanded', ariaexpandedstate);\n });\n $('.tool_dataprivacy-expand-all').data('visibilityState', currentstate);\n\n str.get_string(currentstate, 'tool_dataprivacy').then(function(langString) {\n $('.tool_dataprivacy-expand-all').html(langString);\n return;\n }).catch(Notification.exception);\n\n $(':header i.fa').each(function() {\n $(this).removeClass(iconclassnow);\n $(this).addClass(iconclassnext);\n });\n $(':header img.icon').each(function() {\n $(this).attr('src', imagenow);\n });\n }\n };\n});\n"],"names":["define","$","url","str","Notification","expandedImage","imageUrl","collapsedImage","CLASSES","expandCollapse","targetnode","thisnode","hasClass","removeClass","addClass","attr","find","expandCollapseAll","nextstate","currentstate","ariaexpandedstate","iconclassnow","iconclassnext","imagenow","each","this","data","get_string","then","langString","html","catch","exception"],"mappings":";;;;;;;AAuBAA,0CAAO,CAAC,SAAU,WAAY,WAAY,sBAAsB,SAASC,EAAGC,IAAKC,IAAKC,kBAE9EC,cAAgBJ,EAAE,oBAAsBC,IAAII,SAAS,cAAgB,OACrEC,eAAiBN,EAAE,oBAAsBC,IAAII,SAAS,eAAiB,OAKvEE,eACQ,iBADRA,iBAEU,sBAG+C,CAOzDC,eAAgB,SAASC,WAAYC,UAC7BD,WAAWE,SAAS,SACpBF,WAAWG,YAAY,QACvBH,WAAWI,SAAS,WACpBJ,WAAWK,KAAK,iBAAiB,GACjCJ,SAASK,KAAK,gBAAgBH,YAAYL,gBAC1CG,SAASK,KAAK,gBAAgBF,SAASN,kBACvCG,SAASK,KAAK,oBAAoBD,KAAK,MAAOV,cAAcU,KAAK,UAEjEL,WAAWG,YAAY,WACvBH,WAAWI,SAAS,QACpBJ,WAAWK,KAAK,iBAAiB,GACjCJ,SAASK,KAAK,gBAAgBH,YAAYL,kBAC1CG,SAASK,KAAK,gBAAgBF,SAASN,gBACvCG,SAASK,KAAK,oBAAoBD,KAAK,MAAOR,eAAeQ,KAAK,UAS1EE,kBAAmB,SAASC,eACpBC,aAA6B,WAAbD,UAA0B,OAAS,UACnDE,kBAAkC,WAAbF,UACrBG,aAA6B,WAAbH,UAA0BV,eAAiBA,iBAC3Dc,cAA8B,WAAbJ,UAA0BV,iBAAmBA,eAC9De,SAAyB,WAAbL,UAA0Bb,cAAcU,KAAK,OAASR,eAAeQ,KAAK,OAC1Fd,EAAE,IAAMkB,cAAcK,MAAK,WACvBvB,EAAEwB,MAAMZ,YAAYM,cACpBlB,EAAEwB,MAAMX,SAASI,WACjBjB,EAAEwB,MAAMV,KAAK,gBAAiBK,sBAElCnB,EAAE,gCAAgCyB,KAAK,kBAAmBP,cAE1DhB,IAAIwB,WAAWR,aAAc,oBAAoBS,MAAK,SAASC,YAC3D5B,EAAE,gCAAgC6B,KAAKD,eAExCE,MAAM3B,aAAa4B,WAEtB/B,EAAE,gBAAgBuB,MAAK,WACnBvB,EAAEwB,MAAMZ,YAAYQ,cACpBpB,EAAEwB,MAAMX,SAASQ,kBAErBrB,EAAE,oBAAoBuB,MAAK,WACvBvB,EAAEwB,MAAMV,KAAK,MAAOQ"} \ No newline at end of file +{"version":3,"file":"expand_contract.min.js","sources":["../src/expand_contract.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Potential user selector module.\n *\n * @module tool_dataprivacy/expand_contract\n * @copyright 2018 Adrian Greeve\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/url', 'core/str', 'core/notification'], function($, url, str, Notification) {\n\n var expandedImage = $('\"\"');\n var collapsedImage = $('\"\"');\n\n /*\n * Class names to apply when expanding/collapsing nodes.\n */\n var CLASSES = {\n EXPAND: 'fa-caret-right',\n COLLAPSE: 'fa-caret-down'\n };\n\n return /** @alias module:tool_dataprivacy/expand-collapse */ {\n /**\n * Expand or collapse a selected node.\n *\n * @param {object} targetnode The node that we want to expand / collapse\n * @param {object} thisnode The node that was clicked.\n */\n expandCollapse: function(targetnode, thisnode) {\n if (targetnode.hasClass('hide')) {\n targetnode.removeClass('hide');\n targetnode.addClass('visible');\n targetnode.attr('aria-expanded', true);\n thisnode.find(':header i.fa').removeClass(CLASSES.EXPAND);\n thisnode.find(':header i.fa').addClass(CLASSES.COLLAPSE);\n thisnode.find(':header img.icon').attr('src', expandedImage.attr('src'));\n } else {\n targetnode.removeClass('visible');\n targetnode.addClass('hide');\n targetnode.attr('aria-expanded', false);\n thisnode.find(':header i.fa').removeClass(CLASSES.COLLAPSE);\n thisnode.find(':header i.fa').addClass(CLASSES.EXPAND);\n thisnode.find(':header img.icon').attr('src', collapsedImage.attr('src'));\n }\n },\n\n /**\n * Expand or collapse all nodes on this page.\n *\n * @param {string} nextstate The next state to change to.\n */\n expandCollapseAll: function(nextstate) {\n var currentstate = (nextstate == 'visible') ? 'hide' : 'visible';\n var ariaexpandedstate = (nextstate == 'visible') ? true : false;\n var iconclassnow = (nextstate == 'visible') ? CLASSES.EXPAND : CLASSES.COLLAPSE;\n var iconclassnext = (nextstate == 'visible') ? CLASSES.COLLAPSE : CLASSES.EXPAND;\n var imagenow = (nextstate == 'visible') ? expandedImage.attr('src') : collapsedImage.attr('src');\n $('.' + currentstate).each(function() {\n $(this).removeClass(currentstate);\n $(this).addClass(nextstate);\n $(this).attr('aria-expanded', ariaexpandedstate);\n });\n $('.tool_dataprivacy-expand-all').data('visibilityState', currentstate);\n\n str.get_string(currentstate, 'tool_dataprivacy').then(function(langString) {\n $('.tool_dataprivacy-expand-all').html(langString);\n return;\n }).catch(Notification.exception);\n\n $(':header i.fa').each(function() {\n $(this).removeClass(iconclassnow);\n $(this).addClass(iconclassnext);\n });\n $(':header img.icon').each(function() {\n $(this).attr('src', imagenow);\n });\n }\n };\n});\n"],"names":["define","$","url","str","Notification","expandedImage","imageUrl","collapsedImage","CLASSES","expandCollapse","targetnode","thisnode","hasClass","removeClass","addClass","attr","find","expandCollapseAll","nextstate","currentstate","ariaexpandedstate","iconclassnow","iconclassnext","imagenow","each","this","data","get_string","then","langString","html","catch","exception"],"mappings":";;;;;;;AAuBAA,0CAAO,CAAC,SAAU,WAAY,WAAY,sBAAsB,SAASC,EAAGC,IAAKC,IAAKC,cAElF,IAAIC,cAAgBJ,EAAE,oBAAsBC,IAAII,SAAS,cAAgB,OACrEC,eAAiBN,EAAE,oBAAsBC,IAAII,SAAS,eAAiB,OAKvEE,eACQ,iBADRA,iBAEU,gBAGd,MAA6D,CAOzDC,eAAgB,SAASC,WAAYC,UAC7BD,WAAWE,SAAS,SACpBF,WAAWG,YAAY,QACvBH,WAAWI,SAAS,WACpBJ,WAAWK,KAAK,iBAAiB,GACjCJ,SAASK,KAAK,gBAAgBH,YAAYL,gBAC1CG,SAASK,KAAK,gBAAgBF,SAASN,kBACvCG,SAASK,KAAK,oBAAoBD,KAAK,MAAOV,cAAcU,KAAK,UAEjEL,WAAWG,YAAY,WACvBH,WAAWI,SAAS,QACpBJ,WAAWK,KAAK,iBAAiB,GACjCJ,SAASK,KAAK,gBAAgBH,YAAYL,kBAC1CG,SAASK,KAAK,gBAAgBF,SAASN,gBACvCG,SAASK,KAAK,oBAAoBD,KAAK,MAAOR,eAAeQ,KAAK,QAEzE,EAODE,kBAAmB,SAASC,WACxB,IAAIC,aAA6B,WAAbD,UAA0B,OAAS,UACnDE,kBAAkC,WAAbF,UACrBG,aAA6B,WAAbH,UAA0BV,eAAiBA,iBAC3Dc,cAA8B,WAAbJ,UAA0BV,iBAAmBA,eAC9De,SAAyB,WAAbL,UAA0Bb,cAAcU,KAAK,OAASR,eAAeQ,KAAK,OAC1Fd,EAAE,IAAMkB,cAAcK,MAAK,WACvBvB,EAAEwB,MAAMZ,YAAYM,cACpBlB,EAAEwB,MAAMX,SAASI,WACjBjB,EAAEwB,MAAMV,KAAK,gBAAiBK,kBAClC,IACAnB,EAAE,gCAAgCyB,KAAK,kBAAmBP,cAE1DhB,IAAIwB,WAAWR,aAAc,oBAAoBS,MAAK,SAASC,YAC3D5B,EAAE,gCAAgC6B,KAAKD,WAE1C,IAAEE,MAAM3B,aAAa4B,WAEtB/B,EAAE,gBAAgBuB,MAAK,WACnBvB,EAAEwB,MAAMZ,YAAYQ,cACpBpB,EAAEwB,MAAMX,SAASQ,cACrB,IACArB,EAAE,oBAAoBuB,MAAK,WACvBvB,EAAEwB,MAAMV,KAAK,MAAOQ,SACxB,GACJ,EAER"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/form-user-selector.min.js.map b/admin/tool/dataprivacy/amd/build/form-user-selector.min.js.map index 5d218425475..2c67080082d 100644 --- a/admin/tool/dataprivacy/amd/build/form-user-selector.min.js.map +++ b/admin/tool/dataprivacy/amd/build/form-user-selector.min.js.map @@ -1 +1 @@ -{"version":3,"file":"form-user-selector.min.js","sources":["../src/form-user-selector.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Potential user selector module.\n *\n * @module tool_dataprivacy/form-user-selector\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_dataprivacy/form-user-selector */ {\n\n processResults: function(selector, results) {\n var users = [];\n $.each(results, function(index, user) {\n users.push({\n value: user.id,\n label: user._label\n });\n });\n return users;\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n\n promise = Ajax.call([{\n methodname: 'tool_dataprivacy_get_users',\n args: {\n query: query\n }\n }]);\n\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results, function(index, user) {\n promises.push(Templates.render('tool_dataprivacy/form-user-selector-suggestion', user));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results, function(index, user) {\n user._label = args[i];\n i++;\n });\n success(results);\n return;\n });\n\n }).fail(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","users","each","index","user","push","value","id","label","_label","transport","query","success","failure","call","methodname","args","then","promises","i","render","when","apply","arguments","fail"],"mappings":";;;;;;;AAuBAA,6CAAO,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,iBAEA,CAE5DC,eAAgB,SAASC,SAAUC,aAC3BC,MAAQ,UACZN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BH,MAAMI,KAAK,CACPC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,YAGbR,OAGXS,UAAW,SAASX,SAAUY,MAAOC,QAASC,SAGhCjB,KAAKkB,KAAK,CAAC,CACjBC,WAAY,6BACZC,KAAM,CACFL,MAAOA,UAIP,GAAGM,MAAK,SAASjB,aACjBkB,SAAW,GACXC,EAAI,SAGRxB,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5Bc,SAASb,KAAKR,UAAUuB,OAAO,iDAAkDhB,UAI9ET,EAAE0B,KAAKC,MAAM3B,EAAE0B,KAAMH,UAAUD,MAAK,eACnCD,KAAOO,UACX5B,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BA,KAAKK,OAASO,KAAKG,GACnBA,OAEJP,QAAQZ,eAIbwB,KAAKX"} \ No newline at end of file +{"version":3,"file":"form-user-selector.min.js","sources":["../src/form-user-selector.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Potential user selector module.\n *\n * @module tool_dataprivacy/form-user-selector\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_dataprivacy/form-user-selector */ {\n\n processResults: function(selector, results) {\n var users = [];\n $.each(results, function(index, user) {\n users.push({\n value: user.id,\n label: user._label\n });\n });\n return users;\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n\n promise = Ajax.call([{\n methodname: 'tool_dataprivacy_get_users',\n args: {\n query: query\n }\n }]);\n\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results, function(index, user) {\n promises.push(Templates.render('tool_dataprivacy/form-user-selector-suggestion', user));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results, function(index, user) {\n user._label = args[i];\n i++;\n });\n success(results);\n return;\n });\n\n }).fail(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","users","each","index","user","push","value","id","label","_label","transport","query","success","failure","call","methodname","args","then","promises","i","render","when","apply","arguments","fail"],"mappings":";;;;;;;AAuBAA,OAAO,sCAAA,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,WAEhE,MAAgE,CAE5DC,eAAgB,SAASC,SAAUC,SAC/B,IAAIC,MAAQ,GAOZ,OANAN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BH,MAAMI,KAAK,CACPC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,QAEpB,IACOR,KACV,EAEDS,UAAW,SAASX,SAAUY,MAAOC,QAASC,SAGhCjB,KAAKkB,KAAK,CAAC,CACjBC,WAAY,6BACZC,KAAM,CACFL,MAAOA,UAIP,GAAGM,MAAK,SAASjB,SACrB,IAAIkB,SAAW,GACXC,EAAI,EAQR,OALAxB,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5Bc,SAASb,KAAKR,UAAUuB,OAAO,iDAAkDhB,MACrF,IAGOT,EAAE0B,KAAKC,MAAM3B,EAAE0B,KAAMH,UAAUD,MAAK,WACvC,IAAID,KAAOO,UACX5B,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BA,KAAKK,OAASO,KAAKG,GACnBA,GACJ,IACAP,QAAQZ,QAEZ,GAEJ,IAAGwB,KAAKX,QACZ,EAIR"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/myrequestactions.min.js.map b/admin/tool/dataprivacy/amd/build/myrequestactions.min.js.map index ac1d3817f17..ea946aedb19 100644 --- a/admin/tool/dataprivacy/amd/build/myrequestactions.min.js.map +++ b/admin/tool/dataprivacy/amd/build/myrequestactions.min.js.map @@ -1 +1 @@ -{"version":3,"file":"myrequestactions.min.js","sources":["../src/myrequestactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * AMD module to enable users to manage their own data requests.\n *\n * @module tool_dataprivacy/myrequestactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\nimport Pending from 'core/pending';\nimport {get_strings as getStrings} from 'core/str';\n\nconst SELECTORS = {\n CANCEL_REQUEST: '[data-action=\"cancel\"][data-requestid]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n document.addEventListener('click', event => {\n const triggerElement = event.target.closest(SELECTORS.CANCEL_REQUEST);\n if (triggerElement === null) {\n return;\n }\n\n event.preventDefault();\n\n const requiredStrings = [\n {key: 'cancelrequest', component: 'tool_dataprivacy'},\n {key: 'cancelrequestconfirmation', component: 'tool_dataprivacy'},\n ];\n\n getStrings(requiredStrings).then(([cancelRequest, cancelConfirm]) => {\n return Notification.confirm(cancelRequest, cancelConfirm, cancelRequest, null, () => {\n const pendingPromise = new Pending('tool/dataprivacy:cancelRequest');\n const request = {\n methodname: 'tool_dataprivacy_cancel_data_request',\n args: {requestid: triggerElement.dataset.requestid}\n };\n\n Ajax.call([request])[0].then(response => {\n if (response.result) {\n window.location.reload();\n } else {\n Notification.addNotification({\n type: 'error',\n message: response.warnings[0].message\n });\n }\n return pendingPromise.resolve();\n }).catch(Notification.exception);\n });\n }).catch();\n });\n};\n"],"names":["SELECTORS","document","addEventListener","event","triggerElement","target","closest","preventDefault","key","component","then","_ref","cancelRequest","cancelConfirm","Notification","confirm","pendingPromise","Pending","request","methodname","args","requestid","dataset","call","response","result","window","location","reload","addNotification","type","message","warnings","resolve","catch","exception"],"mappings":";;;;;;;0NA4BMA,yBACc,uDAMA,KAChBC,SAASC,iBAAiB,SAASC,cACzBC,eAAiBD,MAAME,OAAOC,QAAQN,6BACrB,OAAnBI,sBAIJD,MAAMI,sCAEkB,CACpB,CAACC,IAAK,gBAAiBC,UAAW,oBAClC,CAACD,IAAK,4BAA6BC,UAAW,sBAGtBC,MAAKC,WAAEC,cAAeC,2BACvCC,sBAAaC,QAAQH,cAAeC,cAAeD,cAAe,MAAM,WACrEI,eAAiB,IAAIC,iBAAQ,kCAC7BC,QAAU,CACZC,WAAY,uCACZC,KAAM,CAACC,UAAWjB,eAAekB,QAAQD,0BAGxCE,KAAK,CAACL,UAAU,GAAGR,MAAKc,WACrBA,SAASC,OACTC,OAAOC,SAASC,+BAEHC,gBAAgB,CACzBC,KAAM,QACNC,QAASP,SAASQ,SAAS,GAAGD,UAG/Bf,eAAeiB,aACvBC,MAAMpB,sBAAaqB,iBAE3BD"} \ No newline at end of file +{"version":3,"file":"myrequestactions.min.js","sources":["../src/myrequestactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * AMD module to enable users to manage their own data requests.\n *\n * @module tool_dataprivacy/myrequestactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\nimport Pending from 'core/pending';\nimport {get_strings as getStrings} from 'core/str';\n\nconst SELECTORS = {\n CANCEL_REQUEST: '[data-action=\"cancel\"][data-requestid]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n document.addEventListener('click', event => {\n const triggerElement = event.target.closest(SELECTORS.CANCEL_REQUEST);\n if (triggerElement === null) {\n return;\n }\n\n event.preventDefault();\n\n const requiredStrings = [\n {key: 'cancelrequest', component: 'tool_dataprivacy'},\n {key: 'cancelrequestconfirmation', component: 'tool_dataprivacy'},\n ];\n\n getStrings(requiredStrings).then(([cancelRequest, cancelConfirm]) => {\n return Notification.confirm(cancelRequest, cancelConfirm, cancelRequest, null, () => {\n const pendingPromise = new Pending('tool/dataprivacy:cancelRequest');\n const request = {\n methodname: 'tool_dataprivacy_cancel_data_request',\n args: {requestid: triggerElement.dataset.requestid}\n };\n\n Ajax.call([request])[0].then(response => {\n if (response.result) {\n window.location.reload();\n } else {\n Notification.addNotification({\n type: 'error',\n message: response.warnings[0].message\n });\n }\n return pendingPromise.resolve();\n }).catch(Notification.exception);\n });\n }).catch();\n });\n};\n"],"names":["_interopRequireDefault","obj","__esModule","default","_ajax","_notification","_pending","SELECTORS","_exports","init","document","addEventListener","event","triggerElement","target","closest","preventDefault","getStrings","key","component","then","_ref","cancelRequest","cancelConfirm","Notification","confirm","pendingPromise","Pending","request","methodname","args","requestid","dataset","Ajax","call","response","result","window","location","reload","addNotification","type","message","warnings","resolve","catch","exception"],"mappings":"uKAyBmC,SAAAA,uBAAAC,KAAAA,OAAAA,KAAAA,IAAAC,WAAAD,IAAAE,CAAAA,QAAAF,IAAA;;;;;;;kFAFnCG,MAAAJ,uBAAAI,OACAC,cAAAL,uBAAAK,eACAC,SAAAN,uBAAAM,UAGA,MAAMC,yBACc,yCA0ClBC,SAAAC,KApCkBA,KAChBC,SAASC,iBAAiB,SAASC,QAC/B,MAAMC,eAAiBD,MAAME,OAAOC,QAAQR,0BAC5C,GAAuB,OAAnBM,eACA,OAGJD,MAAMI,kBAON,EAAAC,KAAAA,aALwB,CACpB,CAACC,IAAK,gBAAiBC,UAAW,oBAClC,CAACD,IAAK,4BAA6BC,UAAW,sBAGtBC,MAAKC,OAAoC,IAAlCC,cAAeC,eAAcF,KAC5D,OAAOG,cAAYrB,QAACsB,QAAQH,cAAeC,cAAeD,cAAe,MAAM,KAC3E,MAAMI,eAAiB,IAAIC,SAAOxB,QAAC,kCAC7ByB,QAAU,CACZC,WAAY,uCACZC,KAAM,CAACC,UAAWlB,eAAemB,QAAQD,YAG7CE,MAAAA,QAAKC,KAAK,CAACN,UAAU,GAAGR,MAAKe,WACrBA,SAASC,OACTC,OAAOC,SAASC,SAEhBf,cAAYrB,QAACqC,gBAAgB,CACzBC,KAAM,QACNC,QAASP,SAASQ,SAAS,GAAGD,UAG/BhB,eAAekB,aACvBC,MAAMrB,cAAYrB,QAAC2C,UAAU,GAClC,IACHD,OAAO,GACZ,CACJ"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/purposesactions.min.js.map b/admin/tool/dataprivacy/amd/build/purposesactions.min.js.map index 6e7f8f4da8f..a692a2ffe22 100644 --- a/admin/tool/dataprivacy/amd/build/purposesactions.min.js.map +++ b/admin/tool/dataprivacy/amd/build/purposesactions.min.js.map @@ -1 +1 @@ -{"version":3,"file":"purposesactions.min.js","sources":["../src/purposesactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * AMD module for purposes actions.\n *\n * @module tool_dataprivacy/purposesactions\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{DELETE: string}}\n */\n var ACTIONS = {\n DELETE: '[data-action=\"deletepurpose\"]',\n };\n\n /**\n * PurposesActions class.\n */\n var PurposesActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n PurposesActions.prototype.registerEvents = function() {\n $(ACTIONS.DELETE).click(function(e) {\n e.preventDefault();\n\n var id = $(this).data('id');\n var purposename = $(this).data('name');\n var stringkeys = [\n {\n key: 'deletepurpose',\n component: 'tool_dataprivacy'\n },\n {\n key: 'deletepurposetext',\n component: 'tool_dataprivacy',\n param: purposename\n },\n {\n key: 'delete'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langStrings) {\n var title = langStrings[0];\n var confirmMessage = langStrings[1];\n var buttonText = langStrings[2];\n return ModalFactory.create({\n title: title,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n }).then(function(modal) {\n modal.setSaveButtonText(buttonText);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n\n var request = {\n methodname: 'tool_dataprivacy_delete_purpose',\n args: {'id': id}\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n $('tr[data-purposeid=\"' + id + '\"]').remove();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n });\n }).done(function(modal) {\n modal.show();\n\n }).fail(Notification.exception);\n });\n };\n\n return /** @alias module:tool_dataprivacy/purposesactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {PurposesActions}\n */\n 'init': function() {\n return new PurposesActions();\n }\n };\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","PurposesActions","registerEvents","prototype","click","e","preventDefault","id","this","data","stringkeys","key","component","param","get_strings","then","langStrings","title","confirmMessage","buttonText","create","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","request","methodname","args","call","done","result","remove","addNotification","message","warnings","fail","exception","hidden","destroy","show"],"mappings":";;;;;;;AAsBAA,0CAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,sBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,iBAO3CC,eACQ,gCAMRC,gBAAkB,gBACbC,yBAMTD,gBAAgBE,UAAUD,eAAiB,WACvCR,EAAEM,gBAAgBI,OAAM,SAASC,GAC7BA,EAAEC,qBAEEC,GAAKb,EAAEc,MAAMC,KAAK,MAElBC,WAAa,CACb,CACIC,IAAK,gBACLC,UAAW,oBAEf,CACID,IAAK,oBACLC,UAAW,mBACXC,MATUnB,EAAEc,MAAMC,KAAK,SAW3B,CACIE,IAAK,WAIbd,IAAIiB,YAAYJ,YAAYK,MAAK,SAASC,iBAClCC,MAAQD,YAAY,GACpBE,eAAiBF,YAAY,GAC7BG,WAAaH,YAAY,UACtBlB,aAAasB,OAAO,CACvBH,MAAOA,MACPI,KAAMH,eACNI,KAAMxB,aAAayB,MAAMC,cAC1BT,MAAK,SAASU,cACbA,MAAMC,kBAAkBP,YAGxBM,MAAME,UAAUC,GAAG7B,YAAY8B,MAAM,eAE7BC,QAAU,CACVC,WAAY,kCACZC,KAAM,IAAOzB,KAGjBZ,KAAKsC,KAAK,CAACH,UAAU,GAAGI,MAAK,SAASzB,MAC9BA,KAAK0B,OACLzC,EAAE,sBAAwBa,GAAK,MAAM6B,SAErCxC,aAAayC,gBAAgB,CACzBC,QAAS7B,KAAK8B,SAAS,GAAGD,QAC1BhB,KAAM,aAGfkB,KAAK5C,aAAa6C,cAIzBhB,MAAME,UAAUC,GAAG7B,YAAY2C,QAAQ,WAEnCjB,MAAMkB,aAGHlB,YAEZS,MAAK,SAAST,OACbA,MAAMmB,UAEPJ,KAAK5C,aAAa6C,eAIgC,MASjD,kBACG,IAAIxC"} \ No newline at end of file +{"version":3,"file":"purposesactions.min.js","sources":["../src/purposesactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * AMD module for purposes actions.\n *\n * @module tool_dataprivacy/purposesactions\n * @copyright 2018 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{DELETE: string}}\n */\n var ACTIONS = {\n DELETE: '[data-action=\"deletepurpose\"]',\n };\n\n /**\n * PurposesActions class.\n */\n var PurposesActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n PurposesActions.prototype.registerEvents = function() {\n $(ACTIONS.DELETE).click(function(e) {\n e.preventDefault();\n\n var id = $(this).data('id');\n var purposename = $(this).data('name');\n var stringkeys = [\n {\n key: 'deletepurpose',\n component: 'tool_dataprivacy'\n },\n {\n key: 'deletepurposetext',\n component: 'tool_dataprivacy',\n param: purposename\n },\n {\n key: 'delete'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langStrings) {\n var title = langStrings[0];\n var confirmMessage = langStrings[1];\n var buttonText = langStrings[2];\n return ModalFactory.create({\n title: title,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n }).then(function(modal) {\n modal.setSaveButtonText(buttonText);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n\n var request = {\n methodname: 'tool_dataprivacy_delete_purpose',\n args: {'id': id}\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n $('tr[data-purposeid=\"' + id + '\"]').remove();\n } else {\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n return modal;\n });\n }).done(function(modal) {\n modal.show();\n\n }).fail(Notification.exception);\n });\n };\n\n return /** @alias module:tool_dataprivacy/purposesactions */ {\n // Public variables and functions.\n\n /**\n * Initialise the module.\n *\n * @method init\n * @return {PurposesActions}\n */\n 'init': function() {\n return new PurposesActions();\n }\n };\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","ACTIONS","PurposesActions","this","registerEvents","prototype","click","e","preventDefault","id","data","stringkeys","key","component","param","get_strings","then","langStrings","title","confirmMessage","buttonText","create","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","request","methodname","args","call","done","result","remove","addNotification","message","warnings","fail","exception","hidden","destroy","show","init"],"mappings":";;;;;;;AAsBAA,OAAM,mCAAC,CACH,SACA,YACA,oBACA,WACA,qBACA,sBACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,aAO/C,IAAIC,eACQ,gCAMRC,gBAAkB,WAClBC,KAAKC,kBAyET,OAnEAF,gBAAgBG,UAAUD,eAAiB,WACvCT,EAAEM,gBAAgBK,OAAM,SAASC,GAC7BA,EAAEC,iBAEF,IAAIC,GAAKd,EAAEQ,MAAMO,KAAK,MAElBC,WAAa,CACb,CACIC,IAAK,gBACLC,UAAW,oBAEf,CACID,IAAK,oBACLC,UAAW,mBACXC,MATUnB,EAAEQ,MAAMO,KAAK,SAW3B,CACIE,IAAK,WAIbd,IAAIiB,YAAYJ,YAAYK,MAAK,SAASC,aACtC,IAAIC,MAAQD,YAAY,GACpBE,eAAiBF,YAAY,GAC7BG,WAAaH,YAAY,GAC7B,OAAOlB,aAAasB,OAAO,CACvBH,MAAOA,MACPI,KAAMH,eACNI,KAAMxB,aAAayB,MAAMC,cAC1BT,MAAK,SAASU,OA6Bb,OA5BAA,MAAMC,kBAAkBP,YAGxBM,MAAME,UAAUC,GAAG7B,YAAY8B,MAAM,WAEjC,IAAIC,QAAU,CACVC,WAAY,kCACZC,KAAM,CAACxB,GAAMA,KAGjBb,KAAKsC,KAAK,CAACH,UAAU,GAAGI,MAAK,SAASzB,MAC9BA,KAAK0B,OACLzC,EAAE,sBAAwBc,GAAK,MAAM4B,SAErCxC,aAAayC,gBAAgB,CACzBC,QAAS7B,KAAK8B,SAAS,GAAGD,QAC1BhB,KAAM,SAGjB,IAAEkB,KAAK5C,aAAa6C,UACzB,IAGAhB,MAAME,UAAUC,GAAG7B,YAAY2C,QAAQ,WAEnCjB,MAAMkB,SACV,IAEOlB,KACX,GACJ,IAAGS,MAAK,SAAST,OACbA,MAAMmB,MAET,IAAEJ,KAAK5C,aAAa6C,UACzB,KAGyD,CASzDI,KAAQ,WACJ,OAAO,IAAI5C,eACf,EAER"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/request_filter.min.js.map b/admin/tool/dataprivacy/amd/build/request_filter.min.js.map index 2bc86c5ab28..88b14ec6118 100644 --- a/admin/tool/dataprivacy/amd/build/request_filter.min.js.map +++ b/admin/tool/dataprivacy/amd/build/request_filter.min.js.map @@ -1 +1 @@ -{"version":3,"file":"request_filter.min.js","sources":["../src/request_filter.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * JS module for the data requests filter.\n *\n * @module tool_dataprivacy/request_filter\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'], function($, Autocomplete, Str, Notification) {\n\n /**\n * Selectors.\n *\n * @access private\n * @type {{REQUEST_FILTERS: string}}\n */\n var SELECTORS = {\n REQUEST_FILTERS: '#request-filters'\n };\n\n /**\n * Init function.\n *\n * @method init\n * @private\n */\n var init = function() {\n var stringkeys = [\n {\n key: 'filter',\n component: 'moodle'\n },\n {\n key: 'nofiltersapplied',\n component: 'moodle'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langstrings) {\n var placeholder = langstrings[0];\n var noSelectionString = langstrings[1];\n return Autocomplete.enhance(SELECTORS.REQUEST_FILTERS, false, '', placeholder, false, true, noSelectionString, true);\n }).fail(Notification.exception);\n\n var last = $(SELECTORS.REQUEST_FILTERS).val();\n $(SELECTORS.REQUEST_FILTERS).on('change', function() {\n var current = $(this).val();\n // Prevent form from submitting unnecessarily, eg. on blur when no filter is selected.\n if (last.join(',') !== current.join(',')) {\n // If we're submitting without filters, set the hidden input 'filters-cleared' to 1.\n if (current.length === 0) {\n $('#filters-cleared').val(1);\n }\n $(this.form).submit();\n }\n });\n };\n\n return /** @alias module:core/form-autocomplete */ {\n /**\n * Initialise the unified user filter.\n *\n * @method init\n */\n init: function() {\n init();\n }\n };\n});\n"],"names":["define","$","Autocomplete","Str","Notification","SELECTORS","init","get_strings","key","component","then","langstrings","placeholder","noSelectionString","enhance","fail","exception","last","val","on","current","this","join","length","form","submit"],"mappings":";;;;;;;AAsBAA,yCAAO,CAAC,SAAU,yBAA0B,WAAY,sBAAsB,SAASC,EAAGC,aAAcC,IAAKC,kBAQrGC,0BACiB,yBAyC8B,CAM/CC,KAAM,YAtCC,WAYPH,IAAII,YAXa,CACb,CACIC,IAAK,SACLC,UAAW,UAEf,CACID,IAAK,mBACLC,UAAW,YAISC,MAAK,SAASC,iBAClCC,YAAcD,YAAY,GAC1BE,kBAAoBF,YAAY,UAC7BT,aAAaY,QAAQT,2BAA2B,EAAO,GAAIO,aAAa,GAAO,EAAMC,mBAAmB,MAChHE,KAAKX,aAAaY,eAEjBC,KAAOhB,EAAEI,2BAA2Ba,MACxCjB,EAAEI,2BAA2Bc,GAAG,UAAU,eAClCC,QAAUnB,EAAEoB,MAAMH,MAElBD,KAAKK,KAAK,OAASF,QAAQE,KAAK,OAET,IAAnBF,QAAQG,QACRtB,EAAE,oBAAoBiB,IAAI,GAE9BjB,EAAEoB,KAAKG,MAAMC,aAYjBnB"} \ No newline at end of file +{"version":3,"file":"request_filter.min.js","sources":["../src/request_filter.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * JS module for the data requests filter.\n *\n * @module tool_dataprivacy/request_filter\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'], function($, Autocomplete, Str, Notification) {\n\n /**\n * Selectors.\n *\n * @access private\n * @type {{REQUEST_FILTERS: string}}\n */\n var SELECTORS = {\n REQUEST_FILTERS: '#request-filters'\n };\n\n /**\n * Init function.\n *\n * @method init\n * @private\n */\n var init = function() {\n var stringkeys = [\n {\n key: 'filter',\n component: 'moodle'\n },\n {\n key: 'nofiltersapplied',\n component: 'moodle'\n }\n ];\n\n Str.get_strings(stringkeys).then(function(langstrings) {\n var placeholder = langstrings[0];\n var noSelectionString = langstrings[1];\n return Autocomplete.enhance(SELECTORS.REQUEST_FILTERS, false, '', placeholder, false, true, noSelectionString, true);\n }).fail(Notification.exception);\n\n var last = $(SELECTORS.REQUEST_FILTERS).val();\n $(SELECTORS.REQUEST_FILTERS).on('change', function() {\n var current = $(this).val();\n // Prevent form from submitting unnecessarily, eg. on blur when no filter is selected.\n if (last.join(',') !== current.join(',')) {\n // If we're submitting without filters, set the hidden input 'filters-cleared' to 1.\n if (current.length === 0) {\n $('#filters-cleared').val(1);\n }\n $(this.form).submit();\n }\n });\n };\n\n return /** @alias module:core/form-autocomplete */ {\n /**\n * Initialise the unified user filter.\n *\n * @method init\n */\n init: function() {\n init();\n }\n };\n});\n"],"names":["define","$","Autocomplete","Str","Notification","SELECTORS","init","get_strings","key","component","then","langstrings","placeholder","noSelectionString","enhance","fail","exception","last","val","on","current","this","join","length","form","submit"],"mappings":";;;;;;;AAsBAA,yCAAO,CAAC,SAAU,yBAA0B,WAAY,sBAAsB,SAASC,EAAGC,aAAcC,IAAKC,cAQzG,IAAIC,0BACiB,mBAyCrB,MAAmD,CAM/CC,KAAM,YAtCC,WAYPH,IAAII,YAXa,CACb,CACIC,IAAK,SACLC,UAAW,UAEf,CACID,IAAK,mBACLC,UAAW,YAISC,MAAK,SAASC,aACtC,IAAIC,YAAcD,YAAY,GAC1BE,kBAAoBF,YAAY,GACpC,OAAOT,aAAaY,QAAQT,2BAA2B,EAAO,GAAIO,aAAa,GAAO,EAAMC,mBAAmB,EAClH,IAAEE,KAAKX,aAAaY,WAErB,IAAIC,KAAOhB,EAAEI,2BAA2Ba,MACxCjB,EAAEI,2BAA2Bc,GAAG,UAAU,WACtC,IAAIC,QAAUnB,EAAEoB,MAAMH,MAElBD,KAAKK,KAAK,OAASF,QAAQE,KAAK,OAET,IAAnBF,QAAQG,QACRtB,EAAE,oBAAoBiB,IAAI,GAE9BjB,EAAEoB,KAAKG,MAAMC,SAErB,IAUInB,EACJ,EAER"} \ No newline at end of file diff --git a/admin/tool/dataprivacy/amd/build/requestactions.min.js.map b/admin/tool/dataprivacy/amd/build/requestactions.min.js.map index 4d822b3e809..9f4c6fbc406 100644 --- a/admin/tool/dataprivacy/amd/build/requestactions.min.js.map +++ b/admin/tool/dataprivacy/amd/build/requestactions.min.js.map @@ -1 +1 @@ -{"version":3,"file":"requestactions.min.js","sources":["../src/requestactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Request actions.\n *\n * @module tool_dataprivacy/requestactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/templates',\n 'tool_dataprivacy/data_request_modal',\n 'tool_dataprivacy/events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, ModalDataRequest, DataPrivacyEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{APPROVE_REQUEST: string}}\n * @type {{DENY_REQUEST: string}}\n * @type {{VIEW_REQUEST: string}}\n * @type {{MARK_COMPLETE: string}}\n * @type {{CHANGE_BULK_ACTION: string}}\n * @type {{CONFIRM_BULK_ACTION: string}}\n * @type {{SELECT_ALL: string}}\n */\n var ACTIONS = {\n APPROVE_REQUEST: '[data-action=\"approve\"]',\n DENY_REQUEST: '[data-action=\"deny\"]',\n VIEW_REQUEST: '[data-action=\"view\"]',\n MARK_COMPLETE: '[data-action=\"complete\"]',\n CHANGE_BULK_ACTION: '[id=\"bulk-action\"]',\n CONFIRM_BULK_ACTION: '[id=\"confirm-bulk-action\"]',\n SELECT_ALL: '[data-action=\"selectall\"]'\n };\n\n /**\n * List of available bulk actions.\n *\n * @type {{APPROVE: number}}\n * @type {{DENY: number}}\n */\n var BULK_ACTIONS = {\n APPROVE: 1,\n DENY: 2\n };\n\n /**\n * List of selectors.\n *\n * @type {{SELECT_REQUEST: string}}\n */\n var SELECTORS = {\n SELECT_REQUEST: '.selectrequests'\n };\n\n /**\n * RequestActions class.\n */\n var RequestActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n RequestActions.prototype.registerEvents = function() {\n $(ACTIONS.VIEW_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n\n // Cancel the request.\n var params = {\n 'requestid': requestId\n };\n\n var request = {\n methodname: 'tool_dataprivacy_get_data_request',\n args: params\n };\n\n var promises = Ajax.call([request]);\n $.when(promises[0]).then(function(data) {\n if (data.result) {\n return data.result;\n }\n // Fail.\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n return false;\n\n }).then(function(data) {\n var body = Templates.render('tool_dataprivacy/request_details', data);\n var templateContext = {\n approvedeny: data.approvedeny,\n canmarkcomplete: data.canmarkcomplete\n };\n return ModalFactory.create({\n title: data.typename,\n body: body,\n type: ModalDataRequest.TYPE,\n large: true,\n templateContext: templateContext\n });\n\n }).then(function(modal) {\n // Handle approve event.\n modal.getRoot().on(DataPrivacyEvents.approve, function() {\n showConfirmation(DataPrivacyEvents.approve, approveEventWsData(requestId));\n });\n\n // Handle deny event.\n modal.getRoot().on(DataPrivacyEvents.deny, function() {\n showConfirmation(DataPrivacyEvents.deny, denyEventWsData(requestId));\n });\n\n // Handle send event.\n modal.getRoot().on(DataPrivacyEvents.complete, function() {\n var params = {\n 'requestid': requestId\n };\n handleSave('tool_dataprivacy_mark_complete', params);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n // Show the modal!\n modal.show();\n\n return;\n\n }).catch(Notification.exception);\n });\n\n $(ACTIONS.APPROVE_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.approve, approveEventWsData(requestId));\n });\n\n $(ACTIONS.DENY_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.deny, denyEventWsData(requestId));\n });\n\n $(ACTIONS.MARK_COMPLETE).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.complete, completeEventWsData(requestId));\n });\n\n $(ACTIONS.CONFIRM_BULK_ACTION).click(function() {\n var requestIds = [];\n var actionEvent = '';\n var wsdata = {};\n var bulkActionKeys = [\n {\n key: 'selectbulkaction',\n component: 'tool_dataprivacy'\n },\n {\n key: 'selectdatarequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'ok'\n }\n ];\n\n var bulkaction = parseInt($('#bulk-action').val());\n\n if (bulkaction != BULK_ACTIONS.APPROVE && bulkaction != BULK_ACTIONS.DENY) {\n Str.get_strings(bulkActionKeys).done(function(langStrings) {\n Notification.alert('', langStrings[0], langStrings[2]);\n }).fail(Notification.exception);\n\n return;\n }\n\n $(\".selectrequests:checked\").each(function() {\n requestIds.push($(this).val());\n });\n\n if (requestIds.length < 1) {\n Str.get_strings(bulkActionKeys).done(function(langStrings) {\n Notification.alert('', langStrings[1], langStrings[2]);\n }).fail(Notification.exception);\n\n return;\n }\n\n switch (bulkaction) {\n case BULK_ACTIONS.APPROVE:\n actionEvent = DataPrivacyEvents.bulkApprove;\n wsdata = bulkApproveEventWsData(requestIds);\n break;\n case BULK_ACTIONS.DENY:\n actionEvent = DataPrivacyEvents.bulkDeny;\n wsdata = bulkDenyEventWsData(requestIds);\n }\n\n showConfirmation(actionEvent, wsdata);\n });\n\n $(ACTIONS.SELECT_ALL).change(function(e) {\n e.preventDefault();\n\n var selectAll = $(this).is(':checked');\n $(SELECTORS.SELECT_REQUEST).prop('checked', selectAll);\n });\n };\n\n /**\n * Return the webservice data for the approve request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function approveEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_approve_data_request',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Return the webservice data for the bulk approve request action.\n *\n * @param {Array} requestIds The array of request ID's.\n * @return {Object}\n */\n function bulkApproveEventWsData(requestIds) {\n return {\n 'wsfunction': 'tool_dataprivacy_bulk_approve_data_requests',\n 'wsparams': {'requestids': requestIds}\n };\n }\n\n /**\n * Return the webservice data for the deny request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function denyEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_deny_data_request',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Return the webservice data for the bulk deny request action.\n *\n * @param {Array} requestIds The array of request ID's.\n * @return {Object}\n */\n function bulkDenyEventWsData(requestIds) {\n return {\n 'wsfunction': 'tool_dataprivacy_bulk_deny_data_requests',\n 'wsparams': {'requestids': requestIds}\n };\n }\n\n /**\n * Return the webservice data for the complete request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function completeEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_mark_complete',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Show the confirmation dialogue.\n *\n * @param {String} action The action name.\n * @param {Object} wsdata Object containing ws data.\n */\n function showConfirmation(action, wsdata) {\n var keys = [];\n\n switch (action) {\n case DataPrivacyEvents.approve:\n keys = [\n {\n key: 'approverequest',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmapproval',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.bulkApprove:\n keys = [\n {\n key: 'bulkapproverequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmbulkapproval',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.deny:\n keys = [\n {\n key: 'denyrequest',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmdenial',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.bulkDeny:\n keys = [\n {\n key: 'bulkdenyrequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmbulkdenial',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.complete:\n keys = [\n {\n key: 'markcomplete',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmcompletion',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n }\n\n var modalTitle = '';\n Str.get_strings(keys).then(function(langStrings) {\n modalTitle = langStrings[0];\n var confirmMessage = langStrings[1];\n return ModalFactory.create({\n title: modalTitle,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n });\n }).then(function(modal) {\n modal.setSaveButtonText(modalTitle);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n handleSave(wsdata.wsfunction, wsdata.wsparams);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return;\n\n }).catch(Notification.exception);\n }\n\n /**\n * Calls a web service function and reloads the page on success and shows a notification.\n * Displays an error notification, otherwise.\n *\n * @param {String} wsfunction The web service function to call.\n * @param {Object} params The parameters for the web service functoon.\n */\n function handleSave(wsfunction, params) {\n // Confirm the request.\n var request = {\n methodname: wsfunction,\n args: params\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n // On success, reload the page so that the data request table will be updated.\n // TODO: Probably in the future, better to reload the table or the target data request via AJAX.\n window.location.reload();\n } else {\n // Add the notification.\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n }\n\n return RequestActions;\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","Templates","ModalDataRequest","DataPrivacyEvents","ACTIONS","BULK_ACTIONS","SELECTORS","RequestActions","registerEvents","approveEventWsData","requestId","denyEventWsData","showConfirmation","action","wsdata","keys","approve","key","component","bulkApprove","deny","bulkDeny","complete","modalTitle","get_strings","then","langStrings","confirmMessage","create","title","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","handleSave","wsfunction","wsparams","hidden","destroy","show","catch","exception","params","request","methodname","args","call","done","data","result","window","location","reload","addNotification","message","warnings","fail","prototype","click","e","preventDefault","this","promises","when","render","templateContext","approvedeny","canmarkcomplete","typename","TYPE","large","completeEventWsData","requestIds","actionEvent","bulkActionKeys","bulkaction","parseInt","val","each","push","length","alert","bulkApproveEventWsData","bulkDenyEventWsData","change","selectAll","is","prop"],"mappings":";;;;;;;AAsBAA,yCAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,oBACA,iBACA,sCACA,4BACJ,SAASC,EAAGC,KAAMC,aAAcC,IAAKC,aAAcC,YAAaC,UAAWC,iBAAkBC,uBAarFC,wBACiB,0BADjBA,qBAEc,uBAFdA,qBAGc,uBAHdA,sBAIe,2BAJfA,4BAMqB,6BANrBA,mBAOY,4BASZC,qBACS,EADTA,kBAEM,EAQNC,yBACgB,kBAMhBC,eAAiB,gBACZC,2BAyKAC,mBAAmBC,iBACjB,YACW,iDACF,WAAcA,qBAuBzBC,gBAAgBD,iBACd,YACW,8CACF,WAAcA,qBAoCzBE,iBAAiBC,OAAQC,YAC1BC,KAAO,UAEHF,aACCV,kBAAkBa,QACnBD,KAAO,CACH,CACIE,IAAK,iBACLC,UAAW,oBAEf,CACID,IAAK,kBACLC,UAAW,gCAIlBf,kBAAkBgB,YACnBJ,KAAO,CACH,CACIE,IAAK,sBACLC,UAAW,oBAEf,CACID,IAAK,sBACLC,UAAW,gCAIlBf,kBAAkBiB,KACnBL,KAAO,CACH,CACIE,IAAK,cACLC,UAAW,oBAEf,CACID,IAAK,gBACLC,UAAW,gCAI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,IAAK,OAIT+D,WAAaC,SAAStF,EAAE,gBAAgBuF,UAExCF,YAAc3E,sBAAwB2E,YAAc3E,qBAQxDV,EAAE,2BAA2BwF,MAAK,WAC9BN,WAAWO,KAAKzF,EAAEuE,MAAMgB,UAGxBL,WAAWQ,OAAS,EACpBvF,IAAI0B,YAAYuD,gBAAgB3B,MAAK,SAAS1B,aAC1C7B,aAAayF,MAAM,GAAI5D,YAAY,GAAIA,YAAY,OACpDmC,KAAKhE,aAAaiD,uBAKjBkC,iBACC3E,qBACDyE,YAAc3E,kBAAkBgB,YAChCL,gBAqCgB+D,kBACrB,YACW,uDACF,YAAeA,aAxCVU,CAAuBV,uBAE/BxE,kBACDyE,YAAc3E,kBAAkBkB,SAChCP,gBA2Da+D,kBAClB,YACW,oDACF,YAAeA,aA9DVW,CAAoBX,YAGrCjE,iBAAiBkE,YAAahE,aA7B1BhB,IAAI0B,YAAYuD,gBAAgB3B,MAAK,SAAS1B,aAC1C7B,aAAayF,MAAM,GAAI5D,YAAY,GAAIA,YAAY,OACpDmC,KAAKhE,aAAaiD,cA8B7BnD,EAAES,oBAAoBqF,QAAO,SAASzB,GAClCA,EAAEC,qBAEEyB,UAAY/F,EAAEuE,MAAMyB,GAAG,YAC3BhG,EAAEW,0BAA0BsF,KAAK,UAAWF,eAwM7CnF"} \ No newline at end of file +{"version":3,"file":"requestactions.min.js","sources":["../src/requestactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Request actions.\n *\n * @module tool_dataprivacy/requestactions\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events',\n 'core/templates',\n 'tool_dataprivacy/data_request_modal',\n 'tool_dataprivacy/events'],\nfunction($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, ModalDataRequest, DataPrivacyEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{APPROVE_REQUEST: string}}\n * @type {{DENY_REQUEST: string}}\n * @type {{VIEW_REQUEST: string}}\n * @type {{MARK_COMPLETE: string}}\n * @type {{CHANGE_BULK_ACTION: string}}\n * @type {{CONFIRM_BULK_ACTION: string}}\n * @type {{SELECT_ALL: string}}\n */\n var ACTIONS = {\n APPROVE_REQUEST: '[data-action=\"approve\"]',\n DENY_REQUEST: '[data-action=\"deny\"]',\n VIEW_REQUEST: '[data-action=\"view\"]',\n MARK_COMPLETE: '[data-action=\"complete\"]',\n CHANGE_BULK_ACTION: '[id=\"bulk-action\"]',\n CONFIRM_BULK_ACTION: '[id=\"confirm-bulk-action\"]',\n SELECT_ALL: '[data-action=\"selectall\"]'\n };\n\n /**\n * List of available bulk actions.\n *\n * @type {{APPROVE: number}}\n * @type {{DENY: number}}\n */\n var BULK_ACTIONS = {\n APPROVE: 1,\n DENY: 2\n };\n\n /**\n * List of selectors.\n *\n * @type {{SELECT_REQUEST: string}}\n */\n var SELECTORS = {\n SELECT_REQUEST: '.selectrequests'\n };\n\n /**\n * RequestActions class.\n */\n var RequestActions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n RequestActions.prototype.registerEvents = function() {\n $(ACTIONS.VIEW_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n\n // Cancel the request.\n var params = {\n 'requestid': requestId\n };\n\n var request = {\n methodname: 'tool_dataprivacy_get_data_request',\n args: params\n };\n\n var promises = Ajax.call([request]);\n $.when(promises[0]).then(function(data) {\n if (data.result) {\n return data.result;\n }\n // Fail.\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n return false;\n\n }).then(function(data) {\n var body = Templates.render('tool_dataprivacy/request_details', data);\n var templateContext = {\n approvedeny: data.approvedeny,\n canmarkcomplete: data.canmarkcomplete\n };\n return ModalFactory.create({\n title: data.typename,\n body: body,\n type: ModalDataRequest.TYPE,\n large: true,\n templateContext: templateContext\n });\n\n }).then(function(modal) {\n // Handle approve event.\n modal.getRoot().on(DataPrivacyEvents.approve, function() {\n showConfirmation(DataPrivacyEvents.approve, approveEventWsData(requestId));\n });\n\n // Handle deny event.\n modal.getRoot().on(DataPrivacyEvents.deny, function() {\n showConfirmation(DataPrivacyEvents.deny, denyEventWsData(requestId));\n });\n\n // Handle send event.\n modal.getRoot().on(DataPrivacyEvents.complete, function() {\n var params = {\n 'requestid': requestId\n };\n handleSave('tool_dataprivacy_mark_complete', params);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n // Show the modal!\n modal.show();\n\n return;\n\n }).catch(Notification.exception);\n });\n\n $(ACTIONS.APPROVE_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.approve, approveEventWsData(requestId));\n });\n\n $(ACTIONS.DENY_REQUEST).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.deny, denyEventWsData(requestId));\n });\n\n $(ACTIONS.MARK_COMPLETE).click(function(e) {\n e.preventDefault();\n\n var requestId = $(this).data('requestid');\n showConfirmation(DataPrivacyEvents.complete, completeEventWsData(requestId));\n });\n\n $(ACTIONS.CONFIRM_BULK_ACTION).click(function() {\n var requestIds = [];\n var actionEvent = '';\n var wsdata = {};\n var bulkActionKeys = [\n {\n key: 'selectbulkaction',\n component: 'tool_dataprivacy'\n },\n {\n key: 'selectdatarequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'ok'\n }\n ];\n\n var bulkaction = parseInt($('#bulk-action').val());\n\n if (bulkaction != BULK_ACTIONS.APPROVE && bulkaction != BULK_ACTIONS.DENY) {\n Str.get_strings(bulkActionKeys).done(function(langStrings) {\n Notification.alert('', langStrings[0], langStrings[2]);\n }).fail(Notification.exception);\n\n return;\n }\n\n $(\".selectrequests:checked\").each(function() {\n requestIds.push($(this).val());\n });\n\n if (requestIds.length < 1) {\n Str.get_strings(bulkActionKeys).done(function(langStrings) {\n Notification.alert('', langStrings[1], langStrings[2]);\n }).fail(Notification.exception);\n\n return;\n }\n\n switch (bulkaction) {\n case BULK_ACTIONS.APPROVE:\n actionEvent = DataPrivacyEvents.bulkApprove;\n wsdata = bulkApproveEventWsData(requestIds);\n break;\n case BULK_ACTIONS.DENY:\n actionEvent = DataPrivacyEvents.bulkDeny;\n wsdata = bulkDenyEventWsData(requestIds);\n }\n\n showConfirmation(actionEvent, wsdata);\n });\n\n $(ACTIONS.SELECT_ALL).change(function(e) {\n e.preventDefault();\n\n var selectAll = $(this).is(':checked');\n $(SELECTORS.SELECT_REQUEST).prop('checked', selectAll);\n });\n };\n\n /**\n * Return the webservice data for the approve request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function approveEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_approve_data_request',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Return the webservice data for the bulk approve request action.\n *\n * @param {Array} requestIds The array of request ID's.\n * @return {Object}\n */\n function bulkApproveEventWsData(requestIds) {\n return {\n 'wsfunction': 'tool_dataprivacy_bulk_approve_data_requests',\n 'wsparams': {'requestids': requestIds}\n };\n }\n\n /**\n * Return the webservice data for the deny request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function denyEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_deny_data_request',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Return the webservice data for the bulk deny request action.\n *\n * @param {Array} requestIds The array of request ID's.\n * @return {Object}\n */\n function bulkDenyEventWsData(requestIds) {\n return {\n 'wsfunction': 'tool_dataprivacy_bulk_deny_data_requests',\n 'wsparams': {'requestids': requestIds}\n };\n }\n\n /**\n * Return the webservice data for the complete request action.\n *\n * @param {Number} requestId The ID of the request.\n * @return {Object}\n */\n function completeEventWsData(requestId) {\n return {\n 'wsfunction': 'tool_dataprivacy_mark_complete',\n 'wsparams': {'requestid': requestId}\n };\n }\n\n /**\n * Show the confirmation dialogue.\n *\n * @param {String} action The action name.\n * @param {Object} wsdata Object containing ws data.\n */\n function showConfirmation(action, wsdata) {\n var keys = [];\n\n switch (action) {\n case DataPrivacyEvents.approve:\n keys = [\n {\n key: 'approverequest',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmapproval',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.bulkApprove:\n keys = [\n {\n key: 'bulkapproverequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmbulkapproval',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.deny:\n keys = [\n {\n key: 'denyrequest',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmdenial',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.bulkDeny:\n keys = [\n {\n key: 'bulkdenyrequests',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmbulkdenial',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n case DataPrivacyEvents.complete:\n keys = [\n {\n key: 'markcomplete',\n component: 'tool_dataprivacy'\n },\n {\n key: 'confirmcompletion',\n component: 'tool_dataprivacy'\n }\n ];\n break;\n }\n\n var modalTitle = '';\n Str.get_strings(keys).then(function(langStrings) {\n modalTitle = langStrings[0];\n var confirmMessage = langStrings[1];\n return ModalFactory.create({\n title: modalTitle,\n body: confirmMessage,\n type: ModalFactory.types.SAVE_CANCEL\n });\n }).then(function(modal) {\n modal.setSaveButtonText(modalTitle);\n\n // Handle save event.\n modal.getRoot().on(ModalEvents.save, function() {\n handleSave(wsdata.wsfunction, wsdata.wsparams);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n modal.show();\n\n return;\n\n }).catch(Notification.exception);\n }\n\n /**\n * Calls a web service function and reloads the page on success and shows a notification.\n * Displays an error notification, otherwise.\n *\n * @param {String} wsfunction The web service function to call.\n * @param {Object} params The parameters for the web service functoon.\n */\n function handleSave(wsfunction, params) {\n // Confirm the request.\n var request = {\n methodname: wsfunction,\n args: params\n };\n\n Ajax.call([request])[0].done(function(data) {\n if (data.result) {\n // On success, reload the page so that the data request table will be updated.\n // TODO: Probably in the future, better to reload the table or the target data request via AJAX.\n window.location.reload();\n } else {\n // Add the notification.\n Notification.addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n }).fail(Notification.exception);\n }\n\n return RequestActions;\n});\n"],"names":["define","$","Ajax","Notification","Str","ModalFactory","ModalEvents","Templates","ModalDataRequest","DataPrivacyEvents","ACTIONS","BULK_ACTIONS","SELECTORS","RequestActions","this","registerEvents","approveEventWsData","requestId","wsfunction","wsparams","requestid","denyEventWsData","showConfirmation","action","wsdata","keys","approve","key","component","bulkApprove","deny","bulkDeny","complete","modalTitle","get_strings","then","langStrings","confirmMessage","create","title","body","type","types","SAVE_CANCEL","modal","setSaveButtonText","getRoot","on","save","handleSave","hidden","destroy","show","catch","exception","params","request","methodname","args","call","done","data","result","window","location","reload","addNotification","message","warnings","fail","prototype","click","e","preventDefault","promises","when","render","templateContext","approvedeny","canmarkcomplete","typename","TYPE","large","completeEventWsData","requestIds","actionEvent","bulkActionKeys","bulkaction","parseInt","val","each","push","length","alert","requestids","bulkApproveEventWsData","bulkDenyEventWsData","change","selectAll","is","prop"],"mappings":";;;;;;;AAsBAA,yCAAO,CACH,SACA,YACA,oBACA,WACA,qBACA,oBACA,iBACA,sCACA,4BACJ,S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,IAEIL,WAAWQ,OAAS,EACpBxF,IAAI8B,YAAYoD,gBAAgB1B,MAAK,SAASxB,aAC1CjC,aAAa0F,MAAM,GAAIzD,YAAY,GAAIA,YAAY,GACtD,IAAEiC,KAAKlE,aAAamD,eAHzB,CAQA,OAAQiC,YACJ,KAAK5E,qBACD0E,YAAc5E,kBAAkBoB,YAChCL,OAqChB,SAAgC4D,YAC5B,MAAO,CACHlE,WAAc,8CACdC,SAAY,CAAC2E,WAAcV,YAEnC,CA1CyBW,CAAuBX,YAChC,MACJ,KAAKzE,kBACD0E,YAAc5E,kBAAkBsB,SAChCP,OA2DhB,SAA6B4D,YACzB,MAAO,CACHlE,WAAc,2CACdC,SAAY,CAAC2E,WAAcV,YAEnC,CAhEyBY,CAAoBZ,YAGrC9D,iBAAiB+D,YAAa7D,OAZ9B,MAjBIpB,IAAI8B,YAAYoD,gBAAgB1B,MAAK,SAASxB,aAC1CjC,aAAa0F,MAAM,GAAIzD,YAAY,GAAIA,YAAY,GACtD,IAAEiC,KAAKlE,aAAamD,UA4B7B,IAEArD,EAAES,oBAAoBuF,QAAO,SAASzB,GAClCA,EAAEC,iBAEF,IAAIyB,UAAYjG,EAAEa,MAAMqF,GAAG,YAC3BlG,EAAEW,0BAA0BwF,KAAK,UAAWF,UAChD,KAuMGrF,cACX"} \ No newline at end of file diff --git a/admin/tool/langimport/amd/build/search.min.js.map b/admin/tool/langimport/amd/build/search.min.js.map index 273a4d3edba..f2437c3b1c0 100644 --- a/admin/tool/langimport/amd/build/search.min.js.map +++ b/admin/tool/langimport/amd/build/search.min.js.map @@ -1 +1 @@ -{"version":3,"file":"search.min.js","sources":["../src/search.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Add search filtering of available language packs\n *\n * @module tool_langimport/search\n * @copyright 2021 Paul Holden \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Pending from 'core/pending';\nimport {debounce} from 'core/utils';\n\nconst SELECTORS = {\n AVAILABLE_LANG_SELECT: 'select',\n AVAILABLE_LANG_SEARCH: '[data-action=\"search\"]',\n};\n\nconst DEBOUNCE_TIMER = 250;\n\n/**\n * Initialize module\n *\n * @param {Element} form\n */\nexport const init = form => {\n const availableLangsElement = form.querySelector(SELECTORS.AVAILABLE_LANG_SELECT);\n\n const availableLangsFilter = (event) => {\n const pendingPromise = new Pending('tool_langimport/search:filter');\n\n // Remove existing options.\n availableLangsElement.querySelectorAll('option').forEach((option) => {\n option.remove();\n });\n\n // Filter for matching languages.\n const searchTerm = event.target.value.toLowerCase();\n const availableLanguages = JSON.parse(availableLangsElement.dataset.availableLanguages);\n const filteredLanguages = Object.keys(availableLanguages).reduce((matches, langcode) => {\n if (availableLanguages[langcode].toLowerCase().includes(searchTerm)) {\n matches[langcode] = availableLanguages[langcode];\n }\n return matches;\n }, []);\n\n // Re-create filtered options.\n Object.entries(filteredLanguages).forEach(([langcode, langname]) => {\n const option = document.createElement('option');\n option.value = langcode;\n option.innerText = langname;\n availableLangsElement.append(option);\n });\n\n pendingPromise.resolve();\n };\n\n // Cache initial available language options.\n const availableLanguages = {};\n availableLangsElement.querySelectorAll('option').forEach((option) => {\n availableLanguages[option.value] = option.text;\n });\n availableLangsElement.dataset.availableLanguages = JSON.stringify(availableLanguages);\n\n // Register event listeners on the search element.\n const availableLangsSearch = form.querySelector(SELECTORS.AVAILABLE_LANG_SEARCH);\n availableLangsSearch.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n }\n });\n\n // Debounce the event listener to allow the user to finish typing.\n const availableLangsSearchDebounce = debounce(availableLangsFilter, DEBOUNCE_TIMER);\n availableLangsSearch.addEventListener('keyup', (event) => {\n const pendingPromise = new Pending('tool_langimport/search:keyup');\n\n availableLangsSearchDebounce(event);\n setTimeout(() => {\n pendingPromise.resolve();\n }, DEBOUNCE_TIMER);\n });\n};\n"],"names":["SELECTORS","form","availableLangsElement","querySelector","availableLanguages","querySelectorAll","forEach","option","value","text","dataset","JSON","stringify","availableLangsSearch","addEventListener","event","key","preventDefault","availableLangsSearchDebounce","pendingPromise","Pending","remove","searchTerm","target","toLowerCase","parse","filteredLanguages","Object","keys","reduce","matches","langcode","includes","entries","_ref","langname","document","createElement","innerText","append","resolve","setTimeout"],"mappings":";;;;;;;kJA0BMA,gCACqB,SADrBA,gCAEqB,uCAUPC,aACVC,sBAAwBD,KAAKE,cAAcH,iCAgC3CI,mBAAqB,GAC3BF,sBAAsBG,iBAAiB,UAAUC,SAASC,SACtDH,mBAAmBG,OAAOC,OAASD,OAAOE,QAE9CP,sBAAsBQ,QAAQN,mBAAqBO,KAAKC,UAAUR,0BAG5DS,qBAAuBZ,KAAKE,cAAcH,iCAChDa,qBAAqBC,iBAAiB,WAAYC,QAC5B,UAAdA,MAAMC,KACND,MAAME,0BAKRC,8BAA+B,oBA7CPH,cACpBI,eAAiB,IAAIC,iBAAQ,iCAGnClB,sBAAsBG,iBAAiB,UAAUC,SAASC,SACtDA,OAAOc,kBAILC,WAAaP,MAAMQ,OAAOf,MAAMgB,cAChCpB,mBAAqBO,KAAKc,MAAMvB,sBAAsBQ,QAAQN,oBAC9DsB,kBAAoBC,OAAOC,KAAKxB,oBAAoByB,QAAO,CAACC,QAASC,YACnE3B,mBAAmB2B,UAAUP,cAAcQ,SAASV,cACpDQ,QAAQC,UAAY3B,mBAAmB2B,WAEpCD,UACR,IAGHH,OAAOM,QAAQP,mBAAmBpB,SAAQ4B,WAAEH,SAAUI,qBAC5C5B,OAAS6B,SAASC,cAAc,UACtC9B,OAAOC,MAAQuB,SACfxB,OAAO+B,UAAYH,SACnBjC,sBAAsBqC,OAAOhC,WAGjCY,eAAeqB,YApCA,KAwDnB3B,qBAAqBC,iBAAiB,SAAUC,cACtCI,eAAiB,IAAIC,iBAAQ,gCAEnCF,6BAA6BH,OAC7B0B,YAAW,KACPtB,eAAeqB,YA7DJ"} \ No newline at end of file +{"version":3,"file":"search.min.js","sources":["../src/search.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Add search filtering of available language packs\n *\n * @module tool_langimport/search\n * @copyright 2021 Paul Holden \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Pending from 'core/pending';\nimport {debounce} from 'core/utils';\n\nconst SELECTORS = {\n AVAILABLE_LANG_SELECT: 'select',\n AVAILABLE_LANG_SEARCH: '[data-action=\"search\"]',\n};\n\nconst DEBOUNCE_TIMER = 250;\n\n/**\n * Initialize module\n *\n * @param {Element} form\n */\nexport const init = form => {\n const availableLangsElement = form.querySelector(SELECTORS.AVAILABLE_LANG_SELECT);\n\n const availableLangsFilter = (event) => {\n const pendingPromise = new Pending('tool_langimport/search:filter');\n\n // Remove existing options.\n availableLangsElement.querySelectorAll('option').forEach((option) => {\n option.remove();\n });\n\n // Filter for matching languages.\n const searchTerm = event.target.value.toLowerCase();\n const availableLanguages = JSON.parse(availableLangsElement.dataset.availableLanguages);\n const filteredLanguages = Object.keys(availableLanguages).reduce((matches, langcode) => {\n if (availableLanguages[langcode].toLowerCase().includes(searchTerm)) {\n matches[langcode] = availableLanguages[langcode];\n }\n return matches;\n }, []);\n\n // Re-create filtered options.\n Object.entries(filteredLanguages).forEach(([langcode, langname]) => {\n const option = document.createElement('option');\n option.value = langcode;\n option.innerText = langname;\n availableLangsElement.append(option);\n });\n\n pendingPromise.resolve();\n };\n\n // Cache initial available language options.\n const availableLanguages = {};\n availableLangsElement.querySelectorAll('option').forEach((option) => {\n availableLanguages[option.value] = option.text;\n });\n availableLangsElement.dataset.availableLanguages = JSON.stringify(availableLanguages);\n\n // Register event listeners on the search element.\n const availableLangsSearch = form.querySelector(SELECTORS.AVAILABLE_LANG_SEARCH);\n availableLangsSearch.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n }\n });\n\n // Debounce the event listener to allow the user to finish typing.\n const availableLangsSearchDebounce = debounce(availableLangsFilter, DEBOUNCE_TIMER);\n availableLangsSearch.addEventListener('keyup', (event) => {\n const pendingPromise = new Pending('tool_langimport/search:keyup');\n\n availableLangsSearchDebounce(event);\n setTimeout(() => {\n pendingPromise.resolve();\n }, DEBOUNCE_TIMER);\n });\n};\n"],"names":["obj","_pending","__esModule","default","SELECTORS","_exports","init","form","availableLangsElement","querySelector","availableLanguages","querySelectorAll","forEach","option","value","text","dataset","JSON","stringify","availableLangsSearch","addEventListener","event","key","preventDefault","availableLangsSearchDebounce","debounce","pendingPromise","Pending","remove","searchTerm","target","toLowerCase","parse","filteredLanguages","Object","keys","reduce","matches","langcode","includes","entries","_ref","langname","document","createElement","innerText","append","resolve","setTimeout"],"mappings":"4GAuBmC,IAAAA;;;;;;;kFAAnCC,UAAmCD,IAAnCC,WAAmCD,IAAAE,WAAAF,IAAAG,CAAAA,QAAAH,KAGnC,MAAMI,gCACqB,SADrBA,gCAEqB,yBAmEzBC,SAAAC,KAzDkBC,OAChB,MAAMC,sBAAwBD,KAAKE,cAAcL,iCAgC3CM,mBAAqB,CAAA,EAC3BF,sBAAsBG,iBAAiB,UAAUC,SAASC,SACtDH,mBAAmBG,OAAOC,OAASD,OAAOE,IAAI,IAElDP,sBAAsBQ,QAAQN,mBAAqBO,KAAKC,UAAUR,oBAGlE,MAAMS,qBAAuBZ,KAAKE,cAAcL,iCAChDe,qBAAqBC,iBAAiB,WAAYC,QAC5B,UAAdA,MAAMC,KACND,MAAME,gBACV,IAIJ,MAAMC,8BAA+B,EAAAC,OAAAA,WA7CPJ,QAC1B,MAAMK,eAAiB,IAAIC,SAAOxB,QAAC,iCAGnCK,sBAAsBG,iBAAiB,UAAUC,SAASC,SACtDA,OAAOe,QAAQ,IAInB,MAAMC,WAAaR,MAAMS,OAAOhB,MAAMiB,cAChCrB,mBAAqBO,KAAKe,MAAMxB,sBAAsBQ,QAAQN,oBAC9DuB,kBAAoBC,OAAOC,KAAKzB,oBAAoB0B,QAAO,CAACC,QAASC,YACnE5B,mBAAmB4B,UAAUP,cAAcQ,SAASV,cACpDQ,QAAQC,UAAY5B,mBAAmB4B,WAEpCD,UACR,IAGHH,OAAOM,QAAQP,mBAAmBrB,SAAQ6B,OAA0B,IAAxBH,SAAUI,UAASD,KAC3D,MAAM5B,OAAS8B,SAASC,cAAc,UACtC/B,OAAOC,MAAQwB,SACfzB,OAAOgC,UAAYH,SACnBlC,sBAAsBsC,OAAOjC,OAAO,IAGxCa,eAAeqB,SAAS,GApCT,KAwDnB5B,qBAAqBC,iBAAiB,SAAUC,QAC5C,MAAMK,eAAiB,IAAIC,SAAOxB,QAAC,gCAEnCqB,6BAA6BH,OAC7B2B,YAAW,KACPtB,eAAeqB,SAAS,GA7Db,IA8DG,GACpB,CACJ"} \ No newline at end of file diff --git a/admin/tool/licensemanager/amd/build/delete_license.min.js.map b/admin/tool/licensemanager/amd/build/delete_license.min.js.map index 71785b2bf5c..30e44982e2f 100644 --- a/admin/tool/licensemanager/amd/build/delete_license.min.js.map +++ b/admin/tool/licensemanager/amd/build/delete_license.min.js.map @@ -1 +1 @@ -{"version":3,"file":"delete_license.min.js","sources":["../src/delete_license.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Modal for confirming deletion of a custom license.\n *\n * @module tool_licensemanager/delete_license\n * @copyright 2019 Tom Dickman \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/modal_factory', 'core/modal_events', 'core/url', 'core/str'],\n function($, ModalFactory, ModalEvents, Url, String) {\n\n var trigger = $('.delete-license');\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: String.get_string('deletelicense', 'tool_licensemanager'),\n body: String.get_string('deletelicenseconfirmmessage', 'tool_licensemanager'),\n preShowCallback: function(triggerElement, modal) {\n triggerElement = $(triggerElement);\n let params = {\n 'action': 'delete',\n 'license': triggerElement.data('license')\n };\n modal.deleteURL = Url.relativeUrl('/admin/tool/licensemanager/index.php', params, true);\n },\n large: true,\n }, trigger)\n .done(function(modal) {\n modal.getRoot().on(ModalEvents.save, function(e) {\n // Stop the default save button behaviour which is to close the modal.\n e.preventDefault();\n // Redirect to delete url.\n window.location.href = modal.deleteURL;\n });\n });\n });\n"],"names":["define","$","ModalFactory","ModalEvents","Url","String","trigger","create","type","types","SAVE_CANCEL","title","get_string","body","preShowCallback","triggerElement","modal","params","data","deleteURL","relativeUrl","large","done","getRoot","on","save","e","preventDefault","window","location","href"],"mappings":";;;;;;;AAsBAA,4CAAO,CAAC,SAAU,qBAAsB,oBAAqB,WAAY,aACrE,SAASC,EAAGC,aAAcC,YAAaC,IAAKC,YAEpCC,QAAUL,EAAE,mBAChBC,aAAaK,OAAO,CAChBC,KAAMN,aAAaO,MAAMC,YACzBC,MAAON,OAAOO,WAAW,gBAAiB,uBAC1CC,KAAMR,OAAOO,WAAW,8BAA+B,uBACvDE,gBAAiB,SAASC,eAAgBC,WAElCC,OAAS,QACC,kBAFdF,eAAiBd,EAAEc,iBAGWG,KAAK,YAEnCF,MAAMG,UAAYf,IAAIgB,YAAY,uCAAwCH,QAAQ,IAEtFI,OAAO,GACRf,SACEgB,MAAK,SAASN,OACXA,MAAMO,UAAUC,GAAGrB,YAAYsB,MAAM,SAASC,GAE1CA,EAAEC,iBAEFC,OAAOC,SAASC,KAAOd,MAAMG"} \ No newline at end of file +{"version":3,"file":"delete_license.min.js","sources":["../src/delete_license.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Modal for confirming deletion of a custom license.\n *\n * @module tool_licensemanager/delete_license\n * @copyright 2019 Tom Dickman \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/modal_factory', 'core/modal_events', 'core/url', 'core/str'],\n function($, ModalFactory, ModalEvents, Url, String) {\n\n var trigger = $('.delete-license');\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: String.get_string('deletelicense', 'tool_licensemanager'),\n body: String.get_string('deletelicenseconfirmmessage', 'tool_licensemanager'),\n preShowCallback: function(triggerElement, modal) {\n triggerElement = $(triggerElement);\n let params = {\n 'action': 'delete',\n 'license': triggerElement.data('license')\n };\n modal.deleteURL = Url.relativeUrl('/admin/tool/licensemanager/index.php', params, true);\n },\n large: true,\n }, trigger)\n .done(function(modal) {\n modal.getRoot().on(ModalEvents.save, function(e) {\n // Stop the default save button behaviour which is to close the modal.\n e.preventDefault();\n // Redirect to delete url.\n window.location.href = modal.deleteURL;\n });\n });\n });\n"],"names":["define","$","ModalFactory","ModalEvents","Url","String","trigger","create","type","types","SAVE_CANCEL","title","get_string","body","preShowCallback","triggerElement","modal","params","action","license","data","deleteURL","relativeUrl","large","done","getRoot","on","save","e","preventDefault","window","location","href"],"mappings":";;;;;;;AAsBAA,OAAM,qCAAC,CAAC,SAAU,qBAAsB,oBAAqB,WAAY,aACrE,SAASC,EAAGC,aAAcC,YAAaC,IAAKC,QAExC,IAAIC,QAAUL,EAAE,mBAChBC,aAAaK,OAAO,CAChBC,KAAMN,aAAaO,MAAMC,YACzBC,MAAON,OAAOO,WAAW,gBAAiB,uBAC1CC,KAAMR,OAAOO,WAAW,8BAA+B,uBACvDE,gBAAiB,SAASC,eAAgBC,OAEtC,IAAIC,OAAS,CACTC,OAAU,SACVC,SAHJJ,eAAiBd,EAAEc,iBAGWK,KAAK,YAEnCJ,MAAMK,UAAYjB,IAAIkB,YAAY,uCAAwCL,QAAQ,EACrF,EACDM,OAAO,GACRjB,SACEkB,MAAK,SAASR,OACXA,MAAMS,UAAUC,GAAGvB,YAAYwB,MAAM,SAASC,GAE1CA,EAAEC,iBAEFC,OAAOC,SAASC,KAAOhB,MAAMK,SACjC,GACJ,GACR"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/actionselector.min.js.map b/admin/tool/lp/amd/build/actionselector.min.js.map index 1061e04a7e2..1a1f845b27c 100644 --- a/admin/tool/lp/amd/build/actionselector.min.js.map +++ b/admin/tool/lp/amd/build/actionselector.min.js.map @@ -1 +1 @@ -{"version":3,"file":"actionselector.min.js","sources":["../src/actionselector.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Action selector.\n *\n * To handle 'save' events use: actionselector.on('save')\n * This will receive the information to display in popup.\n * The actions have the format [{'text': sometext, 'value' : somevalue}].\n *\n * @module tool_lp/actionselector\n * @copyright 2016 Serge Gauthier - \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base'],\n function($, Notification, Ajax, Templates, Dialogue, EventBase) {\n\n /**\n * Action selector class.\n *\n * @class tool_lp/actionselector\n * @param {String} title The title of popup.\n * @param {String} message The message to display.\n * @param {object} actions The actions that can be selected.\n * @param {String} confirm Text for confirm button.\n * @param {String} cancel Text for cancel button.\n */\n var ActionSelector = function(title, message, actions, confirm, cancel) {\n var self = this;\n\n EventBase.prototype.constructor.apply(this, []);\n self._title = title;\n self._message = message;\n self._actions = actions;\n self._confirm = confirm;\n self._cancel = cancel;\n self._selectedValue = null;\n self._reset();\n };\n\n ActionSelector.prototype = Object.create(EventBase.prototype);\n\n /** @property {String} The value that was selected. */\n ActionSelector.prototype._selectedValue = null;\n /** @property {Dialogue} The reference to the dialogue. */\n ActionSelector.prototype._popup = null;\n /** @property {String} The title of popup. */\n ActionSelector.prototype._title = null;\n /** @property {String} The message in popup. */\n ActionSelector.prototype._message = null;\n /** @property {object} The information for radion buttons. */\n ActionSelector.prototype._actions = null;\n /** @property {String} The text for confirm button. */\n ActionSelector.prototype._confirm = null;\n /** @property {String} The text for cancel button. */\n ActionSelector.prototype._cancel = null;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n ActionSelector.prototype._afterRender = function() {\n var self = this;\n\n // Confirm button is disabled until a choice is done.\n self._find('[data-action=\"action-selector-confirm\"]').attr('disabled', 'disabled');\n\n // Add listener for radio buttons change.\n self._find('[data-region=\"action-selector-radio-buttons\"]').change(function() {\n self._selectedValue = $(\"input[type='radio']:checked\").val();\n self._find('[data-action=\"action-selector-confirm\"]').removeAttr('disabled');\n self._refresh.bind(self);\n });\n\n // Add listener for cancel.\n self._find('[data-action=\"action-selector-cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for confirm.\n self._find('[data-action=\"action-selector-confirm\"]').click(function(e) {\n e.preventDefault();\n if (!self._selectedValue.length) {\n return;\n }\n self._trigger('save', {action: self._selectedValue});\n self.close();\n });\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n ActionSelector.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the action selector.\n *\n * @method display\n * @return {Promise}\n */\n ActionSelector.prototype.display = function() {\n var self = this;\n return self._render().then(function(html) {\n self._popup = new Dialogue(\n self._title,\n html,\n self._afterRender.bind(self)\n );\n return;\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery} The node\n * @method _find\n */\n ActionSelector.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n ActionSelector.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"action-selector\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n ActionSelector.prototype._render = function() {\n var self = this;\n var choices = [];\n for (var i in self._actions) {\n choices.push(self._actions[i]);\n }\n var content = {'message': self._message, 'choices': choices,\n 'confirm': self._confirm, 'cancel': self._cancel};\n\n return Templates.render('tool_lp/action_selector', content);\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n ActionSelector.prototype._reset = function() {\n this._popup = null;\n this._selectedValue = '';\n };\n\n return ActionSelector;\n\n});\n"],"names":["define","$","Notification","Ajax","Templates","Dialogue","EventBase","ActionSelector","title","message","actions","confirm","cancel","prototype","constructor","apply","this","_title","_message","_actions","_confirm","_cancel","_selectedValue","_reset","Object","create","_popup","_afterRender","self","_find","attr","change","val","removeAttr","_refresh","bind","click","e","preventDefault","close","length","_trigger","action","display","_render","then","html","fail","exception","selector","getContent","find","replaceWith","choices","i","push","content","render"],"mappings":";;;;;;;;;;;AA2BAA,gCAAO,CAAC,SACA,oBACA,YACA,iBACA,mBACA,uBACA,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,SAAUC,eAYrDC,eAAiB,SAASC,MAAOC,QAASC,QAASC,QAASC,QAG5DN,UAAUO,UAAUC,YAAYC,MAAMC,KAAM,IAFjCA,KAGNC,OAAST,MAHHQ,KAINE,SAAWT,QAJLO,KAKNG,SAAWT,QALLM,KAMNI,SAAWT,QANLK,KAONK,QAAUT,OAPJI,KAQNM,eAAiB,KARXN,KASNO,iBAGThB,eAAeM,UAAYW,OAAOC,OAAOnB,UAAUO,YAG1BS,eAAiB,KAE1Cf,eAAeM,UAAUa,OAAS,KAElCnB,eAAeM,UAAUI,OAAS,KAElCV,eAAeM,UAAUK,SAAW,KAEpCX,eAAeM,UAAUM,SAAW,KAEpCZ,eAAeM,UAAUO,SAAW,KAEpCb,eAAeM,UAAUQ,QAAU,KAOnCd,eAAeM,UAAUc,aAAe,eAChCC,KAAOZ,KAGXY,KAAKC,MAAM,2CAA2CC,KAAK,WAAY,YAGvEF,KAAKC,MAAM,iDAAiDE,QAAO,WAC/DH,KAAKN,eAAiBrB,EAAE,+BAA+B+B,MACvDJ,KAAKC,MAAM,2CAA2CI,WAAW,YACjEL,KAAKM,SAASC,KAAKP,SAIvBA,KAAKC,MAAM,0CAA0CO,OAAM,SAASC,GAChEA,EAAEC,iBACFV,KAAKW,WAITX,KAAKC,MAAM,2CAA2CO,OAAM,SAASC,GACjEA,EAAEC,iBACGV,KAAKN,eAAekB,SAGzBZ,KAAKa,SAAS,OAAQ,CAACC,OAAQd,KAAKN,iBACpCM,KAAKW,aASbhC,eAAeM,UAAU0B,MAAQ,WAClBvB,KACNU,OAAOa,QADDvB,KAENO,UASThB,eAAeM,UAAU8B,QAAU,eAC3Bf,KAAOZ,YACJY,KAAKgB,UAAUC,MAAK,SAASC,MAChClB,KAAKF,OAAS,IAAIrB,SACduB,KAAKX,OACL6B,KACAlB,KAAKD,aAAaQ,KAAKP,UAG5BmB,KAAK7C,aAAa8C,YAUzBzC,eAAeM,UAAUgB,MAAQ,SAASoB,iBAC/BhD,EAAEe,KAAKU,OAAOwB,cAAcC,KAAKF,WAS5C1C,eAAeM,UAAUqB,SAAW,eAC5BN,KAAOZ,YACJY,KAAKgB,UAAUC,MAAK,SAASC,MAChClB,KAAKC,MAAM,mCAAmCuB,YAAYN,MAC1DlB,KAAKD,mBAWbpB,eAAeM,UAAU+B,QAAU,eAE3BS,QAAU,OACT,IAAIC,KAFEtC,KAEQG,SACfkC,QAAQE,KAHDvC,KAGWG,SAASmC,QAE3BE,QAAU,SALHxC,KAKoBE,iBAAqBmC,gBALzCrC,KAMSI,gBANTJ,KAMkCK,gBAEtCjB,UAAUqD,OAAO,0BAA2BD,UAUvDjD,eAAeM,UAAUU,OAAS,gBACzBG,OAAS,UACTJ,eAAiB,IAGnBf"} \ No newline at end of file +{"version":3,"file":"actionselector.min.js","sources":["../src/actionselector.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Action selector.\n *\n * To handle 'save' events use: actionselector.on('save')\n * This will receive the information to display in popup.\n * The actions have the format [{'text': sometext, 'value' : somevalue}].\n *\n * @module tool_lp/actionselector\n * @copyright 2016 Serge Gauthier - \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base'],\n function($, Notification, Ajax, Templates, Dialogue, EventBase) {\n\n /**\n * Action selector class.\n *\n * @class tool_lp/actionselector\n * @param {String} title The title of popup.\n * @param {String} message The message to display.\n * @param {object} actions The actions that can be selected.\n * @param {String} confirm Text for confirm button.\n * @param {String} cancel Text for cancel button.\n */\n var ActionSelector = function(title, message, actions, confirm, cancel) {\n var self = this;\n\n EventBase.prototype.constructor.apply(this, []);\n self._title = title;\n self._message = message;\n self._actions = actions;\n self._confirm = confirm;\n self._cancel = cancel;\n self._selectedValue = null;\n self._reset();\n };\n\n ActionSelector.prototype = Object.create(EventBase.prototype);\n\n /** @property {String} The value that was selected. */\n ActionSelector.prototype._selectedValue = null;\n /** @property {Dialogue} The reference to the dialogue. */\n ActionSelector.prototype._popup = null;\n /** @property {String} The title of popup. */\n ActionSelector.prototype._title = null;\n /** @property {String} The message in popup. */\n ActionSelector.prototype._message = null;\n /** @property {object} The information for radion buttons. */\n ActionSelector.prototype._actions = null;\n /** @property {String} The text for confirm button. */\n ActionSelector.prototype._confirm = null;\n /** @property {String} The text for cancel button. */\n ActionSelector.prototype._cancel = null;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n ActionSelector.prototype._afterRender = function() {\n var self = this;\n\n // Confirm button is disabled until a choice is done.\n self._find('[data-action=\"action-selector-confirm\"]').attr('disabled', 'disabled');\n\n // Add listener for radio buttons change.\n self._find('[data-region=\"action-selector-radio-buttons\"]').change(function() {\n self._selectedValue = $(\"input[type='radio']:checked\").val();\n self._find('[data-action=\"action-selector-confirm\"]').removeAttr('disabled');\n self._refresh.bind(self);\n });\n\n // Add listener for cancel.\n self._find('[data-action=\"action-selector-cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for confirm.\n self._find('[data-action=\"action-selector-confirm\"]').click(function(e) {\n e.preventDefault();\n if (!self._selectedValue.length) {\n return;\n }\n self._trigger('save', {action: self._selectedValue});\n self.close();\n });\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n ActionSelector.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the action selector.\n *\n * @method display\n * @return {Promise}\n */\n ActionSelector.prototype.display = function() {\n var self = this;\n return self._render().then(function(html) {\n self._popup = new Dialogue(\n self._title,\n html,\n self._afterRender.bind(self)\n );\n return;\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery} The node\n * @method _find\n */\n ActionSelector.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n ActionSelector.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"action-selector\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n ActionSelector.prototype._render = function() {\n var self = this;\n var choices = [];\n for (var i in self._actions) {\n choices.push(self._actions[i]);\n }\n var content = {'message': self._message, 'choices': choices,\n 'confirm': self._confirm, 'cancel': self._cancel};\n\n return Templates.render('tool_lp/action_selector', content);\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n ActionSelector.prototype._reset = function() {\n this._popup = null;\n this._selectedValue = '';\n };\n\n return ActionSelector;\n\n});\n"],"names":["define","$","Notification","Ajax","Templates","Dialogue","EventBase","ActionSelector","title","message","actions","confirm","cancel","prototype","constructor","apply","this","_title","_message","_actions","_confirm","_cancel","_selectedValue","_reset","Object","create","_popup","_afterRender","self","_find","attr","change","val","removeAttr","_refresh","bind","click","e","preventDefault","close","length","_trigger","action","display","_render","then","html","fail","exception","selector","getContent","find","replaceWith","choices","i","push","content","render"],"mappings":";;;;;;;;;;;AA2BAA,OAAM,yBAAC,CAAC,SACA,oBACA,YACA,iBACA,mBACA,uBACA,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,SAAUC,WAYzD,IAAIC,eAAiB,SAASC,MAAOC,QAASC,QAASC,QAASC,QAG5DN,UAAUO,UAAUC,YAAYC,MAAMC,KAAM,IAFjCA,KAGNC,OAAST,MAHHQ,KAINE,SAAWT,QAJLO,KAKNG,SAAWT,QALLM,KAMNI,SAAWT,QANLK,KAONK,QAAUT,OAPJI,KAQNM,eAAiB,KARXN,KASNO,UA4IT,OAzIAhB,eAAeM,UAAYW,OAAOC,OAAOnB,UAAUO,YAG1BS,eAAiB,KAE1Cf,eAAeM,UAAUa,OAAS,KAElCnB,eAAeM,UAAUI,OAAS,KAElCV,eAAeM,UAAUK,SAAW,KAEpCX,eAAeM,UAAUM,SAAW,KAEpCZ,eAAeM,UAAUO,SAAW,KAEpCb,eAAeM,UAAUQ,QAAU,KAOnCd,eAAeM,UAAUc,aAAe,WACpC,IAAIC,KAAOZ,KAGXY,KAAKC,MAAM,2CAA2CC,KAAK,WAAY,YAGvEF,KAAKC,MAAM,iDAAiDE,QAAO,WAC/DH,KAAKN,eAAiBrB,EAAE,+BAA+B+B,MACvDJ,KAAKC,MAAM,2CAA2CI,WAAW,YACjEL,KAAKM,SAASC,KAAKP,KACvB,IAGAA,KAAKC,MAAM,0CAA0CO,OAAM,SAASC,GAChEA,EAAEC,iBACFV,KAAKW,OACT,IAGAX,KAAKC,MAAM,2CAA2CO,OAAM,SAASC,GACjEA,EAAEC,iBACGV,KAAKN,eAAekB,SAGzBZ,KAAKa,SAAS,OAAQ,CAACC,OAAQd,KAAKN,iBACpCM,KAAKW,QACT,KAQJhC,eAAeM,UAAU0B,MAAQ,WAClBvB,KACNU,OAAOa,QADDvB,KAENO,UASThB,eAAeM,UAAU8B,QAAU,WAC/B,IAAIf,KAAOZ,KACX,OAAOY,KAAKgB,UAAUC,MAAK,SAASC,MAChClB,KAAKF,OAAS,IAAIrB,SACduB,KAAKX,OACL6B,KACAlB,KAAKD,aAAaQ,KAAKP,MAG9B,IAAEmB,KAAK7C,aAAa8C,YAUzBzC,eAAeM,UAAUgB,MAAQ,SAASoB,UACtC,OAAOhD,EAAEe,KAAKU,OAAOwB,cAAcC,KAAKF,WAS5C1C,eAAeM,UAAUqB,SAAW,WAChC,IAAIN,KAAOZ,KACX,OAAOY,KAAKgB,UAAUC,MAAK,SAASC,MAChClB,KAAKC,MAAM,mCAAmCuB,YAAYN,MAC1DlB,KAAKD,cAET,KASJpB,eAAeM,UAAU+B,QAAU,WAC/B,IACIS,QAAU,GACd,IAAK,IAAIC,KAFEtC,KAEQG,SACfkC,QAAQE,KAHDvC,KAGWG,SAASmC,IAE/B,IAAIE,QAAU,CAAC/C,QALJO,KAKoBE,SAAUmC,QAAWA,QAChD1C,QANOK,KAMSI,SAAUR,OANnBI,KAMkCK,SAE7C,OAAOjB,UAAUqD,OAAO,0BAA2BD,UAUvDjD,eAAeM,UAAUU,OAAS,WAC9BP,KAAKU,OAAS,KACdV,KAAKM,eAAiB,IAGnBf,cAEX"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencies.min.js.map b/admin/tool/lp/amd/build/competencies.min.js.map index 38cbcbe25d1..364bb966074 100644 --- a/admin/tool/lp/amd/build/competencies.min.js.map +++ b/admin/tool/lp/amd/build/competencies.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competencies.min.js","sources":["../src/competencies.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle add/remove competency links.\n *\n * @module tool_lp/competencies\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/competencypicker',\n 'tool_lp/dragdrop-reorder',\n 'core/pending'],\n function($, notification, ajax, templates, str, Picker, dragdrop, Pending) {\n\n /**\n * Constructor\n *\n * @class tool_lp/competencies\n * @param {Number} itemid\n * @param {String} itemtype\n * @param {Number} pagectxid\n */\n var competencies = function(itemid, itemtype, pagectxid) {\n this.itemid = itemid;\n this.itemtype = itemtype;\n this.pageContextId = pagectxid;\n this.pickerInstance = null;\n\n $('[data-region=\"actions\"] button').prop('disabled', false);\n this.registerEvents();\n this.registerDragDrop();\n };\n\n /**\n * Initialise the drag/drop code.\n * @method registerDragDrop\n */\n competencies.prototype.registerDragDrop = function() {\n var localthis = this;\n // Init this module.\n str.get_string('movecompetency', 'tool_lp').done(\n function(movestring) {\n dragdrop.dragdrop('movecompetency',\n movestring,\n {identifier: 'movecompetency', component: 'tool_lp'},\n {identifier: 'movecompetencyafter', component: 'tool_lp'},\n 'drag-samenode',\n 'drag-parentnode',\n 'drag-handlecontainer',\n function(drag, drop) {\n localthis.handleDrop(drag, drop);\n });\n }\n ).fail(notification.exception);\n\n };\n\n /**\n * Handle a drop from a drag/drop operation.\n *\n * @method handleDrop\n * @param {DOMNode} drag The dragged node.\n * @param {DOMNode} drop The dropped on node.\n */\n competencies.prototype.handleDrop = function(drag, drop) {\n var fromid = $(drag).data('id');\n var toid = $(drop).data('id');\n var localthis = this;\n var requests = [];\n\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_course_competency',\n args: {courseid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_template_competency',\n args: {templateid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_plan_competency',\n args: {planid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else {\n return;\n }\n\n requests[0].fail(notification.exception);\n };\n\n /**\n * Pick a competency\n *\n * @method pickCompetency\n * @return {Promise}\n */\n competencies.prototype.pickCompetency = function() {\n var self = this;\n var requests;\n var pagerender;\n var pageregion;\n var pageContextIncludes;\n\n if (!self.pickerInstance) {\n if (self.itemtype === 'template' || self.itemtype === 'course') {\n pageContextIncludes = 'parents';\n }\n self.pickerInstance = new Picker(self.pageContextId, false, pageContextIncludes);\n self.pickerInstance.on('save', function(e, data) {\n var compIds = data.competencyIds;\n var pendingPromise = new Pending();\n\n if (self.itemtype === \"course\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_course',\n args: {courseid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: self.itemid, moduleid: 0}\n });\n\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n\n } else if (self.itemtype === \"template\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_template',\n args: {templateid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: self.itemid, pagecontext: {contextid: self.pageContextId}}\n });\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (self.itemtype === \"plan\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_plan',\n args: {planid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_plan_page',\n args: {planid: self.itemid}\n });\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n ajax.call(requests)[requests.length - 1]\n .then(function(context) {\n return templates.render(pagerender, context);\n })\n .then(function(html, js) {\n templates.replaceNode($('[data-region=\"' + pageregion + '\"]'), html, js);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n return self.pickerInstance.display();\n };\n\n /**\n * Delete the link between competency and course, template or plan. Reload the page.\n *\n * @method doDelete\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.doDelete = function(deleteid) {\n var localthis = this;\n var requests = [],\n pagerender = '',\n pageregion = '';\n\n // Delete the link and reload the page template.\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_course',\n args: {courseid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_template',\n args: {templateid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: localthis.itemid, pagecontext: {contextid: localthis.pageContextId}}}\n ]);\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_plan',\n args: {planid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_plan_page',\n args: {planid: localthis.itemid}}\n ]);\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n\n requests[1].done(function(context) {\n templates.render(pagerender, context).done(function(html, js) {\n $('[data-region=\"' + pageregion + '\"]').replaceWith(html);\n templates.runTemplateJS(js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n *\n * @method deleteHandler\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.deleteHandler = function(deleteid) {\n var localthis = this;\n var requests = [];\n var message;\n\n if (localthis.itemtype == 'course') {\n message = 'unlinkcompetencycourse';\n } else if (localthis.itemtype == 'template') {\n message = 'unlinkcompetencytemplate';\n } else if (localthis.itemtype == 'plan') {\n message = 'unlinkcompetencyplan';\n } else {\n return;\n }\n\n requests = ajax.call([{\n methodname: 'core_competency_read_competency',\n args: {id: deleteid}\n }]);\n\n requests[0].done(function(competency) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: message, component: 'tool_lp', param: competency.shortname},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Unlink the competency X from the course?\n strings[2], // Confirm.\n strings[3], // Cancel.\n function() {\n localthis.doDelete(deleteid);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Register the javascript event handlers for this page.\n *\n * @method registerEvents\n */\n competencies.prototype.registerEvents = function() {\n var localthis = this;\n\n if (localthis.itemtype == 'course') {\n // Course completion rule handling.\n $('[data-region=\"coursecompetenciespage\"]').on('change', 'select[data-field=\"ruleoutcome\"]', function(e) {\n var pendingPromise = new Pending();\n var requests = [];\n var pagerender = 'tool_lp/course_competencies_page';\n var pageregion = 'coursecompetenciespage';\n var coursecompetencyid = $(e.target).data('id');\n var ruleoutcome = $(e.target).val();\n requests = ajax.call([\n {methodname: 'core_competency_set_course_competency_ruleoutcome',\n args: {coursecompetencyid: coursecompetencyid, ruleoutcome: ruleoutcome}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n\n requests[1].then(function(context) {\n return templates.render(pagerender, context);\n })\n .then(function(html, js) {\n return templates.replaceNode($('[data-region=\"' + pageregion + '\"]'), html, js);\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n $('[data-region=\"actions\"] button').click(function(e) {\n var pendingPromise = new Pending();\n e.preventDefault();\n\n localthis.pickCompetency()\n .then(pendingPromise.resolve)\n .catch();\n });\n $('[data-action=\"delete-competency-link\"]').click(function(e) {\n e.preventDefault();\n\n var deleteid = $(e.target).closest('[data-id]').data('id');\n localthis.deleteHandler(deleteid);\n });\n };\n\n return /** @alias module:tool_lp/competencies */ competencies;\n});\n"],"names":["define","$","notification","ajax","templates","str","Picker","dragdrop","Pending","competencies","itemid","itemtype","pagectxid","pageContextId","pickerInstance","prop","registerEvents","registerDragDrop","prototype","localthis","this","get_string","done","movestring","identifier","component","drag","drop","handleDrop","fail","exception","fromid","data","toid","requests","call","methodname","args","courseid","competencyidfrom","competencyidto","templateid","planid","pickCompetency","pagerender","pageregion","pageContextIncludes","self","on","e","compIds","competencyIds","pendingPromise","each","index","compId","push","competencyid","moduleid","pagecontext","contextid","length","then","context","render","html","js","replaceNode","resolve","catch","display","doDelete","deleteid","replaceWith","runTemplateJS","deleteHandler","message","id","competency","get_strings","key","param","shortname","strings","confirm","coursecompetencyid","target","ruleoutcome","val","click","preventDefault","closest"],"mappings":";;;;;;;AAsBAA,8BAAO,CAAC,SACA,oBACA,YACA,iBACA,WACA,2BACA,2BACA,iBACD,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,IAAKC,OAAQC,SAAUC,aAUjEC,aAAe,SAASC,OAAQC,SAAUC,gBACrCF,OAASA,YACTC,SAAWA,cACXE,cAAgBD,eAChBE,eAAiB,KAEtBb,EAAE,kCAAkCc,KAAK,YAAY,QAChDC,sBACAC,2BAOTR,aAAaS,UAAUD,iBAAmB,eAClCE,UAAYC,KAEhBf,IAAIgB,WAAW,iBAAkB,WAAWC,MACxC,SAASC,YACLhB,SAASA,SAA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AK,SAAS6D,SACbjF,aAAakF,QACTD,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRA,QAAQ,IACR,WACIhE,UAAUoD,SAASC,gBAG5B3C,KAAK3B,aAAa4B,cACtBD,KAAK3B,aAAa4B,YAQzBrB,aAAaS,UAAUF,eAAiB,eAChCG,UAAYC,KAEU,UAAtBD,UAAUR,UAEVV,EAAE,0CAA0C+C,GAAG,SAAU,oCAAoC,SAASC,OAC9FG,eAAiB,IAAI5C,QAIrB6E,mBAAqBpF,EAAEgD,EAAEqC,QAAQtD,KAAK,MACtCuD,YAActF,EAAEgD,EAAEqC,QAAQE,MACnBrF,KAAKgC,KAAK,CACjB,CAACC,WAAY,oDACXC,KAAM,CAACgD,mBAAoBA,mBAAoBE,YAAaA,cAC9D,CAACnD,WAAY,4CACXC,KAAM,CAACC,SAAUnB,UAAUT,OAAQgD,SAAU,MAG1C,GAAGI,MAAK,SAASC,gBACf3D,UAAU4D,OAZJ,mCAYuBD,YAEvCD,MAAK,SAASG,KAAMC,WACV9D,UAAU+D,YAAYlE,EAAE,0CAAuCgE,KAAMC,OAE/EJ,KAAKV,eAAegB,SACpBC,MAAMnE,aAAa4B,cAI5B7B,EAAE,kCAAkCwF,OAAM,SAASxC,OAC3CG,eAAiB,IAAI5C,QACzByC,EAAEyC,iBAEFvE,UAAUwB,iBACLmB,KAAKV,eAAegB,SACpBC,WAETpE,EAAE,0CAA0CwF,OAAM,SAASxC,GACvDA,EAAEyC,qBAEElB,SAAWvE,EAAEgD,EAAEqC,QAAQK,QAAQ,aAAa3D,KAAK,MACrDb,UAAUwD,cAAcH,cAIiB/D"} \ No newline at end of file +{"version":3,"file":"competencies.min.js","sources":["../src/competencies.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle add/remove competency links.\n *\n * @module tool_lp/competencies\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/competencypicker',\n 'tool_lp/dragdrop-reorder',\n 'core/pending'],\n function($, notification, ajax, templates, str, Picker, dragdrop, Pending) {\n\n /**\n * Constructor\n *\n * @class tool_lp/competencies\n * @param {Number} itemid\n * @param {String} itemtype\n * @param {Number} pagectxid\n */\n var competencies = function(itemid, itemtype, pagectxid) {\n this.itemid = itemid;\n this.itemtype = itemtype;\n this.pageContextId = pagectxid;\n this.pickerInstance = null;\n\n $('[data-region=\"actions\"] button').prop('disabled', false);\n this.registerEvents();\n this.registerDragDrop();\n };\n\n /**\n * Initialise the drag/drop code.\n * @method registerDragDrop\n */\n competencies.prototype.registerDragDrop = function() {\n var localthis = this;\n // Init this module.\n str.get_string('movecompetency', 'tool_lp').done(\n function(movestring) {\n dragdrop.dragdrop('movecompetency',\n movestring,\n {identifier: 'movecompetency', component: 'tool_lp'},\n {identifier: 'movecompetencyafter', component: 'tool_lp'},\n 'drag-samenode',\n 'drag-parentnode',\n 'drag-handlecontainer',\n function(drag, drop) {\n localthis.handleDrop(drag, drop);\n });\n }\n ).fail(notification.exception);\n\n };\n\n /**\n * Handle a drop from a drag/drop operation.\n *\n * @method handleDrop\n * @param {DOMNode} drag The dragged node.\n * @param {DOMNode} drop The dropped on node.\n */\n competencies.prototype.handleDrop = function(drag, drop) {\n var fromid = $(drag).data('id');\n var toid = $(drop).data('id');\n var localthis = this;\n var requests = [];\n\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_course_competency',\n args: {courseid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_template_competency',\n args: {templateid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_plan_competency',\n args: {planid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else {\n return;\n }\n\n requests[0].fail(notification.exception);\n };\n\n /**\n * Pick a competency\n *\n * @method pickCompetency\n * @return {Promise}\n */\n competencies.prototype.pickCompetency = function() {\n var self = this;\n var requests;\n var pagerender;\n var pageregion;\n var pageContextIncludes;\n\n if (!self.pickerInstance) {\n if (self.itemtype === 'template' || self.itemtype === 'course') {\n pageContextIncludes = 'parents';\n }\n self.pickerInstance = new Picker(self.pageContextId, false, pageContextIncludes);\n self.pickerInstance.on('save', function(e, data) {\n var compIds = data.competencyIds;\n var pendingPromise = new Pending();\n\n if (self.itemtype === \"course\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_course',\n args: {courseid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: self.itemid, moduleid: 0}\n });\n\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n\n } else if (self.itemtype === \"template\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_template',\n args: {templateid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: self.itemid, pagecontext: {contextid: self.pageContextId}}\n });\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (self.itemtype === \"plan\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_plan',\n args: {planid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_plan_page',\n args: {planid: self.itemid}\n });\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n ajax.call(requests)[requests.length - 1]\n .then(function(context) {\n return templates.render(pagerender, context);\n })\n .then(function(html, js) {\n templates.replaceNode($('[data-region=\"' + pageregion + '\"]'), html, js);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n return self.pickerInstance.display();\n };\n\n /**\n * Delete the link between competency and course, template or plan. Reload the page.\n *\n * @method doDelete\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.doDelete = function(deleteid) {\n var localthis = this;\n var requests = [],\n pagerender = '',\n pageregion = '';\n\n // Delete the link and reload the page template.\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_course',\n args: {courseid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_template',\n args: {templateid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: localthis.itemid, pagecontext: {contextid: localthis.pageContextId}}}\n ]);\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_plan',\n args: {planid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_plan_page',\n args: {planid: localthis.itemid}}\n ]);\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n\n requests[1].done(function(context) {\n templates.render(pagerender, context).done(function(html, js) {\n $('[data-region=\"' + pageregion + '\"]').replaceWith(html);\n templates.runTemplateJS(js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n *\n * @method deleteHandler\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.deleteHandler = function(deleteid) {\n var localthis = this;\n var requests = [];\n var message;\n\n if (localthis.itemtype == 'course') {\n message = 'unlinkcompetencycourse';\n } else if (localthis.itemtype == 'template') {\n message = 'unlinkcompetencytemplate';\n } else if (localthis.itemtype == 'plan') {\n message = 'unlinkcompetencyplan';\n } else {\n return;\n }\n\n requests = ajax.call([{\n methodname: 'core_competency_read_competency',\n args: {id: deleteid}\n }]);\n\n requests[0].done(function(competency) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: message, component: 'tool_lp', param: competency.shortname},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Unlink the competency X from the course?\n strings[2], // Confirm.\n strings[3], // Cancel.\n function() {\n localthis.doDelete(deleteid);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Register the javascript event handlers for this page.\n *\n * @method registerEvents\n */\n competencies.prototype.registerEvents = function() {\n var localthis = this;\n\n if (localthis.itemtype == 'course') {\n // Course completion rule handling.\n $('[data-region=\"coursecompetenciespage\"]').on('change', 'select[data-field=\"ruleoutcome\"]', function(e) {\n var pendingPromise = new Pending();\n var requests = [];\n var pagerender = 'tool_lp/course_competencies_page';\n var pageregion = 'coursecompetenciespage';\n var coursecompetencyid = $(e.target).data('id');\n var ruleoutcome = $(e.target).val();\n requests = ajax.call([\n {methodname: 'core_competency_set_course_competency_ruleoutcome',\n args: {coursecompetencyid: coursecompetencyid, ruleoutcome: ruleoutcome}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n\n requests[1].then(function(context) {\n return templates.render(pagerender, context);\n })\n .then(function(html, js) {\n return templates.replaceNode($('[data-region=\"' + pageregion + '\"]'), html, js);\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n $('[data-region=\"actions\"] button').click(function(e) {\n var pendingPromise = new Pending();\n e.preventDefault();\n\n localthis.pickCompetency()\n .then(pendingPromise.resolve)\n .catch();\n });\n $('[data-action=\"delete-competency-link\"]').click(function(e) {\n e.preventDefault();\n\n var deleteid = $(e.target).closest('[data-id]').data('id');\n localthis.deleteHandler(deleteid);\n });\n };\n\n return /** @alias module:tool_lp/competencies */ competencies;\n});\n"],"names":["define","$","notification","ajax","templates","str","Picker","dragdrop","Pending","competencies","itemid","itemtype","pagectxid","this","pageContextId","pickerInstance","prop","registerEvents","registerDragDrop","prototype","localthis","get_string","done","movestring","identifier","component","drag","drop","handleDrop","fail","exception","fromid","data","toid","requests","call","methodname","args","courseid","competencyidfrom","competencyidto","templateid","planid","pickCompetency","pagerender","pageregion","pageContextIncludes","self","on","e","compIds","competencyIds","pendingPromise","each","index","compId","push","competencyid","moduleid","pagecontext","contextid","length","then","context","render","html","js","replaceNode","resolve","catch","display","doDelete","deleteid","replaceWith","runTemplateJS","deleteHandler","message","id","competency","get_strings","key","param","shortname","strings","confirm","coursecompetencyid","target","ruleoutcome","val","click","preventDefault","closest"],"mappings":";;;;;;;AAsBAA,OAAO,uBAAA,CAAC,SACA,oBACA,YACA,iBACA,WACA,2BACA,2BACA,iBACD,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,IAAKC,OAAQC,SAAUC,SAUrE,IAAIC,aAAe,SAASC,OAAQC,SAAUC,WAC1CC,KAAKH,OAASA,OACdG,KAAKF,SAAWA,SAChBE,KAAKC,cAAgBF,UACrBC,KAAKE,eAAiB,KAEtBd,EAAE,kCAAkCe,KAAK,YAAY,GACrDH,KAAKI,iBACLJ,KAAKK,oBA8ST,OAvSAT,aAAaU,UAAUD,iBAAmB,WACtC,IAAIE,UAAYP,KAEhBR,IAAIgB,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AC5B,KAG6C/D,YACrD"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_outcomes.min.js.map b/admin/tool/lp/amd/build/competency_outcomes.min.js.map index e3bf7de9983..21e84e73a39 100644 --- a/admin/tool/lp/amd/build/competency_outcomes.min.js.map +++ b/admin/tool/lp/amd/build/competency_outcomes.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competency_outcomes.min.js","sources":["../src/competency_outcomes.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency rule config.\n *\n * @module tool_lp/competency_outcomes\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str'],\n function($, Str) {\n\n var OUTCOME_NONE = 0,\n OUTCOME_EVIDENCE = 1,\n OUTCOME_COMPLETE = 2,\n OUTCOME_RECOMMEND = 3;\n\n return {\n\n NONE: OUTCOME_NONE,\n EVIDENCE: OUTCOME_EVIDENCE,\n COMPLETE: OUTCOME_COMPLETE,\n RECOMMEND: OUTCOME_RECOMMEND,\n\n /**\n * Get all the outcomes.\n *\n * @return {Object} Indexed by outcome code, contains code and name.\n * @method getAll\n */\n getAll: function() {\n var self = this;\n return Str.get_strings([\n {key: 'competencyoutcome_none', component: 'tool_lp'},\n {key: 'competencyoutcome_evidence', component: 'tool_lp'},\n {key: 'competencyoutcome_recommend', component: 'tool_lp'},\n {key: 'competencyoutcome_complete', component: 'tool_lp'},\n ]).then(function(strings) {\n var outcomes = {};\n outcomes[self.NONE] = {code: self.NONE, name: strings[0]};\n outcomes[self.EVIDENCE] = {code: self.EVIDENCE, name: strings[1]};\n outcomes[self.RECOMMEND] = {code: self.RECOMMEND, name: strings[2]};\n outcomes[self.COMPLETE] = {code: self.COMPLETE, name: strings[3]};\n return outcomes;\n });\n },\n\n /**\n * Get the string for an outcome.\n *\n * @param {Number} id The outcome code.\n * @return {Promise} Resolved with the string.\n * @method getString\n */\n getString: function(id) {\n var self = this,\n all = self.getAll();\n\n return all.then(function(outcomes) {\n if (typeof outcomes[id] === 'undefined') {\n return $.Deferred().reject().promise();\n }\n return outcomes[id].name;\n });\n }\n };\n});\n"],"names":["define","$","Str","NONE","EVIDENCE","COMPLETE","RECOMMEND","getAll","self","this","get_strings","key","component","then","strings","outcomes","code","name","getString","id","Deferred","reject","promise"],"mappings":";;;;;;;AAuBAA,qCAAO,CAAC,SACA,aACA,SAASC,EAAGC,WAOT,CAEHC,KAPe,EAQfC,SAPmB,EAQnBC,SAPmB,EAQnBC,UAPoB,EAepBC,OAAQ,eACAC,KAAOC,YACJP,IAAIQ,YAAY,CACnB,CAACC,IAAK,yBAA0BC,UAAW,WAC3C,CAACD,IAAK,6BAA8BC,UAAW,WAC/C,CAACD,IAAK,8BAA+BC,UAAW,WAChD,CAACD,IAAK,6BAA8BC,UAAW,aAChDC,MAAK,SAASC,aACTC,SAAW,UACfA,SAASP,KAAKL,MAAQ,CAACa,KAAMR,KAAKL,KAAMc,KAAMH,QAAQ,IACtDC,SAASP,KAAKJ,UAAY,CAACY,KAAMR,KAAKJ,SAAUa,KAAMH,QAAQ,IAC9DC,SAASP,KAAKF,WAAa,CAACU,KAAMR,KAAKF,UAAWW,KAAMH,QAAQ,IAChEC,SAASP,KAAKH,UAAY,CAACW,KAAMR,KAAKH,SAAUY,KAAMH,QAAQ,IACvDC,aAWfG,UAAW,SAASC,WACLV,KACIF,SAEJM,MAAK,SAASE,sBACO,IAAjBA,SAASI,IACTlB,EAAEmB,WAAWC,SAASC,UAE1BP,SAASI,IAAIF"} \ No newline at end of file +{"version":3,"file":"competency_outcomes.min.js","sources":["../src/competency_outcomes.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency rule config.\n *\n * @module tool_lp/competency_outcomes\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str'],\n function($, Str) {\n\n var OUTCOME_NONE = 0,\n OUTCOME_EVIDENCE = 1,\n OUTCOME_COMPLETE = 2,\n OUTCOME_RECOMMEND = 3;\n\n return {\n\n NONE: OUTCOME_NONE,\n EVIDENCE: OUTCOME_EVIDENCE,\n COMPLETE: OUTCOME_COMPLETE,\n RECOMMEND: OUTCOME_RECOMMEND,\n\n /**\n * Get all the outcomes.\n *\n * @return {Object} Indexed by outcome code, contains code and name.\n * @method getAll\n */\n getAll: function() {\n var self = this;\n return Str.get_strings([\n {key: 'competencyoutcome_none', component: 'tool_lp'},\n {key: 'competencyoutcome_evidence', component: 'tool_lp'},\n {key: 'competencyoutcome_recommend', component: 'tool_lp'},\n {key: 'competencyoutcome_complete', component: 'tool_lp'},\n ]).then(function(strings) {\n var outcomes = {};\n outcomes[self.NONE] = {code: self.NONE, name: strings[0]};\n outcomes[self.EVIDENCE] = {code: self.EVIDENCE, name: strings[1]};\n outcomes[self.RECOMMEND] = {code: self.RECOMMEND, name: strings[2]};\n outcomes[self.COMPLETE] = {code: self.COMPLETE, name: strings[3]};\n return outcomes;\n });\n },\n\n /**\n * Get the string for an outcome.\n *\n * @param {Number} id The outcome code.\n * @return {Promise} Resolved with the string.\n * @method getString\n */\n getString: function(id) {\n var self = this,\n all = self.getAll();\n\n return all.then(function(outcomes) {\n if (typeof outcomes[id] === 'undefined') {\n return $.Deferred().reject().promise();\n }\n return outcomes[id].name;\n });\n }\n };\n});\n"],"names":["define","$","Str","NONE","EVIDENCE","COMPLETE","RECOMMEND","getAll","self","this","get_strings","key","component","then","strings","outcomes","code","name","getString","id","Deferred","reject","promise"],"mappings":";;;;;;;AAuBAA,OAAM,8BAAC,CAAC,SACA,aACA,SAASC,EAAGC,KAOhB,MAAO,CAEHC,KAPe,EAQfC,SAPmB,EAQnBC,SAPmB,EAQnBC,UAPoB,EAepBC,OAAQ,WACJ,IAAIC,KAAOC,KACX,OAAOP,IAAIQ,YAAY,CACnB,CAACC,IAAK,yBAA0BC,UAAW,WAC3C,CAACD,IAAK,6BAA8BC,UAAW,WAC/C,CAACD,IAAK,8BAA+BC,UAAW,WAChD,CAACD,IAAK,6BAA8BC,UAAW,aAChDC,MAAK,SAASC,SACb,IAAIC,SAAW,CAAA,EAKf,OAJAA,SAASP,KAAKL,MAAQ,CAACa,KAAMR,KAAKL,KAAMc,KAAMH,QAAQ,IACtDC,SAASP,KAAKJ,UAAY,CAACY,KAAMR,KAAKJ,SAAUa,KAAMH,QAAQ,IAC9DC,SAASP,KAAKF,WAAa,CAACU,KAAMR,KAAKF,UAAWW,KAAMH,QAAQ,IAChEC,SAASP,KAAKH,UAAY,CAACW,KAAMR,KAAKH,SAAUY,KAAMH,QAAQ,IACvDC,QACX,GACH,EASDG,UAAW,SAASC,IAIhB,OAHWV,KACIF,SAEJM,MAAK,SAASE,UACrB,YAA4B,IAAjBA,SAASI,IACTlB,EAAEmB,WAAWC,SAASC,UAE1BP,SAASI,IAAIF,IACxB,GACJ,EAER"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_plan_navigation.min.js.map b/admin/tool/lp/amd/build/competency_plan_navigation.min.js.map index 613139fd6e8..06915ce77e5 100644 --- a/admin/tool/lp/amd/build/competency_plan_navigation.min.js.map +++ b/admin/tool/lp/amd/build/competency_plan_navigation.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competency_plan_navigation.min.js","sources":["../src/competency_plan_navigation.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Event click on selecting competency in the competency autocomplete.\n *\n * @module tool_lp/competency_plan_navigation\n * @copyright 2016 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * CompetencyPlanNavigation\n *\n * @class\n * @param {String} competencySelector The selector of the competency element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} userId The user id\n * @param {Number} competencyId The competency id\n * @param {Number} planId The plan id\n */\n var CompetencyPlanNavigation = function(competencySelector, baseUrl, userId, competencyId, planId) {\n this._baseUrl = baseUrl;\n this._userId = userId + '';\n this._competencyId = competencyId + '';\n this._planId = planId;\n this._ignoreFirstCompetency = true;\n\n $(competencySelector).on('change', this._competencyChanged.bind(this));\n };\n\n /**\n * The competency was changed in the select list.\n *\n * @method _competencyChanged\n * @param {Event} e\n */\n CompetencyPlanNavigation.prototype._competencyChanged = function(e) {\n if (this._ignoreFirstCompetency) {\n this._ignoreFirstCompetency = false;\n return;\n }\n var newCompetencyId = $(e.target).val();\n var queryStr = '?userid=' + this._userId + '&planid=' + this._planId + '&competencyid=' + newCompetencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the competency. */\n CompetencyPlanNavigation.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n CompetencyPlanNavigation.prototype._userId = null;\n /** @property {Number} The id of the plan. */\n CompetencyPlanNavigation.prototype._planId = null;\n /** @property {String} Plugin base url. */\n CompetencyPlanNavigation.prototype._baseUrl = null;\n /** @property {Boolean} Ignore the first change event for competencies. */\n CompetencyPlanNavigation.prototype._ignoreFirstCompetency = null;\n\n return CompetencyPlanNavigation;\n});\n"],"names":["define","$","CompetencyPlanNavigation","competencySelector","baseUrl","userId","competencyId","planId","_baseUrl","_userId","_competencyId","_planId","_ignoreFirstCompetency","on","this","_competencyChanged","bind","prototype","e","newCompetencyId","target","val","queryStr","document","location"],"mappings":";;;;;;;AAuBAA,4CAAO,CAAC,WAAW,SAASC,OAYpBC,yBAA2B,SAASC,mBAAoBC,QAASC,OAAQC,aAAcC,aAClFC,SAAWJ,aACXK,QAAUJ,OAAS,QACnBK,cAAgBJ,aAAe,QAC/BK,QAAUJ,YACVK,wBAAyB,EAE9BX,EAAEE,oBAAoBU,GAAG,SAAUC,KAAKC,mBAAmBC,KAAKF,eASpEZ,yBAAyBe,UAAUF,mBAAqB,SAASG,MACzDJ,KAAKF,4BACAA,wBAAyB,WAG9BO,gBAAkBlB,EAAEiB,EAAEE,QAAQC,MAC9BC,SAAW,WAAaR,KAAKL,QAAU,WAAaK,KAAKH,QAAU,iBAAmBQ,gBAC1FI,SAASC,SAAWV,KAAKN,SAAWc,WAIxCpB,yBAAyBe,UAAUP,cAAgB,KAEnDR,yBAAyBe,UAAUR,QAAU,KAE7CP,yBAAyBe,UAAUN,QAAU,KAE7CT,yBAAyBe,UAAUT,SAAW,KAE9CN,yBAAyBe,UAAUL,uBAAyB,KAErDV"} \ No newline at end of file +{"version":3,"file":"competency_plan_navigation.min.js","sources":["../src/competency_plan_navigation.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Event click on selecting competency in the competency autocomplete.\n *\n * @module tool_lp/competency_plan_navigation\n * @copyright 2016 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * CompetencyPlanNavigation\n *\n * @class\n * @param {String} competencySelector The selector of the competency element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} userId The user id\n * @param {Number} competencyId The competency id\n * @param {Number} planId The plan id\n */\n var CompetencyPlanNavigation = function(competencySelector, baseUrl, userId, competencyId, planId) {\n this._baseUrl = baseUrl;\n this._userId = userId + '';\n this._competencyId = competencyId + '';\n this._planId = planId;\n this._ignoreFirstCompetency = true;\n\n $(competencySelector).on('change', this._competencyChanged.bind(this));\n };\n\n /**\n * The competency was changed in the select list.\n *\n * @method _competencyChanged\n * @param {Event} e\n */\n CompetencyPlanNavigation.prototype._competencyChanged = function(e) {\n if (this._ignoreFirstCompetency) {\n this._ignoreFirstCompetency = false;\n return;\n }\n var newCompetencyId = $(e.target).val();\n var queryStr = '?userid=' + this._userId + '&planid=' + this._planId + '&competencyid=' + newCompetencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the competency. */\n CompetencyPlanNavigation.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n CompetencyPlanNavigation.prototype._userId = null;\n /** @property {Number} The id of the plan. */\n CompetencyPlanNavigation.prototype._planId = null;\n /** @property {String} Plugin base url. */\n CompetencyPlanNavigation.prototype._baseUrl = null;\n /** @property {Boolean} Ignore the first change event for competencies. */\n CompetencyPlanNavigation.prototype._ignoreFirstCompetency = null;\n\n return CompetencyPlanNavigation;\n});\n"],"names":["define","$","CompetencyPlanNavigation","competencySelector","baseUrl","userId","competencyId","planId","this","_baseUrl","_userId","_competencyId","_planId","_ignoreFirstCompetency","on","_competencyChanged","bind","prototype","e","newCompetencyId","target","val","queryStr","document","location"],"mappings":";;;;;;;AAuBAA,4CAAO,CAAC,WAAW,SAASC,GAYxB,IAAIC,yBAA2B,SAASC,mBAAoBC,QAASC,OAAQC,aAAcC,QACvFC,KAAKC,SAAWL,QAChBI,KAAKE,QAAUL,OAAS,GACxBG,KAAKG,cAAgBL,aAAe,GACpCE,KAAKI,QAAUL,OACfC,KAAKK,wBAAyB,EAE9BZ,EAAEE,oBAAoBW,GAAG,SAAUN,KAAKO,mBAAmBC,KAAKR,QA8BpE,OArBAN,yBAAyBe,UAAUF,mBAAqB,SAASG,GAC7D,GAAIV,KAAKK,uBACLL,KAAKK,wBAAyB,MADlC,CAIA,IAAIM,gBAAkBlB,EAAEiB,EAAEE,QAAQC,MAC9BC,SAAW,WAAad,KAAKE,QAAU,WAAaF,KAAKI,QAAU,iBAAmBO,gBAC1FI,SAASC,SAAWhB,KAAKC,SAAWa,QAHpC,GAOJpB,yBAAyBe,UAAUN,cAAgB,KAEnDT,yBAAyBe,UAAUP,QAAU,KAE7CR,yBAAyBe,UAAUL,QAAU,KAE7CV,yBAAyBe,UAAUR,SAAW,KAE9CP,yBAAyBe,UAAUJ,uBAAyB,KAErDX,wBACX"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_rule.min.js.map b/admin/tool/lp/amd/build/competency_rule.min.js.map index a0fe9913190..7f7eec6de61 100644 --- a/admin/tool/lp/amd/build/competency_rule.min.js.map +++ b/admin/tool/lp/amd/build/competency_rule.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competency_rule.min.js","sources":["../src/competency_rule.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency rule base module.\n *\n * @module tool_lp/competencyrule\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * Competency rule abstract class.\n *\n * Any competency rule should extend this object. The event 'change' should be\n * triggered on the instance when the configuration has changed. This will allow\n * the components using the rule to gather the config, or check its validity.\n *\n * this._triggerChange();\n *\n * @param {Tree} tree The competency tree.\n */\n var Rule = function(tree) {\n this._eventNode = $('
');\n this._ready = $.Deferred();\n this._tree = tree;\n };\n\n /** @property {Object} The current competency. */\n Rule.prototype._competency = null;\n /** @property {Node} The node we attach the events to. */\n Rule.prototype._eventNode = null;\n /** @property {Promise} Resolved when the object is ready. */\n Rule.prototype._ready = null;\n /** @property {Tree} The competency tree. */\n Rule.prototype._tree = null;\n\n /**\n * Whether or not the current competency can be configured using this rule.\n *\n * @return {Boolean}\n * @method canConfig\n */\n Rule.prototype.canConfig = function() {\n return this._tree.hasChildren(this._competency.id);\n };\n\n /**\n * The config established by this rule.\n *\n * To override in subclasses when relevant.\n *\n * @return {String|null}\n * @method getConfig\n */\n Rule.prototype.getConfig = function() {\n return null;\n };\n\n // eslint-disable-line valid-jsdoc\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n // eslint-enable-line valid-jsdoc\n Rule.prototype.getType = function() {\n throw new Error('Not implemented');\n };\n\n /**\n * The init process.\n *\n * Do not override this, instead override _load.\n *\n * @return {Promise} Revoled when the plugin is initialised.\n * @method init\n */\n Rule.prototype.init = function() {\n return this._load();\n };\n\n /**\n * Callback to inject the template.\n *\n * @returns {Promise} Resolved when done.\n * @method injectTemplate\n */\n Rule.prototype.injectTemplate = function() {\n return $.Deferred().reject().promise();\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * Plugins should override this.\n *\n * @return {Boolean}\n * @method _isValid\n */\n Rule.prototype.isValid = function() {\n return false;\n };\n\n /**\n * Load the class.\n *\n * @return {Promise}\n * @method _load\n * @protected\n */\n Rule.prototype._load = function() {\n return $.when();\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Rule.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Sets the current competency.\n *\n * @param {Competency} competency\n * @method setTargetCompetency\n */\n Rule.prototype.setTargetCompetency = function(competency) {\n this._competency = competency;\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n * @protected\n */\n Rule.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n /**\n * Trigger the change event.\n *\n * @method _triggerChange\n * @protected\n */\n Rule.prototype._triggerChange = function() {\n this._trigger('change', this);\n };\n\n return /** @alias module:tool_lp/competency_rule */ Rule;\n\n});\n"],"names":["define","$","Rule","tree","_eventNode","_ready","Deferred","_tree","prototype","_competency","canConfig","this","hasChildren","id","getConfig","getType","Error","init","_load","injectTemplate","reject","promise","isValid","when","on","type","handler","setTargetCompetency","competency","_trigger","data","trigger","_triggerChange"],"mappings":";;;;;;;AAuBAA,iCAAO,CAAC,WAAW,SAASC,OAapBC,KAAO,SAASC,WACXC,WAAaH,EAAE,cACfI,OAASJ,EAAEK,gBACXC,MAAQJ,aAIjBD,KAAKM,UAAUC,YAAc,KAE7BP,KAAKM,UAAUJ,WAAa,KAE5BF,KAAKM,UAAUH,OAAS,KAExBH,KAAKM,UAAUD,MAAQ,KAQvBL,KAAKM,UAAUE,UAAY,kBAChBC,KAAKJ,MAAMK,YAAYD,KAAKF,YAAYI,KAWnDX,KAAKM,UAAUM,UAAY,kBAChB,MAWXZ,KAAKM,UAAUO,QAAU,iBACf,IAAIC,MAAM,oBAWpBd,KAAKM,UAAUS,KAAO,kBACXN,KAAKO,SAShBhB,KAAKM,UAAUW,eAAiB,kBACrBlB,EAAEK,WAAWc,SAASC,WAWjCnB,KAAKM,UAAUc,QAAU,kBACd,GAUXpB,KAAKM,UAAUU,MAAQ,kBACZjB,EAAEsB,QAUbrB,KAAKM,UAAUgB,GAAK,SAASC,KAAMC,cAC1BtB,WAAWoB,GAAGC,KAAMC,UAS7BxB,KAAKM,UAAUmB,oBAAsB,SAASC,iBACrCnB,YAAcmB,YAWvB1B,KAAKM,UAAUqB,SAAW,SAASJ,KAAMK,WAChC1B,WAAW2B,QAAQN,KAAM,CAACK,QASnC5B,KAAKM,UAAUwB,eAAiB,gBACvBH,SAAS,SAAUlB,OAGwBT"} \ No newline at end of file +{"version":3,"file":"competency_rule.min.js","sources":["../src/competency_rule.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency rule base module.\n *\n * @module tool_lp/competencyrule\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * Competency rule abstract class.\n *\n * Any competency rule should extend this object. The event 'change' should be\n * triggered on the instance when the configuration has changed. This will allow\n * the components using the rule to gather the config, or check its validity.\n *\n * this._triggerChange();\n *\n * @param {Tree} tree The competency tree.\n */\n var Rule = function(tree) {\n this._eventNode = $('
');\n this._ready = $.Deferred();\n this._tree = tree;\n };\n\n /** @property {Object} The current competency. */\n Rule.prototype._competency = null;\n /** @property {Node} The node we attach the events to. */\n Rule.prototype._eventNode = null;\n /** @property {Promise} Resolved when the object is ready. */\n Rule.prototype._ready = null;\n /** @property {Tree} The competency tree. */\n Rule.prototype._tree = null;\n\n /**\n * Whether or not the current competency can be configured using this rule.\n *\n * @return {Boolean}\n * @method canConfig\n */\n Rule.prototype.canConfig = function() {\n return this._tree.hasChildren(this._competency.id);\n };\n\n /**\n * The config established by this rule.\n *\n * To override in subclasses when relevant.\n *\n * @return {String|null}\n * @method getConfig\n */\n Rule.prototype.getConfig = function() {\n return null;\n };\n\n // eslint-disable-line valid-jsdoc\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n // eslint-enable-line valid-jsdoc\n Rule.prototype.getType = function() {\n throw new Error('Not implemented');\n };\n\n /**\n * The init process.\n *\n * Do not override this, instead override _load.\n *\n * @return {Promise} Revoled when the plugin is initialised.\n * @method init\n */\n Rule.prototype.init = function() {\n return this._load();\n };\n\n /**\n * Callback to inject the template.\n *\n * @returns {Promise} Resolved when done.\n * @method injectTemplate\n */\n Rule.prototype.injectTemplate = function() {\n return $.Deferred().reject().promise();\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * Plugins should override this.\n *\n * @return {Boolean}\n * @method _isValid\n */\n Rule.prototype.isValid = function() {\n return false;\n };\n\n /**\n * Load the class.\n *\n * @return {Promise}\n * @method _load\n * @protected\n */\n Rule.prototype._load = function() {\n return $.when();\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Rule.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Sets the current competency.\n *\n * @param {Competency} competency\n * @method setTargetCompetency\n */\n Rule.prototype.setTargetCompetency = function(competency) {\n this._competency = competency;\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n * @protected\n */\n Rule.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n /**\n * Trigger the change event.\n *\n * @method _triggerChange\n * @protected\n */\n Rule.prototype._triggerChange = function() {\n this._trigger('change', this);\n };\n\n return /** @alias module:tool_lp/competency_rule */ Rule;\n\n});\n"],"names":["define","$","Rule","tree","this","_eventNode","_ready","Deferred","_tree","prototype","_competency","canConfig","hasChildren","id","getConfig","getType","Error","init","_load","injectTemplate","reject","promise","isValid","when","on","type","handler","setTargetCompetency","competency","_trigger","data","trigger","_triggerChange"],"mappings":";;;;;;;AAuBAA,iCAAO,CAAC,WAAW,SAASC,GAaxB,IAAIC,KAAO,SAASC,MAChBC,KAAKC,WAAaJ,EAAE,SACpBG,KAAKE,OAASL,EAAEM,WAChBH,KAAKI,MAAQL,MAsIjB,OAlIAD,KAAKO,UAAUC,YAAc,KAE7BR,KAAKO,UAAUJ,WAAa,KAE5BH,KAAKO,UAAUH,OAAS,KAExBJ,KAAKO,UAAUD,MAAQ,KAQvBN,KAAKO,UAAUE,UAAY,WACvB,OAAOP,KAAKI,MAAMI,YAAYR,KAAKM,YAAYG,KAWnDX,KAAKO,UAAUK,UAAY,WACvB,OAAO,MAWXZ,KAAKO,UAAUM,QAAU,WACrB,MAAM,IAAIC,MAAM,oBAWpBd,KAAKO,UAAUQ,KAAO,WAClB,OAAOb,KAAKc,SAShBhB,KAAKO,UAAUU,eAAiB,WAC5B,OAAOlB,EAAEM,WAAWa,SAASC,WAWjCnB,KAAKO,UAAUa,QAAU,WACrB,OAAO,GAUXpB,KAAKO,UAAUS,MAAQ,WACnB,OAAOjB,EAAEsB,QAUbrB,KAAKO,UAAUe,GAAK,SAASC,KAAMC,SAC/BtB,KAAKC,WAAWmB,GAAGC,KAAMC,UAS7BxB,KAAKO,UAAUkB,oBAAsB,SAASC,YAC1CxB,KAAKM,YAAckB,YAWvB1B,KAAKO,UAAUoB,SAAW,SAASJ,KAAMK,MACrC1B,KAAKC,WAAW0B,QAAQN,KAAM,CAACK,QASnC5B,KAAKO,UAAUuB,eAAiB,WAC5B5B,KAAKyB,SAAS,SAAUzB,OAGwBF,IAExD"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_rule_all.min.js.map b/admin/tool/lp/amd/build/competency_rule_all.min.js.map index cb5f90d05f7..400f8734e59 100644 --- a/admin/tool/lp/amd/build/competency_rule_all.min.js.map +++ b/admin/tool/lp/amd/build/competency_rule_all.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competency_rule_all.min.js","sources":["../src/competency_rule_all.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency rule all module.\n *\n * @module tool_lp/competency_rule_all\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str',\n 'tool_lp/competency_rule',\n ],\n function($, Str, RuleBase) {\n\n /**\n * Competency rule all class.\n *\n * @class tool_lp/competency_rule_all\n */\n var Rule = function() {\n RuleBase.apply(this, arguments);\n };\n Rule.prototype = Object.create(RuleBase.prototype);\n\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n Rule.prototype.getType = function() {\n return 'core_competency\\\\competency_rule_all';\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method isValid\n */\n Rule.prototype.isValid = function() {\n return true;\n };\n\n return Rule;\n});\n"],"names":["define","$","Str","RuleBase","Rule","apply","this","arguments","prototype","Object","create","getType","isValid"],"mappings":";;;;;;;AAuBAA,qCAAO,CAAC,SACA,WACA,4BAEA,SAASC,EAAGC,IAAKC,cAOjBC,KAAO,WACPD,SAASE,MAAMC,KAAMC,mBAEzBH,KAAKI,UAAYC,OAAOC,OAAOP,SAASK,YAQzBG,QAAU,iBACd,wCASXP,KAAKI,UAAUI,QAAU,kBACd,GAGJR"} \ No newline at end of file +{"version":3,"file":"competency_rule_all.min.js","sources":["../src/competency_rule_all.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency rule all module.\n *\n * @module tool_lp/competency_rule_all\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str',\n 'tool_lp/competency_rule',\n ],\n function($, Str, RuleBase) {\n\n /**\n * Competency rule all class.\n *\n * @class tool_lp/competency_rule_all\n */\n var Rule = function() {\n RuleBase.apply(this, arguments);\n };\n Rule.prototype = Object.create(RuleBase.prototype);\n\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n Rule.prototype.getType = function() {\n return 'core_competency\\\\competency_rule_all';\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method isValid\n */\n Rule.prototype.isValid = function() {\n return true;\n };\n\n return Rule;\n});\n"],"names":["define","$","Str","RuleBase","Rule","apply","this","arguments","prototype","Object","create","getType","isValid"],"mappings":";;;;;;;AAuBAA,OAAO,8BAAA,CAAC,SACA,WACA,4BAEA,SAASC,EAAGC,IAAKC,UAOrB,IAAIC,KAAO,WACPD,SAASE,MAAMC,KAAMC,YAwBzB,OAtBAH,KAAKI,UAAYC,OAAOC,OAAOP,SAASK,YAQzBG,QAAU,WACrB,MAAO,wCASXP,KAAKI,UAAUI,QAAU,WACrB,OAAO,GAGJR,IACX"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competency_rule_points.min.js.map b/admin/tool/lp/amd/build/competency_rule_points.min.js.map index d3583f13916..c047dacfdaf 100644 --- a/admin/tool/lp/amd/build/competency_rule_points.min.js.map +++ b/admin/tool/lp/amd/build/competency_rule_points.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competency_rule_points.min.js","sources":["../src/competency_rule_points.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency rule points module.\n *\n * @module tool_lp/competency_rule_all\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str',\n 'core/templates',\n 'tool_lp/competency_rule',\n ],\n function($, Str, Templates, RuleBase) {\n\n /**\n * Competency rule points class.\n */\n var Rule = function() {\n RuleBase.apply(this, arguments);\n };\n Rule.prototype = Object.create(RuleBase.prototype);\n\n /** @property {Node} Reference to the container in which the template was included. */\n Rule.prototype._container = null;\n /** @property {Boolean} Whether or not the template was included. */\n Rule.prototype._templateLoaded = false;\n\n /**\n * The config established by this rule.\n *\n * @return {String}\n * @method getConfig\n */\n Rule.prototype.getConfig = function() {\n return JSON.stringify({\n base: {\n points: this._getRequiredPoints(),\n },\n competencies: this._getCompetenciesConfig()\n });\n };\n\n /**\n * Gathers the input provided by the user for competencies.\n *\n * @return {Array} Containing id, points and required.\n * @method _getCompetenciesConfig\n * @protected\n */\n Rule.prototype._getCompetenciesConfig = function() {\n var competencies = [];\n\n this._container.find('[data-competency]').each(function() {\n var node = $(this),\n id = node.data('competency'),\n points = parseInt(node.find('[name=\"points\"]').val(), 10),\n required = node.find('[name=\"required\"]').prop('checked');\n\n competencies.push({\n id: id,\n points: points,\n required: required ? 1 : 0\n });\n });\n\n return competencies;\n };\n\n /**\n * Fetches the required points set by the user.\n *\n * @return {Number}\n * @method _getRequiredPoints\n * @protected\n */\n Rule.prototype._getRequiredPoints = function() {\n return parseInt(this._container.find('[name=\"requiredpoints\"]').val() || 1, 10);\n };\n\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n Rule.prototype.getType = function() {\n return 'core_competency\\\\competency_rule_points';\n };\n\n /**\n * Callback to inject the template.\n *\n * @param {Node} container Node to inject in.\n * @return {Promise} Resolved when done.\n * @method injectTemplate\n */\n Rule.prototype.injectTemplate = function(container) {\n var self = this,\n children = this._tree.getChildren(this._competency.id),\n context,\n config = {\n base: {points: 2},\n competencies: []\n };\n\n this._templateLoaded = false;\n\n // Only pre-load the configuration when the competency is using this rule.\n if (self._competency.ruletype == self.getType()) {\n try {\n config = JSON.parse(self._competency.ruleconfig);\n } catch (e) {\n // eslint-disable-line no-empty\n }\n }\n\n context = {\n requiredpoints: (config && config.base) ? config.base.points : 2,\n competency: self._competency,\n children: []\n };\n\n $.each(children, function(index, child) {\n var competency = {\n id: child.id,\n shortname: child.shortname,\n required: false,\n points: 0\n };\n\n if (config) {\n $.each(config.competencies, function(index, comp) {\n if (comp.id == competency.id) {\n competency.required = comp.required ? true : false;\n competency.points = comp.points;\n }\n });\n }\n\n context.children.push(competency);\n });\n\n return Templates.render('tool_lp/competency_rule_points', context).then(function(html) {\n self._container = container;\n container.html(html);\n container.find('input').change(function() {\n self._triggerChange();\n });\n\n // We're done, let's trigger a change.\n self._templateLoaded = true;\n self._triggerChange();\n return;\n });\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method isValid\n */\n Rule.prototype.isValid = function() {\n if (!this._templateLoaded) {\n return false;\n }\n\n var required = this._getRequiredPoints(),\n max = 0,\n valid = true;\n\n $.each(this._getCompetenciesConfig(), function(index, competency) {\n if (competency.points < 0) {\n valid = false;\n }\n max += competency.points;\n });\n\n valid = valid && max >= required;\n return valid;\n };\n\n return Rule;\n});\n"],"names":["define","$","Str","Templates","RuleBase","Rule","apply","this","arguments","prototype","Object","create","_container","_templateLoaded","getConfig","JSON","stringify","base","points","_getRequiredPoints","competencies","_getCompetenciesConfig","find","each","node","id","data","parseInt","val","required","prop","push","getType","injectTemplate","container","context","self","children","_tree","getChildren","_competency","config","ruletype","parse","ruleconfig","e","requiredpoints","competency","index","child","shortname","comp","render","then","html","change","_triggerChange","isValid","max","valid"],"mappings":";;;;;;;AAuBAA,wCAAO,CAAC,SACA,WACA,iBACA,4BAEA,SAASC,EAAGC,IAAKC,UAAWC,cAK5BC,KAAO,WACPD,SAASE,MAAMC,KAAMC,mBAEzBH,KAAKI,UAAYC,OAAOC,OAAOP,SAASK,YAGzBG,WAAa,KAE5BP,KAAKI,UAAUI,iBAAkB,EAQjCR,KAAKI,UAAUK,UAAY,kBAChBC,KAAKC,UAAU,CAClBC,KAAM,CACFC,OAAQX,KAAKY,sBAEjBC,aAAcb,KAAKc,4BAW3BhB,KAAKI,UAAUY,uBAAyB,eAChCD,aAAe,eAEdR,WAAWU,KAAK,qBAAqBC,MAAK,eACvCC,KAAOvB,EAAEM,MACTkB,GAAKD,KAAKE,KAAK,cACfR,OAASS,SAASH,KAAKF,KAAK,mBAAmBM,MAAO,IACtDC,SAAWL,KAAKF,KAAK,qBAAqBQ,KAAK,WAEnDV,aAAaW,KAAK,CACdN,GAAIA,GACJP,OAAQA,OACRW,SAAUA,SAAW,EAAI,OAI1BT,cAUXf,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OAAQ,GAEZD,KAAOX,WAAW7B,UAGtByC,MAAQA,OAASD,KAAO7B,UAIrBxB"} \ No newline at end of file +{"version":3,"file":"competency_rule_points.min.js","sources":["../src/competency_rule_points.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency rule points module.\n *\n * @module tool_lp/competency_rule_all\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/str',\n 'core/templates',\n 'tool_lp/competency_rule',\n ],\n function($, Str, Templates, RuleBase) {\n\n /**\n * Competency rule points class.\n */\n var Rule = function() {\n RuleBase.apply(this, arguments);\n };\n Rule.prototype = Object.create(RuleBase.prototype);\n\n /** @property {Node} Reference to the container in which the template was included. */\n Rule.prototype._container = null;\n /** @property {Boolean} Whether or not the template was included. */\n Rule.prototype._templateLoaded = false;\n\n /**\n * The config established by this rule.\n *\n * @return {String}\n * @method getConfig\n */\n Rule.prototype.getConfig = function() {\n return JSON.stringify({\n base: {\n points: this._getRequiredPoints(),\n },\n competencies: this._getCompetenciesConfig()\n });\n };\n\n /**\n * Gathers the input provided by the user for competencies.\n *\n * @return {Array} Containing id, points and required.\n * @method _getCompetenciesConfig\n * @protected\n */\n Rule.prototype._getCompetenciesConfig = function() {\n var competencies = [];\n\n this._container.find('[data-competency]').each(function() {\n var node = $(this),\n id = node.data('competency'),\n points = parseInt(node.find('[name=\"points\"]').val(), 10),\n required = node.find('[name=\"required\"]').prop('checked');\n\n competencies.push({\n id: id,\n points: points,\n required: required ? 1 : 0\n });\n });\n\n return competencies;\n };\n\n /**\n * Fetches the required points set by the user.\n *\n * @return {Number}\n * @method _getRequiredPoints\n * @protected\n */\n Rule.prototype._getRequiredPoints = function() {\n return parseInt(this._container.find('[name=\"requiredpoints\"]').val() || 1, 10);\n };\n\n /**\n * Return the type of the module.\n *\n * @return {String}\n * @method getType\n */\n Rule.prototype.getType = function() {\n return 'core_competency\\\\competency_rule_points';\n };\n\n /**\n * Callback to inject the template.\n *\n * @param {Node} container Node to inject in.\n * @return {Promise} Resolved when done.\n * @method injectTemplate\n */\n Rule.prototype.injectTemplate = function(container) {\n var self = this,\n children = this._tree.getChildren(this._competency.id),\n context,\n config = {\n base: {points: 2},\n competencies: []\n };\n\n this._templateLoaded = false;\n\n // Only pre-load the configuration when the competency is using this rule.\n if (self._competency.ruletype == self.getType()) {\n try {\n config = JSON.parse(self._competency.ruleconfig);\n } catch (e) {\n // eslint-disable-line no-empty\n }\n }\n\n context = {\n requiredpoints: (config && config.base) ? config.base.points : 2,\n competency: self._competency,\n children: []\n };\n\n $.each(children, function(index, child) {\n var competency = {\n id: child.id,\n shortname: child.shortname,\n required: false,\n points: 0\n };\n\n if (config) {\n $.each(config.competencies, function(index, comp) {\n if (comp.id == competency.id) {\n competency.required = comp.required ? true : false;\n competency.points = comp.points;\n }\n });\n }\n\n context.children.push(competency);\n });\n\n return Templates.render('tool_lp/competency_rule_points', context).then(function(html) {\n self._container = container;\n container.html(html);\n container.find('input').change(function() {\n self._triggerChange();\n });\n\n // We're done, let's trigger a change.\n self._templateLoaded = true;\n self._triggerChange();\n return;\n });\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method isValid\n */\n Rule.prototype.isValid = function() {\n if (!this._templateLoaded) {\n return false;\n }\n\n var required = this._getRequiredPoints(),\n max = 0,\n valid = true;\n\n $.each(this._getCompetenciesConfig(), function(index, competency) {\n if (competency.points < 0) {\n valid = false;\n }\n max += competency.points;\n });\n\n valid = valid && max >= required;\n return valid;\n };\n\n return Rule;\n});\n"],"names":["define","$","Str","Templates","RuleBase","Rule","apply","this","arguments","prototype","Object","create","_container","_templateLoaded","getConfig","JSON","stringify","base","points","_getRequiredPoints","competencies","_getCompetenciesConfig","find","each","node","id","data","parseInt","val","required","prop","push","getType","injectTemplate","container","context","self","children","_tree","getChildren","_competency","config","ruletype","parse","ruleconfig","e","requiredpoints","competency","index","child","shortname","comp","render","then","html","change","_triggerChange","isValid","max","valid"],"mappings":";;;;;;;AAuBAA,wCAAO,CAAC,SACA,WACA,iBACA,4BAEA,SAASC,EAAGC,IAAKC,UAAWC,UAKhC,IAAIC,KAAO,WACPD,SAASE,MAAMC,KAAMC,YAoKzB,OAlKAH,KAAKI,UAAYC,OAAOC,OAAOP,SAASK,YAGzBG,WAAa,KAE5BP,KAAKI,UAAUI,iBAAkB,EAQjCR,KAAKI,UAAUK,UAAY,WACvB,OAAOC,KAAKC,UAAU,CAClBC,KAAM,CACFC,OAAQX,KAAKY,sBAEjBC,aAAcb,KAAKc,4BAW3BhB,KAAKI,UAAUY,uBAAyB,WACpC,IAAID,aAAe,GAenB,OAbAb,KAAKK,WAAWU,KAAK,qBAAqBC,MAAK,WAC3C,IAAIC,KAAOvB,EAAEM,MACTkB,GAAKD,KAAKE,KAAK,cACfR,OAASS,SAASH,KAAKF,KAAK,mBAAmBM,MAAO,IACtDC,SAAWL,KAAKF,KAAK,qBAAqBQ,KAAK,WAEnDV,aAAaW,KAAK,CACdN,GAAIA,GACJP,OAAQA,OACRW,SAAUA,SAAW,EAAI,GAEjC,IAEOT,cAUXf,KAAKI,UAAUU,mBAAqB,WAChC,OAAOQ,SAASpB,KAAKK,WAAWU,KAAK,2BAA2BM,OAAS,EAAG,KAShFvB,KAAKI,UAAUuB,QAAU,WACrB,MAAO,2CAUX3B,KAAKI,UAAUwB,eAAiB,SAASC,WACrC,IAEIC,QAFAC,KAAO7B,KACP8B,SAAW9B,KAAK+B,MAAMC,YAAYhC,K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in/tool/lp/amd/build/competencyactions.min.js.map index aeac60ed8e9..dffbf67e91e 100644 --- a/admin/tool/lp/amd/build/competencyactions.min.js.map +++ b/admin/tool/lp/amd/build/competencyactions.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competencyactions.min.js","sources":["../src/competencyactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle selection changes and actions on the competency tree.\n *\n * @module tool_lp/competencyactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/url',\n 'core/templates',\n 'core/notification',\n 'core/str',\n 'core/ajax',\n 'tool_lp/dragdrop-reorder',\n 'tool_lp/tree',\n 'tool_lp/dialogue',\n 'tool_lp/menubar',\n 'tool_lp/competencypicker',\n 'tool_lp/competency_outcomes',\n 'tool_lp/competencyruleconfig',\n 'core/pending',\n ],\n function(\n $, url, templates, notification, str, ajax, dragdrop, Ariatree, Dialogue, menubar, Picker, Outcomes, RuleConfig, Pending\n ) {\n\n // Private variables and functions.\n /** @var {Object} treeModel - This is an object representing the nodes in the tree. */\n var treeModel = null;\n /** @var {Node} moveSource - The start of a drag operation */\n var moveSource = null;\n /** @var {Node} moveTarget - The end of a drag operation */\n var moveTarget = null;\n /** @var {Number} pageContextId The page context ID. */\n var pageContextId;\n /** @var {Object} Picker instance. */\n var pickerInstance;\n /** @var {Object} Rule config instance. */\n var ruleConfigInstance;\n /** @var {Object} The competency we're picking a relation to. */\n var relatedTarget;\n /** @var {Object} Taxonomy constants indexed per level. */\n var taxonomiesConstants;\n /** @var {Array} The rules modules. Values are object containing type, namd and amd. */\n var rulesModules;\n /** @var {Number} the selected competency ID. */\n var selectedCompetencyId = null;\n\n /**\n * Respond to choosing the \"Add\" menu item for the selected node in the tree.\n * @method addHandler\n */\n var addHandler = function() {\n var parent = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n pagecontextid: pageContextId\n };\n\n if (parent !== null) {\n // We are adding at a sub node.\n params.parentid = parent.id;\n }\n\n var relocate = function() {\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n if (parent !== null && treeModel.hasRule(parent.id)) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'addingcompetencywillresetparentrule', component: 'tool_lp', param: parent.shortname},\n {key: 'yes', component: 'core'},\n {key: 'no', component: 'core'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0],\n strings[1],\n strings[2],\n strings[3],\n relocate\n );\n }).fail(notification.exception);\n } else {\n relocate();\n }\n };\n\n /**\n * A source and destination has been chosen - so time to complete a move.\n * @method doMove\n */\n var doMove = function() {\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n var requests = ajax.call([{\n methodname: 'core_competency_set_parent_competency',\n args: {competencyid: moveSource, parentid: moveTarget}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Confirms a competency move.\n *\n * @method confirmMove\n */\n var confirmMove = function() {\n moveTarget = typeof moveTarget === \"undefined\" ? 0 : moveTarget;\n if (moveTarget == moveSource) {\n // No move to do.\n return;\n }\n\n var targetComp = treeModel.getCompetency(moveTarget) || {},\n sourceComp = treeModel.getCompetency(moveSource) || {},\n confirmMessage = 'movecompetencywillresetrules',\n showConfirm = false;\n\n // We shouldn't be moving the competency to the same parent.\n if (sourceComp.parentid == moveTarget) {\n return;\n }\n\n // If we are moving to a child of self.\n if (targetComp.path && targetComp.path.indexOf('/' + sourceComp.id + '/') >= 0) {\n confirmMessage = 'movecompetencytochildofselfwillresetrules';\n\n // Show a confirmation if self has rules, as they'll disappear.\n showConfirm = showConfirm || treeModel.hasRule(sourceComp.id);\n }\n\n // Show a confirmation if the current parent, or the destination have rules.\n showConfirm = showConfirm || (treeModel.hasRule(targetComp.id) || treeModel.hasRule(sourceComp.parentid));\n\n // Show confirm, and/or do the things.\n if (showConfirm) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp'},\n {key: 'yes', component: 'moodle'},\n {key: 'no', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doMove\n );\n }).fail(notification.exception);\n\n } else {\n doMove();\n }\n };\n\n /**\n * A move competency popup was opened - initialise the aria tree in it.\n * @method initMovePopup\n * @param {dialogue} popup The tool_lp/dialogue that was created.\n */\n var initMovePopup = function(popup) {\n var body = $(popup.getContent());\n var treeRoot = body.find('[data-enhance=movetree]');\n var tree = new Ariatree(treeRoot, false);\n tree.on('selectionchanged', function(evt, params) {\n var target = params.selected;\n moveTarget = $(target).data('id');\n });\n treeRoot.show();\n\n body.on('click', '[data-action=\"move\"]', function() {\n popup.close();\n confirmMove();\n });\n body.on('click', '[data-action=\"cancel\"]', function() {\n popup.close();\n });\n };\n\n /**\n * Turn a flat list of competencies into a tree structure (recursive).\n * @method addCompetencyChildren\n * @param {Object} parent The current parent node in the tree\n * @param {Object[]} competencies The flat list of competencies\n */\n var addCompetencyChildren = function(parent, competencies) {\n var i;\n\n for (i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n };\n\n /**\n * A node was chosen and \"Move\" was selected from the menu. Open a popup to select the target.\n * @param {Event} e\n * @method moveHandler\n */\n var moveHandler = function(e) {\n e.preventDefault();\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n // Remember what we are moving.\n moveSource = competency.id;\n\n // Load data for the template.\n var requests = ajax.call([\n {\n methodname: 'core_competency_search_competencies',\n args: {\n competencyframeworkid: competency.competencyframeworkid,\n searchtext: ''\n }\n }, {\n methodname: 'core_competency_read_competency_framework',\n args: {\n id: competency.competencyframeworkid\n }\n }\n ]);\n\n // When all data has arrived, continue.\n $.when.apply(null, requests).done(function(competencies, framework) {\n\n // Expand the list of competencies into a tree.\n var i;\n var competenciestree = [];\n for (i = 0; i < competencies.length; i++) {\n var onecompetency = competencies[i];\n if (onecompetency.parentid == \"0\") {\n onecompetency.children = [];\n onecompetency.haschildren = 0;\n competenciestree[competenciestree.length] = onecompetency;\n addCompetencyChildren(onecompetency, competencies);\n }\n }\n\n str.get_strings([\n {key: 'movecompetency', component: 'tool_lp', param: competency.shortname},\n {key: 'move', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n\n var context = {\n framework: framework,\n competencies: competenciestree\n };\n\n templates.render('tool_lp/competencies_move_tree', context)\n .done(function(tree) {\n new Dialogue(\n strings[0], // Move competency x.\n tree, // The move tree.\n initMovePopup\n );\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n };\n\n /**\n * Edit the selected competency.\n * @method editHandler\n */\n var editHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n id: competency.id,\n parentid: competency.parentid,\n pagecontextid: pageContextId\n };\n\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n /**\n * Re-render the page with the latest data.\n * @param {Object} context\n * @method reloadPage\n */\n var reloadPage = function(context) {\n templates.render('tool_lp/manage_competencies_page', context)\n .done(function(newhtml, newjs) {\n $('[data-region=\"managecompetencies\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n })\n .fail(notification.exception);\n };\n\n /**\n * Perform a search and render the page with the new search results.\n * @param {Event} e\n * @method updateSearchHandler\n */\n var updateSearchHandler = function(e) {\n e.preventDefault();\n\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"up\". This only affects the sort order within the same branch of the tree.\n * @method moveUpHandler\n */\n var moveUpHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_up_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"down\". This only affects the sort order within the same branch of the tree.\n * @method moveDownHandler\n */\n var moveDownHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_down_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Open a dialogue to show all the courses using the selected competency.\n * @method seeCoursesHandler\n */\n var seeCoursesHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_list_courses_using_competency',\n args: {id: competency.id}\n }]);\n\n requests[0].done(function(courses) {\n var context = {\n courses: courses\n };\n templates.render('tool_lp/linked_courses_summary', context).done(function(html) {\n str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {\n new Dialogue(\n linkedcourses, // Title.\n html, // The linked courses.\n initMovePopup\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Open a competencies popup to relate competencies.\n *\n * @method relateCompetenciesHandler\n */\n var relateCompetenciesHandler = function() {\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n\n if (!pickerInstance) {\n pickerInstance = new Picker(pageContextId, relatedTarget.competencyframeworkid);\n pickerInstance.on('save', function(e, data) {\n var pendingPromise = new Pending();\n var compIds = data.competencyIds;\n\n var calls = [];\n $.each(compIds, function(index, value) {\n calls.push({\n methodname: 'core_competency_add_related_competency',\n args: {competencyid: value, relatedcompetencyid: relatedTarget.id}\n });\n });\n\n calls.push({\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: relatedTarget.id}\n });\n\n var promises = ajax.call(calls);\n\n promises[calls.length - 1].then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n pickerInstance.setDisallowedCompetencyIDs([relatedTarget.id]);\n pickerInstance.display();\n };\n\n var ruleConfigHandler = function(e) {\n e.preventDefault();\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n ruleConfigInstance.setTargetCompetencyId(relatedTarget.id);\n ruleConfigInstance.display();\n };\n\n var ruleConfigSaveHandler = function(e, config) {\n var update = {\n id: relatedTarget.id,\n shortname: relatedTarget.shortname,\n idnumber: relatedTarget.idnumber,\n description: relatedTarget.description,\n descriptionformat: relatedTarget.descriptionformat,\n ruletype: config.ruletype,\n ruleoutcome: config.ruleoutcome,\n ruleconfig: config.ruleconfig\n };\n var promise = ajax.call([{\n methodname: 'core_competency_update_competency',\n args: {competency: update}\n }]);\n promise[0].then(function(result) {\n if (result) {\n relatedTarget.ruletype = config.ruletype;\n relatedTarget.ruleoutcome = config.ruleoutcome;\n relatedTarget.ruleconfig = config.ruleconfig;\n renderCompetencySummary(relatedTarget);\n }\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Delete a competency.\n * @method doDelete\n */\n var doDelete = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_delete_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(function(success) {\n if (success === false) {\n str.get_strings([\n {key: 'competencycannotbedeleted', component: 'tool_lp', param: competency.shortname},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.alert(\n null,\n strings[0]\n );\n }).fail(notification.exception);\n }\n }).fail(notification.exception);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n * @method deleteCompetencyHandler\n */\n var deleteCompetencyHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency'),\n confirmMessage = 'deletecompetency';\n\n if (treeModel.hasRule(competency.parentid)) {\n confirmMessage = 'deletecompetencyparenthasrule';\n }\n\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp', param: competency.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragStart\n * @param {Event} e\n */\n var dragStart = function(e) {\n e.originalEvent.dataTransfer.setData('text', $(e.target).parent().data('id'));\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method allowDrop\n * @param {Event} e\n */\n var allowDrop = function(e) {\n e.originalEvent.dataTransfer.dropEffect = 'move';\n e.preventDefault();\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragEnter\n * @param {Event} e\n */\n var dragEnter = function(e) {\n e.preventDefault();\n $(this).addClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragLeave\n * @param {Event} e\n */\n var dragLeave = function(e) {\n e.preventDefault();\n $(this).removeClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dropOver\n * @param {Event} e\n */\n var dropOver = function(e) {\n e.preventDefault();\n moveSource = e.originalEvent.dataTransfer.getData('text');\n moveTarget = $(e.target).parent().data('id');\n $(this).removeClass('currentdragtarget');\n\n confirmMove();\n };\n\n /**\n * Deletes a related competency without confirmation.\n *\n * @param {Event} e The event that triggered the action.\n * @method deleteRelatedHandler\n */\n var deleteRelatedHandler = function(e) {\n e.preventDefault();\n\n var relatedid = this.id.substr(11);\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var removeRelated = ajax.call([\n {methodname: 'core_competency_remove_related_competency',\n args: {relatedcompetencyid: relatedid, competencyid: competency.id}},\n {methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}}\n ]);\n\n removeRelated[1].done(function(context) {\n templates.render('tool_lp/related_competencies', context).done(function(html) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n updatedRelatedCompetencies();\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Updates the competencies list (with relations) and add listeners.\n *\n * @method updatedRelatedCompetencies\n */\n var updatedRelatedCompetencies = function() {\n\n // Listeners to newly loaded related competencies.\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n\n };\n\n /**\n * Log the competency viewed event.\n *\n * @param {Object} competency The competency.\n * @method triggerCompetencyViewedEvent\n */\n var triggerCompetencyViewedEvent = function(competency) {\n if (competency.id !== selectedCompetencyId) {\n // Set the selected competency id.\n selectedCompetencyId = competency.id;\n ajax.call([{\n methodname: 'core_competency_competency_viewed',\n args: {id: competency.id}\n }]);\n }\n };\n\n /**\n * Return the taxonomy constant for a level.\n *\n * @param {Number} level The level.\n * @return {String}\n * @function getTaxonomyAtLevel\n */\n var getTaxonomyAtLevel = function(level) {\n var constant = taxonomiesConstants[level];\n if (!constant) {\n constant = 'competency';\n }\n return constant;\n };\n\n /**\n * Render the competency summary.\n *\n * @param {Object} competency The competency.\n */\n var renderCompetencySummary = function(competency) {\n var promise = $.Deferred().resolve().promise(),\n context = {};\n\n context.competency = competency;\n context.showdeleterelatedaction = true;\n context.showrelatedcompetencies = true;\n context.showrule = false;\n context.pluginbaseurl = url.relativeUrl('/admin/tool/lp');\n\n if (competency.ruleoutcome != Outcomes.NONE) {\n // Get the outcome and rule name.\n promise = Outcomes.getString(competency.ruleoutcome).then(function(str) {\n var name;\n $.each(rulesModules, function(index, modInfo) {\n if (modInfo.type == competency.ruletype) {\n name = modInfo.name;\n }\n });\n return [str, name];\n });\n }\n\n promise.then(function(strs) {\n if (typeof strs !== 'undefined') {\n context.showrule = true;\n context.rule = {\n outcome: strs[0],\n type: strs[1]\n };\n }\n return context;\n }).then(function(context) {\n return templates.render('tool_lp/competency_summary', context);\n }).then(function(html) {\n $('[data-region=\"competencyinfo\"]').html(html);\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n return templates.render('tool_lp/loading', {});\n }).then(function(html, js) {\n templates.replaceNodeContents('[data-region=\"relatedcompetencies\"]', html, js);\n return ajax.call([{\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}\n }])[0];\n }).then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Return the string \"Add \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strAddTaxonomy\n */\n var strAddTaxonomy = function(level) {\n return str.get_string('taxonomy_add_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strSelectedTaxonomy\n */\n var strSelectedTaxonomy = function(level) {\n return str.get_string('taxonomy_selected_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Handler when a node in the aria tree is selected.\n * @method selectionChanged\n * @param {Event} evt The event that triggered the selection change.\n * @param {Object} params The parameters for the event. Contains a list of selected nodes.\n * @return {Boolean}\n */\n var selectionChanged = function(evt, params) {\n var node = params.selected,\n id = $(node).data('id'),\n btn = $('[data-region=\"competencyactions\"] [data-action=\"add\"]'),\n actionMenu = $('[data-region=\"competencyactionsmenu\"]'),\n selectedTitle = $('[data-region=\"selected-competency\"]'),\n level = 0,\n sublevel = 1;\n\n menubar.closeAll();\n\n if (typeof id === \"undefined\") {\n // Assume this is the root of the tree.\n // Here we are only getting the text from the top of the tree, to do it we clone the tree,\n // remove all children and then call text on the result.\n $('[data-region=\"competencyinfo\"]').html(node.clone().children().remove().end().text());\n $('[data-region=\"competencyactions\"]').data('competency', null);\n actionMenu.hide();\n\n } else {\n var competency = treeModel.getCompetency(id);\n\n level = treeModel.getCompetencyLevel(id);\n sublevel = level + 1;\n\n actionMenu.show();\n $('[data-region=\"competencyactions\"]').data('competency', competency);\n renderCompetencySummary(competency);\n // Log Competency viewed event.\n triggerCompetencyViewedEvent(competency);\n }\n strSelectedTaxonomy(level).then(function(str) {\n selectedTitle.text(str);\n return;\n }).catch(notification.exception);\n\n strAddTaxonomy(sublevel).then(function(str) {\n btn.show()\n .find('[data-region=\"term\"]')\n .text(str);\n return;\n }).catch(notification.exception);\n\n // We handled this event so consume it.\n evt.preventDefault();\n return false;\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @function parseTaxonomies\n * @param {String} taxonomiesstr Comma separated list of taxonomies.\n * @return {Array} of level => taxonomystr\n */\n var parseTaxonomies = function(taxonomiesstr) {\n var all = taxonomiesstr.split(',');\n all.unshift(\"\");\n delete all[0];\n\n // Note we don't need to fill holes, because other functions check for empty anyway.\n return all;\n };\n\n return {\n /**\n * Initialise this page (attach event handlers etc).\n *\n * @method init\n * @param {Object} model The tree model provides some useful functions for loading and searching competencies.\n * @param {Number} pagectxid The page context ID.\n * @param {Object} taxonomies Constants indexed by level.\n * @param {Object} rulesMods The modules of the rules.\n */\n init: function(model, pagectxid, taxonomies, rulesMods) {\n treeModel = model;\n pageContextId = pagectxid;\n taxonomiesConstants = parseTaxonomies(taxonomies);\n rulesModules = rulesMods;\n\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').on('click', addHandler);\n\n menubar.enhance('.competencyactionsmenu', {\n '[data-action=\"edit\"]': editHandler,\n '[data-action=\"delete\"]': deleteCompetencyHandler,\n '[data-action=\"move\"]': moveHandler,\n '[data-action=\"moveup\"]': moveUpHandler,\n '[data-action=\"movedown\"]': moveDownHandler,\n '[data-action=\"linkedcourses\"]': seeCoursesHandler,\n '[data-action=\"relatedcompetencies\"]': relateCompetenciesHandler.bind(this),\n '[data-action=\"competencyrules\"]': ruleConfigHandler.bind(this)\n });\n $('[data-region=\"competencyactionsmenu\"]').hide();\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').hide();\n\n $('[data-region=\"filtercompetencies\"]').on('submit', updateSearchHandler);\n // Simple html5 drag drop because we already added an accessible alternative.\n var top = $('[data-region=\"managecompetencies\"] [data-enhance=\"tree\"]');\n top.on('dragstart', 'li>span', dragStart)\n .on('dragover', 'li>span', allowDrop)\n .on('dragenter', 'li>span', dragEnter)\n .on('dragleave', 'li>span', dragLeave)\n .on('drop', 'li>span', dropOver);\n\n model.on('selectionchanged', selectionChanged);\n\n // Prepare the configuration tool.\n ruleConfigInstance = new RuleConfig(treeModel, rulesModules);\n ruleConfigInstance.on('save', ruleConfigSaveHandler.bind(this));\n }\n };\n});\n"],"names":["define","$","url","templates","notification","str","ajax","dragdrop","Ariatree","Dialogue","menubar","Picker","Outcomes","RuleConfig","Pending","pageContextId","pickerInstance","ruleConfigInstance","relatedTarget","taxonomiesConstants","rulesModules","treeModel","moveSource","moveTarget","selectedCompetencyId","addHandler","parent","data","params","competencyframeworkid","getCompetencyFrameworkId","pagecontextid","parentid","id","relocate","queryparams","param","window","location","relativeUrl","hasRule","get_strings","key","component","shortname","done","strings","confirm","fail","exception","doMove","frameworkid","call","methodname","args","competencyid","search","val","reloadPage","confirmMove","targetComp","getCompetency","sourceComp","confirmMessage","showConfirm","path","indexOf","initMovePopup","popup","body","getContent","treeRoot","find","on","evt","target","selected","show","close","addCompetencyChildren","competencies","i","length","haschildren","children","moveHandler","e","preventDefault","competency","requests","searchtext","when","apply","framework","competenciestree","onecompetency","context","render","tree","editHandler","newhtml","newjs","replaceWith","runTemplateJS","updateSearchHandler","moveUpHandler","moveDownHandler","seeCoursesHandler","courses","html","get_string","linkedcourses","relateCompetenciesHandler","pendingPromise","compIds","competencyIds","calls","each","index","value","push","relatedcompetencyid","then","js","updatedRelatedCompetencies","resolve","catch","setDisallowedCompetencyIDs","display","ruleConfigHandler","setTargetCompetencyId","ruleConfigSaveHandler","config","update","idnumber","description","descriptionformat","ruletype","ruleoutcome","ruleconfig","result","renderCompetencySummary","doDelete","success","alert","deleteCompetencyHandler","dragStart","originalEvent","dataTransfer","setData","allowDrop","dropEffect","dragEnter","this","addClass","dragLeave","removeClass","dropOver","getData","deleteRelatedHandler","relatedid","substr","getTaxonomyAtLevel","level","constant","promise","Deferred","showdeleterelatedaction","showrelatedcompetencies","showrule","pluginbaseurl","NONE","getString","name","modInfo","type","strs","rule","outcome","replaceNodeContents","selectionChanged","node","btn","actionMenu","selectedTitle","sublevel","closeAll","clone","remove","end","text","hide","getCompetencyLevel","triggerCompetencyViewedEvent","strSelectedTaxonomy","strAddTaxonomy","init","model","pagectxid","taxonomies","rulesMods","all","split","unshift","enhance","bind"],"mappings":";;;;;;;AAsBAA,mCAAO,CAAC,SACA,WACA,iBACA,oBACA,WACA,YACA,2BACA,eACA,mBACA,kBACA,2BACA,8BACA,+BACA,iBAED,SACKC,EAAGC,IAAKC,UAAWC,aAAcC,IAAKC,KAAMC,SAAUC,SAAUC,SAAUC,QAASC,OAAQC,SAAUC,WAAYC,aAWrHC,cAEAC,eAEAC,mBAEAC,cAEAC,oBAEAC,aAhBAC,UAAY,KAEZC,WAAa,KAEbC,WAAa,KAcbC,qBAAuB,KAMvBC,WAAa,eACTC,OAASzB,EAAE,qCAAqC0B,KAAK,cAErDC,OAAS,CACTC,sBAAuBR,UAAUS,2BACjCC,cAAehB,eAGJ,OAAXW,SAEAE,OAAOI,SAAWN,OAAOO,QAGzBC,SAAW,eACPC,YAAclC,EAAEmC,MAAMR,QAC1BS,OAAOC,SAAWpC,IAAIqC,YAAY,qCAAuCJ,cAG9D,OAAXT,QAAmBL,UAAUmB,QAAQd,OAAOO,IAC5C5B,IAAIoC,YAAY,CACZ,CAACC,IAAK,UAAWC,UAAW,UAC5B,CAACD,IAAK,sCAAuCC,UAAW,UAAWP,MAAOV,OAAOkB,WACjF,CAACF,IAAK,MAAOC,UAAW,QACxB,CAACD,IAAK,KAAMC,UAAW,UACxBE,MAAK,SAASC,SACb1C,aAAa2C,QACTD,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRZ,aAELc,KAAK5C,aAAa6C,WAErBf,YAQJgB,OAAS,eACLC,YAAclD,EAAE,sCAAsC0B,KAAK,eAChDrB,KAAK8C,KAAK,CAAC,CACtBC,WAAY,wCACZC,KAAM,CAACC,aAAcjC,WAAYU,SAAUT,aAC5C,CACC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yC8L,OAC3C9L,EAAE,yDAAyD8L,OAE3D9L,EAAE,sCAAsCwE,GAAG,SAAU+B,qBAE3CvG,EAAE,4DACRwE,GAAG,YAAa,UAAWyE,WAC1BzE,GAAG,WAAY,UAAW6E,WAC1B7E,GAAG,YAAa,UAAW+E,WAC3B/E,GAAG,YAAa,UAAWkF,WAC3BlF,GAAG,OAAQ,UAAWoF,UAE3BwC,MAAM5H,GAAG,mBAAoB2G,mBAG7BnK,mBAAqB,IAAIJ,WAAWQ,UAAWD,eAC5BqD,GAAG,OAAQ0D,sBAAsB0E,KAAKpD"} \ No newline at end of file +{"version":3,"file":"competencyactions.min.js","sources":["../src/competencyactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle selection changes and actions on the competency tree.\n *\n * @module tool_lp/competencyactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/url',\n 'core/templates',\n 'core/notification',\n 'core/str',\n 'core/ajax',\n 'tool_lp/dragdrop-reorder',\n 'tool_lp/tree',\n 'tool_lp/dialogue',\n 'tool_lp/menubar',\n 'tool_lp/competencypicker',\n 'tool_lp/competency_outcomes',\n 'tool_lp/competencyruleconfig',\n 'core/pending',\n ],\n function(\n $, url, templates, notification, str, ajax, dragdrop, Ariatree, Dialogue, menubar, Picker, Outcomes, RuleConfig, Pending\n ) {\n\n // Private variables and functions.\n /** @var {Object} treeModel - This is an object representing the nodes in the tree. */\n var treeModel = null;\n /** @var {Node} moveSource - The start of a drag operation */\n var moveSource = null;\n /** @var {Node} moveTarget - The end of a drag operation */\n var moveTarget = null;\n /** @var {Number} pageContextId The page context ID. */\n var pageContextId;\n /** @var {Object} Picker instance. */\n var pickerInstance;\n /** @var {Object} Rule config instance. */\n var ruleConfigInstance;\n /** @var {Object} The competency we're picking a relation to. */\n var relatedTarget;\n /** @var {Object} Taxonomy constants indexed per level. */\n var taxonomiesConstants;\n /** @var {Array} The rules modules. Values are object containing type, namd and amd. */\n var rulesModules;\n /** @var {Number} the selected competency ID. */\n var selectedCompetencyId = null;\n\n /**\n * Respond to choosing the \"Add\" menu item for the selected node in the tree.\n * @method addHandler\n */\n var addHandler = function() {\n var parent = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n pagecontextid: pageContextId\n };\n\n if (parent !== null) {\n // We are adding at a sub node.\n params.parentid = parent.id;\n }\n\n var relocate = function() {\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n if (parent !== null && treeModel.hasRule(parent.id)) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'addingcompetencywillresetparentrule', component: 'tool_lp', param: parent.shortname},\n {key: 'yes', component: 'core'},\n {key: 'no', component: 'core'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0],\n strings[1],\n strings[2],\n strings[3],\n relocate\n );\n }).fail(notification.exception);\n } else {\n relocate();\n }\n };\n\n /**\n * A source and destination has been chosen - so time to complete a move.\n * @method doMove\n */\n var doMove = function() {\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n var requests = ajax.call([{\n methodname: 'core_competency_set_parent_competency',\n args: {competencyid: moveSource, parentid: moveTarget}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Confirms a competency move.\n *\n * @method confirmMove\n */\n var confirmMove = function() {\n moveTarget = typeof moveTarget === \"undefined\" ? 0 : moveTarget;\n if (moveTarget == moveSource) {\n // No move to do.\n return;\n }\n\n var targetComp = treeModel.getCompetency(moveTarget) || {},\n sourceComp = treeModel.getCompetency(moveSource) || {},\n confirmMessage = 'movecompetencywillresetrules',\n showConfirm = false;\n\n // We shouldn't be moving the competency to the same parent.\n if (sourceComp.parentid == moveTarget) {\n return;\n }\n\n // If we are moving to a child of self.\n if (targetComp.path && targetComp.path.indexOf('/' + sourceComp.id + '/') >= 0) {\n confirmMessage = 'movecompetencytochildofselfwillresetrules';\n\n // Show a confirmation if self has rules, as they'll disappear.\n showConfirm = showConfirm || treeModel.hasRule(sourceComp.id);\n }\n\n // Show a confirmation if the current parent, or the destination have rules.\n showConfirm = showConfirm || (treeModel.hasRule(targetComp.id) || treeModel.hasRule(sourceComp.parentid));\n\n // Show confirm, and/or do the things.\n if (showConfirm) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp'},\n {key: 'yes', component: 'moodle'},\n {key: 'no', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doMove\n );\n }).fail(notification.exception);\n\n } else {\n doMove();\n }\n };\n\n /**\n * A move competency popup was opened - initialise the aria tree in it.\n * @method initMovePopup\n * @param {dialogue} popup The tool_lp/dialogue that was created.\n */\n var initMovePopup = function(popup) {\n var body = $(popup.getContent());\n var treeRoot = body.find('[data-enhance=movetree]');\n var tree = new Ariatree(treeRoot, false);\n tree.on('selectionchanged', function(evt, params) {\n var target = params.selected;\n moveTarget = $(target).data('id');\n });\n treeRoot.show();\n\n body.on('click', '[data-action=\"move\"]', function() {\n popup.close();\n confirmMove();\n });\n body.on('click', '[data-action=\"cancel\"]', function() {\n popup.close();\n });\n };\n\n /**\n * Turn a flat list of competencies into a tree structure (recursive).\n * @method addCompetencyChildren\n * @param {Object} parent The current parent node in the tree\n * @param {Object[]} competencies The flat list of competencies\n */\n var addCompetencyChildren = function(parent, competencies) {\n var i;\n\n for (i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n };\n\n /**\n * A node was chosen and \"Move\" was selected from the menu. Open a popup to select the target.\n * @param {Event} e\n * @method moveHandler\n */\n var moveHandler = function(e) {\n e.preventDefault();\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n // Remember what we are moving.\n moveSource = competency.id;\n\n // Load data for the template.\n var requests = ajax.call([\n {\n methodname: 'core_competency_search_competencies',\n args: {\n competencyframeworkid: competency.competencyframeworkid,\n searchtext: ''\n }\n }, {\n methodname: 'core_competency_read_competency_framework',\n args: {\n id: competency.competencyframeworkid\n }\n }\n ]);\n\n // When all data has arrived, continue.\n $.when.apply(null, requests).done(function(competencies, framework) {\n\n // Expand the list of competencies into a tree.\n var i;\n var competenciestree = [];\n for (i = 0; i < competencies.length; i++) {\n var onecompetency = competencies[i];\n if (onecompetency.parentid == \"0\") {\n onecompetency.children = [];\n onecompetency.haschildren = 0;\n competenciestree[competenciestree.length] = onecompetency;\n addCompetencyChildren(onecompetency, competencies);\n }\n }\n\n str.get_strings([\n {key: 'movecompetency', component: 'tool_lp', param: competency.shortname},\n {key: 'move', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n\n var context = {\n framework: framework,\n competencies: competenciestree\n };\n\n templates.render('tool_lp/competencies_move_tree', context)\n .done(function(tree) {\n new Dialogue(\n strings[0], // Move competency x.\n tree, // The move tree.\n initMovePopup\n );\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n };\n\n /**\n * Edit the selected competency.\n * @method editHandler\n */\n var editHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n id: competency.id,\n parentid: competency.parentid,\n pagecontextid: pageContextId\n };\n\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n /**\n * Re-render the page with the latest data.\n * @param {Object} context\n * @method reloadPage\n */\n var reloadPage = function(context) {\n templates.render('tool_lp/manage_competencies_page', context)\n .done(function(newhtml, newjs) {\n $('[data-region=\"managecompetencies\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n })\n .fail(notification.exception);\n };\n\n /**\n * Perform a search and render the page with the new search results.\n * @param {Event} e\n * @method updateSearchHandler\n */\n var updateSearchHandler = function(e) {\n e.preventDefault();\n\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"up\". This only affects the sort order within the same branch of the tree.\n * @method moveUpHandler\n */\n var moveUpHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_up_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"down\". This only affects the sort order within the same branch of the tree.\n * @method moveDownHandler\n */\n var moveDownHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_down_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Open a dialogue to show all the courses using the selected competency.\n * @method seeCoursesHandler\n */\n var seeCoursesHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_list_courses_using_competency',\n args: {id: competency.id}\n }]);\n\n requests[0].done(function(courses) {\n var context = {\n courses: courses\n };\n templates.render('tool_lp/linked_courses_summary', context).done(function(html) {\n str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {\n new Dialogue(\n linkedcourses, // Title.\n html, // The linked courses.\n initMovePopup\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Open a competencies popup to relate competencies.\n *\n * @method relateCompetenciesHandler\n */\n var relateCompetenciesHandler = function() {\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n\n if (!pickerInstance) {\n pickerInstance = new Picker(pageContextId, relatedTarget.competencyframeworkid);\n pickerInstance.on('save', function(e, data) {\n var pendingPromise = new Pending();\n var compIds = data.competencyIds;\n\n var calls = [];\n $.each(compIds, function(index, value) {\n calls.push({\n methodname: 'core_competency_add_related_competency',\n args: {competencyid: value, relatedcompetencyid: relatedTarget.id}\n });\n });\n\n calls.push({\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: relatedTarget.id}\n });\n\n var promises = ajax.call(calls);\n\n promises[calls.length - 1].then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n pickerInstance.setDisallowedCompetencyIDs([relatedTarget.id]);\n pickerInstance.display();\n };\n\n var ruleConfigHandler = function(e) {\n e.preventDefault();\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n ruleConfigInstance.setTargetCompetencyId(relatedTarget.id);\n ruleConfigInstance.display();\n };\n\n var ruleConfigSaveHandler = function(e, config) {\n var update = {\n id: relatedTarget.id,\n shortname: relatedTarget.shortname,\n idnumber: relatedTarget.idnumber,\n description: relatedTarget.description,\n descriptionformat: relatedTarget.descriptionformat,\n ruletype: config.ruletype,\n ruleoutcome: config.ruleoutcome,\n ruleconfig: config.ruleconfig\n };\n var promise = ajax.call([{\n methodname: 'core_competency_update_competency',\n args: {competency: update}\n }]);\n promise[0].then(function(result) {\n if (result) {\n relatedTarget.ruletype = config.ruletype;\n relatedTarget.ruleoutcome = config.ruleoutcome;\n relatedTarget.ruleconfig = config.ruleconfig;\n renderCompetencySummary(relatedTarget);\n }\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Delete a competency.\n * @method doDelete\n */\n var doDelete = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_delete_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(function(success) {\n if (success === false) {\n str.get_strings([\n {key: 'competencycannotbedeleted', component: 'tool_lp', param: competency.shortname},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.alert(\n null,\n strings[0]\n );\n }).fail(notification.exception);\n }\n }).fail(notification.exception);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n * @method deleteCompetencyHandler\n */\n var deleteCompetencyHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency'),\n confirmMessage = 'deletecompetency';\n\n if (treeModel.hasRule(competency.parentid)) {\n confirmMessage = 'deletecompetencyparenthasrule';\n }\n\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp', param: competency.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragStart\n * @param {Event} e\n */\n var dragStart = function(e) {\n e.originalEvent.dataTransfer.setData('text', $(e.target).parent().data('id'));\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method allowDrop\n * @param {Event} e\n */\n var allowDrop = function(e) {\n e.originalEvent.dataTransfer.dropEffect = 'move';\n e.preventDefault();\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragEnter\n * @param {Event} e\n */\n var dragEnter = function(e) {\n e.preventDefault();\n $(this).addClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragLeave\n * @param {Event} e\n */\n var dragLeave = function(e) {\n e.preventDefault();\n $(this).removeClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dropOver\n * @param {Event} e\n */\n var dropOver = function(e) {\n e.preventDefault();\n moveSource = e.originalEvent.dataTransfer.getData('text');\n moveTarget = $(e.target).parent().data('id');\n $(this).removeClass('currentdragtarget');\n\n confirmMove();\n };\n\n /**\n * Deletes a related competency without confirmation.\n *\n * @param {Event} e The event that triggered the action.\n * @method deleteRelatedHandler\n */\n var deleteRelatedHandler = function(e) {\n e.preventDefault();\n\n var relatedid = this.id.substr(11);\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var removeRelated = ajax.call([\n {methodname: 'core_competency_remove_related_competency',\n args: {relatedcompetencyid: relatedid, competencyid: competency.id}},\n {methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}}\n ]);\n\n removeRelated[1].done(function(context) {\n templates.render('tool_lp/related_competencies', context).done(function(html) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n updatedRelatedCompetencies();\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Updates the competencies list (with relations) and add listeners.\n *\n * @method updatedRelatedCompetencies\n */\n var updatedRelatedCompetencies = function() {\n\n // Listeners to newly loaded related competencies.\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n\n };\n\n /**\n * Log the competency viewed event.\n *\n * @param {Object} competency The competency.\n * @method triggerCompetencyViewedEvent\n */\n var triggerCompetencyViewedEvent = function(competency) {\n if (competency.id !== selectedCompetencyId) {\n // Set the selected competency id.\n selectedCompetencyId = competency.id;\n ajax.call([{\n methodname: 'core_competency_competency_viewed',\n args: {id: competency.id}\n }]);\n }\n };\n\n /**\n * Return the taxonomy constant for a level.\n *\n * @param {Number} level The level.\n * @return {String}\n * @function getTaxonomyAtLevel\n */\n var getTaxonomyAtLevel = function(level) {\n var constant = taxonomiesConstants[level];\n if (!constant) {\n constant = 'competency';\n }\n return constant;\n };\n\n /**\n * Render the competency summary.\n *\n * @param {Object} competency The competency.\n */\n var renderCompetencySummary = function(competency) {\n var promise = $.Deferred().resolve().promise(),\n context = {};\n\n context.competency = competency;\n context.showdeleterelatedaction = true;\n context.showrelatedcompetencies = true;\n context.showrule = false;\n context.pluginbaseurl = url.relativeUrl('/admin/tool/lp');\n\n if (competency.ruleoutcome != Outcomes.NONE) {\n // Get the outcome and rule name.\n promise = Outcomes.getString(competency.ruleoutcome).then(function(str) {\n var name;\n $.each(rulesModules, function(index, modInfo) {\n if (modInfo.type == competency.ruletype) {\n name = modInfo.name;\n }\n });\n return [str, name];\n });\n }\n\n promise.then(function(strs) {\n if (typeof strs !== 'undefined') {\n context.showrule = true;\n context.rule = {\n outcome: strs[0],\n type: strs[1]\n };\n }\n return context;\n }).then(function(context) {\n return templates.render('tool_lp/competency_summary', context);\n }).then(function(html) {\n $('[data-region=\"competencyinfo\"]').html(html);\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n return templates.render('tool_lp/loading', {});\n }).then(function(html, js) {\n templates.replaceNodeContents('[data-region=\"relatedcompetencies\"]', html, js);\n return ajax.call([{\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}\n }])[0];\n }).then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Return the string \"Add \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strAddTaxonomy\n */\n var strAddTaxonomy = function(level) {\n return str.get_string('taxonomy_add_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strSelectedTaxonomy\n */\n var strSelectedTaxonomy = function(level) {\n return str.get_string('taxonomy_selected_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Handler when a node in the aria tree is selected.\n * @method selectionChanged\n * @param {Event} evt The event that triggered the selection change.\n * @param {Object} params The parameters for the event. Contains a list of selected nodes.\n * @return {Boolean}\n */\n var selectionChanged = function(evt, params) {\n var node = params.selected,\n id = $(node).data('id'),\n btn = $('[data-region=\"competencyactions\"] [data-action=\"add\"]'),\n actionMenu = $('[data-region=\"competencyactionsmenu\"]'),\n selectedTitle = $('[data-region=\"selected-competency\"]'),\n level = 0,\n sublevel = 1;\n\n menubar.closeAll();\n\n if (typeof id === \"undefined\") {\n // Assume this is the root of the tree.\n // Here we are only getting the text from the top of the tree, to do it we clone the tree,\n // remove all children and then call text on the result.\n $('[data-region=\"competencyinfo\"]').html(node.clone().children().remove().end().text());\n $('[data-region=\"competencyactions\"]').data('competency', null);\n actionMenu.hide();\n\n } else {\n var competency = treeModel.getCompetency(id);\n\n level = treeModel.getCompetencyLevel(id);\n sublevel = level + 1;\n\n actionMenu.show();\n $('[data-region=\"competencyactions\"]').data('competency', competency);\n renderCompetencySummary(competency);\n // Log Competency viewed event.\n triggerCompetencyViewedEvent(competency);\n }\n strSelectedTaxonomy(level).then(function(str) {\n selectedTitle.text(str);\n return;\n }).catch(notification.exception);\n\n strAddTaxonomy(sublevel).then(function(str) {\n btn.show()\n .find('[data-region=\"term\"]')\n .text(str);\n return;\n }).catch(notification.exception);\n\n // We handled this event so consume it.\n evt.preventDefault();\n return false;\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @function parseTaxonomies\n * @param {String} taxonomiesstr Comma separated list of taxonomies.\n * @return {Array} of level => taxonomystr\n */\n var parseTaxonomies = function(taxonomiesstr) {\n var all = taxonomiesstr.split(',');\n all.unshift(\"\");\n delete all[0];\n\n // Note we don't need to fill holes, because other functions check for empty anyway.\n return all;\n };\n\n return {\n /**\n * Initialise this page (attach event handlers etc).\n *\n * @method init\n * @param {Object} model The tree model provides some useful functions for loading and searching competencies.\n * @param {Number} pagectxid The page context ID.\n * @param {Object} taxonomies Constants indexed by level.\n * @param {Object} rulesMods The modules of the rules.\n */\n init: function(model, pagectxid, taxonomies, rulesMods) {\n treeModel = model;\n pageContextId = pagectxid;\n taxonomiesConstants = parseTaxonomies(taxonomies);\n rulesModules = rulesMods;\n\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').on('click', addHandler);\n\n menubar.enhance('.competencyactionsmenu', {\n '[data-action=\"edit\"]': editHandler,\n '[data-action=\"delete\"]': deleteCompetencyHandler,\n '[data-action=\"move\"]': moveHandler,\n '[data-action=\"moveup\"]': moveUpHandler,\n '[data-action=\"movedown\"]': moveDownHandler,\n '[data-action=\"linkedcourses\"]': seeCoursesHandler,\n '[data-action=\"relatedcompetencies\"]': relateCompetenciesHandler.bind(this),\n '[data-action=\"competencyrules\"]': ruleConfigHandler.bind(this)\n });\n $('[data-region=\"competencyactionsmenu\"]').hide();\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').hide();\n\n $('[data-region=\"filtercompetencies\"]').on('submit', updateSearchHandler);\n // Simple html5 drag drop because we already added an accessible alternative.\n var top = $('[data-region=\"managecompetencies\"] [data-enhance=\"tree\"]');\n top.on('dragstart', 'li>span', dragStart)\n .on('dragover', 'li>span', allowDrop)\n .on('dragenter', 'li>span', dragEnter)\n .on('dragleave', 'li>span', dragLeave)\n .on('drop', 'li>span', dropOver);\n\n model.on('selectionchanged', selectionChanged);\n\n // Prepare the configuration tool.\n ruleConfigInstance = new RuleConfig(treeModel, rulesModules);\n ruleConfigInstance.on('save', ruleConfigSaveHandler.bind(this));\n }\n };\n});\n"],"names":["define","$","url","templates","notification","str","ajax","dragdrop","Ariatree","Dialogue","menubar","Picker","Outcomes","RuleConfig","Pending","pageContextId","pickerInstance","ruleConfigInstance","relatedTarget","taxonomiesConstants","rulesModules","treeModel","moveSource","moveTarget","selectedCompetencyId","addHandler","parent","data","params","competencyframeworkid","getCompetencyFrameworkId","pagecontextid","parentid","id","relocate","queryparams","param","window","location","relativeUrl","hasRule","get_strings","key","component","shortname","done","strings","confirm","fail","exception","doMove","frameworkid","call","methodname","args","competencyid","search","val","reloadPage","confirmMove","targetComp","getCompetency","sourceComp","confirmMessage","showConfirm","path","indexOf","initMovePopup","popup","body","getContent","treeRoot","find","on","evt","target","selected","show","close","addCompetencyChildren","competencies","i","length","haschildren","children","moveHandler","e","preventDefault","competency","requests","searchtext","when","apply","framework","competenciestree","onecompetency","context","render","tree","editHandler","newhtml","newjs","replaceWith","runTemplateJS","updateSearchHandler","moveUpHandler","moveDownHandler","seeCoursesHandler","courses","html","get_string","linkedcourses","relateCompetenciesHandler","pendingPromise","compIds","competencyIds","calls","each","index","value","push","relatedcompetencyid","then","js","updatedRelatedCompetencies","resolve","catch","setDisallowedCompetencyIDs","display","ruleConfigHandler","setTargetCompetencyId","ruleConfigSaveHandler","config","update","idnumber","description","descriptionformat","ruletype","ruleoutcome","ruleconfig","result","renderCompetencySummary","doDelete","success","alert","deleteCompetencyHandler","dragStart","originalEvent","dataTransfer","setData","allowDrop","dropEffect","dragEnter","this","addClass","dragLeave","removeClass","dropOver","getData","deleteRelatedHandler","relatedid","substr","getTaxonomyAtLevel","level","constant","promise","Deferred","showdeleterelatedaction","showrelatedcompetencies","showrule","pluginbaseurl","NONE","getString","name","modInfo","type","strs","rule","outcome","replaceNodeContents","selectionChanged","node","btn","actionMenu","selectedTitle","sublevel","closeAll","clone","remove","end","text","hide","getCompetencyLevel","triggerCompetencyViewedEvent","strSelectedTaxonomy","strAddTaxonomy","init","model","pagectxid","taxonomies","rulesMods","all","split","unshift","enhance","bind"],"mappings":";;;;;;;AAsBAA,OAAM,4BAAC,CAAC,SACA,WACA,iBACA,oBACA,WACA,YACA,2BACA,eACA,mBACA,kBACA,2BACA,8BACA,+BACA,iBAED,SACKC,EAAGC,IAAKC,UAAWC,aAAcC,IAAKC,KAAMC,SAAUC,SAAUC,SAAUC,QAASC,OAAQC,SAAUC,WAAYC,SAKzH,IAMIC,cAEAC,eAEAC,mBAEAC,cAEAC,oBAEAC,aAhBAC,UAAY,KAEZC,WAAa,KAEbC,WAAa,KAcbC,qBAAuB,KAMvBC,WAAa,WACb,IAAIC,OAASzB,EAAE,qCAAqC0B,KAAK,cAErDC,OAAS,CACTC,sBAAuBR,UAAUS,2BACjCC,cAAehB,eAGJ,OAAXW,SAEAE,OAAOI,SAAWN,OAAOO,IAG7B,IAAIC,SAAW,WACX,IAAIC,YAAclC,EAAEmC,MAAMR,QAC1BS,OAAOC,SAAWpC,IAAIqC,YAAY,qCAAuCJ,cAG9D,OAAXT,QAAmBL,UAAUmB,QAAQd,OAAOO,IAC5C5B,IAAIoC,YAAY,CACZ,CAACC,IAAK,UAAWC,UAAW,UAC5B,CAACD,IAAK,sCAAuCC,UAAW,UAAWP,MAAOV,OAAOkB,WACjF,CAACF,IAAK,MAAOC,UAAW,QACxB,CAACD,IAAK,KAAMC,UAAW,UACxBE,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d/build/competencydialogue.min.js.map b/admin/tool/lp/amd/build/competencydialogue.min.js.map index 3a66a43e0e3..4c05f338921 100644 --- a/admin/tool/lp/amd/build/competencydialogue.min.js.map +++ b/admin/tool/lp/amd/build/competencydialogue.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competencydialogue.min.js","sources":["../src/competencydialogue.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Display Competency in dialogue box.\n *\n * @module tool_lp/Competencydialogue\n * @copyright 2015 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/dialogue'],\n function($, notification, ajax, templates, str, Dialogue) {\n\n /**\n * The main instance we'll be working with.\n *\n * @type {Competencydialogue}\n */\n var instance;\n\n /**\n * Constructor for CompetencyDialogue.\n */\n var Competencydialogue = function() {\n // Intentionally left empty.\n };\n\n /**\n * Log the competency viewed event.\n *\n * @param {Number} competencyId The competency ID.\n * @method triggerCompetencyViewedEvent\n */\n Competencydialogue.prototype.triggerCompetencyViewedEvent = function(competencyId) {\n ajax.call([{\n methodname: 'core_competency_competency_viewed',\n args: {id: competencyId}\n }]);\n };\n\n /**\n * Display a dialogue box by competencyid.\n *\n * @param {Number} competencyid The competency ID.\n * @param {Object} options The options.\n * @method showDialogue\n */\n Competencydialogue.prototype.showDialogue = function(competencyid, options) {\n\n var datapromise = this.getCompetencyDataPromise(competencyid, options);\n var localthis = this;\n datapromise.done(function(data) {\n // Inner Html in the dialogue content.\n templates.render('tool_lp/competency_summary', data)\n .done(function(html) {\n // Log competency viewed event.\n localthis.triggerCompetencyViewedEvent(competencyid);\n\n // Show the dialogue.\n new Dialogue(\n data.competency.shortname,\n html\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Display a dialogue box from data.\n *\n * @param {Object} dataSource data to be used to display dialogue box\n * @method showDialogueFromData\n */\n Competencydialogue.prototype.showDialogueFromData = function(dataSource) {\n\n var localthis = this;\n // Inner Html in the dialogue content.\n templates.render('tool_lp/competency_summary', dataSource)\n .done(function(html) {\n // Log competency viewed event.\n localthis.triggerCompetencyViewedEvent(dataSource.id);\n\n // Show the dialogue.\n new Dialogue(\n dataSource.shortname,\n html,\n localthis.enhanceDialogue\n );\n }).fail(notification.exception);\n };\n\n /**\n * The action on the click event.\n *\n * @param {Event} e event click\n * @method clickEventHandler\n */\n Competencydialogue.prototype.clickEventHandler = function(e) {\n\n var compdialogue = e.data.compdialogue;\n var currentTarget = $(e.currentTarget);\n var competencyid = currentTarget.data('id');\n var includerelated = !(currentTarget.data('excluderelated'));\n var includecourses = currentTarget.data('includecourses');\n\n // Show the dialogue box.\n compdialogue.showDialogue(competencyid, {\n includerelated: includerelated,\n includecourses: includecourses\n });\n e.preventDefault();\n };\n\n /**\n * Get a promise on data competency.\n *\n * @param {Number} competencyid\n * @param {Object} options\n * @return {Promise} return promise on data request\n * @method getCompetencyDataPromise\n */\n Competencydialogue.prototype.getCompetencyDataPromise = function(competencyid, options) {\n\n var requests = ajax.call([\n {methodname: 'tool_lp_data_for_competency_summary',\n args: {competencyid: competencyid,\n includerelated: options.includerelated || false,\n includecourses: options.includecourses || false\n }\n }\n ]);\n\n return requests[0].then(function(context) {\n return context;\n }).fail(notification.exception);\n };\n\n return /** @alias module:tool_lp/competencydialogue */ {\n\n /**\n * Initialise the competency dialogue module.\n *\n * Only the first call matters.\n */\n init: function() {\n if (typeof instance !== 'undefined') {\n return;\n }\n\n // Instantiate the one instance and delegate event on the body.\n instance = new Competencydialogue();\n $('body').delegate('[data-action=\"competency-dialogue\"]', 'click', {compdialogue: instance},\n instance.clickEventHandler.bind(instance));\n }\n };\n});\n"],"names":["define","$","notification","ajax","templates","str","Dialogue","instance","Competencydialogue","prototype","triggerCompetencyViewedEvent","competencyId","call","methodname","args","id","showDialogue","competencyid","options","datapromise","this","getCompetencyDataPromise","localthis","done","data","render","html","competency","shortname","fail","exception","showDialogueFromData","dataSource","enhanceDialogue","clickEventHandler","e","compdialogue","currentTarget","includerelated","includecourses","preventDefault","then","context","init","delegate","bind"],"mappings":";;;;;;;AAsBAA,oCAAO,CAAC,SACA,oBACA,YACA,iBACA,WACA,qBACD,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,IAAKC,cAO/CC,SAKAC,mBAAqB,oBAUzBA,mBAAmBC,UAAUC,6BAA+B,SAASC,cACjER,KAAKS,KAAK,CAAC,CACHC,WAAY,oCACZC,KAAM,CAACC,GAAIJ,kBAWvBH,mBAAmBC,UAAUO,aAAe,SAASC,aAAcC,aAE3DC,YAAcC,KAAKC,yBAAyBJ,aAAcC,SAC1DI,UAAYF,KAChBD,YAAYI,MAAK,SAASC,MAEtBpB,UAAUqB,OAAO,6BAA8BD,MAC1CD,MAAK,SAASG,MAEXJ,UAAUZ,6BAA6BO,kBAGnCX,SACAkB,KAAKG,WAAWC,UAChBF,SAELG,KAAK3B,aAAa4B,cAC1BD,KAAK3B,aAAa4B,YASzBtB,mBAAmBC,UAAUsB,qBAAuB,SAASC,gBAErDV,UAAYF,KAEhBhB,UAAUqB,OAAO,6BAA8BO,YAC1CT,MAAK,SAASG,MAEXJ,UAAUZ,6BAA6BsB,WAAWjB,QAG9CT,SACA0B,WAAWJ,UACXF,KACAJ,UAAUW,oBAEfJ,KAAK3B,aAAa4B,YAS7BtB,mBAAmBC,UAAUyB,kBAAoB,SAASC,OAElDC,aAAeD,EAAEX,KAAKY,aACtBC,cAAgBpC,EAAEkC,EAAEE,eACpBpB,aAAeoB,cAAcb,KAAK,MAClCc,gBAAmBD,cAAcb,KAAK,kBACtCe,eAAiBF,cAAcb,KAAK,kBAGxCY,aAAapB,aAAaC,aAAc,CACpCqB,eAAgBA,eAChBC,eAAgBA,iBAEpBJ,EAAEK,kBAWNhC,mBAAmBC,UAAUY,yBAA2B,SAASJ,aAAcC,gBAE5Df,KAAKS,KAAK,CACrB,CAACC,WAAY,sCACXC,KAAM,CAACG,aAAcA,aACbqB,eAAgBpB,QAAQoB,iBAAkB,EAC1CC,eAAgBrB,QAAQqB,iBAAkB,MAKxC,GAAGE,MAAK,SAASC,gBACvBA,WACPb,KAAK3B,aAAa4B,YAG8B,CAOnDa,KAAM,gBACsB,IAAbpC,WAKXA,SAAW,IAAIC,mBACfP,EAAE,QAAQ2C,SAAS,sCAAuC,QAAS,CAACR,aAAc7B,UAC9EA,SAAS2B,kBAAkBW,KAAKtC"} \ No newline at end of file +{"version":3,"file":"competencydialogue.min.js","sources":["../src/competencydialogue.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Display Competency in dialogue box.\n *\n * @module tool_lp/Competencydialogue\n * @copyright 2015 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/dialogue'],\n function($, notification, ajax, templates, str, Dialogue) {\n\n /**\n * The main instance we'll be working with.\n *\n * @type {Competencydialogue}\n */\n var instance;\n\n /**\n * Constructor for CompetencyDialogue.\n */\n var Competencydialogue = function() {\n // Intentionally left empty.\n };\n\n /**\n * Log the competency viewed event.\n *\n * @param {Number} competencyId The competency ID.\n * @method triggerCompetencyViewedEvent\n */\n Competencydialogue.prototype.triggerCompetencyViewedEvent = function(competencyId) {\n ajax.call([{\n methodname: 'core_competency_competency_viewed',\n args: {id: competencyId}\n }]);\n };\n\n /**\n * Display a dialogue box by competencyid.\n *\n * @param {Number} competencyid The competency ID.\n * @param {Object} options The options.\n * @method showDialogue\n */\n Competencydialogue.prototype.showDialogue = function(competencyid, options) {\n\n var datapromise = this.getCompetencyDataPromise(competencyid, options);\n var localthis = this;\n datapromise.done(function(data) {\n // Inner Html in the dialogue content.\n templates.render('tool_lp/competency_summary', data)\n .done(function(html) {\n // Log competency viewed event.\n localthis.triggerCompetencyViewedEvent(competencyid);\n\n // Show the dialogue.\n new Dialogue(\n data.competency.shortname,\n html\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Display a dialogue box from data.\n *\n * @param {Object} dataSource data to be used to display dialogue box\n * @method showDialogueFromData\n */\n Competencydialogue.prototype.showDialogueFromData = function(dataSource) {\n\n var localthis = this;\n // Inner Html in the dialogue content.\n templates.render('tool_lp/competency_summary', dataSource)\n .done(function(html) {\n // Log competency viewed event.\n localthis.triggerCompetencyViewedEvent(dataSource.id);\n\n // Show the dialogue.\n new Dialogue(\n dataSource.shortname,\n html,\n localthis.enhanceDialogue\n );\n }).fail(notification.exception);\n };\n\n /**\n * The action on the click event.\n *\n * @param {Event} e event click\n * @method clickEventHandler\n */\n Competencydialogue.prototype.clickEventHandler = function(e) {\n\n var compdialogue = e.data.compdialogue;\n var currentTarget = $(e.currentTarget);\n var competencyid = currentTarget.data('id');\n var includerelated = !(currentTarget.data('excluderelated'));\n var includecourses = currentTarget.data('includecourses');\n\n // Show the dialogue box.\n compdialogue.showDialogue(competencyid, {\n includerelated: includerelated,\n includecourses: includecourses\n });\n e.preventDefault();\n };\n\n /**\n * Get a promise on data competency.\n *\n * @param {Number} competencyid\n * @param {Object} options\n * @return {Promise} return promise on data request\n * @method getCompetencyDataPromise\n */\n Competencydialogue.prototype.getCompetencyDataPromise = function(competencyid, options) {\n\n var requests = ajax.call([\n {methodname: 'tool_lp_data_for_competency_summary',\n args: {competencyid: competencyid,\n includerelated: options.includerelated || false,\n includecourses: options.includecourses || false\n }\n }\n ]);\n\n return requests[0].then(function(context) {\n return context;\n }).fail(notification.exception);\n };\n\n return /** @alias module:tool_lp/competencydialogue */ {\n\n /**\n * Initialise the competency dialogue module.\n *\n * Only the first call matters.\n */\n init: function() {\n if (typeof instance !== 'undefined') {\n return;\n }\n\n // Instantiate the one instance and delegate event on the body.\n instance = new Competencydialogue();\n $('body').delegate('[data-action=\"competency-dialogue\"]', 'click', {compdialogue: instance},\n instance.clickEventHandler.bind(instance));\n }\n };\n});\n"],"names":["define","$","notification","ajax","templates","str","Dialogue","instance","Competencydialogue","prototype","triggerCompetencyViewedEvent","competencyId","call","methodname","args","id","showDialogue","competencyid","options","datapromise","this","getCompetencyDataPromise","localthis","done","data","render","html","competency","shortname","fail","exception","showDialogueFromData","dataSource","enhanceDialogue","clickEventHandler","e","compdialogue","currentTarget","includerelated","includecourses","preventDefault","then","context","init","delegate","bind"],"mappings":";;;;;;;AAsBAA,OAAM,6BAAC,CAAC,SACA,oBACA,YACA,iBACA,WACA,qBACD,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,IAAKC,UAOnD,IAAIC,SAKAC,mBAAqB,aAkHzB,OAxGAA,mBAAmBC,UAAUC,6BAA+B,SAASC,cACjER,KAAKS,KAAK,CAAC,CACHC,WAAY,oCACZC,KAAM,CAACC,GAAIJ,kBAWvBH,mBAAmBC,UAAUO,aAAe,SAASC,aAAcC,SAE/D,IAAIC,YAAcC,KAAKC,yBAAyBJ,aAAcC,SAC1DI,UAAYF,KAChBD,YAAYI,MAAK,SAASC,MAEtBpB,UAAUqB,OAAO,6BAA8BD,MAC1CD,MAAK,SAASG,MAEXJ,UAAUZ,6BAA6BO,cAGvC,IAAIX,SACAkB,KAAKG,WAAWC,UAChBF,KAEP,IAAEG,KAAK3B,aAAa4B,UAC5B,IAAED,KAAK3B,aAAa4B,YASzBtB,mBAAmBC,UAAUsB,qBAAuB,SAASC,YAEzD,IAAIV,UAAYF,KAEhBhB,UAAUqB,OAAO,6BAA8BO,YAC1CT,MAAK,SAASG,MAEXJ,UAAUZ,6BAA6BsB,WAAWjB,IAGlD,IAAIT,SACA0B,WAAWJ,UACXF,KACAJ,UAAUW,gBAEjB,IAAEJ,KAAK3B,aAAa4B,YAS7BtB,mBAAmBC,UAAUyB,kBAAoB,SAASC,GAEtD,IAAIC,aAAeD,EAAEX,KAAKY,aACtBC,cAAgBpC,EAAEkC,EAAEE,eACpBpB,aAAeoB,cAAcb,KAAK,MAClCc,gBAAmBD,cAAcb,KAAK,kBACtCe,eAAiBF,cAAcb,KAAK,kBAGxCY,aAAapB,aAAaC,aAAc,CACpCqB,eAAgBA,eAChBC,eAAgBA,iBAEpBJ,EAAEK,kBAWNhC,mBAAmBC,UAAUY,yBAA2B,SAASJ,aAAcC,SAW3E,OATef,KAAKS,KAAK,CACrB,CAACC,WAAY,sCACXC,KAAM,CAACG,aAAcA,aACbqB,eAAgBpB,QAAQoB,iBAAkB,EAC1CC,eAAgBrB,QAAQqB,iBAAkB,MAKxC,GAAGE,MAAK,SAASC,SAC9B,OAAOA,OACT,IAAEb,KAAK3B,aAAa4B,YAG8B,CAOnDa,KAAM,gBACsB,IAAbpC,WAKXA,SAAW,IAAIC,mBACfP,EAAE,QAAQ2C,SAAS,sCAAuC,QAAS,CAACR,aAAc7B,UAC9EA,SAAS2B,kBAAkBW,KAAKtC,WACxC,EAER"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencypicker.min.js.map b/admin/tool/lp/amd/build/competencypicker.min.js.map index 6fca0dc076b..a3a62cff38a 100644 --- a/admin/tool/lp/amd/build/competencypicker.min.js.map +++ b/admin/tool/lp/amd/build/competencypicker.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competencypicker.min.js","sources":["../src/competencypicker.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency picker.\n *\n * To handle 'save' events use: picker.on('save')\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @module tool_lp/competencypicker\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'core/str',\n 'tool_lp/tree',\n 'core/pending'\n ],\n function($, Notification, Ajax, Templates, Dialogue, Str, Tree, Pending) {\n\n /**\n * Competency picker class.\n * @param {Number} pageContextId The page context ID.\n * @param {Number|false} singleFramework The ID of the framework when limited to one.\n * @param {String} pageContextIncludes One of 'children', 'parents', 'self'.\n * @param {Boolean} multiSelect Support multi-select in the tree.\n */\n var Picker = function(pageContextId, singleFramework, pageContextIncludes, multiSelect) {\n var self = this;\n self._eventNode = $('
');\n self._frameworks = [];\n self._reset();\n\n self._pageContextId = pageContextId;\n self._pageContextIncludes = pageContextIncludes || 'children';\n self._multiSelect = (typeof multiSelect === 'undefined' || multiSelect === true);\n if (singleFramework) {\n self._frameworkId = singleFramework;\n self._singleFramework = true;\n }\n };\n\n /** @property {Array} The competencies fetched. */\n Picker.prototype._competencies = null;\n /** @property {Array} The competencies that cannot be picked. */\n Picker.prototype._disallowedCompetencyIDs = null;\n /** @property {Node} The node we attach the events to. */\n Picker.prototype._eventNode = null;\n /** @property {Array} The list of frameworks fetched. */\n Picker.prototype._frameworks = null;\n /** @property {Number} The current framework ID. */\n Picker.prototype._frameworkId = null;\n /** @property {Number} The page context ID. */\n Picker.prototype._pageContextId = null;\n /** @property {Number} Relevant contexts inclusion. */\n Picker.prototype._pageContextIncludes = null;\n /** @property {Dialogue} The reference to the dialogue. */\n Picker.prototype._popup = null;\n /** @property {String} The string we filter the competencies with. */\n Picker.prototype._searchText = '';\n /** @property {Object} The competency that was selected. */\n Picker.prototype._selectedCompetencies = null;\n /** @property {Boolean} Whether we can browse frameworks or not. */\n Picker.prototype._singleFramework = false;\n /** @property {Boolean} Do we allow multi select? */\n Picker.prototype._multiSelect = true;\n /** @property {Boolean} Do we allow to display hidden framework? */\n Picker.prototype._onlyVisible = true;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n Picker.prototype._afterRender = function() {\n var self = this;\n\n // Initialise the tree.\n var tree = new Tree(self._find('[data-enhance=linktree]'), self._multiSelect);\n\n // To prevent jiggling we only show the tree after it is enhanced.\n self._find('[data-enhance=linktree]').show();\n\n tree.on('selectionchanged', function(evt, params) {\n var selected = params.selected;\n evt.preventDefault();\n var validIds = [];\n $.each(selected, function(index, item) {\n var compId = $(item).data('id'),\n valid = true;\n\n if (typeof compId === 'undefined') {\n // Do not allow picking nodes with no id.\n valid = false;\n } else {\n $.each(self._disallowedCompetencyIDs, function(i, id) {\n if (id == compId) {\n valid = false;\n }\n });\n }\n if (valid) {\n validIds.push(compId);\n }\n });\n\n self._selectedCompetencies = validIds;\n\n // TODO Implement disabling of nodes in the tree module somehow.\n if (!self._selectedCompetencies.length) {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').attr('disabled', 'disabled');\n } else {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').removeAttr('disabled');\n }\n });\n\n // Add listener for framework change.\n if (!self._singleFramework) {\n self._find('[data-action=\"chooseframework\"]').change(function(e) {\n self._frameworkId = $(e.target).val();\n self._loadCompetencies().then(self._refresh.bind(self)).catch(Notification.exception);\n });\n }\n\n // Add listener for search.\n self._find('[data-region=\"filtercompetencies\"] button').click(function(e) {\n e.preventDefault();\n $(e.target).attr('disabled', 'disabled');\n self._searchText = self._find('[data-region=\"filtercompetencies\"] input').val() || '';\n return self._refresh().always(function() {\n $(e.target).removeAttr('disabled');\n });\n });\n\n // Add listener for cancel.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for add.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').click(function(e) {\n e.preventDefault();\n var pendingPromise = new Pending();\n if (!self._selectedCompetencies.length) {\n return;\n }\n\n if (self._multiSelect) {\n self._trigger('save', {competencyIds: self._selectedCompetencies});\n } else {\n // We checked above that the array has at least one value.\n self._trigger('save', {competencyId: self._selectedCompetencies[0]});\n }\n\n // The dialogue here is a YUI dialogue and doesn't support Promises at all.\n // However, it is typically synchronous so this shoudl suffice.\n self.close();\n pendingPromise.resolve();\n });\n\n // The list of selected competencies will be modified while looping (because of the listeners above).\n var currentItems = self._selectedCompetencies.slice(0);\n\n $.each(currentItems, function(index, id) {\n var node = self._find('[data-id=' + id + ']');\n if (node.length) {\n tree.toggleItem(node);\n tree.updateFocus(node);\n }\n });\n\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Picker.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @return {Promise}\n */\n Picker.prototype.display = function() {\n var self = this;\n return $.when(Str.get_string('competencypicker', 'tool_lp'), self._render())\n .then(function(title, render) {\n self._popup = new Dialogue(\n title,\n render[0],\n self._afterRender.bind(self)\n );\n return;\n }).catch(Notification.exception);\n };\n\n /**\n * Fetch the competencies.\n *\n * @param {Number} frameworkId The frameworkId.\n * @param {String} searchText Limit the competencies to those matching the text.\n * @method _fetchCompetencies\n * @return {Promise}\n */\n Picker.prototype._fetchCompetencies = function(frameworkId, searchText) {\n var self = this;\n\n return Ajax.call([\n {methodname: 'core_competency_search_competencies', args: {\n searchtext: searchText,\n competencyframeworkid: frameworkId\n }}\n ])[0].done(function(competencies) {\n /**\n * @param {Object} parent\n * @param {Array} competencies\n */\n function addCompetencyChildren(parent, competencies) {\n for (var i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n }\n\n // Expand the list of competencies into a tree.\n var i, comp;\n var tree = [];\n for (i = 0; i < competencies.length; i++) {\n comp = competencies[i];\n if (comp.parentid == \"0\") { // Loose check for now, because WS returns a string.\n comp.children = [];\n comp.haschildren = 0;\n tree[tree.length] = comp;\n addCompetencyChildren(comp, competencies);\n }\n }\n\n self._competencies = tree;\n\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery}\n * @method _find\n */\n Picker.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Convenience method to get a framework object.\n *\n * @param {Number} fid The framework ID.\n * @return {Object}\n * @method _getFramework\n */\n Picker.prototype._getFramework = function(fid) {\n var frm;\n $.each(this._frameworks, function(i, f) {\n if (f.id == fid) {\n frm = f;\n return;\n }\n });\n return frm;\n };\n\n /**\n * Load the competencies.\n *\n * @method _loadCompetencies\n * @return {Promise}\n */\n Picker.prototype._loadCompetencies = function() {\n return this._fetchCompetencies(this._frameworkId, this._searchText);\n };\n\n /**\n * Load the frameworks.\n *\n * @method _loadFrameworks\n * @return {Promise}\n */\n Picker.prototype._loadFrameworks = function() {\n var promise,\n self = this;\n\n // Quit early because we already have the data.\n if (self._frameworks.length > 0) {\n return $.when();\n }\n\n if (self._singleFramework) {\n promise = Ajax.call([\n {methodname: 'core_competency_read_competency_framework', args: {\n id: this._frameworkId\n }}\n ])[0].then(function(framework) {\n return [framework];\n });\n } else {\n promise = Ajax.call([\n {methodname: 'core_competency_list_competency_frameworks', args: {\n sort: 'shortname',\n context: {contextid: self._pageContextId},\n includes: self._pageContextIncludes,\n onlyvisible: self._onlyVisible\n }}\n ])[0];\n }\n\n return promise.done(function(frameworks) {\n self._frameworks = frameworks;\n }).fail(Notification.exception);\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Picker.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @return {Promise}\n */\n Picker.prototype._preRender = function() {\n var self = this;\n return self._loadFrameworks().then(function() {\n if (!self._frameworkId && self._frameworks.length > 0) {\n self._frameworkId = self._frameworks[0].id;\n }\n\n // We could not set a framework ID, that probably means there are no frameworks accessible.\n if (!self._frameworkId) {\n self._frameworks = [];\n return $.when();\n }\n\n return self._loadCompetencies();\n });\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n Picker.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"competencylinktree\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n Picker.prototype._render = function() {\n var self = this;\n return self._preRender().then(function() {\n\n if (!self._singleFramework) {\n $.each(self._frameworks, function(i, framework) {\n if (framework.id == self._frameworkId) {\n framework.selected = true;\n } else {\n framework.selected = false;\n }\n });\n }\n\n var context = {\n competencies: self._competencies,\n framework: self._getFramework(self._frameworkId),\n frameworks: self._frameworks,\n search: self._searchText,\n singleFramework: self._singleFramework,\n };\n\n return Templates.render('tool_lp/competency_picker', context);\n });\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n Picker.prototype._reset = function() {\n this._competencies = [];\n this._disallowedCompetencyIDs = [];\n this._popup = null;\n this._searchText = '';\n this._selectedCompetencies = [];\n };\n\n /**\n * Set what competencies cannot be picked.\n *\n * This needs to be set after reset/close.\n *\n * @param {Number[]} ids The IDs.\n * @method _setDisallowedCompetencyIDs\n */\n Picker.prototype.setDisallowedCompetencyIDs = function(ids) {\n this._disallowedCompetencyIDs = ids;\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _reset\n */\n Picker.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return Picker;\n\n});\n"],"names":["define","$","Notification","Ajax","Templates","Dialogue","Str","Tree","Pending","Picker","pageContextId","singleFramework","pageContextIncludes","multiSelect","this","_eventNode","_frameworks","_reset","_pageContextId","_pageContextIncludes","_multiSelect","_frameworkId","_singleFramework","prototype","_competencies","_disallowedCompetencyIDs","_popup","_searchText","_selectedCompetencies","_onlyVisible","_afterRender","self","tree","_find","show","on","evt","params","selected","preventDefault","validIds","each","index","item","compId","data","valid","i","id","push","length","removeAttr","attr","change","e","target","val","_loadCompetencies","then","_refresh","bind","catch","exception","click","always","close","pendingPromise","_trigger","competencyIds","competencyId","resolve","currentItems","slice","node","toggleItem","updateFocus","display","when","get_string","_render","title","render","_fetchCompetencies","frameworkId","searchText","call","methodname","args","searchtext","competencyframeworkid","done","competencies","addCompetencyChildren","parent","parentid","haschildren","children","comp","fail","selector","getContent","find","_getFramework","fid","frm","f","_loadFrameworks","framework","sort","context","contextid","includes","onlyvisible","frameworks","type","handler","_preRender","html","replaceWith","search","setDisallowedCompetencyIDs","ids","trigger"],"mappings":";;;;;;;;;;;AA2BAA,kCAAO,CAAC,SACA,oBACA,YACA,iBACA,mBACA,WACA,eACA,iBAEA,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,SAAUC,IAAKC,KAAMC,aAShEC,OAAS,SAASC,cAAeC,gBAAiBC,oBAAqBC,aAC5DC,KACNC,WAAad,EAAE,eADTa,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wB,IAWjCnB,OAAOc,UAAUiG,2BAA6B,SAASC,UAC9ChG,yBAA2BgG,KAUpChH,OAAOc,UAAU4C,SAAW,SAAS+C,KAAMrE,WAClC9B,WAAW2G,QAAQR,KAAM,CAACrE,QAG5BpC"} \ No newline at end of file +{"version":3,"file":"competencypicker.min.js","sources":["../src/competencypicker.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency picker.\n *\n * To handle 'save' events use: picker.on('save')\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @module tool_lp/competencypicker\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'core/str',\n 'tool_lp/tree',\n 'core/pending'\n ],\n function($, Notification, Ajax, Templates, Dialogue, Str, Tree, Pending) {\n\n /**\n * Competency picker class.\n * @param {Number} pageContextId The page context ID.\n * @param {Number|false} singleFramework The ID of the framework when limited to one.\n * @param {String} pageContextIncludes One of 'children', 'parents', 'self'.\n * @param {Boolean} multiSelect Support multi-select in the tree.\n */\n var Picker = function(pageContextId, singleFramework, pageContextIncludes, multiSelect) {\n var self = this;\n self._eventNode = $('
');\n self._frameworks = [];\n self._reset();\n\n self._pageContextId = pageContextId;\n self._pageContextIncludes = pageContextIncludes || 'children';\n self._multiSelect = (typeof multiSelect === 'undefined' || multiSelect === true);\n if (singleFramework) {\n self._frameworkId = singleFramework;\n self._singleFramework = true;\n }\n };\n\n /** @property {Array} The competencies fetched. */\n Picker.prototype._competencies = null;\n /** @property {Array} The competencies that cannot be picked. */\n Picker.prototype._disallowedCompetencyIDs = null;\n /** @property {Node} The node we attach the events to. */\n Picker.prototype._eventNode = null;\n /** @property {Array} The list of frameworks fetched. */\n Picker.prototype._frameworks = null;\n /** @property {Number} The current framework ID. */\n Picker.prototype._frameworkId = null;\n /** @property {Number} The page context ID. */\n Picker.prototype._pageContextId = null;\n /** @property {Number} Relevant contexts inclusion. */\n Picker.prototype._pageContextIncludes = null;\n /** @property {Dialogue} The reference to the dialogue. */\n Picker.prototype._popup = null;\n /** @property {String} The string we filter the competencies with. */\n Picker.prototype._searchText = '';\n /** @property {Object} The competency that was selected. */\n Picker.prototype._selectedCompetencies = null;\n /** @property {Boolean} Whether we can browse frameworks or not. */\n Picker.prototype._singleFramework = false;\n /** @property {Boolean} Do we allow multi select? */\n Picker.prototype._multiSelect = true;\n /** @property {Boolean} Do we allow to display hidden framework? */\n Picker.prototype._onlyVisible = true;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n Picker.prototype._afterRender = function() {\n var self = this;\n\n // Initialise the tree.\n var tree = new Tree(self._find('[data-enhance=linktree]'), self._multiSelect);\n\n // To prevent jiggling we only show the tree after it is enhanced.\n self._find('[data-enhance=linktree]').show();\n\n tree.on('selectionchanged', function(evt, params) {\n var selected = params.selected;\n evt.preventDefault();\n var validIds = [];\n $.each(selected, function(index, item) {\n var compId = $(item).data('id'),\n valid = true;\n\n if (typeof compId === 'undefined') {\n // Do not allow picking nodes with no id.\n valid = false;\n } else {\n $.each(self._disallowedCompetencyIDs, function(i, id) {\n if (id == compId) {\n valid = false;\n }\n });\n }\n if (valid) {\n validIds.push(compId);\n }\n });\n\n self._selectedCompetencies = validIds;\n\n // TODO Implement disabling of nodes in the tree module somehow.\n if (!self._selectedCompetencies.length) {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').attr('disabled', 'disabled');\n } else {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').removeAttr('disabled');\n }\n });\n\n // Add listener for framework change.\n if (!self._singleFramework) {\n self._find('[data-action=\"chooseframework\"]').change(function(e) {\n self._frameworkId = $(e.target).val();\n self._loadCompetencies().then(self._refresh.bind(self)).catch(Notification.exception);\n });\n }\n\n // Add listener for search.\n self._find('[data-region=\"filtercompetencies\"] button').click(function(e) {\n e.preventDefault();\n $(e.target).attr('disabled', 'disabled');\n self._searchText = self._find('[data-region=\"filtercompetencies\"] input').val() || '';\n return self._refresh().always(function() {\n $(e.target).removeAttr('disabled');\n });\n });\n\n // Add listener for cancel.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for add.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').click(function(e) {\n e.preventDefault();\n var pendingPromise = new Pending();\n if (!self._selectedCompetencies.length) {\n return;\n }\n\n if (self._multiSelect) {\n self._trigger('save', {competencyIds: self._selectedCompetencies});\n } else {\n // We checked above that the array has at least one value.\n self._trigger('save', {competencyId: self._selectedCompetencies[0]});\n }\n\n // The dialogue here is a YUI dialogue and doesn't support Promises at all.\n // However, it is typically synchronous so this shoudl suffice.\n self.close();\n pendingPromise.resolve();\n });\n\n // The list of selected competencies will be modified while looping (because of the listeners above).\n var currentItems = self._selectedCompetencies.slice(0);\n\n $.each(currentItems, function(index, id) {\n var node = self._find('[data-id=' + id + ']');\n if (node.length) {\n tree.toggleItem(node);\n tree.updateFocus(node);\n }\n });\n\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Picker.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @return {Promise}\n */\n Picker.prototype.display = function() {\n var self = this;\n return $.when(Str.get_string('competencypicker', 'tool_lp'), self._render())\n .then(function(title, render) {\n self._popup = new Dialogue(\n title,\n render[0],\n self._afterRender.bind(self)\n );\n return;\n }).catch(Notification.exception);\n };\n\n /**\n * Fetch the competencies.\n *\n * @param {Number} frameworkId The frameworkId.\n * @param {String} searchText Limit the competencies to those matching the text.\n * @method _fetchCompetencies\n * @return {Promise}\n */\n Picker.prototype._fetchCompetencies = function(frameworkId, searchText) {\n var self = this;\n\n return Ajax.call([\n {methodname: 'core_competency_search_competencies', args: {\n searchtext: searchText,\n competencyframeworkid: frameworkId\n }}\n ])[0].done(function(competencies) {\n /**\n * @param {Object} parent\n * @param {Array} competencies\n */\n function addCompetencyChildren(parent, competencies) {\n for (var i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n }\n\n // Expand the list of competencies into a tree.\n var i, comp;\n var tree = [];\n for (i = 0; i < competencies.length; i++) {\n comp = competencies[i];\n if (comp.parentid == \"0\") { // Loose check for now, because WS returns a string.\n comp.children = [];\n comp.haschildren = 0;\n tree[tree.length] = comp;\n addCompetencyChildren(comp, competencies);\n }\n }\n\n self._competencies = tree;\n\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery}\n * @method _find\n */\n Picker.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Convenience method to get a framework object.\n *\n * @param {Number} fid The framework ID.\n * @return {Object}\n * @method _getFramework\n */\n Picker.prototype._getFramework = function(fid) {\n var frm;\n $.each(this._frameworks, function(i, f) {\n if (f.id == fid) {\n frm = f;\n return;\n }\n });\n return frm;\n };\n\n /**\n * Load the competencies.\n *\n * @method _loadCompetencies\n * @return {Promise}\n */\n Picker.prototype._loadCompetencies = function() {\n return this._fetchCompetencies(this._frameworkId, this._searchText);\n };\n\n /**\n * Load the frameworks.\n *\n * @method _loadFrameworks\n * @return {Promise}\n */\n Picker.prototype._loadFrameworks = function() {\n var promise,\n self = this;\n\n // Quit early because we already have the data.\n if (self._frameworks.length > 0) {\n return $.when();\n }\n\n if (self._singleFramework) {\n promise = Ajax.call([\n {methodname: 'core_competency_read_competency_framework', args: {\n id: this._frameworkId\n }}\n ])[0].then(function(framework) {\n return [framework];\n });\n } else {\n promise = Ajax.call([\n {methodname: 'core_competency_list_competency_frameworks', args: {\n sort: 'shortname',\n context: {contextid: self._pageContextId},\n includes: self._pageContextIncludes,\n onlyvisible: self._onlyVisible\n }}\n ])[0];\n }\n\n return promise.done(function(frameworks) {\n self._frameworks = frameworks;\n }).fail(Notification.exception);\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Picker.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @return {Promise}\n */\n Picker.prototype._preRender = function() {\n var self = this;\n return self._loadFrameworks().then(function() {\n if (!self._frameworkId && self._frameworks.length > 0) {\n self._frameworkId = self._frameworks[0].id;\n }\n\n // We could not set a framework ID, that probably means there are no frameworks accessible.\n if (!self._frameworkId) {\n self._frameworks = [];\n return $.when();\n }\n\n return self._loadCompetencies();\n });\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n Picker.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"competencylinktree\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n Picker.prototype._render = function() {\n var self = this;\n return self._preRender().then(function() {\n\n if (!self._singleFramework) {\n $.each(self._frameworks, function(i, framework) {\n if (framework.id == self._frameworkId) {\n framework.selected = true;\n } else {\n framework.selected = false;\n }\n });\n }\n\n var context = {\n competencies: self._competencies,\n framework: self._getFramework(self._frameworkId),\n frameworks: self._frameworks,\n search: self._searchText,\n singleFramework: self._singleFramework,\n };\n\n return Templates.render('tool_lp/competency_picker', context);\n });\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n Picker.prototype._reset = function() {\n this._competencies = [];\n this._disallowedCompetencyIDs = [];\n this._popup = null;\n this._searchText = '';\n this._selectedCompetencies = [];\n };\n\n /**\n * Set what competencies cannot be picked.\n *\n * This needs to be set after reset/close.\n *\n * @param {Number[]} ids The IDs.\n * @method _setDisallowedCompetencyIDs\n */\n Picker.prototype.setDisallowedCompetencyIDs = function(ids) {\n this._disallowedCompetencyIDs = ids;\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _reset\n */\n Picker.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return Picker;\n\n});\n"],"names":["define","$","Notification","Ajax","Templates","Dialogue","Str","Tree","Pending","Picker","pageContextId","singleFramework","pageContextIncludes","multiSelect","this","_eventNode","_frameworks","_reset","_pageContextId","_pageContextIncludes","_multiSelect","_frameworkId","_singleFramework","prototype","_competencies","_disallowedCompetencyIDs","_popup","_searchText","_selectedCompetencies","_onlyVisible","_afterRender","self","tree","_find","show","on","evt","params","selected","preventDefault","validIds","each","index","item","compId","data","valid","i","id","push","length","removeAttr","attr","change","e","target","val","_loadCompetencies","then","_refresh","bind","catch","exception","click","always","close","pendingPromise","_trigger","competencyIds","competencyId","resolve","currentItems","slice","node","toggleItem","updateFocus","display","when","get_string","_render","title","render","_fetchCompetencies","frameworkId","searchText","call","methodname","args","searchtext","competencyframeworkid","done","competencies","addCompetencyChildren","parent","parentid","haschildren","children","comp","fail","selector","getContent","find","_getFramework","fid","frm","f","_loadFrameworks","framework","sort","context","contextid","includes","onlyvisible","frameworks","type","handler","_preRender","html","replaceWith","search","setDisallowedCompetencyIDs","ids","trigger"],"mappings":";;;;;;;;;;;AA2BAA,OAAO,2BAAA,CAAC,SACA,oBACA,YACA,iBACA,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1D,MAAK,WAErB3B,KAAKT,kBACNrB,EAAEwC,KAAKV,KAAKf,aAAa,SAAS+B,EAAG4D,WAC7BA,UAAU3D,IAAMjB,KAAKV,aACrBsF,UAAUrE,UAAW,EAErBqE,UAAUrE,UAAW,CAE7B,IAGJ,IAAIuE,QAAU,CACVlB,aAAc5D,KAAKP,cACnBmF,UAAW5E,KAAKuE,cAAcvE,KAAKV,cACnC4F,WAAYlF,KAAKf,YACjBuG,OAAQxF,KAAKJ,YACbhB,gBAAiBoB,KAAKT,kBAG1B,OAAOlB,UAAU6E,OAAO,4BAA6B4B,QACzD,KAUJpG,OAAOc,UAAUN,OAAS,WACtBH,KAAKU,cAAgB,GACrBV,KAAKW,yBAA2B,GAChCX,KAAKY,OAAS,KACdZ,KAAKa,YAAc,GACnBb,KAAKc,sBAAwB,IAWjCnB,OAAOc,UAAUiG,2BAA6B,SAASC,KACnD3G,KAAKW,yBAA2BgG,KAUpChH,OAAOc,UAAU4C,SAAW,SAAS+C,KAAMrE,MACvC/B,KAAKC,WAAW2G,QAAQR,KAAM,CAACrE,QAG5BpC,MAEX"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencypicker_user_plans.min.js.map b/admin/tool/lp/amd/build/competencypicker_user_plans.min.js.map index 26cd77c5717..e335b578fb7 100644 --- a/admin/tool/lp/amd/build/competencypicker_user_plans.min.js.map +++ b/admin/tool/lp/amd/build/competencypicker_user_plans.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competencypicker_user_plans.min.js","sources":["../src/competencypicker_user_plans.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency picker from user plans.\n *\n * To handle 'save' events use: picker.on('save').\n *\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @module tool_lp/competencypicker_user_plans\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/tree',\n 'tool_lp/competencypicker'\n ],\n function($, Notification, Ajax, Templates, Str, Tree, PickerBase) {\n\n /**\n * Competency picker in plan class.\n *\n * @class tool_lp/competencypicker_user_plans\n * @param {Number} userId\n * @param {Number|false} singlePlan The ID of the plan when limited to one.\n * @param {Boolean} multiSelect Support multi-select in the tree.\n */\n var Picker = function(userId, singlePlan, multiSelect) {\n PickerBase.prototype.constructor.apply(this, [1, false, 'self', multiSelect]);\n this._userId = userId;\n this._plans = [];\n\n if (singlePlan) {\n this._planId = singlePlan;\n this._singlePlan = true;\n }\n };\n Picker.prototype = Object.create(PickerBase.prototype);\n\n /** @property {Array} The list of plans fetched. */\n Picker.prototype._plans = null;\n /** @property {Number} The current plan ID. */\n Picker.prototype._planId = null;\n /** @property {Boolean} Whether we can browse plans or not. */\n Picker.prototype._singlePlan = false;\n /** @property {Number} The user the plans belongs to. */\n Picker.prototype._userId = null;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n Picker.prototype._afterRender = function() {\n var self = this;\n PickerBase.prototype._afterRender.apply(self, arguments);\n\n // Add listener for framework change.\n if (!self._singlePlan) {\n self._find('[data-action=\"chooseplan\"]').change(function(e) {\n self._planId = $(e.target).val();\n self._loadCompetencies().then(self._refresh.bind(self))\n .catch(Notification.exception);\n });\n }\n };\n\n /**\n * Fetch the competencies.\n *\n * @param {Number} planId The planId.\n * @param {String} searchText Limit the competencies to those matching the text.\n * @method _fetchCompetencies\n * @return {Promise} The promise object.\n */\n Picker.prototype._fetchCompetencies = function(planId, searchText) {\n var self = this;\n\n return Ajax.call([\n {methodname: 'core_competency_list_plan_competencies', args: {\n id: planId\n }}\n ])[0].done(function(competencies) {\n\n // Expand the list of competencies into a fake tree.\n var i, comp;\n var tree = [];\n for (i = 0; i < competencies.length; i++) {\n comp = competencies[i].competency;\n if (comp.shortname.toLowerCase().indexOf(searchText.toLowerCase()) < 0) {\n continue;\n }\n comp.children = [];\n comp.haschildren = 0;\n tree.push(comp);\n }\n\n self._competencies = tree;\n\n }).fail(Notification.exception);\n };\n\n /**\n * Convenience method to get a plan object.\n *\n * @param {Number} id The plan ID.\n * @return {Object|undefined} The plan.\n * @method _getPlan\n */\n Picker.prototype._getPlan = function(id) {\n var plan;\n $.each(this._plans, function(i, f) {\n if (f.id == id) {\n plan = f;\n return;\n }\n });\n return plan;\n };\n\n /**\n * Load the competencies.\n *\n * @method _loadCompetencies\n * @return {Promise}\n */\n Picker.prototype._loadCompetencies = function() {\n return this._fetchCompetencies(this._planId, this._searchText);\n };\n\n /**\n * Load the plans.\n *\n * @method _loadPlans\n * @return {Promise}\n */\n Picker.prototype._loadPlans = function() {\n var promise,\n self = this;\n\n // Quit early because we already have the data.\n if (self._plans.length > 0) {\n return $.when();\n }\n\n if (self._singlePlan) {\n promise = Ajax.call([\n {methodname: 'core_competency_read_plan', args: {\n id: this._planId\n }}\n ])[0].then(function(plan) {\n return [plan];\n });\n } else {\n promise = Ajax.call([\n {methodname: 'core_competency_list_user_plans', args: {\n userid: self._userId\n }}\n ])[0];\n }\n\n return promise.done(function(plans) {\n self._plans = plans;\n }).fail(Notification.exception);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @return {Promise}\n */\n Picker.prototype._preRender = function() {\n var self = this;\n return self._loadPlans().then(function() {\n if (!self._planId && self._plans.length > 0) {\n self._planId = self._plans[0].id;\n }\n\n // We could not set a framework ID, that probably means there are no frameworks accessible.\n if (!self._planId) {\n self._plans = [];\n return $.when();\n }\n\n return self._loadCompetencies();\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n Picker.prototype._render = function() {\n var self = this;\n return self._preRender().then(function() {\n\n if (!self._singlePlan) {\n $.each(self._plans, function(i, plan) {\n if (plan.id == self._planId) {\n plan.selected = true;\n } else {\n plan.selected = false;\n }\n });\n }\n\n var context = {\n competencies: self._competencies,\n plan: self._getPlan(self._planId),\n plans: self._plans,\n search: self._searchText,\n singlePlan: self._singlePlan,\n };\n\n return Templates.render('tool_lp/competency_picker_user_plans', context);\n });\n };\n\n return Picker;\n});\n"],"names":["define","$","Notification","Ajax","Templates","Str","Tree","PickerBase","Picker","userId","singlePlan","multiSelect","prototype","constructor","apply","this","_userId","_plans","_planId","_singlePlan","Object","create","_afterRender","self","arguments","_find","change","e","target","val","_loadCompetencies","then","_refresh","bind","catch","exception","_fetchCompetencies","planId","searchText","call","methodname","args","id","done","competencies","i","comp","tree","length","competency","shortname","toLowerCase","indexOf","children","haschildren","push","_competencies","fail","_getPlan","plan","each","f","_searchText","_loadPlans","when","userid","plans","_preRender","_render","selected","context","search","render"],"mappings":";;;;;;;;;;;;AA4BAA,6CAAO,CAAC,SACA,oBACA,YACA,iBACA,WACA,eACA,6BAEA,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,IAAKC,KAAMC,gBAUtDC,OAAS,SAASC,OAAQC,WAAYC,aACtCJ,WAAWK,UAAUC,YAAYC,MAAMC,KAAM,CAAC,GAAG,EAAO,OAAQJ,mBAC3DK,QAAUP,YACVQ,OAAS,GAEVP,kBACKQ,QAAUR,gBACVS,aAAc,WAG3BX,OAAOI,UAAYQ,OAAOC,OAAOd,WAAWK,YAG3BK,OAAS,KAE1BT,OAAOI,UAAUM,QAAU,KAE3BV,OAAOI,UAAUO,aAAc,EAE/BX,OAAOI,UAAUI,QAAU,KAO3BR,OAAOI,UAAUU,aAAe,eACxBC,KAAOR,KACXR,WAAWK,UAAUU,aAAaR,MAAMS,K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UAAUuD,WAAa,eACtB5C,KAAOR,YACJQ,KAAKwC,aAAahC,MAAK,kBACrBR,KAAKL,SAAWK,KAAKN,OAAO+B,OAAS,IACtCzB,KAAKL,QAAUK,KAAKN,OAAO,GAAGyB,IAI7BnB,KAAKL,QAKHK,KAAKO,qBAJRP,KAAKN,OAAS,GACPhB,EAAE+D,YAarBxD,OAAOI,UAAUwD,QAAU,eACnB7C,KAAOR,YACJQ,KAAK4C,aAAapC,MAAK,WAErBR,KAAKJ,aACNlB,EAAE2D,KAAKrC,KAAKN,QAAQ,SAAS4B,EAAGc,MACxBA,KAAKjB,IAAMnB,KAAKL,QAChByC,KAAKU,UAAW,EAEhBV,KAAKU,UAAW,SAKxBC,QAAU,CACV1B,aAAcrB,KAAKiC,cACnBG,KAAMpC,KAAKmC,SAASnC,KAAKL,SACzBgD,MAAO3C,KAAKN,OACZsD,OAAQhD,KAAKuC,YACbpD,WAAYa,KAAKJ,oBAGdf,UAAUoE,OAAO,uCAAwCF,aAIjE9D"} \ No newline at end of file +{"version":3,"file":"competencypicker_user_plans.min.js","sources":["../src/competencypicker_user_plans.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency picker from user plans.\n *\n * To handle 'save' events use: picker.on('save').\n *\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @module tool_lp/competencypicker_user_plans\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/tree',\n 'tool_lp/competencypicker'\n ],\n function($, Notification, Ajax, Templates, Str, Tree, PickerBase) {\n\n /**\n * Competency picker in plan class.\n *\n * @class tool_lp/competencypicker_user_plans\n * @param {Number} userId\n * @param {Number|false} singlePlan The ID of the plan when limited to one.\n * @param {Boolean} multiSelect Support multi-select in the tree.\n */\n var Picker = function(userId, singlePlan, multiSelect) {\n PickerBase.prototype.constructor.apply(this, [1, false, 'self', multiSelect]);\n this._userId = userId;\n this._plans = [];\n\n if (singlePlan) {\n this._planId = singlePlan;\n this._singlePlan = true;\n }\n };\n Picker.prototype = Object.create(PickerBase.prototype);\n\n /** @property {Array} The list of plans fetched. */\n Picker.prototype._plans = null;\n /** @property {Number} The current plan ID. */\n Picker.prototype._planId = null;\n /** @property {Boolean} Whether we can browse plans or not. */\n Picker.prototype._singlePlan = false;\n /** @property {Number} The user the plans belongs to. */\n Picker.prototype._userId = null;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n Picker.prototype._afterRender = function() {\n var self = this;\n PickerBase.prototype._afterRender.apply(self, arguments);\n\n // Add listener for framework change.\n if (!self._singlePlan) {\n self._find('[data-action=\"chooseplan\"]').change(function(e) {\n self._planId = $(e.target).val();\n self._loadCompetencies().then(self._refresh.bind(self))\n .catch(Notification.exception);\n });\n }\n };\n\n /**\n * Fetch the competencies.\n *\n * @param {Number} planId The planId.\n * @param {String} searchText Limit the competencies to those matching the text.\n * @method _fetchCompetencies\n * @return {Promise} The promise object.\n */\n Picker.prototype._fetchCompetencies = function(planId, searchText) {\n var self = this;\n\n return Ajax.call([\n {methodname: 'core_competency_list_plan_competencies', args: {\n id: planId\n }}\n ])[0].done(function(competencies) {\n\n // Expand the list of competencies into a fake tree.\n var i, comp;\n var tree = [];\n for (i = 0; i < competencies.length; i++) {\n comp = competencies[i].competency;\n if (comp.shortname.toLowerCase().indexOf(searchText.toLowerCase()) < 0) {\n continue;\n }\n comp.children = [];\n comp.haschildren = 0;\n tree.push(comp);\n }\n\n self._competencies = tree;\n\n }).fail(Notification.exception);\n };\n\n /**\n * Convenience method to get a plan object.\n *\n * @param {Number} id The plan ID.\n * @return {Object|undefined} The plan.\n * @method _getPlan\n */\n Picker.prototype._getPlan = function(id) {\n var plan;\n $.each(this._plans, function(i, f) {\n if (f.id == id) {\n plan = f;\n return;\n }\n });\n return plan;\n };\n\n /**\n * Load the competencies.\n *\n * @method _loadCompetencies\n * @return {Promise}\n */\n Picker.prototype._loadCompetencies = function() {\n return this._fetchCompetencies(this._planId, this._searchText);\n };\n\n /**\n * Load the plans.\n *\n * @method _loadPlans\n * @return {Promise}\n */\n Picker.prototype._loadPlans = function() {\n var promise,\n self = this;\n\n // Quit early because we already have the data.\n if (self._plans.length > 0) {\n return $.when();\n }\n\n if (self._singlePlan) {\n promise = Ajax.call([\n {methodname: 'core_competency_read_plan', args: {\n id: this._planId\n }}\n ])[0].then(function(plan) {\n return [plan];\n });\n } else {\n promise = Ajax.call([\n {methodname: 'core_competency_list_user_plans', args: {\n userid: self._userId\n }}\n ])[0];\n }\n\n return promise.done(function(plans) {\n self._plans = plans;\n }).fail(Notification.exception);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @return {Promise}\n */\n Picker.prototype._preRender = function() {\n var self = this;\n return self._loadPlans().then(function() {\n if (!self._planId && self._plans.length > 0) {\n self._planId = self._plans[0].id;\n }\n\n // We could not set a framework ID, that probably means there are no frameworks accessible.\n if (!self._planId) {\n self._plans = [];\n return $.when();\n }\n\n return self._loadCompetencies();\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n Picker.prototype._render = function() {\n var self = this;\n return self._preRender().then(function() {\n\n if (!self._singlePlan) {\n $.each(self._plans, function(i, plan) {\n if (plan.id == self._planId) {\n plan.selected = true;\n } else {\n plan.selected = false;\n }\n });\n }\n\n var context = {\n competencies: self._competencies,\n plan: self._getPlan(self._planId),\n plans: self._plans,\n search: self._searchText,\n singlePlan: self._singlePlan,\n };\n\n return Templates.render('tool_lp/competency_picker_user_plans', context);\n });\n };\n\n return Picker;\n});\n"],"names":["define","$","Notification","Ajax","Templates","Str","Tree","PickerBase","Picker","userId","singlePlan","multiSelect","prototype","constructor","apply","this","_userId","_plans","_planId","_singlePlan","Object","create","_afterRender","self","arguments","_find","change","e","target","val","_loadCompetencies","then","_refresh","bind","catch","exception","_fetchCompetencies","planId","searchText","call","methodname","args","id","done","competencies","i","comp","tree","length","competency","shortname","toLowerCase","indexOf","children","haschildren","push","_competencies","fail","_getPlan","plan","each","f","_searchText","_loadPlans","when","userid","plans","_preRender","_render","selected","context","search","render"],"mappings":";;;;;;;;;;;;AA4BAA,OAAO,sCAAA,CAAC,SACA,oBACA,YACA,iBACA,WACA,eACA,6BAEA,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,IAAKC,KAAMC,YAU1D,IAAIC,OAAS,SAASC,OAAQC,WAAYC,aACtCJ,WAAWK,UAAUC,YAAYC,MAAMC,KAAM,CAAC,GAAG,EAAO,OAAQJ,cAChEI,KAAKC,QAAUP,OACfM,KAAKE,OAAS,GAEVP,aACAK,KAAKG,QAAUR,WACfK,KAAKI,aAAc,IA2L3B,OAxLAX,OAAOI,UAAYQ,OAAOC,OAAOd,WAAWK,YAG3BK,OAAS,KAE1BT,OAAOI,UAAUM,QAAU,KAE3BV,OAAOI,UAAUO,aAAc,EAE/BX,OAAOI,UAAUI,QAAU,KAO3BR,OAAOI,UAAUU,aAAe,WAC5B,IAAIC,KAAOR,KACXR,WAAWK,UAAUU,aAAaR,MAAMS,KAAMC,WAGzCD,KAAKJ,aACNI,KAAKE,MAAM,8BAA8BC,QAAO,SAASC,GACrDJ,KAAKL,QAAUjB,EAAE0B,EAAEC,QAAQC,MAC3BN,KAAKO,oBAAoBC,KAAKR,KAAKS,SAASC,KAAKV,OAChDW,MAAMhC,aAAaiC,UACxB,KAYR3B,OAAOI,UAAUw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,QAAUK,KAAKN,OAAO,GAAGyB,IAI7BnB,KAAKL,QAKHK,KAAKO,qBAJRP,KAAKN,OAAS,GACPhB,EAAE+D,OAIjB,KASJxD,OAAOI,UAAUwD,QAAU,WACvB,IAAI7C,KAAOR,KACX,OAAOQ,KAAK4C,aAAapC,MAAK,WAErBR,KAAKJ,aACNlB,EAAE2D,KAAKrC,KAAKN,QAAQ,SAAS4B,EAAGc,MACxBA,KAAKjB,IAAMnB,KAAKL,QAChByC,KAAKU,UAAW,EAEhBV,KAAKU,UAAW,CAExB,IAGJ,IAAIC,QAAU,CACV1B,aAAcrB,KAAKiC,cACnBG,KAAMpC,KAAKmC,SAASnC,KAAKL,SACzBgD,MAAO3C,KAAKN,OACZsD,OAAQhD,KAAKuC,YACbpD,WAAYa,KAAKJ,aAGrB,OAAOf,UAAUoE,OAAO,uCAAwCF,QACpE,KAGG9D,MACX"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencyruleconfig.min.js.map b/admin/tool/lp/amd/build/competencyruleconfig.min.js.map index b288205ebb3..662a2b995d5 100644 --- a/admin/tool/lp/amd/build/competencyruleconfig.min.js.map +++ b/admin/tool/lp/amd/build/competencyruleconfig.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competencyruleconfig.min.js","sources":["../src/competencyruleconfig.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency rule config.\n *\n * @module tool_lp/competencyruleconfig\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/competency_outcomes',\n 'core/str'],\n function($, Notification, Templates, Dialogue, Outcomes, Str) {\n\n /**\n * Competency rule class.\n *\n * When implementing this you should attach a listener to the event 'save'\n * on the instance. E.g.\n *\n * var config = new RuleConfig(tree, modules);\n * config.on('save', function(e, config) { ... });\n *\n * @param {competencytree} tree The competency tree.\n * @param {Array} rulesModules The modules containing the rules: [{ typeName: { amd: amdModule, name: ruleName }}].\n */\n var RuleConfig = function(tree, rulesModules) {\n this._eventNode = $('
');\n this._tree = tree;\n this._rulesModules = rulesModules;\n this._setUp();\n };\n\n /** @property {Object} The current competency. */\n RuleConfig.prototype._competency = null;\n /** @property {Node} The node we attach the events to. */\n RuleConfig.prototype._eventNode = null;\n /** @property {Array} Outcomes options. */\n RuleConfig.prototype._outcomesOption = null;\n /** @property {Dialogue} The dialogue. */\n RuleConfig.prototype._popup = null;\n /** @property {Promise} Resolved when the module is ready. */\n RuleConfig.prototype._ready = null;\n /** @property {Array} The rules. */\n RuleConfig.prototype._rules = null;\n /** @property {Array} The rules modules. */\n RuleConfig.prototype._rulesModules = null;\n /** @property {competencytree} The competency tree. */\n RuleConfig.prototype._tree = null;\n\n /**\n * After change.\n *\n * Triggered when a change occured.\n *\n * @method _afterChange\n * @protected\n */\n RuleConfig.prototype._afterChange = function() {\n if (!this._isValid()) {\n this._find('[data-action=\"save\"]').prop('disabled', true);\n } else {\n this._find('[data-action=\"save\"]').prop('disabled', false);\n }\n };\n\n /**\n * After change in rule's config.\n *\n * Triggered when a change occured in a specific rule config.\n *\n * @method _afterRuleConfigChange\n * @protected\n * @param {Event} e\n * @param {Rule} rule\n */\n RuleConfig.prototype._afterRuleConfigChange = function(e, rule) {\n if (rule != this._getRule()) {\n // This rule is not the current one any more, we can ignore.\n return;\n }\n this._afterChange();\n };\n\n /**\n * After render hook.\n *\n * @method _afterRender\n * @protected\n */\n RuleConfig.prototype._afterRender = function() {\n var self = this;\n\n self._find('[name=\"outcome\"]').on('change', function() {\n self._switchedOutcome();\n }).trigger('change');\n\n self._find('[name=\"rule\"]').on('change', function() {\n self._switchedRule();\n }).trigger('change');\n\n self._find('[data-action=\"save\"]').on('click', function() {\n self._trigger('save', self._getConfig());\n self.close();\n });\n\n self._find('[data-action=\"cancel\"]').on('click', function() {\n self.close();\n });\n };\n\n /**\n * Whether the current competency can be configured.\n *\n * @return {Boolean}\n * @method canBeConfigured\n */\n RuleConfig.prototype.canBeConfigured = function() {\n var can = false;\n $.each(this._rules, function(index, rule) {\n if (rule.canConfig()) {\n can = true;\n return;\n }\n });\n return can;\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n RuleConfig.prototype.close = function() {\n this._popup.close();\n this._popup = null;\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @returns {Promise}\n */\n RuleConfig.prototype.display = function() {\n var self = this;\n if (!self._competency) {\n return false;\n }\n return $.when(Str.get_string('competencyrule', 'tool_lp'), self._render())\n .then(function(title, render) {\n self._popup = new Dialogue(\n title,\n render[0],\n self._afterRender.bind(self),\n null,\n false,\n '515px'\n );\n return;\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery}\n * @method _find\n * @protected\n */\n RuleConfig.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Get the applicable outcome options.\n *\n * @return {Array}\n * @method _getApplicableOutcomesOptions\n * @protected\n */\n RuleConfig.prototype._getApplicableOutcomesOptions = function() {\n var self = this,\n options = [];\n\n $.each(self._outcomesOption, function(index, outcome) {\n options.push({\n code: outcome.code,\n name: outcome.name,\n selected: (outcome.code == self._competency.ruleoutcome) ? true : false,\n });\n });\n\n return options;\n };\n\n /**\n * Get the applicable rules options.\n *\n * @return {Array}\n * @method _getApplicableRulesOptions\n * @protected\n */\n RuleConfig.prototype._getApplicableRulesOptions = function() {\n var self = this,\n options = [];\n\n $.each(self._rules, function(index, rule) {\n if (!rule.canConfig()) {\n return;\n }\n options.push({\n name: self._getRuleName(rule.getType()),\n type: rule.getType(),\n selected: (rule.getType() == self._competency.ruletype) ? true : false,\n });\n });\n\n return options;\n };\n\n /**\n * Get the full config for the competency.\n *\n * @return {Object} Contains rule, ruleoutcome and ruleconfig.\n * @method _getConfig\n * @protected\n */\n RuleConfig.prototype._getConfig = function() {\n var rule = this._getRule();\n return {\n ruletype: rule ? rule.getType() : null,\n ruleconfig: rule ? rule.getConfig() : null,\n ruleoutcome: this._getOutcome()\n };\n };\n\n /**\n * Get the selected outcome code.\n *\n * @return {String}\n * @method _getOutcome\n * @protected\n */\n RuleConfig.prototype._getOutcome = function() {\n return this._find('[name=\"outcome\"]').val();\n };\n\n /**\n * Get the selected rule.\n *\n * @return {null|Rule}\n * @method _getRule\n * @protected\n */\n RuleConfig.prototype._getRule = function() {\n var result,\n type = this._find('[name=\"rule\"]').val();\n\n $.each(this._rules, function(index, rule) {\n if (rule.getType() == type) {\n result = rule;\n return;\n }\n });\n\n return result;\n };\n\n /**\n * Return the name of a rule.\n *\n * @param {String} type The type of a rule.\n * @return {String}\n * @method _getRuleName\n * @protected\n */\n RuleConfig.prototype._getRuleName = function(type) {\n var self = this,\n name;\n $.each(self._rulesModules, function(index, modInfo) {\n if (modInfo.type == type) {\n name = modInfo.name;\n return;\n }\n });\n return name;\n };\n\n /**\n * Initialise the outcomes.\n *\n * @return {Promise}\n * @method _initOutcomes\n * @protected\n */\n RuleConfig.prototype._initOutcomes = function() {\n var self = this;\n return Outcomes.getAll().then(function(outcomes) {\n self._outcomesOption = outcomes;\n return;\n });\n };\n\n /**\n * Initialise the rules.\n *\n * @return {Promise}\n * @method _initRules\n * @protected\n */\n RuleConfig.prototype._initRules = function() {\n var self = this,\n promises = [];\n $.each(self._rules, function(index, rule) {\n var promise = rule.init().then(function() {\n rule.setTargetCompetency(self._competency);\n rule.on('change', self._afterRuleConfigChange.bind(self));\n return;\n }, function() {\n // Upon failure remove the rule, and resolve the promise.\n self._rules.splice(index, 1);\n return $.when();\n });\n promises.push(promise);\n });\n\n return $.when.apply($.when, promises);\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method _isValid\n * @protected\n */\n RuleConfig.prototype._isValid = function() {\n var outcome = this._getOutcome(),\n rule = this._getRule();\n\n if (outcome == Outcomes.NONE) {\n return true;\n } else if (!rule) {\n return false;\n }\n\n return rule.isValid();\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n RuleConfig.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @protected\n * @return {Promise}\n */\n RuleConfig.prototype._preRender = function() {\n // We need to have all the information about the rule plugins first.\n return this.ready();\n };\n\n /**\n * Returns a promise that is resolved when the module is ready.\n *\n * @return {Promise}\n * @method ready\n * @protected\n */\n RuleConfig.prototype.ready = function() {\n return this._ready.promise();\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @protected\n * @return {Promise}\n */\n RuleConfig.prototype._render = function() {\n var self = this;\n return this._preRender().then(function() {\n var config;\n\n if (!self.canBeConfigured()) {\n config = false;\n } else {\n config = {};\n config.outcomes = self._getApplicableOutcomesOptions();\n config.rules = self._getApplicableRulesOptions();\n }\n\n var context = {\n competencyshortname: self._competency.shortname,\n config: config\n };\n\n return Templates.render('tool_lp/competency_rule_config', context);\n });\n };\n\n /**\n * Set the target competency.\n *\n * @param {Number} competencyId The target competency Id.\n * @method setTargetCompetencyId\n */\n RuleConfig.prototype.setTargetCompetencyId = function(competencyId) {\n var self = this;\n self._competency = self._tree.getCompetency(competencyId);\n $.each(self._rules, function(index, rule) {\n rule.setTargetCompetency(self._competency);\n });\n };\n\n /**\n * Set up the instance.\n *\n * @method _setUp\n * @protected\n */\n RuleConfig.prototype._setUp = function() {\n var self = this,\n promises = [],\n modules = [];\n\n self._ready = $.Deferred();\n self._rules = [];\n\n $.each(self._rulesModules, function(index, rule) {\n modules.push(rule.amd);\n });\n\n // Load all the modules.\n require(modules, function() {\n $.each(arguments, function(index, Module) {\n // Instantiate the rule and listen to it.\n var rule = new Module(self._tree);\n self._rules.push(rule);\n });\n\n // Load all the option values.\n promises.push(self._initRules());\n promises.push(self._initOutcomes());\n\n // Ready when everything is done.\n $.when.apply($.when, promises).always(function() {\n self._ready.resolve();\n });\n });\n };\n\n /**\n * Called when the user switches outcome.\n *\n * @method _switchedOutcome\n * @protected\n */\n RuleConfig.prototype._switchedOutcome = function() {\n var self = this,\n type = self._getOutcome();\n\n if (type == Outcomes.NONE) {\n // Reset to defaults.\n self._find('[data-region=\"rule-type\"]').hide()\n .find('[name=\"rule\"]').val(-1);\n self._find('[data-region=\"rule-config\"]').empty().hide();\n self._afterChange();\n return;\n }\n\n self._find('[data-region=\"rule-type\"]').show();\n self._find('[data-region=\"rule-config\"]').show();\n self._afterChange();\n };\n\n /**\n * Called when the user switches rule.\n *\n * @method _switchedRule\n * @protected\n */\n RuleConfig.prototype._switchedRule = function() {\n var self = this,\n container = self._find('[data-region=\"rule-config\"]'),\n rule = self._getRule();\n\n if (!rule) {\n container.empty().hide();\n self._afterChange();\n return;\n }\n rule.injectTemplate(container).then(function() {\n container.show();\n return;\n }).always(function() {\n self._afterChange();\n }).catch(function() {\n container.empty().hide();\n });\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n * @protected\n */\n RuleConfig.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return /** @alias module:tool_lp/competencyruleconfig */ RuleConfig;\n\n});\n"],"names":["define","$","Notification","Templates","Dialogue","Outcomes","Str","RuleConfig","tree","rulesModules","_eventNode","_tree","_rulesModules","_setUp","prototype","_competency","_outcomesOption","_popup","_ready","_rules","_afterChange","this","_isValid","_find","prop","_afterRuleConfigChange","e","rule","_getRule","_afterRender","self","on","_switchedOutcome","trigger","_switchedRule","_trigger","_getConfig","close","canBeConfigured","can","each","index","canConfig","display","when","get_string","_render","then","title","render","bind","fail","exception","selector","getContent","find","_getApplicableOutcomesOptions","options","outcome","push","code","name","selected","ruleoutcome","_getApplicableRulesOptions","_getRuleName","getType","type","ruletype","ruleconfig","getConfig","_getOutcome","val","result","modInfo","_initOutcomes","getAll","outcomes","_initRules","promises","promise","init","setTargetCompetency","splice","apply","NONE","isValid","handler","_preRender","ready","config","rules","context","competencyshortname","shortname","setTargetCompetencyId","competencyId","getCompetency","modules","Deferred","amd","require","arguments","Module","always","resolve","hide","empty","show","container","injectTemplate","catch","data"],"mappings":";;;;;;;AAuBAA,sCAAO,CAAC,SACA,oBACA,iBACA,mBACA,8BACA,aACA,SAASC,EAAGC,aAAcC,UAAWC,SAAUC,SAAUC,SAczDC,WAAa,SAASC,KAAMC,mBACvBC,WAAaT,EAAE,oBACfU,MAAQH,UACRI,cAAgBH,kBAChBI,iBAITN,WAAWO,UAAUC,YAAc,KAEnCR,WAAWO,UAAUJ,WAAa,KAElCH,WAAWO,UAAUE,gBAAkB,KAEvCT,WAAWO,UAAUG,OAAS,KAE9BV,WAAWO,UAAUI,OAAS,KAE9BX,WAAWO,UAAUK,OAAS,KAE9BZ,WAAWO,UAAUF,cAAgB,KAErCL,WAAWO,UAAUH,MAAQ,KAU7BJ,WAAWO,UAAUM,aAAe,WAC3BC,KAAKC,gBAGDC,MAAM,wBAAwBC,KAAK,YAAY,QAF/CD,MAAM,wBAAwBC,KAAK,YAAY,IAgB5DjB,WAAWO,UAAUW,uBAAyB,SAASC,EAAGC,MAClDA,MAAQN,KAAKO,iBAIZR,gBASTb,WAAWO,UAAUe,aAAe,eAC5BC,KAAOT,KAEXS,KAAKP,MAAM,oBAAoBQ,GAAG,UAAU,WACxCD,KAAKE,sBACNC,QAAQ,UAEXH,KAAKP,MAAM,iBAAiBQ,GAAG,UAAU,WACrCD,KAAKI,mBACND,QAAQ,UAEXH,KAAKP,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M,+BAA+BoF,QAAQD,YAP3CrF,KAQFD,eAREC,KAYNE,MAAM,6BAA6BqF,OAZ7BvF,KAaNE,MAAM,+BAA+BqF,OAb/BvF,KAcND,gBASTb,WAAWO,UAAUoB,cAAgB,eAC7BJ,KAAOT,KACPwF,UAAY/E,KAAKP,MAAM,+BACvBI,KAAOG,KAAKF,eAEXD,YACDkF,UAAUF,QAAQD,YAClB5E,KAAKV,eAGTO,KAAKmF,eAAeD,WAAW9D,MAAK,WAChC8D,UAAUD,UAEXJ,QAAO,WACN1E,KAAKV,kBACN2F,OAAM,WACLF,UAAUF,QAAQD,WAY1BnG,WAAWO,UAAUqB,SAAW,SAASgC,KAAM6C,WACtCtG,WAAWuB,QAAQkC,KAAM,CAAC6C,QAGsBzG"} \ No newline at end of file +{"version":3,"file":"competencyruleconfig.min.js","sources":["../src/competencyruleconfig.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency rule config.\n *\n * @module tool_lp/competencyruleconfig\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/competency_outcomes',\n 'core/str'],\n function($, Notification, Templates, Dialogue, Outcomes, Str) {\n\n /**\n * Competency rule class.\n *\n * When implementing this you should attach a listener to the event 'save'\n * on the instance. E.g.\n *\n * var config = new RuleConfig(tree, modules);\n * config.on('save', function(e, config) { ... });\n *\n * @param {competencytree} tree The competency tree.\n * @param {Array} rulesModules The modules containing the rules: [{ typeName: { amd: amdModule, name: ruleName }}].\n */\n var RuleConfig = function(tree, rulesModules) {\n this._eventNode = $('
');\n this._tree = tree;\n this._rulesModules = rulesModules;\n this._setUp();\n };\n\n /** @property {Object} The current competency. */\n RuleConfig.prototype._competency = null;\n /** @property {Node} The node we attach the events to. */\n RuleConfig.prototype._eventNode = null;\n /** @property {Array} Outcomes options. */\n RuleConfig.prototype._outcomesOption = null;\n /** @property {Dialogue} The dialogue. */\n RuleConfig.prototype._popup = null;\n /** @property {Promise} Resolved when the module is ready. */\n RuleConfig.prototype._ready = null;\n /** @property {Array} The rules. */\n RuleConfig.prototype._rules = null;\n /** @property {Array} The rules modules. */\n RuleConfig.prototype._rulesModules = null;\n /** @property {competencytree} The competency tree. */\n RuleConfig.prototype._tree = null;\n\n /**\n * After change.\n *\n * Triggered when a change occured.\n *\n * @method _afterChange\n * @protected\n */\n RuleConfig.prototype._afterChange = function() {\n if (!this._isValid()) {\n this._find('[data-action=\"save\"]').prop('disabled', true);\n } else {\n this._find('[data-action=\"save\"]').prop('disabled', false);\n }\n };\n\n /**\n * After change in rule's config.\n *\n * Triggered when a change occured in a specific rule config.\n *\n * @method _afterRuleConfigChange\n * @protected\n * @param {Event} e\n * @param {Rule} rule\n */\n RuleConfig.prototype._afterRuleConfigChange = function(e, rule) {\n if (rule != this._getRule()) {\n // This rule is not the current one any more, we can ignore.\n return;\n }\n this._afterChange();\n };\n\n /**\n * After render hook.\n *\n * @method _afterRender\n * @protected\n */\n RuleConfig.prototype._afterRender = function() {\n var self = this;\n\n self._find('[name=\"outcome\"]').on('change', function() {\n self._switchedOutcome();\n }).trigger('change');\n\n self._find('[name=\"rule\"]').on('change', function() {\n self._switchedRule();\n }).trigger('change');\n\n self._find('[data-action=\"save\"]').on('click', function() {\n self._trigger('save', self._getConfig());\n self.close();\n });\n\n self._find('[data-action=\"cancel\"]').on('click', function() {\n self.close();\n });\n };\n\n /**\n * Whether the current competency can be configured.\n *\n * @return {Boolean}\n * @method canBeConfigured\n */\n RuleConfig.prototype.canBeConfigured = function() {\n var can = false;\n $.each(this._rules, function(index, rule) {\n if (rule.canConfig()) {\n can = true;\n return;\n }\n });\n return can;\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n RuleConfig.prototype.close = function() {\n this._popup.close();\n this._popup = null;\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @returns {Promise}\n */\n RuleConfig.prototype.display = function() {\n var self = this;\n if (!self._competency) {\n return false;\n }\n return $.when(Str.get_string('competencyrule', 'tool_lp'), self._render())\n .then(function(title, render) {\n self._popup = new Dialogue(\n title,\n render[0],\n self._afterRender.bind(self),\n null,\n false,\n '515px'\n );\n return;\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery}\n * @method _find\n * @protected\n */\n RuleConfig.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Get the applicable outcome options.\n *\n * @return {Array}\n * @method _getApplicableOutcomesOptions\n * @protected\n */\n RuleConfig.prototype._getApplicableOutcomesOptions = function() {\n var self = this,\n options = [];\n\n $.each(self._outcomesOption, function(index, outcome) {\n options.push({\n code: outcome.code,\n name: outcome.name,\n selected: (outcome.code == self._competency.ruleoutcome) ? true : false,\n });\n });\n\n return options;\n };\n\n /**\n * Get the applicable rules options.\n *\n * @return {Array}\n * @method _getApplicableRulesOptions\n * @protected\n */\n RuleConfig.prototype._getApplicableRulesOptions = function() {\n var self = this,\n options = [];\n\n $.each(self._rules, function(index, rule) {\n if (!rule.canConfig()) {\n return;\n }\n options.push({\n name: self._getRuleName(rule.getType()),\n type: rule.getType(),\n selected: (rule.getType() == self._competency.ruletype) ? true : false,\n });\n });\n\n return options;\n };\n\n /**\n * Get the full config for the competency.\n *\n * @return {Object} Contains rule, ruleoutcome and ruleconfig.\n * @method _getConfig\n * @protected\n */\n RuleConfig.prototype._getConfig = function() {\n var rule = this._getRule();\n return {\n ruletype: rule ? rule.getType() : null,\n ruleconfig: rule ? rule.getConfig() : null,\n ruleoutcome: this._getOutcome()\n };\n };\n\n /**\n * Get the selected outcome code.\n *\n * @return {String}\n * @method _getOutcome\n * @protected\n */\n RuleConfig.prototype._getOutcome = function() {\n return this._find('[name=\"outcome\"]').val();\n };\n\n /**\n * Get the selected rule.\n *\n * @return {null|Rule}\n * @method _getRule\n * @protected\n */\n RuleConfig.prototype._getRule = function() {\n var result,\n type = this._find('[name=\"rule\"]').val();\n\n $.each(this._rules, function(index, rule) {\n if (rule.getType() == type) {\n result = rule;\n return;\n }\n });\n\n return result;\n };\n\n /**\n * Return the name of a rule.\n *\n * @param {String} type The type of a rule.\n * @return {String}\n * @method _getRuleName\n * @protected\n */\n RuleConfig.prototype._getRuleName = function(type) {\n var self = this,\n name;\n $.each(self._rulesModules, function(index, modInfo) {\n if (modInfo.type == type) {\n name = modInfo.name;\n return;\n }\n });\n return name;\n };\n\n /**\n * Initialise the outcomes.\n *\n * @return {Promise}\n * @method _initOutcomes\n * @protected\n */\n RuleConfig.prototype._initOutcomes = function() {\n var self = this;\n return Outcomes.getAll().then(function(outcomes) {\n self._outcomesOption = outcomes;\n return;\n });\n };\n\n /**\n * Initialise the rules.\n *\n * @return {Promise}\n * @method _initRules\n * @protected\n */\n RuleConfig.prototype._initRules = function() {\n var self = this,\n promises = [];\n $.each(self._rules, function(index, rule) {\n var promise = rule.init().then(function() {\n rule.setTargetCompetency(self._competency);\n rule.on('change', self._afterRuleConfigChange.bind(self));\n return;\n }, function() {\n // Upon failure remove the rule, and resolve the promise.\n self._rules.splice(index, 1);\n return $.when();\n });\n promises.push(promise);\n });\n\n return $.when.apply($.when, promises);\n };\n\n /**\n * Whether or not the current config is valid.\n *\n * @return {Boolean}\n * @method _isValid\n * @protected\n */\n RuleConfig.prototype._isValid = function() {\n var outcome = this._getOutcome(),\n rule = this._getRule();\n\n if (outcome == Outcomes.NONE) {\n return true;\n } else if (!rule) {\n return false;\n }\n\n return rule.isValid();\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n RuleConfig.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @protected\n * @return {Promise}\n */\n RuleConfig.prototype._preRender = function() {\n // We need to have all the information about the rule plugins first.\n return this.ready();\n };\n\n /**\n * Returns a promise that is resolved when the module is ready.\n *\n * @return {Promise}\n * @method ready\n * @protected\n */\n RuleConfig.prototype.ready = function() {\n return this._ready.promise();\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @protected\n * @return {Promise}\n */\n RuleConfig.prototype._render = function() {\n var self = this;\n return this._preRender().then(function() {\n var config;\n\n if (!self.canBeConfigured()) {\n config = false;\n } else {\n config = {};\n config.outcomes = self._getApplicableOutcomesOptions();\n config.rules = self._getApplicableRulesOptions();\n }\n\n var context = {\n competencyshortname: self._competency.shortname,\n config: config\n };\n\n return Templates.render('tool_lp/competency_rule_config', context);\n });\n };\n\n /**\n * Set the target competency.\n *\n * @param {Number} competencyId The target competency Id.\n * @method setTargetCompetencyId\n */\n RuleConfig.prototype.setTargetCompetencyId = function(competencyId) {\n var self = this;\n self._competency = self._tree.getCompetency(competencyId);\n $.each(self._rules, function(index, rule) {\n rule.setTargetCompetency(self._competency);\n });\n };\n\n /**\n * Set up the instance.\n *\n * @method _setUp\n * @protected\n */\n RuleConfig.prototype._setUp = function() {\n var self = this,\n promises = [],\n modules = [];\n\n self._ready = $.Deferred();\n self._rules = [];\n\n $.each(self._rulesModules, function(index, rule) {\n modules.push(rule.amd);\n });\n\n // Load all the modules.\n require(modules, function() {\n $.each(arguments, function(index, Module) {\n // Instantiate the rule and listen to it.\n var rule = new Module(self._tree);\n self._rules.push(rule);\n });\n\n // Load all the option values.\n promises.push(self._initRules());\n promises.push(self._initOutcomes());\n\n // Ready when everything is done.\n $.when.apply($.when, promises).always(function() {\n self._ready.resolve();\n });\n });\n };\n\n /**\n * Called when the user switches outcome.\n *\n * @method _switchedOutcome\n * @protected\n */\n RuleConfig.prototype._switchedOutcome = function() {\n var self = this,\n type = self._getOutcome();\n\n if (type == Outcomes.NONE) {\n // Reset to defaults.\n self._find('[data-region=\"rule-type\"]').hide()\n .find('[name=\"rule\"]').val(-1);\n self._find('[data-region=\"rule-config\"]').empty().hide();\n self._afterChange();\n return;\n }\n\n self._find('[data-region=\"rule-type\"]').show();\n self._find('[data-region=\"rule-config\"]').show();\n self._afterChange();\n };\n\n /**\n * Called when the user switches rule.\n *\n * @method _switchedRule\n * @protected\n */\n RuleConfig.prototype._switchedRule = function() {\n var self = this,\n container = self._find('[data-region=\"rule-config\"]'),\n rule = self._getRule();\n\n if (!rule) {\n container.empty().hide();\n self._afterChange();\n return;\n }\n rule.injectTemplate(container).then(function() {\n container.show();\n return;\n }).always(function() {\n self._afterChange();\n }).catch(function() {\n container.empty().hide();\n });\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n * @protected\n */\n RuleConfig.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return /** @alias module:tool_lp/competencyruleconfig */ RuleConfig;\n\n});\n"],"names":["define","$","Notification","Templates","Dialogue","Outcomes","Str","RuleConfig","tree","rulesModules","this","_eventNode","_tree","_rulesModules","_setUp","prototype","_competency","_outcomesOption","_popup","_ready","_rules","_afterChange","_isValid","_find","prop","_afterRuleConfigChange","e","rule","_getRule","_afterRender","self","on","_switchedOutcome","trigger","_switchedRule","_trigger","_getConfig","close","canBeConfigured","can","each","index","canConfig","display","when","get_string","_render","then","title","render","bind","fail","exception","selector","getContent","find","_getApplicableOutcomesOptions","options","outcome","push","code","name","selected","ruleoutcome","_getApplicableRulesOptions","_getRuleName","getType","type","ruletype","ruleconfig","getConfig","_getOutcome","val","result","modInfo","_initOutcomes","getAll","outcomes","_initRules","promises","promise","init","setTargetCompetency","splice","apply","NONE","isValid","handler","_preRender","ready","config","rules","context","competencyshortname","shortname","setTargetCompetencyId","competencyId","getCompetency","modules","Deferred","amd","require","arguments","Module","always","resolve","hide","empty","show","container","injectTemplate","catch","data"],"mappings":";;;;;;;AAuBAA,OAAM,+BAAC,CAAC,SACA,oBACA,iBACA,mBACA,8BACA,aACA,SAASC,EAAGC,aAAcC,UAAWC,SAAUC,SAAUC,KAc7D,IAAIC,WAAa,SAASC,KAAMC,cAC5BC,KAAKC,WAAaV,EAAE,eACpBS,KAAKE,MAAQJ,KACbE,KAAKG,cAAgBJ,aACrBC,KAAKI,UAifT,OA7eAP,WAAWQ,UAAUC,YAAc,KAEnCT,WAAWQ,UAAUJ,WAAa,KAElCJ,WAAWQ,UAAUE,gBAAkB,KAEvCV,WAAWQ,UAAUG,OAAS,KAE9BX,WAAWQ,UAAUI,OAAS,KAE9BZ,WAAWQ,UAAUK,OAAS,KAE9Bb,WAAWQ,UAAUF,cAAgB,KAErCN,WAAWQ,UAAUH,MAAQ,KAU7BL,WAAWQ,UAAUM,aAAe,WAC3BX,KAAKY,WAGNZ,KAAKa,MAAM,wBAAwBC,KAAK,YAAY,GAFpDd,KAAKa,MAAM,wBAAwBC,KAAK,YAAY,IAgB5DjB,WAAWQ,UAAUU,uBAAyB,SAASC,EAAGC,MAClDA,MAAQjB,KAAKkB,YAIjBlB,KAAKW,gBASTd,WAAWQ,UAAUc,aAAe,WAChC,IAAIC,KAAOpB,KAEXoB,KAAKP,MAAM,oBAAoBQ,GAAG,UAAU,WACxCD,KAAKE,kBACT,IAAGC,QAAQ,UAEXH,KAAKP,MAAM,iBAAiBQ,GAAG,UAAU,WACrCD,KAAKI,eACT,IAAGD,QAAQ,UAEXH,KAAKP,MAAM,wBAAwBQ,GAAG,SAAS,WAC3CD,KAAKK,SAAS,OAAQL,KAAKM,cAC3BN,KAAKO,OACT,IAEAP,KAAKP,MAAM,0BAA0BQ,GAAG,SAAS,WAC7CD,KAAKO,OACT,KASJ9B,WAAW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yB,QAAO,WAClC1E,KAAKX,OAAOsF,SAChB,GACJ,KASJlG,WAAWQ,UAAUiB,iBAAmB,WAIpC,GAHWtB,KACK6D,eAEJlE,SAASgF,KAMjB,OATO3E,KAKFa,MAAM,6BAA6BmF,OACnCnD,KAAK,iBAAiBiB,KAAK,GANzB9D,KAOFa,MAAM,+BAA+BoF,QAAQD,YAP3ChG,KAQFW,eAREX,KAYNa,MAAM,6BAA6BqF,OAZ7BlG,KAaNa,MAAM,+BAA+BqF,OAb/BlG,KAcNW,gBASTd,WAAWQ,UAAUmB,cAAgB,WACjC,IAAIJ,KAAOpB,KACPmG,UAAY/E,KAAKP,MAAM,+BACvBI,KAAOG,KAAKF,WAEhB,IAAKD,KAGD,OAFAkF,UAAUF,QAAQD,YAClB5E,KAAKT,eAGTM,KAAKmF,eAAeD,WAAW9D,MAAK,WAChC8D,UAAUD,MAEd,IAAGJ,QAAO,WACN1E,KAAKT,cACT,IAAG0F,OAAM,WACLF,UAAUF,QAAQD,MACtB,KAWJnG,WAAWQ,UAAUoB,SAAW,SAASgC,KAAM6C,MAC3CtG,KAAKC,WAAWsB,QAAQkC,KAAM,CAAC6C,QAGsBzG,UAE7D"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencytree.min.js.map b/admin/tool/lp/amd/build/competencytree.min.js.map index 30b8cbf7e8e..c28221adb54 100644 --- a/admin/tool/lp/amd/build/competencytree.min.js.map +++ b/admin/tool/lp/amd/build/competencytree.min.js.map @@ -1 +1 @@ -{"version":3,"file":"competencytree.min.js","sources":["../src/competencytree.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle selection changes on the competency tree.\n *\n * @module tool_lp/competencyselect\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/ajax', 'core/notification', 'core/templates', 'tool_lp/tree', 'tool_lp/competency_outcomes', 'jquery'],\n function(ajax, notification, templates, Ariatree, CompOutcomes, $) {\n\n // Private variables and functions.\n /** @var {Object[]} competencies - Cached list of competencies */\n var competencies = {};\n\n /** @var {Number} competencyFrameworkId - The current framework id */\n var competencyFrameworkId = 0;\n\n /** @var {String} competencyFrameworkShortName - The current framework short name */\n var competencyFrameworkShortName = '';\n\n /** @var {String} treeSelector - The selector for the root of the tree. */\n var treeSelector = '';\n\n /** @var {String} currentNodeId - The data-id of the current node in the tree. */\n var currentNodeId = '';\n\n /** @var {Boolean} competencyFramworkCanManage - Can manage the competencies framework */\n var competencyFramworkCanManage = false;\n\n /**\n * Build a tree from the flat list of competencies.\n * @param {Object} parent The parent competency.\n * @param {Array} all The list of all competencies.\n */\n var addChildren = function(parent, all) {\n var i = 0;\n var current = false;\n parent.haschildren = false;\n parent.children = [];\n for (i = 0; i < all.length; i++) {\n current = all[i];\n if (current.parentid == parent.id) {\n parent.haschildren = true;\n parent.children.push(current);\n addChildren(current, all);\n }\n }\n };\n\n /**\n * Load the list of competencies via ajax. Competencies are filtered by the searchtext.\n * @param {String} searchtext The text to filter on.\n * @return {promise}\n */\n var loadCompetencies = function(searchtext) {\n var deferred = $.Deferred();\n\n templates.render('tool_lp/loading', {}).done(function(loadinghtml, loadingjs) {\n templates.replaceNodeContents($(treeSelector), loadinghtml, loadingjs);\n\n var promises = ajax.call([{\n methodname: 'core_competency_search_competencies',\n args: {\n searchtext: searchtext,\n competencyframeworkid: competencyFrameworkId\n }\n }]);\n promises[0].done(function(result) {\n competencies = {};\n var i = 0;\n for (i = 0; i < result.length; i++) {\n competencies[result[i].id] = result[i];\n }\n\n var children = [];\n var competency = false;\n for (i = 0; i < result.length; i++) {\n competency = result[i];\n if (parseInt(competency.parentid, 10) === 0) {\n children.push(competency);\n addChildren(competency, result);\n }\n }\n var context = {\n shortname: competencyFrameworkShortName,\n canmanage: competencyFramworkCanManage,\n competencies: children\n };\n templates.render('tool_lp/competencies_tree_root', context).done(function(html, js) {\n templates.replaceNodeContents($(treeSelector), $(html).html(), js);\n var tree = new Ariatree(treeSelector, false);\n\n if (currentNodeId) {\n var node = $(treeSelector).find('[data-id=' + currentNodeId + ']');\n if (node.length) {\n tree.selectItem(node);\n tree.updateFocus(node);\n }\n }\n deferred.resolve(competencies);\n }).fail(deferred.reject);\n }).fail(deferred.reject);\n });\n\n return deferred.promise();\n };\n\n /**\n * Whenever the current item in the tree is changed - remember the \"id\".\n * @param {Event} evt\n * @param {Object} params The parameters for the event (This is the selected node).\n */\n var rememberCurrent = function(evt, params) {\n var node = params.selected;\n currentNodeId = node.attr('data-id');\n };\n\n return /** @alias module:tool_lp/competencytree */ {\n // Public variables and functions.\n /**\n * Initialise the tree.\n *\n * @param {Number} id The competency framework id.\n * @param {String} shortname The framework shortname\n * @param {String} search The current search string\n * @param {String} selector The selector for the tree div\n * @param {Boolean} canmanage Can manage the competencies\n * @param {Number} competencyid The id of the competency to show first\n */\n init: function(id, shortname, search, selector, canmanage, competencyid) {\n competencyFrameworkId = id;\n competencyFrameworkShortName = shortname;\n competencyFramworkCanManage = canmanage;\n treeSelector = selector;\n loadCompetencies(search).fail(notification.exception);\n if (competencyid > 0) {\n currentNodeId = competencyid;\n }\n\n this.on('selectionchanged', rememberCurrent);\n },\n\n /**\n * Add an event handler for custom events emitted by the tree.\n *\n * @param {String} eventname The name of the event - only \"selectionchanged\" for now\n * @param {Function} handler The handler for the event.\n */\n on: function(eventname, handler) {\n // We can't use the tree on function directly\n // because the tree gets rebuilt whenever the search string changes,\n // instead we attach the listner to the root node of the tree which never\n // gets destroyed (same as \"on()\" code in the tree.js).\n $(treeSelector).on(eventname, handler);\n },\n\n /**\n * Get the children of a competency.\n *\n * @param {Number} id The competency ID.\n * @return {Array}\n * @method getChildren\n */\n getChildren: function(id) {\n var children = [];\n $.each(competencies, function(index, competency) {\n if (competency.parentid == id) {\n children.push(competency);\n }\n });\n return children;\n },\n\n /**\n * Get the competency framework id this model was initiliased with.\n *\n * @return {Number}\n */\n getCompetencyFrameworkId: function() {\n return competencyFrameworkId;\n },\n\n /**\n * Get a competency by id\n *\n * @param {Number} id The competency id\n * @return {Object}\n */\n getCompetency: function(id) {\n return competencies[id];\n },\n\n /**\n * Get the competency level.\n *\n * @param {Number} id The competency ID.\n * @return {Number}\n */\n getCompetencyLevel: function(id) {\n var competency = this.getCompetency(id),\n level = competency.path.replace(/^\\/|\\/$/g, '').split('/').length;\n return level;\n },\n\n /**\n * Whether a competency has children.\n *\n * @param {Number} id The competency ID.\n * @return {Boolean}\n * @method hasChildren\n */\n hasChildren: function(id) {\n return this.getChildren(id).length > 0;\n },\n\n /**\n * Does the competency have a rule?\n *\n * @param {Number} id The competency ID.\n * @return {Boolean}\n */\n hasRule: function(id) {\n var comp = this.getCompetency(id);\n if (comp) {\n return comp.ruleoutcome != CompOutcomes.OUTCOME_NONE\n && comp.ruletype;\n }\n return false;\n },\n\n /**\n * Reload all the page competencies framework competencies.\n * @method reloadCompetencies\n * @return {Promise}\n */\n reloadCompetencies: function() {\n return loadCompetencies('').fail(notification.exception);\n },\n\n /**\n * Get all competencies for this framework.\n *\n * @return {Object[]}\n */\n listCompetencies: function() {\n return competencies;\n },\n\n };\n });\n"],"names":["define","ajax","notification","templates","Ariatree","CompOutcomes","$","competencies","competencyFrameworkId","competencyFrameworkShortName","treeSelector","currentNodeId","competencyFramworkCanManage","addChildren","parent","all","i","current","haschildren","children","length","parentid","id","push","loadCompetencies","searchtext","deferred","Deferred","render","done","loadinghtml","loadingjs","replaceNodeContents","call","methodname","args","competencyframeworkid","result","competency","parseInt","context","shortname","canmanage","html","js","tree","node","find","selectItem","updateFocus","resolve","fail","reject","promise","rememberCurrent","evt","params","selected","attr","init","search","selector","competencyid","exception","on","eventname","handler","getChildren","each","index","getCompetencyFrameworkId","getCompetency","getCompetencyLevel","this","path","replace","split","hasChildren","hasRule","comp","ruleoutcome","OUTCOME_NONE","ruletype","reloadCompetencies","listCompetencies"],"mappings":";;;;;;;AAsBAA,gCAAO,CAAC,YAAa,oBAAqB,iBAAkB,eAAgB,8BAA+B,WACpG,SAASC,KAAMC,aAAcC,UAAWC,SAAUC,aAAcC,OAI/DC,aAAe,GAGfC,sBAAwB,EAGxBC,6BAA+B,GAG/BC,aAAe,GAGfC,cAAgB,GAGhBC,6BAA8B,EAO9BC,YAAc,SAASC,OAAQC,SAC3BC,EAAI,EACJC,SAAU,MACdH,OAAOI,aAAc,EACrBJ,OAAOK,SAAW,GACbH,EAAI,EAAGA,EAAID,IAAIK,OAAQJ,KACxBC,QAAUF,IAAIC,IACFK,UAAYP,OAAOQ,KAC3BR,OAAOI,aAAc,EACrBJ,OAAOK,SAASI,KAAKN,SACrBJ,YAAYI,QAASF,OAU7BS,iBAAmB,SAASC,gBACxBC,SAAWpB,EAAEqB,kBAEjBxB,UAAUyB,OAAO,kBAAmB,IAAIC,MAAK,SAASC,YAAaC,WAC/D5B,UAAU6B,oBAAoB1B,EAAEI,cAAeoB,YAAaC,WAE7C9B,KAAKgC,KAAK,CAAC,CACtBC,WAAY,sCACZC,KAAM,CACFV,WAAYA,WACZW,sBAAuB5B,0BAGtB,GAAGqB,MAAK,SAASQ,QACtB9B,aAAe,OACXS,EAAI,MACHA,EAAI,EAAGA,EAAIqB,OAAOjB,OAAQJ,IAC3BT,aAAa8B,OAAOrB,GAAGM,IAAMe,OAAOrB,OAGpCG,SAAW,GACXmB,YAAa,MACZtB,EAAI,EAAGA,EAAIqB,OAAOjB,OAAQJ,IAC3BsB,WAAaD,OAAOrB,GACsB,IAAtCuB,SAASD,WAAWjB,SAAU,MAC9BF,SAASI,KAAKe,YACdzB,YAAYyB,WAAYD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AC1ByD,OACOA,KAAKC,aAAe3E,aAAa4E,cACjCF,KAAKG,WAUpBC,mBAAoB,kBACT3D,iBAAiB,IAAI2B,KAAKjD,aAAa6D,YAQlDqB,iBAAkB,kBACP7E"} \ No newline at end of file +{"version":3,"file":"competencytree.min.js","sources":["../src/competencytree.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle selection changes on the competency tree.\n *\n * @module tool_lp/competencyselect\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/ajax', 'core/notification', 'core/templates', 'tool_lp/tree', 'tool_lp/competency_outcomes', 'jquery'],\n function(ajax, notification, templates, Ariatree, CompOutcomes, $) {\n\n // Private variables and functions.\n /** @var {Object[]} competencies - Cached list of competencies */\n var competencies = {};\n\n /** @var {Number} competencyFrameworkId - The current framework id */\n var competencyFrameworkId = 0;\n\n /** @var {String} competencyFrameworkShortName - The current framework short name */\n var competencyFrameworkShortName = '';\n\n /** @var {String} treeSelector - The selector for the root of the tree. */\n var treeSelector = '';\n\n /** @var {String} currentNodeId - The data-id of the current node in the tree. */\n var currentNodeId = '';\n\n /** @var {Boolean} competencyFramworkCanManage - Can manage the competencies framework */\n var competencyFramworkCanManage = false;\n\n /**\n * Build a tree from the flat list of competencies.\n * @param {Object} parent The parent competency.\n * @param {Array} all The list of all competencies.\n */\n var addChildren = function(parent, all) {\n var i = 0;\n var current = false;\n parent.haschildren = false;\n parent.children = [];\n for (i = 0; i < all.length; i++) {\n current = all[i];\n if (current.parentid == parent.id) {\n parent.haschildren = true;\n parent.children.push(current);\n addChildren(current, all);\n }\n }\n };\n\n /**\n * Load the list of competencies via ajax. Competencies are filtered by the searchtext.\n * @param {String} searchtext The text to filter on.\n * @return {promise}\n */\n var loadCompetencies = function(searchtext) {\n var deferred = $.Deferred();\n\n templates.render('tool_lp/loading', {}).done(function(loadinghtml, loadingjs) {\n templates.replaceNodeContents($(treeSelector), loadinghtml, loadingjs);\n\n var promises = ajax.call([{\n methodname: 'core_competency_search_competencies',\n args: {\n searchtext: searchtext,\n competencyframeworkid: competencyFrameworkId\n }\n }]);\n promises[0].done(function(result) {\n competencies = {};\n var i = 0;\n for (i = 0; i < result.length; i++) {\n competencies[result[i].id] = result[i];\n }\n\n var children = [];\n var competency = false;\n for (i = 0; i < result.length; i++) {\n competency = result[i];\n if (parseInt(competency.parentid, 10) === 0) {\n children.push(competency);\n addChildren(competency, result);\n }\n }\n var context = {\n shortname: competencyFrameworkShortName,\n canmanage: competencyFramworkCanManage,\n competencies: children\n };\n templates.render('tool_lp/competencies_tree_root', context).done(function(html, js) {\n templates.replaceNodeContents($(treeSelector), $(html).html(), js);\n var tree = new Ariatree(treeSelector, false);\n\n if (currentNodeId) {\n var node = $(treeSelector).find('[data-id=' + currentNodeId + ']');\n if (node.length) {\n tree.selectItem(node);\n tree.updateFocus(node);\n }\n }\n deferred.resolve(competencies);\n }).fail(deferred.reject);\n }).fail(deferred.reject);\n });\n\n return deferred.promise();\n };\n\n /**\n * Whenever the current item in the tree is changed - remember the \"id\".\n * @param {Event} evt\n * @param {Object} params The parameters for the event (This is the selected node).\n */\n var rememberCurrent = function(evt, params) {\n var node = params.selected;\n currentNodeId = node.attr('data-id');\n };\n\n return /** @alias module:tool_lp/competencytree */ {\n // Public variables and functions.\n /**\n * Initialise the tree.\n *\n * @param {Number} id The competency framework id.\n * @param {String} shortname The framework shortname\n * @param {String} search The current search string\n * @param {String} selector The selector for the tree div\n * @param {Boolean} canmanage Can manage the competencies\n * @param {Number} competencyid The id of the competency to show first\n */\n init: function(id, shortname, search, selector, canmanage, competencyid) {\n competencyFrameworkId = id;\n competencyFrameworkShortName = shortname;\n competencyFramworkCanManage = canmanage;\n treeSelector = selector;\n loadCompetencies(search).fail(notification.exception);\n if (competencyid > 0) {\n currentNodeId = competencyid;\n }\n\n this.on('selectionchanged', rememberCurrent);\n },\n\n /**\n * Add an event handler for custom events emitted by the tree.\n *\n * @param {String} eventname The name of the event - only \"selectionchanged\" for now\n * @param {Function} handler The handler for the event.\n */\n on: function(eventname, handler) {\n // We can't use the tree on function directly\n // because the tree gets rebuilt whenever the search string changes,\n // instead we attach the listner to the root node of the tree which never\n // gets destroyed (same as \"on()\" code in the tree.js).\n $(treeSelector).on(eventname, handler);\n },\n\n /**\n * Get the children of a competency.\n *\n * @param {Number} id The competency ID.\n * @return {Array}\n * @method getChildren\n */\n getChildren: function(id) {\n var children = [];\n $.each(competencies, function(index, competency) {\n if (competency.parentid == id) {\n children.push(competency);\n }\n });\n return children;\n },\n\n /**\n * Get the competency framework id this model was initiliased with.\n *\n * @return {Number}\n */\n getCompetencyFrameworkId: function() {\n return competencyFrameworkId;\n },\n\n /**\n * Get a competency by id\n *\n * @param {Number} id The competency id\n * @return {Object}\n */\n getCompetency: function(id) {\n return competencies[id];\n },\n\n /**\n * Get the competency level.\n *\n * @param {Number} id The competency ID.\n * @return {Number}\n */\n getCompetencyLevel: function(id) {\n var competency = this.getCompetency(id),\n level = competency.path.replace(/^\\/|\\/$/g, '').split('/').length;\n return level;\n },\n\n /**\n * Whether a competency has children.\n *\n * @param {Number} id The competency ID.\n * @return {Boolean}\n * @method hasChildren\n */\n hasChildren: function(id) {\n return this.getChildren(id).length > 0;\n },\n\n /**\n * Does the competency have a rule?\n *\n * @param {Number} id The competency ID.\n * @return {Boolean}\n */\n hasRule: function(id) {\n var comp = this.getCompetency(id);\n if (comp) {\n return comp.ruleoutcome != CompOutcomes.OUTCOME_NONE\n && comp.ruletype;\n }\n return false;\n },\n\n /**\n * Reload all the page competencies framework competencies.\n * @method reloadCompetencies\n * @return {Promise}\n */\n reloadCompetencies: function() {\n return loadCompetencies('').fail(notification.exception);\n },\n\n /**\n * Get all competencies for this framework.\n *\n * @return {Object[]}\n */\n listCompetencies: function() {\n return competencies;\n },\n\n };\n });\n"],"names":["define","ajax","notification","templates","Ariatree","CompOutcomes","$","competencies","competencyFrameworkId","competencyFrameworkShortName","treeSelector","currentNodeId","competencyFramworkCanManage","addChildren","parent","all","i","current","haschildren","children","length","parentid","id","push","loadCompetencies","searchtext","deferred","Deferred","render","done","loadinghtml","loadingjs","replaceNodeContents","call","methodname","args","competencyframeworkid","result","competency","parseInt","context","shortname","canmanage","html","js","tree","node","find","selectItem","updateFocus","resolve","fail","reject","promise","rememberCurrent","evt","params","selected","attr","init","search","selector","competencyid","exception","this","on","eventname","handler","getChildren","each","index","getCompetencyFrameworkId","getCompetency","getCompetencyLevel","path","replace","split","hasChildren","hasRule","comp","ruleoutcome","OUTCOME_NONE","ruletype","reloadCompetencies","listCompetencies"],"mappings":";;;;;;;AAsBAA,OAAM,yBAAC,CAAC,YAAa,oBAAqB,iBAAkB,eAAgB,8BAA+B,WACpG,SAASC,KAAMC,aAAcC,UAAWC,SAAUC,aAAcC,GAInE,IAAIC,aAAe,CAAA,EAGfC,sBAAwB,EAGxBC,6BAA+B,GAG/BC,aAAe,GAGfC,cAAgB,GAGhBC,6BAA8B,EAO9BC,YAAc,SAASC,OAAQC,KAC/B,IAAIC,EAAI,EACJC,SAAU,EAGd,IAFAH,OAAOI,aAAc,EACrBJ,OAAOK,SAAW,GACbH,EAAI,EAAGA,EAAID,IAAIK,OAAQJ,KACxBC,QAAUF,IAAIC,IACFK,UAAYP,OAAOQ,KAC3BR,OAAOI,aAAc,EACrBJ,OAAOK,SAASI,KAAKN,SACrBJ,YAAYI,QAASF,OAU7BS,iBAAmB,SAASC,YAC5B,IAAIC,SAAWpB,EAAEqB,WAiDjB,OA/CAxB,UAAUyB,OAAO,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B,4BAA8B8B,UAC9BhC,aAAemD,SACfrC,iBAAiBoC,QAAQT,KAAKjD,aAAa6D,WACvCD,aAAe,IACfnD,cAAgBmD,cAGpBE,KAAKC,GAAG,mBAAoBX,gBAC9B,EAQFW,GAAI,SAASC,UAAWC,SAKpB7D,EAAEI,cAAcuD,GAAGC,UAAWC,QACjC,EASDC,YAAa,SAAS9C,IAClB,IAAIH,SAAW,GAMf,OALAb,EAAE+D,KAAK9D,cAAc,SAAS+D,MAAOhC,YAC7BA,WAAWjB,UAAYC,IACvBH,SAASI,KAAKe,WAEtB,IACOnB,QACV,EAODoD,yBAA0B,WACtB,OAAO/D,qBACV,EAQDgE,cAAe,SAASlD,IACpB,OAAOf,aAAae,GACvB,EAQDmD,mBAAoB,SAASnD,IAGzB,OAFiB0C,KAAKQ,cAAclD,IACboD,KAAKC,QAAQ,WAAY,IAAIC,MAAM,KAAKxD,MAElE,EASDyD,YAAa,SAASvD,IAClB,OAAO0C,KAAKI,YAAY9C,IAAIF,OAAS,CACxC,EAQD0D,QAAS,SAASxD,IACd,IAAIyD,KAAOf,KAAKQ,cAAclD,IAC9B,QAAIyD,OACOA,KAAKC,aAAe3E,aAAa4E,cACjCF,KAAKG,SAGnB,EAODC,mBAAoB,WAChB,OAAO3D,iBAAiB,IAAI2B,KAAKjD,aAAa6D,UACjD,EAODqB,iBAAkB,WACd,OAAO7E,YACX,EAGP"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/course_competency_settings.min.js.map b/admin/tool/lp/amd/build/course_competency_settings.min.js.map index f473cf570da..7769451a3ca 100644 --- a/admin/tool/lp/amd/build/course_competency_settings.min.js.map +++ b/admin/tool/lp/amd/build/course_competency_settings.min.js.map @@ -1 +1 @@ -{"version":3,"file":"course_competency_settings.min.js","sources":["../src/course_competency_settings.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Change the course competency settings in a popup.\n *\n * @module tool_lp/configurecoursecompetencysettings\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'tool_lp/dialogue',\n 'core/str',\n 'core/ajax',\n 'core/templates',\n 'core/pending'\n ],\n function($, notification, Dialogue, str, ajax, templates, Pending) {\n\n /**\n * Constructor\n *\n * @param {String} selector - selector for the links to open the dialogue.\n */\n var settingsMod = function(selector) {\n $(selector).on('click', this.configureSettings.bind(this));\n };\n\n /** @property {Dialogue} Reference to the dialogue that we opened. */\n settingsMod.prototype._dialogue = null;\n\n /**\n * Open the configure settings dialogue.\n *\n * @param {Event} e\n * @method configureSettings\n */\n settingsMod.prototype.configureSettings = function(e) {\n var pendingPromise = new Pending();\n var courseid = $(e.target).closest('a').data('courseid');\n var currentValue = $(e.target).closest('a').data('pushratingstouserplans');\n var context = {\n courseid: courseid,\n settings: {pushratingstouserplans: currentValue}\n };\n e.preventDefault();\n\n $.when(\n str.get_string('configurecoursecompetencysettings', 'tool_lp'),\n templates.render('tool_lp/course_competency_settings', context),\n )\n .then(function(title, templateResult) {\n this._dialogue = new Dialogue(\n title,\n templateResult[0],\n this.addListeners.bind(this)\n );\n\n return this._dialogue;\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n };\n\n /**\n * Add the save listener to the form.\n *\n * @method addSaveListener\n */\n settingsMod.prototype.addListeners = function() {\n var save = this._find('[data-action=\"save\"]');\n save.on('click', this.saveSettings.bind(this));\n var cancel = this._find('[data-action=\"cancel\"]');\n cancel.on('click', this.cancelChanges.bind(this));\n };\n\n /**\n * Cancel the changes.\n *\n * @param {Event} e\n * @method cancelChanges\n */\n settingsMod.prototype.cancelChanges = function(e) {\n e.preventDefault();\n this._dialogue.close();\n };\n\n /**\n * Cancel the changes.\n *\n * @param {String} selector\n * @return {JQuery}\n */\n settingsMod.prototype._find = function(selector) {\n return $('[data-region=\"coursecompetencysettings\"]').find(selector);\n };\n\n /**\n * Save the settings.\n *\n * @param {Event} e\n * @method saveSettings\n */\n settingsMod.prototype.saveSettings = function(e) {\n var pendingPromise = new Pending();\n e.preventDefault();\n\n var newValue = this._find('input[name=\"pushratingstouserplans\"]:checked').val();\n var courseId = this._find('input[name=\"courseid\"]').val();\n var settings = {pushratingstouserplans: newValue};\n\n ajax.call([\n {methodname: 'core_competency_update_course_competency_settings',\n args: {courseid: courseId, settings: settings}}\n ])[0]\n .then(function() {\n return this.refreshCourseCompetenciesPage();\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n\n };\n\n /**\n * Refresh the course competencies page.\n *\n * @method saveSettings\n */\n settingsMod.prototype.refreshCourseCompetenciesPage = function() {\n var courseId = this._find('input[name=\"courseid\"]').val();\n var pendingPromise = new Pending();\n\n ajax.call([\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: courseId, moduleid: 0}}\n ])[0]\n .then(function(context) {\n return templates.render('tool_lp/course_competencies_page', context);\n })\n .then(function(html, js) {\n templates.replaceNode($('[data-region=\"coursecompetenciespage\"]'), html, js);\n this._dialogue.close();\n\n return;\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n };\n\n return /** @alias module:tool_lp/configurecoursecompetencysettings */ settingsMod;\n});\n"],"names":["define","$","notification","Dialogue","str","ajax","templates","Pending","settingsMod","selector","on","this","configureSettings","bind","prototype","_dialogue","e","pendingPromise","context","courseid","target","closest","data","settings","pushratingstouserplans","preventDefault","when","get_string","render","then","title","templateResult","addListeners","resolve","catch","exception","_find","saveSettings","cancelChanges","close","find","newValue","val","courseId","call","methodname","args","refreshCour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iB,UAExCpC,KAAKuC,KAAK,CACN,CAACC,WAAY,oDACXC,KAAM,CAAC3B,SAAUwB,SAAUpB,SAAUA,aACxC,GACFM,KAAK,kBACKlB,KAAKoC,iCACdlC,KAAKF,OACNkB,KAAKZ,eAAegB,SACpBC,MAAMhC,aAAaiC,YASxB3B,YAAYM,UAAUiC,8BAAgC,eAC9CJ,SAAWhC,KAAKyB,MAAM,0BAA0BM,MAChDzB,eAAiB,IAAIV,QAEzBF,KAAKuC,KAAK,CACN,CAACC,WAAY,4CACXC,KAAM,CAAC3B,SAAUwB,SAAUK,SAAU,MACxC,GACFnB,MAAK,SAASX,gBACJZ,UAAUsB,OAAO,mCAAoCV,YAE/DW,KAAK,SAASoB,KAAMC,IACjB5C,UAAU6C,YAAYlD,EAAE,0CAA2CgD,KAAMC,SACpEnC,UAAUwB,SAGjB1B,KAAKF,OACNkB,KAAKZ,eAAegB,SACpBC,MAAMhC,aAAaiC,YAG8C3B"} \ No newline at end of file +{"version":3,"file":"course_competency_settings.min.js","sources":["../src/course_competency_settings.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Change the course competency settings in a popup.\n *\n * @module tool_lp/configurecoursecompetencysettings\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'tool_lp/dialogue',\n 'core/str',\n 'core/ajax',\n 'core/templates',\n 'core/pending'\n ],\n function($, notification, Dialogue, str, ajax, templates, Pending) {\n\n /**\n * Constructor\n *\n * @param {String} selector - selector for the links to open the dialogue.\n */\n var settingsMod = function(selector) {\n $(selector).on('click', this.configureSettings.bind(this));\n };\n\n /** @property {Dialogue} Reference to the dialogue that we opened. */\n settingsMod.prototype._dialogue = null;\n\n /**\n * Open the configure settings dialogue.\n *\n * @param {Event} e\n * @method configureSettings\n */\n settingsMod.prototype.configureSettings = function(e) {\n var pendingPromise = new Pending();\n var courseid = $(e.target).closest('a').data('courseid');\n var currentValue = $(e.target).closest('a').data('pushratingstouserplans');\n var context = {\n courseid: courseid,\n settings: {pushratingstouserplans: currentValue}\n };\n e.preventDefault();\n\n $.when(\n str.get_string('configurecoursecompetencysettings', 'tool_lp'),\n templates.render('tool_lp/course_competency_settings', context),\n )\n .then(function(title, templateResult) {\n this._dialogue = new Dialogue(\n title,\n templateResult[0],\n this.addListeners.bind(this)\n );\n\n return this._dialogue;\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n };\n\n /**\n * Add the save listener to the form.\n *\n * @method addSaveListener\n */\n settingsMod.prototype.addListeners = function() {\n var save = this._find('[data-action=\"save\"]');\n save.on('click', this.saveSettings.bind(this));\n var cancel = this._find('[data-action=\"cancel\"]');\n cancel.on('click', this.cancelChanges.bind(this));\n };\n\n /**\n * Cancel the changes.\n *\n * @param {Event} e\n * @method cancelChanges\n */\n settingsMod.prototype.cancelChanges = function(e) {\n e.preventDefault();\n this._dialogue.close();\n };\n\n /**\n * Cancel the changes.\n *\n * @param {String} selector\n * @return {JQuery}\n */\n settingsMod.prototype._find = function(selector) {\n return $('[data-region=\"coursecompetencysettings\"]').find(selector);\n };\n\n /**\n * Save the settings.\n *\n * @param {Event} e\n * @method saveSettings\n */\n settingsMod.prototype.saveSettings = function(e) {\n var pendingPromise = new Pending();\n e.preventDefault();\n\n var newValue = this._find('input[name=\"pushratingstouserplans\"]:checked').val();\n var courseId = this._find('input[name=\"courseid\"]').val();\n var settings = {pushratingstouserplans: newValue};\n\n ajax.call([\n {methodname: 'core_competency_update_course_competency_settings',\n args: {courseid: courseId, settings: settings}}\n ])[0]\n .then(function() {\n return this.refreshCourseCompetenciesPage();\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n\n };\n\n /**\n * Refresh the course competencies page.\n *\n * @method saveSettings\n */\n settingsMod.prototype.refreshCourseCompetenciesPage = function() {\n var courseId = this._find('input[name=\"courseid\"]').val();\n var pendingPromise = new Pending();\n\n ajax.call([\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: courseId, moduleid: 0}}\n ])[0]\n .then(function(context) {\n return templates.render('tool_lp/course_competencies_page', context);\n })\n .then(function(html, js) {\n templates.replaceNode($('[data-region=\"coursecompetenciespage\"]'), html, js);\n this._dialogue.close();\n\n return;\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n };\n\n return /** @alias module:tool_lp/configurecoursecompetencysettings */ settingsMod;\n});\n"],"names":["define","$","notification","Dialogue","str","ajax","templates","Pending","settingsMod","selector","on","this","configureSettings","bind","prototype","_dialogue","e","pendingPromise","context","courseid","target","closest","data","settings","pushratingstouserplans","preventDefault","when","get_string","render","then","title","templateResult","addListeners","resolve","catch","exception","_find","saveSettings","cancelChanges","close","find","newValue","val","courseId","call","methodname","args","refreshCourseCompetenciesPage","moduleid","html","js","replaceNode"],"mappings":";;;;;;;AAsBAA,OAAO,qCAAA,CAAC,SACA,oBACA,mBACA,WACA,YACA,iBACA,iBAED,SAASC,EAAGC,aAAcC,SAAUC,IAAKC,KAAMC,UAAWC,SAO7D,IAAIC,YAAc,SAASC,UACvBR,EAAEQ,UAAUC,GAAG,QAASC,KAAKC,kBAAkBC,KAAKF,QA4HxD,OAxHAH,YAAYM,UAAUC,UAAY,KAQlCP,YAAYM,UAAUF,kBAAoB,SAASI,GAC/C,IAAIC,eAAiB,IAAIV,QAGrBW,QAAU,CACVC,SAHWlB,EAAEe,EAAEI,QAAQC,QAAQ,KAAKC,KAAK,YAIzCC,SAAU,CAACC,uBAHIvB,EAAEe,EA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B,MAAK,SAASX,SACX,OAAOZ,UAAUsB,OAAO,mCAAoCV,QAC/D,IACAW,KAAK,SAASoB,KAAMC,IACjB5C,UAAU6C,YAAYlD,EAAE,0CAA2CgD,KAAMC,IACzEvC,KAAKI,UAAUwB,OAGlB,EAAC1B,KAAKF,OACNkB,KAAKZ,eAAegB,SACpBC,MAAMhC,aAAaiC,YAG8C3B,WAC1E"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/dialogue.min.js.map b/admin/tool/lp/amd/build/dialogue.min.js.map index 67352fce7b2..9dcb1ec9faf 100644 --- a/admin/tool/lp/amd/build/dialogue.min.js.map +++ b/admin/tool/lp/amd/build/dialogue.min.js.map @@ -1 +1 @@ -{"version":3,"file":"dialogue.min.js","sources":["../src/dialogue.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Wrapper for the YUI M.core.notification class. Allows us to\n * use the YUI version in AMD code until it is replaced.\n *\n * @module tool_lp/dialogue\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/yui'], function(Y) {\n\n // Private variables and functions.\n /**\n * Constructor\n *\n * @param {String} title Title for the window.\n * @param {String} content The content for the window.\n * @param {function} afterShow Callback executed after the window is opened.\n * @param {function} afterHide Callback executed after the window is closed.\n * @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default).\n * @param {String} height The height of the dialogue.\n */\n var dialogue = function(title, content, afterShow, afterHide, wide, height) {\n M.util.js_pending('tool_lp/dialogue:dialogue');\n\n this.yuiDialogue = null;\n var parent = this;\n\n // Default for wide is false.\n if (typeof wide == 'undefined') {\n wide = false;\n }\n\n Y.use('moodle-core-notification', 'timers', function() {\n var width = '480px';\n if (wide) {\n width = '800px';\n }\n\n if (!height) {\n height = 'auto';\n }\n\n parent.yuiDialogue = new M.core.dialogue({\n headerContent: title,\n bodyContent: content,\n draggable: true,\n visible: false,\n center: true,\n modal: true,\n width: width,\n height: height\n });\n\n parent.yuiDialogue.before('visibleChange', function() {\n M.util.js_pending('tool_lp/dialogue:before:visibleChange');\n });\n\n parent.yuiDialogue.after('visibleChange', function(e) {\n if (e.newVal) {\n // Delay the callback call to the next tick, otherwise it can happen that it is\n // executed before the dialogue constructor returns.\n if ((typeof afterShow !== 'undefined')) {\n Y.soon(function() {\n afterShow(parent);\n parent.yuiDialogue.centerDialogue();\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n });\n } else {\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n }\n } else {\n if ((typeof afterHide !== 'undefined')) {\n Y.soon(function() {\n afterHide(parent);\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n });\n } else {\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n }\n }\n });\n\n parent.yuiDialogue.show();\n M.util.js_complete('tool_lp/dialogue:dialogue');\n });\n };\n\n /**\n * Close this window.\n */\n dialogue.prototype.close = function() {\n this.yuiDialogue.hide();\n this.yuiDialogue.destroy();\n };\n\n /**\n * Get content.\n * @return {node}\n */\n dialogue.prototype.getContent = function() {\n return this.yuiDialogue.bodyNode.getDOMNode();\n };\n\n return /** @alias module:tool_lp/dialogue */ dialogue;\n});\n"],"names":["define","Y","dialogue","title","content","afterShow","afterHide","wide","height","M","util","js_pending","yuiDialogue","parent","this","use","width","core","headerContent","bodyContent","draggable","visible","center","modal","before","after","e","newVal","soon","centerDialogue","js_complete","show","prototype","close","hide","destroy","getContent","bodyNode","getDOMNode"],"mappings":";;;;;;;;AAuBAA,0BAAO,CAAC,aAAa,SAASC,OAatBC,SAAW,SAASC,MAAOC,QAASC,UAAWC,UAAWC,KAAMC,QAChEC,EAAEC,KAAKC,WAAW,kCAEbC,YAAc,SACfC,OAASC,UAGM,IAARP,OACPA,MAAO,GAGXN,EAAEc,IAAI,2BAA4B,UAAU,eACpCC,MAAQ,QACRT,OACAS,MAAQ,SAGPR,SACDA,OAAS,QAGbK,OAAOD,YAAc,IAAIH,EAAEQ,KAAKf,SAAS,CACrCgB,cAAef,MACfgB,YAAaf,QACbgB,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPP,MAAOA,MACPR,OAAQA,SAGZK,OAAOD,YAAYY,OAAO,iBAAiB,WACvCf,EAAEC,KAAKC,WAAW,4CAGtBE,OAAOD,YAAYa,MAAM,iBAAiB,SAASC,GAC3CA,EAAEC,YAGwB,IAAdtB,UACRJ,EAAE2B,MAAK,WACHvB,UAAUQ,QACVA,OAAOD,YAAYiB,iBACnBpB,EAAEC,KAAKoB,YAAY,4CAGvBrB,EAAEC,KAAKoB,YAAY,8CAGG,IAAdxB,UACRL,EAAE2B,MAAK,WACHtB,UAAUO,QACVJ,EAAEC,KAAKoB,YAAY,4CAGvBrB,EAAEC,KAAKoB,YAAY,4CAK/BjB,OAAOD,YAAYmB,OACnBtB,EAAEC,KAAKoB,YAAY,wCAO3B5B,SAAS8B,UAAUC,MAAQ,gBAClBrB,YAAYsB,YACZtB,YAAYuB,WAOrBjC,SAAS8B,UAAUI,WAAa,kBACrBtB,KAAKF,YAAYyB,SAASC,cAGQpC"} \ No newline at end of file +{"version":3,"file":"dialogue.min.js","sources":["../src/dialogue.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Wrapper for the YUI M.core.notification class. Allows us to\n * use the YUI version in AMD code until it is replaced.\n *\n * @module tool_lp/dialogue\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/yui'], function(Y) {\n\n // Private variables and functions.\n /**\n * Constructor\n *\n * @param {String} title Title for the window.\n * @param {String} content The content for the window.\n * @param {function} afterShow Callback executed after the window is opened.\n * @param {function} afterHide Callback executed after the window is closed.\n * @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default).\n * @param {String} height The height of the dialogue.\n */\n var dialogue = function(title, content, afterShow, afterHide, wide, height) {\n M.util.js_pending('tool_lp/dialogue:dialogue');\n\n this.yuiDialogue = null;\n var parent = this;\n\n // Default for wide is false.\n if (typeof wide == 'undefined') {\n wide = false;\n }\n\n Y.use('moodle-core-notification', 'timers', function() {\n var width = '480px';\n if (wide) {\n width = '800px';\n }\n\n if (!height) {\n height = 'auto';\n }\n\n parent.yuiDialogue = new M.core.dialogue({\n headerContent: title,\n bodyContent: content,\n draggable: true,\n visible: false,\n center: true,\n modal: true,\n width: width,\n height: height\n });\n\n parent.yuiDialogue.before('visibleChange', function() {\n M.util.js_pending('tool_lp/dialogue:before:visibleChange');\n });\n\n parent.yuiDialogue.after('visibleChange', function(e) {\n if (e.newVal) {\n // Delay the callback call to the next tick, otherwise it can happen that it is\n // executed before the dialogue constructor returns.\n if ((typeof afterShow !== 'undefined')) {\n Y.soon(function() {\n afterShow(parent);\n parent.yuiDialogue.centerDialogue();\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n });\n } else {\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n }\n } else {\n if ((typeof afterHide !== 'undefined')) {\n Y.soon(function() {\n afterHide(parent);\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n });\n } else {\n M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n }\n }\n });\n\n parent.yuiDialogue.show();\n M.util.js_complete('tool_lp/dialogue:dialogue');\n });\n };\n\n /**\n * Close this window.\n */\n dialogue.prototype.close = function() {\n this.yuiDialogue.hide();\n this.yuiDialogue.destroy();\n };\n\n /**\n * Get content.\n * @return {node}\n */\n dialogue.prototype.getContent = function() {\n return this.yuiDialogue.bodyNode.getDOMNode();\n };\n\n return /** @alias module:tool_lp/dialogue */ dialogue;\n});\n"],"names":["define","Y","dialogue","title","content","afterShow","afterHide","wide","height","M","util","js_pending","this","yuiDialogue","parent","use","width","core","headerContent","bodyContent","draggable","visible","center","modal","before","after","e","newVal","soon","centerDialogue","js_complete","show","prototype","close","hide","destroy","getContent","bodyNode","getDOMNode"],"mappings":";;;;;;;;AAuBAA,0BAAO,CAAC,aAAa,SAASC,GAa1B,IAAIC,SAAW,SAASC,MAAOC,QAASC,UAAWC,UAAWC,KAAMC,QAChEC,EAAEC,KAAKC,WAAW,6BAElBC,KAAKC,YAAc,KACnB,IAAIC,OAASF,UAGM,IAARL,OACPA,MAAO,GAGXN,EAAEc,IAAI,2BAA4B,UAAU,WACxC,IAAIC,MAAQ,QACRT,OACAS,MAAQ,SAGPR,SACDA,OAAS,QAGbM,OAAOD,YAAc,IAAIJ,EAAEQ,KAAKf,SAAS,CACrCgB,cAAef,MACfgB,YAAaf,QACbgB,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPP,MAAOA,MACPR,OAAQA,SAGZM,OAAOD,YAAYW,OAAO,iBAAiB,WACvCf,EAAEC,KAAKC,WAAW,wCACtB,IAEAG,OAAOD,YAAYY,MAAM,iBAAiB,SAASC,GAC3CA,EAAEC,YAGwB,IAAdtB,UACRJ,EAAE2B,MAAK,WACHvB,UAAUS,QACVA,OAAOD,YAAYgB,iBACnBpB,EAAEC,KAAKoB,YAAY,wCACvB,IAEArB,EAAEC,KAAKoB,YAAY,8CAGG,IAAdxB,UACRL,EAAE2B,MAAK,WACHtB,UAAUQ,QACVL,EAAEC,KAAKoB,YAAY,wCACvB,IAEArB,EAAEC,KAAKoB,YAAY,wCAG/B,IAEAhB,OAAOD,YAAYkB,OACnBtB,EAAEC,KAAKoB,YAAY,4BACvB,KAmBJ,OAbA5B,SAAS8B,UAAUC,MAAQ,WACvBrB,KAAKC,YAAYqB,OACjBtB,KAAKC,YAAYsB,WAOrBjC,SAAS8B,UAAUI,WAAa,WAC5B,OAAOxB,KAAKC,YAAYwB,SAASC,cAGQpC,QACjD"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/dragdrop-reorder.min.js.map b/admin/tool/lp/amd/build/dragdrop-reorder.min.js.map index ed41f5b52a8..0ab578b223d 100644 --- a/admin/tool/lp/amd/build/dragdrop-reorder.min.js.map +++ b/admin/tool/lp/amd/build/dragdrop-reorder.min.js.map @@ -1 +1 @@ -{"version":3,"file":"dragdrop-reorder.min.js","sources":["../src/dragdrop-reorder.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Drag and drop reorder via HTML5.\n *\n * @module tool_lp/dragdrop-reorder\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/str', 'core/yui'], function(str, Y) {\n // Private variables and functions.\n\n /**\n * Store the current instance of the core drag drop.\n *\n * @property {object} dragDropInstance M.tool_lp.dragdrop_reorder\n */\n var dragDropInstance = null;\n\n /**\n * Translate the drophit event from YUI\n * into simple drag and drop nodes.\n * @param {Y.Event} e The yui drop event.\n */\n var proxyCallback = function(e) {\n var dragNode = e.drag.get('node');\n var dropNode = e.drop.get('node');\n this.callback(dragNode.getDOMNode(), dropNode.getDOMNode());\n };\n\n return /** @alias module:tool_lp/dragdrop-reorder */ {\n // Public variables and functions.\n /**\n * Create an instance of M.tool_lp.dragdrop\n *\n * @param {String} group Unique string to identify this interaction.\n * @param {String} dragHandleText Alt text for the drag handle.\n * @param {String} sameNodeText Used in keyboard drag drop for the list of items target.\n * @param {String} parentNodeText Used in keyboard drag drop for the parent target.\n * @param {String} sameNodeClass class used to find the each of the list of items.\n * @param {String} parentNodeClass class used to find the container for the list of items.\n * @param {String} dragHandleInsertClass class used to find the location to insert the drag handles.\n * @param {function} callback Drop hit handler.\n */\n dragdrop: function(group,\n dragHandleText,\n sameNodeText,\n parentNodeText,\n sameNodeClass,\n parentNodeClass,\n dragHandleInsertClass,\n callback) {\n // Here we are wrapping YUI. This allows us to start transitioning, but\n // wait for a good alternative without having inconsistent UIs.\n str.get_strings([\n {key: 'emptydragdropregion', component: 'moodle'},\n {key: 'movecontent', component: 'moodle'},\n {key: 'tocontent', component: 'moodle'},\n ]).done(function() {\n Y.use('moodle-tool_lp-dragdrop-reorder', function() {\n\n var context = {\n callback: callback\n };\n if (dragDropInstance) {\n dragDropInstance.destroy();\n }\n dragDropInstance = M.tool_lp.dragdrop_reorder({\n group: group,\n dragHandleText: dragHandleText,\n sameNodeText: sameNodeText,\n parentNodeText: parentNodeText,\n sameNodeClass: sameNodeClass,\n parentNodeClass: parentNodeClass,\n dragHandleInsertClass: dragHandleInsertClass,\n callback: Y.bind(proxyCallback, context)\n });\n });\n });\n }\n\n };\n});\n"],"names":["define","str","Y","dragDropInstance","proxyCallback","e","dragNode","drag","get","dropNode","drop","callback","getDOMNode","dragdrop","group","dragHandleText","sameNodeText","parentNodeText","sameNodeClass","parentNodeClass","dragHandleInsertClass","get_strings","key","component","done","use","context","destroy","M","tool_lp","dragdrop_reorder","bind"],"mappings":";;;;;;;AAsBAA,kCAAO,CAAC,WAAY,aAAa,SAASC,IAAKC,OAQvCC,iBAAmB,KAOnBC,cAAgB,SAASC,OACrBC,SAAWD,EAAEE,KAAKC,IAAI,QACtBC,SAAWJ,EAAEK,KAAKF,IAAI,aACrBG,SAASL,SAASM,aAAcH,SAASG,qBAGG,CAcjDC,SAAU,SAASC,MACAC,eACAC,aACAC,eACAC,cACAC,gBACAC,sBACAT,UAGfV,IAAIoB,YAAY,CACZ,CAACC,IAAK,sBAAuBC,UAAW,UACxC,CAACD,IAAK,cAAeC,UAAW,UAChC,CAACD,IAAK,YAAaC,UAAW,YAC/BC,MAAK,WACJtB,EAAEuB,IAAI,mCAAmC,eAEjCC,QAAU,CACVf,SAAUA,UAEVR,kBACAA,iBAAiBwB,UAErBxB,iBAAmByB,EAAEC,QAAQC,iBAAiB,CAC1ChB,MAAOA,MACPC,eAAgBA,eAChBC,aAAcA,aACdC,eAAgBA,eAChBC,cAAeA,cACfC,gBAAiBA,gBACjBC,sBAAuBA,sBACvBT,SAAUT,EAAE6B,KAAK3B,cAAesB"} \ No newline at end of file +{"version":3,"file":"dragdrop-reorder.min.js","sources":["../src/dragdrop-reorder.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Drag and drop reorder via HTML5.\n *\n * @module tool_lp/dragdrop-reorder\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/str', 'core/yui'], function(str, Y) {\n // Private variables and functions.\n\n /**\n * Store the current instance of the core drag drop.\n *\n * @property {object} dragDropInstance M.tool_lp.dragdrop_reorder\n */\n var dragDropInstance = null;\n\n /**\n * Translate the drophit event from YUI\n * into simple drag and drop nodes.\n * @param {Y.Event} e The yui drop event.\n */\n var proxyCallback = function(e) {\n var dragNode = e.drag.get('node');\n var dropNode = e.drop.get('node');\n this.callback(dragNode.getDOMNode(), dropNode.getDOMNode());\n };\n\n return /** @alias module:tool_lp/dragdrop-reorder */ {\n // Public variables and functions.\n /**\n * Create an instance of M.tool_lp.dragdrop\n *\n * @param {String} group Unique string to identify this interaction.\n * @param {String} dragHandleText Alt text for the drag handle.\n * @param {String} sameNodeText Used in keyboard drag drop for the list of items target.\n * @param {String} parentNodeText Used in keyboard drag drop for the parent target.\n * @param {String} sameNodeClass class used to find the each of the list of items.\n * @param {String} parentNodeClass class used to find the container for the list of items.\n * @param {String} dragHandleInsertClass class used to find the location to insert the drag handles.\n * @param {function} callback Drop hit handler.\n */\n dragdrop: function(group,\n dragHandleText,\n sameNodeText,\n parentNodeText,\n sameNodeClass,\n parentNodeClass,\n dragHandleInsertClass,\n callback) {\n // Here we are wrapping YUI. This allows us to start transitioning, but\n // wait for a good alternative without having inconsistent UIs.\n str.get_strings([\n {key: 'emptydragdropregion', component: 'moodle'},\n {key: 'movecontent', component: 'moodle'},\n {key: 'tocontent', component: 'moodle'},\n ]).done(function() {\n Y.use('moodle-tool_lp-dragdrop-reorder', function() {\n\n var context = {\n callback: callback\n };\n if (dragDropInstance) {\n dragDropInstance.destroy();\n }\n dragDropInstance = M.tool_lp.dragdrop_reorder({\n group: group,\n dragHandleText: dragHandleText,\n sameNodeText: sameNodeText,\n parentNodeText: parentNodeText,\n sameNodeClass: sameNodeClass,\n parentNodeClass: parentNodeClass,\n dragHandleInsertClass: dragHandleInsertClass,\n callback: Y.bind(proxyCallback, context)\n });\n });\n });\n }\n\n };\n});\n"],"names":["define","str","Y","dragDropInstance","proxyCallback","e","dragNode","drag","get","dropNode","drop","this","callback","getDOMNode","dragdrop","group","dragHandleText","sameNodeText","parentNodeText","sameNodeClass","parentNodeClass","dragHandleInsertClass","get_strings","key","component","done","use","context","destroy","M","tool_lp","dragdrop_reorder","bind"],"mappings":";;;;;;;AAsBAA,OAAM,2BAAC,CAAC,WAAY,aAAa,SAASC,IAAKC,GAQ3C,IAAIC,iBAAmB,KAOnBC,cAAgB,SAASC,GACzB,IAAIC,SAAWD,EAAEE,KAAKC,IAAI,QACtBC,SAAWJ,EAAEK,KAAKF,IAAI,QAC1BG,KAAKC,SAASN,SAASO,aAAcJ,SAASI,eAGlD,MAAqD,CAcjDC,SAAU,SAASC,MACAC,eACAC,aACAC,eACAC,cACAC,gBACAC,sBACAT,UAGfX,IAAIqB,YAAY,CACZ,CAACC,IAAK,sBAAuBC,UAAW,UACxC,CAACD,IAAK,cAAeC,UAAW,UAChC,CAACD,IAAK,YAAaC,UAAW,YAC/BC,MAAK,WACJvB,EAAEwB,IAAI,mCAAmC,WAErC,IAAIC,QAAU,CACVf,SAAUA,UAEVT,kBACAA,iBAAiByB,UAErBzB,iBAAmB0B,EAAEC,QAAQC,iBAAiB,CAC1ChB,MAAOA,MACPC,eAAgBA,eAChBC,aAAcA,aACdC,eAAgBA,eAChBC,cAAeA,cACfC,gBAAiBA,gBACjBC,sBAAuBA,sBACvBT,SAAUV,EAAE8B,KAAK5B,cAAeuB,UAExC,GACJ,GACJ,EAGR"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/event_base.min.js.map b/admin/tool/lp/amd/build/event_base.min.js.map index 5acbe6740c4..7416ebf238c 100644 --- a/admin/tool/lp/amd/build/event_base.min.js.map +++ b/admin/tool/lp/amd/build/event_base.min.js.map @@ -1 +1 @@ -{"version":3,"file":"event_base.min.js","sources":["../src/event_base.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Event base javascript module.\n *\n * @module tool_lp/event_base\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'], function($) {\n\n /**\n * Base class.\n */\n var Base = function() {\n this._eventNode = $('
');\n };\n\n /** @property {Node} The node we attach the events to. */\n Base.prototype._eventNode = null;\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Base.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n */\n Base.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return /** @alias module:tool_lp/event_base */ Base;\n});\n"],"names":["define","$","Base","_eventNode","prototype","on","type","handler","_trigger","data","trigger"],"mappings":";;;;;;;AAsBAA,4BAAO,CAAC,WAAW,SAASC,OAKpBC,KAAO,gBACFC,WAAaF,EAAE,uBAIxBC,KAAKE,UAAUD,WAAa,KAS5BD,KAAKE,UAAUC,GAAK,SAASC,KAAMC,cAC1BJ,WAAWE,GAAGC,KAAMC,UAU7BL,KAAKE,UAAUI,SAAW,SAASF,KAAMG,WAChCN,WAAWO,QAAQJ,KAAM,CAACG,QAGYP"} \ No newline at end of file +{"version":3,"file":"event_base.min.js","sources":["../src/event_base.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Event base javascript module.\n *\n * @module tool_lp/event_base\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'], function($) {\n\n /**\n * Base class.\n */\n var Base = function() {\n this._eventNode = $('
');\n };\n\n /** @property {Node} The node we attach the events to. */\n Base.prototype._eventNode = null;\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Base.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _trigger\n */\n Base.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return /** @alias module:tool_lp/event_base */ Base;\n});\n"],"names":["define","$","Base","this","_eventNode","prototype","on","type","handler","_trigger","data","trigger"],"mappings":";;;;;;;AAsBAA,4BAAO,CAAC,WAAW,SAASC,GAKxB,IAAIC,KAAO,WACPC,KAAKC,WAAaH,EAAE,gBA4BxB,OAxBAC,KAAKG,UAAUD,WAAa,KAS5BF,KAAKG,UAAUC,GAAK,SAASC,KAAMC,SAC/BL,KAAKC,WAAWE,GAAGC,KAAMC,UAU7BN,KAAKG,UAAUI,SAAW,SAASF,KAAMG,MACrCP,KAAKC,WAAWO,QAAQJ,KAAM,CAACG,QAGYR,IACnD"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/evidence_delete.min.js.map b/admin/tool/lp/amd/build/evidence_delete.min.js.map index f16b333f0b6..45d1e2cf7bc 100644 --- a/admin/tool/lp/amd/build/evidence_delete.min.js.map +++ b/admin/tool/lp/amd/build/evidence_delete.min.js.map @@ -1 +1 @@ -{"version":3,"file":"evidence_delete.min.js","sources":["../src/evidence_delete.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Evidence delete.\n *\n * @module tool_lp/evidence_delete\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/str',\n 'core/log'],\n function($, Notification, Ajax, Str, Log) {\n\n var selectors = {};\n\n /**\n * Register an event listener.\n *\n * @param {String} triggerSelector The node on which the click will happen.\n * @param {String} containerSelector The parent node that will be removed and contains the evidence ID.\n */\n var register = function(triggerSelector, containerSelector) {\n if (typeof selectors[triggerSelector] !== 'undefined') {\n return;\n }\n\n selectors[triggerSelector] = $('body').delegate(triggerSelector, 'click', function(e) {\n var parent = $(e.currentTarget).parents(containerSelector);\n if (!parent.length || parent.length > 1) {\n Log.error('None or too many evidence container were found.');\n return;\n }\n var evidenceId = parent.data('id');\n if (!evidenceId) {\n Log.error('Evidence ID was not found.');\n return;\n }\n\n e.preventDefault();\n e.stopPropagation();\n\n Str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'areyousure', component: 'moodle'},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n Notification.confirm(\n strings[0], // Confirm.\n strings[1], // Are you sure?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n var promise = Ajax.call([{\n methodname: 'core_competency_delete_evidence',\n args: {\n id: evidenceId\n }\n }]);\n promise[0].then(function() {\n parent.remove();\n return;\n }).fail(Notification.exception);\n }\n );\n }).fail(Notification.exception);\n\n\n });\n };\n\n return /** @alias module:tool_lp/evidence_delete */ {\n\n /**\n * Register an event listener.\n *\n * @param {String} triggerSelector The node on which the click will happen.\n * @param {String} containerSelector The parent node that will be removed and contains the evidence ID.\n * @return {Void}\n */\n register: register\n };\n\n});\n"],"names":["define","$","Notification","Ajax","Str","Log","selectors","register","triggerSelector","containerSelector","delegate","e","parent","currentTarget","parents","length","error","evidenceId","data","preventDefault","stopPropagation","get_strings","key","component","done","strings","confirm","call","methodname","args","id","then","remove","fail","exception"],"mappings":";;;;;;;AAuBAA,iCAAO,CAAC,SACA,oBACA,YACA,WACA,aACA,SAASC,EAAGC,aAAcC,KAAMC,IAAKC,SAErCC,UAAY,SA0DoC,CAShDC,SA3DW,SAASC,gBAAiBC,wBACK,IAA/BH,UAAUE,mBAIrBF,UAAUE,iBAAmBP,EAAE,QAAQS,SAASF,gBAAiB,SAAS,SAASG,OAC3EC,OAASX,EAAEU,EAAEE,eAAeC,QAAQL,uBACnCG,OAAOG,QAAUH,OAAOG,OAAS,EAClCV,IAAIW,MAAM,4DAGVC,WAAaL,OAAOM,KAAK,MACxBD,YAKLN,EAAEQ,iBACFR,EAAES,kBAEFhB,IAAIiB,YAAY,CACZ,CAACC,IAAK,UAAWC,UAAW,UAC5B,CAACD,IAAK,aAAcC,UAAW,UAC/B,CAACD,IAAK,SAAUC,UAAW,UAC3B,CAACD,IAAK,SAAUC,UAAW,YAC5BC,MAAK,SAASC,SACbvB,aAAawB,QACTD,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRA,QAAQ,IACR,WACkBtB,KAAKwB,KAAK,CAAC,CACrBC,WAAY,kCACZC,KAAM,CACFC,GAAIb,eAGJ,GAAGc,MAAK,WACZnB,OAAOoB,YAERC,KAAK/B,aAAagC,iBAG9BD,KAAK/B,aAAagC,YA/BjB7B,IAAIW,MAAM"} \ No newline at end of file +{"version":3,"file":"evidence_delete.min.js","sources":["../src/evidence_delete.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Evidence delete.\n *\n * @module tool_lp/evidence_delete\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/str',\n 'core/log'],\n function($, Notification, Ajax, Str, Log) {\n\n var selectors = {};\n\n /**\n * Register an event listener.\n *\n * @param {String} triggerSelector The node on which the click will happen.\n * @param {String} containerSelector The parent node that will be removed and contains the evidence ID.\n */\n var register = function(triggerSelector, containerSelector) {\n if (typeof selectors[triggerSelector] !== 'undefined') {\n return;\n }\n\n selectors[triggerSelector] = $('body').delegate(triggerSelector, 'click', function(e) {\n var parent = $(e.currentTarget).parents(containerSelector);\n if (!parent.length || parent.length > 1) {\n Log.error('None or too many evidence container were found.');\n return;\n }\n var evidenceId = parent.data('id');\n if (!evidenceId) {\n Log.error('Evidence ID was not found.');\n return;\n }\n\n e.preventDefault();\n e.stopPropagation();\n\n Str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'areyousure', component: 'moodle'},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n Notification.confirm(\n strings[0], // Confirm.\n strings[1], // Are you sure?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n var promise = Ajax.call([{\n methodname: 'core_competency_delete_evidence',\n args: {\n id: evidenceId\n }\n }]);\n promise[0].then(function() {\n parent.remove();\n return;\n }).fail(Notification.exception);\n }\n );\n }).fail(Notification.exception);\n\n\n });\n };\n\n return /** @alias module:tool_lp/evidence_delete */ {\n\n /**\n * Register an event listener.\n *\n * @param {String} triggerSelector The node on which the click will happen.\n * @param {String} containerSelector The parent node that will be removed and contains the evidence ID.\n * @return {Void}\n */\n register: register\n };\n\n});\n"],"names":["define","$","Notification","Ajax","Str","Log","selectors","register","triggerSelector","containerSelector","delegate","e","parent","currentTarget","parents","length","error","evidenceId","data","preventDefault","stopPropagation","get_strings","key","component","done","strings","confirm","call","methodname","args","id","then","remove","fail","exception"],"mappings":";;;;;;;AAuBAA,OAAM,0BAAC,CAAC,SACA,oBACA,YACA,WACA,aACA,SAASC,EAAGC,aAAcC,KAAMC,IAAKC,KAEzC,IAAIC,UAAY,CAAA,EA0DhB,MAAoD,CAShDC,SA3DW,SAASC,gBAAiBC,wBACK,IAA/BH,UAAUE,mBAIrBF,UAAUE,iBAAmBP,EAAE,QAAQS,SAASF,gBAAiB,SAAS,SAASG,GAC/E,IAAIC,OAASX,EAAEU,EAAEE,eAAeC,QAAQL,mBACxC,IAAKG,OAAOG,QAAUH,OAAOG,OAAS,EAClCV,IAAIW,MAAM,uDADd,CAIA,IAAIC,WAAaL,OAAOM,KAAK,MACxBD,YAKLN,EAAEQ,iBACFR,EAAES,kBAEFhB,IAAIiB,YAAY,CACZ,CAACC,IAAK,UAAWC,UAAW,UAC5B,CAACD,IAAK,aAAcC,UAAW,UAC/B,CAACD,IAAK,SAAUC,UAAW,UAC3B,CAACD,IAAK,SAAUC,UAAW,YAC5BC,MAAK,SAASC,SACbvB,aAAawB,QACTD,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRA,QAAQ,IACR,WACkBtB,KAAKwB,KAAK,CAAC,CACrBC,WAAY,kCACZC,KAAM,CACFC,GAAIb,eAGJ,GAAGc,MAAK,WACZnB,OAAOoB,QAEV,IAAEC,KAAK/B,aAAagC,UACzB,GAEP,IAAED,KAAK/B,aAAagC,YA/BjB7B,IAAIW,MAAM,6BAHd,CAqCJ,MAeR"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/form-cohort-selector.min.js.map b/admin/tool/lp/amd/build/form-cohort-selector.min.js.map index aa365af512a..2da3709e6e9 100644 --- a/admin/tool/lp/amd/build/form-cohort-selector.min.js.map +++ b/admin/tool/lp/amd/build/form-cohort-selector.min.js.map @@ -1 +1 @@ -{"version":3,"file":"form-cohort-selector.min.js","sources":["../src/form-cohort-selector.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Cohort selector module.\n *\n * @module tool_lp/form-cohort-selector\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_lp/form-cohort-selector */ {\n\n processResults: function(selector, results) {\n var cohorts = [];\n $.each(results, function(index, cohort) {\n cohorts.push({\n value: cohort.id,\n label: cohort._label\n });\n });\n return cohorts;\n },\n\n transport: function(selector, query, success, failure) {\n var promise,\n contextid = parseInt($(selector).data('contextid'), 10),\n includes = $(selector).data('includes');\n\n promise = Ajax.call([{\n methodname: 'tool_lp_search_cohorts',\n args: {\n query: query,\n context: {contextid: contextid},\n includes: includes\n }\n }]);\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results.cohorts, function(index, cohort) {\n promises.push(Templates.render('tool_lp/form-cohort-selector-suggestion', cohort));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results.cohorts, function(index, cohort) {\n cohort._label = args[i];\n i++;\n });\n success(results.cohorts);\n return;\n });\n\n }).catch(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","cohorts","each","index","cohort","push","value","id","label","_label","transport","query","success","failure","contextid","parseInt","data","includes","call","methodname","args","context","then","promises","i","render","when","apply","arguments","catch"],"mappings":";;;;;;;AAuBAA,sCAAO,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,iBAEP,CAErDC,eAAgB,SAASC,SAAUC,aAC3BC,QAAU,UACdN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,QAC5BH,QAAQI,KAAK,CACTC,MAAOF,OAAOG,GACdC,MAAOJ,OAAOK,YAGfR,SAGXS,UAAW,SAASX,SAAUY,MAAOC,QAASC,aAEtCC,UAAYC,SAASpB,EAAEI,UAAUiB,KAAK,aAAc,IACpDC,SAAWtB,EAAEI,UAAUiB,KAAK,YAEtBpB,KAAKsB,KAAK,CAAC,CACjBC,WAAY,yBACZC,KAAM,CACFT,MAAOA,MACPU,QAAS,CAACP,UAAWA,WACrBG,SAAUA,aAGV,GAAGK,MAAK,SAAStB,aACjBuB,SAAW,GACXC,EAAI,SAGR7B,EAAEO,KAAKF,QAAQC,SAAS,SAASE,MAAOC,QACpCmB,SAASlB,KAAKR,UAAU4B,OAAO,0CAA2CrB,YAIvET,EAAE+B,KAAKC,MAAMhC,EAAE+B,KAAMH,UAAUD,MAAK,eACnCF,KAAOQ,UACXjC,EAAEO,KAAKF,QAAQC,SAAS,SAASE,MAAOC,QACpCA,OAAOK,OAASW,KAAKI,GACrBA,OAEJZ,QAAQZ,QAAQC,eAIrB4B,MAAMhB"} \ No newline at end of file +{"version":3,"file":"form-cohort-selector.min.js","sources":["../src/form-cohort-selector.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Cohort selector module.\n *\n * @module tool_lp/form-cohort-selector\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_lp/form-cohort-selector */ {\n\n processResults: function(selector, results) {\n var cohorts = [];\n $.each(results, function(index, cohort) {\n cohorts.push({\n value: cohort.id,\n label: cohort._label\n });\n });\n return cohorts;\n },\n\n transport: function(selector, query, success, failure) {\n var promise,\n contextid = parseInt($(selector).data('contextid'), 10),\n includes = $(selector).data('includes');\n\n promise = Ajax.call([{\n methodname: 'tool_lp_search_cohorts',\n args: {\n query: query,\n context: {contextid: contextid},\n includes: includes\n }\n }]);\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results.cohorts, function(index, cohort) {\n promises.push(Templates.render('tool_lp/form-cohort-selector-suggestion', cohort));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results.cohorts, function(index, cohort) {\n cohort._label = args[i];\n i++;\n });\n success(results.cohorts);\n return;\n });\n\n }).catch(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","cohorts","each","index","cohort","push","value","id","label","_label","transport","query","success","failure","contextid","parseInt","data","includes","call","methodname","args","context","then","promises","i","render","when","apply","arguments","catch"],"mappings":";;;;;;;AAuBAA,OAAO,+BAAA,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,WAEhE,MAAyD,CAErDC,eAAgB,SAASC,SAAUC,SAC/B,IAAIC,QAAU,GAOd,OANAN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,QAC5BH,QAAQI,KAAK,CACTC,MAAOF,OAAOG,GACdC,MAAOJ,OAAOK,QAEtB,IACOR,OACV,EAEDS,UAAW,SAASX,SAAUY,MAAOC,QAASC,SAC1C,IACIC,UAAYC,SAASpB,EAAEI,UAAUiB,KAAK,aAAc,IACpDC,SAAWtB,EAAEI,UAAUiB,KAAK,YAEtBpB,KAAKsB,KAAK,CAAC,CACjBC,WAAY,yBACZC,KAAM,CACFT,MAAOA,MACPU,QAAS,CAACP,UAAWA,WACrBG,SAAUA,aAGV,GAAGK,MAAK,SAAStB,SACrB,IAAIuB,SAAW,GACXC,EAAI,EAQR,OALA7B,EAAEO,KAAKF,QAAQC,SAAS,SAASE,MAAOC,QACpCmB,SAASlB,KAAKR,UAAU4B,OAAO,0CAA2CrB,QAC9E,IAGOT,EAAE+B,KAAKC,MAAMhC,EAAE+B,KAAMH,UAAUD,MAAK,WACvC,IAAIF,KAAOQ,UACXjC,EAAEO,KAAKF,QAAQC,SAAS,SAASE,MAAOC,QACpCA,OAAOK,OAASW,KAAKI,GACrBA,GACJ,IACAZ,QAAQZ,QAAQC,QAEpB,GAEJ,IAAG4B,MAAMhB,QACb,EAIR"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/form-user-selector.min.js.map b/admin/tool/lp/amd/build/form-user-selector.min.js.map index 795c5d36195..74095aa806e 100644 --- a/admin/tool/lp/amd/build/form-user-selector.min.js.map +++ b/admin/tool/lp/amd/build/form-user-selector.min.js.map @@ -1 +1 @@ -{"version":3,"file":"form-user-selector.min.js","sources":["../src/form-user-selector.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * User selector module.\n *\n * @module tool_lp/form-user-selector\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_lp/form-user-selector */ {\n\n processResults: function(selector, results) {\n var users = [];\n $.each(results, function(index, user) {\n users.push({\n value: user.id,\n label: user._label\n });\n });\n return users;\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n var capability = $(selector).data('capability');\n if (typeof capability === \"undefined\") {\n capability = '';\n }\n\n promise = Ajax.call([{\n methodname: 'tool_lp_search_users',\n args: {\n query: query,\n capability: capability\n }\n }]);\n\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results.users, function(index, user) {\n var ctx = user,\n identity = [];\n $.each(['idnumber', 'email', 'phone1', 'phone2', 'department', 'institution'], function(i, k) {\n if (typeof user[k] !== 'undefined' && user[k] !== '') {\n ctx.hasidentity = true;\n identity.push(user[k]);\n }\n });\n ctx.identity = identity.join(', ');\n promises.push(Templates.render('tool_lp/form-user-selector-suggestion', ctx));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results.users, function(index, user) {\n user._label = args[i];\n i++;\n });\n success(results.users);\n return;\n });\n\n }).catch(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","users","each","index","user","push","value","id","label","_label","transport","query","success","failure","capability","data","call","methodname","args","then","promises","i","ctx","identity","k","hasidentity","join","render","when","apply","arguments","catch"],"mappings":";;;;;;;AAuBAA,oCAAO,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,iBAET,CAEnDC,eAAgB,SAASC,SAAUC,aAC3BC,MAAQ,UACZN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BH,MAAMI,KAAK,CACPC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,YAGbR,OAGXS,UAAW,SAASX,SAAUY,MAAOC,QAASC,aAEtCC,WAAanB,EAAEI,UAAUgB,KAAK,mBACR,IAAfD,aACPA,WAAa,IAGPlB,KAAKoB,KAAK,CAAC,CACjBC,WAAY,uBACZC,KAAM,CACFP,MAAOA,MACPG,WAAYA,eAIZ,GAAGK,MAAK,SAASnB,aACjBoB,SAAW,GACXC,EAAI,SAGR1B,EAAEO,KAAKF,QAAQC,OAAO,SAASE,MAAOC,UAC9BkB,IAAMlB,KACNmB,SAAW,GACf5B,EAAEO,KAAK,CAAC,WAAY,QAAS,SAAU,SAAU,aAAc,gBAAgB,SAASmB,EAAGG,QAChE,IAAZpB,KAAKoB,IAAkC,KAAZpB,KAAKoB,KACvCF,IAAIG,aAAc,EAClBF,SAASlB,KAAKD,KAAKoB,QAG3BF,IAAIC,SAAWA,SAASG,KAAK,MAC7BN,SAASf,KAAKR,UAAU8B,OAAO,wCAAyCL,SAIrE3B,EAAEiC,KAAKC,MAAMlC,EAAEiC,KAAMR,UAAUD,MAAK,eACnCD,KAAOY,UACXnC,EAAEO,KAAKF,QAAQC,OAAO,SAASE,MAAOC,MAClCA,KAAKK,OAASS,KAAKG,GACnBA,OAEJT,QAAQZ,QAAQC,aAIrB8B,MAAMlB"} \ No newline at end of file +{"version":3,"file":"form-user-selector.min.js","sources":["../src/form-user-selector.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * User selector module.\n *\n * @module tool_lp/form-user-selector\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n return /** @alias module:tool_lp/form-user-selector */ {\n\n processResults: function(selector, results) {\n var users = [];\n $.each(results, function(index, user) {\n users.push({\n value: user.id,\n label: user._label\n });\n });\n return users;\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n var capability = $(selector).data('capability');\n if (typeof capability === \"undefined\") {\n capability = '';\n }\n\n promise = Ajax.call([{\n methodname: 'tool_lp_search_users',\n args: {\n query: query,\n capability: capability\n }\n }]);\n\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results.users, function(index, user) {\n var ctx = user,\n identity = [];\n $.each(['idnumber', 'email', 'phone1', 'phone2', 'department', 'institution'], function(i, k) {\n if (typeof user[k] !== 'undefined' && user[k] !== '') {\n ctx.hasidentity = true;\n identity.push(user[k]);\n }\n });\n ctx.identity = identity.join(', ');\n promises.push(Templates.render('tool_lp/form-user-selector-suggestion', ctx));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results.users, function(index, user) {\n user._label = args[i];\n i++;\n });\n success(results.users);\n return;\n });\n\n }).catch(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","users","each","index","user","push","value","id","label","_label","transport","query","success","failure","capability","data","call","methodname","args","then","promises","i","ctx","identity","k","hasidentity","join","render","when","apply","arguments","catch"],"mappings":";;;;;;;AAuBAA,OAAO,6BAAA,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,WAEhE,MAAuD,CAEnDC,eAAgB,SAASC,SAAUC,SAC/B,IAAIC,MAAQ,GAOZ,OANAN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BH,MAAMI,KAAK,CACPC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,QAEpB,IACOR,KACV,EAEDS,UAAW,SAASX,SAAUY,MAAOC,QAASC,SAC1C,IACIC,WAAanB,EAAEI,UAAUgB,KAAK,mBACR,IAAfD,aACPA,WAAa,IAGPlB,KAAKoB,KAAK,CAAC,CACjBC,WAAY,uBACZC,KAAM,CACFP,MAAOA,MACPG,WAAYA,eAIZ,GAAGK,MAAK,SAASnB,SACrB,IAAIoB,SAAW,GACXC,EAAI,EAiBR,OAdA1B,EAAEO,KAAKF,QAAQC,OAAO,SAASE,MAAOC,MAClC,IAAIkB,IAAMlB,KACNmB,SAAW,GACf5B,EAAEO,KAAK,CAAC,WAAY,QAAS,SAAU,SAAU,aAAc,gBAAgB,SAASmB,EAAGG,QAChE,IAAZpB,KAAKoB,IAAkC,KAAZpB,KAAKoB,KACvCF,IAAIG,aAAc,EAClBF,SAASlB,KAAKD,KAAKoB,IAE3B,IACAF,IAAIC,SAAWA,SAASG,KAAK,MAC7BN,SAASf,KAAKR,UAAU8B,OAAO,wCAAyCL,KAC5E,IAGO3B,EAAEiC,KAAKC,MAAMlC,EAAEiC,KAAMR,UAAUD,MAAK,WACvC,IAAID,KAAOY,UACXnC,EAAEO,KAAKF,QAAQC,OAAO,SAASE,MAAOC,MAClCA,KAAKK,OAASS,KAAKG,GACnBA,GACJ,IACAT,QAAQZ,QAAQC,MAEpB,GAEJ,IAAG8B,MAAMlB,QACb,EAIR"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/form_competency_element.min.js.map b/admin/tool/lp/amd/build/form_competency_element.min.js.map index 32c2f6f7dfa..de7bb9b0348 100644 --- a/admin/tool/lp/amd/build/form_competency_element.min.js.map +++ b/admin/tool/lp/amd/build/form_competency_element.min.js.map @@ -1 +1 @@ -{"version":3,"file":"form_competency_element.min.js","sources":["../src/form_competency_element.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Badge select competency actions\n *\n * @module tool_lp/form_competency_element\n * @copyright 2019 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'tool_lp/competencypicker', 'core/ajax', 'core/notification', 'core/templates'],\n function($, Picker, Ajax, Notification, Templates) {\n\n var pickerInstance = null;\n\n var pageContextId = 1;\n\n /**\n * Re-render the list of selected competencies.\n *\n * @method renderCompetencies\n * @return {boolean}\n */\n var renderCompetencies = function() {\n var currentCompetencies = $('[data-action=\"competencies\"]').val();\n var requests = [];\n var i = 0;\n\n if (currentCompetencies != '') {\n currentCompetencies = currentCompetencies.split(',');\n for (i = 0; i < currentCompetencies.length; i++) {\n requests[requests.length] = {\n methodname: 'core_competency_read_competency',\n args: {id: currentCompetencies[i]}\n };\n }\n }\n\n $.when.apply($, Ajax.call(requests, false)).then(function() {\n var i = 0,\n competencies = [];\n\n for (i = 0; i < arguments.length; i++) {\n competencies[i] = arguments[i];\n }\n var context = {\n competencies: competencies\n };\n\n return Templates.render('tool_lp/form_competency_list', context);\n }).then(function(html, js) {\n Templates.replaceNode($('[data-region=\"competencies\"]'), html, js);\n return true;\n }).fail(Notification.exception);\n\n return true;\n };\n\n /**\n * Deselect a competency\n *\n * @method unpickCompetenciesHandler\n * @param {Event} e\n * @return {boolean}\n */\n var unpickCompetenciesHandler = function(e) {\n var currentCompetencies = $('[data-action=\"competencies\"]').val().split(','),\n newCompetencies = [],\n i,\n toRemove = $(e.currentTarget).data('id');\n\n for (i = 0; i < currentCompetencies.length; i++) {\n if (currentCompetencies[i] != toRemove) {\n newCompetencies[newCompetencies.length] = currentCompetencies[i];\n }\n }\n\n $('[data-action=\"competencies\"]').val(newCompetencies.join(','));\n\n return renderCompetencies();\n };\n\n /**\n * Open a competencies popup to relate competencies.\n *\n * @method pickCompetenciesHandler\n */\n var pickCompetenciesHandler = function() {\n var currentCompetencies = $('[data-action=\"competencies\"]').val().split(',');\n\n if (!pickerInstance) {\n pickerInstance = new Picker(pageContextId, false, 'parents', true);\n pickerInstance.on('save', function(e, data) {\n var before = $('[data-action=\"competencies\"]').val();\n var compIds = data.competencyIds;\n if (before != '') {\n compIds = compIds.concat(before.split(','));\n }\n var value = compIds.join(',');\n\n $('[data-action=\"competencies\"]').val(value);\n\n return renderCompetencies();\n });\n }\n\n pickerInstance.setDisallowedCompetencyIDs(currentCompetencies);\n pickerInstance.display();\n };\n\n return /** @alias module:tool_lp/form_competency_element */ {\n /**\n * Listen for clicks on the competency picker and push the changes to the form element.\n *\n * @method init\n * @param {Integer} contextId\n */\n init: function(contextId) {\n pageContextId = contextId;\n renderCompetencies();\n $('[data-action=\"select-competencies\"]').on('click', pickCompetenciesHandler);\n $('body').on('click', '[data-action=\"deselect-competency\"]', unpickCompetenciesHandler);\n }\n };\n});\n"],"names":["define","$","Picker","Ajax","Notification","Templates","pickerInstance","pageContextId","renderCompetencies","currentCompetencies","val","requests","i","split","length","methodname","args","id","when","apply","call","then","competencies","arguments","context","render","html","js","replaceNode","fail","exception","unpickCompetenciesHandler","e","newCompetencies","toRemove","currentTarget","data","join","pickCompetenciesHandler","on","before","compIds","competencyIds","concat","value","setDisallowedCompetencyIDs","display","init","contextId"],"mappings":";;;;;;;AAsBAA,yCAAO,CAAC,SAAU,2BAA4B,YAAa,oBAAqB,mBACxE,SAASC,EAAGC,OAAQC,KAAMC,aAAcC,eAExCC,eAAiB,KAEjBC,cAAgB,EAQhBC,mBAAqB,eACjBC,oBAAsBR,EAAE,gCAAgCS,MACxDC,SAAW,GACXC,EAAI,KAEmB,IAAvBH,wBACAA,oBAAsB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,qBACAP,EAAE,uCAAuCsC,GAAG,QAASD,yBACrDrC,EAAE,QAAQsC,GAAG,QAAS,sCAAuCR"} \ No newline at end of file +{"version":3,"file":"form_competency_element.min.js","sources":["../src/form_competency_element.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Badge select competency actions\n *\n * @module tool_lp/form_competency_element\n * @copyright 2019 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'tool_lp/competencypicker', 'core/ajax', 'core/notification', 'core/templates'],\n function($, Picker, Ajax, Notification, Templates) {\n\n var pickerInstance = null;\n\n var pageContextId = 1;\n\n /**\n * Re-render the list of selected competencies.\n *\n * @method renderCompetencies\n * @return {boolean}\n */\n var renderCompetencies = function() {\n var currentCompetencies = $('[data-action=\"competencies\"]').val();\n var requests = [];\n var i = 0;\n\n if (currentCompetencies != '') {\n currentCompetencies = currentCompetencies.split(',');\n for (i = 0; i < currentCompetencies.length; i++) {\n requests[requests.length] = {\n methodname: 'core_competency_read_competency',\n args: {id: currentCompetencies[i]}\n };\n }\n }\n\n $.when.apply($, Ajax.call(requests, false)).then(function() {\n var i = 0,\n competencies = [];\n\n for (i = 0; i < arguments.length; i++) {\n competencies[i] = arguments[i];\n }\n var context = {\n competencies: competencies\n };\n\n return Templates.render('tool_lp/form_competency_list', context);\n }).then(function(html, js) {\n Templates.replaceNode($('[data-region=\"competencies\"]'), html, js);\n return true;\n }).fail(Notification.exception);\n\n return true;\n };\n\n /**\n * Deselect a competency\n *\n * @method unpickCompetenciesHandler\n * @param {Event} e\n * @return {boolean}\n */\n var unpickCompetenciesHandler = function(e) {\n var currentCompetencies = $('[data-action=\"competencies\"]').val().split(','),\n newCompetencies = [],\n i,\n toRemove = $(e.currentTarget).data('id');\n\n for (i = 0; i < currentCompetencies.length; i++) {\n if (currentCompetencies[i] != toRemove) {\n newCompetencies[newCompetencies.length] = currentCompetencies[i];\n }\n }\n\n $('[data-action=\"competencies\"]').val(newCompetencies.join(','));\n\n return renderCompetencies();\n };\n\n /**\n * Open a competencies popup to relate competencies.\n *\n * @method pickCompetenciesHandler\n */\n var pickCompetenciesHandler = function() {\n var currentCompetencies = $('[data-action=\"competencies\"]').val().split(',');\n\n if (!pickerInstance) {\n pickerInstance = new Picker(pageContextId, false, 'parents', true);\n pickerInstance.on('save', function(e, data) {\n var before = $('[data-action=\"competencies\"]').val();\n var compIds = data.competencyIds;\n if (before != '') {\n compIds = compIds.concat(before.split(','));\n }\n var value = compIds.join(',');\n\n $('[data-action=\"competencies\"]').val(value);\n\n return renderCompetencies();\n });\n }\n\n pickerInstance.setDisallowedCompetencyIDs(currentCompetencies);\n pickerInstance.display();\n };\n\n return /** @alias module:tool_lp/form_competency_element */ {\n /**\n * Listen for clicks on the competency picker and push the changes to the form element.\n *\n * @method init\n * @param {Integer} contextId\n */\n init: function(contextId) {\n pageContextId = contextId;\n renderCompetencies();\n $('[data-action=\"select-competencies\"]').on('click', pickCompetenciesHandler);\n $('body').on('click', '[data-action=\"deselect-competency\"]', unpickCompetenciesHandler);\n }\n };\n});\n"],"names":["define","$","Picker","Ajax","Notification","Templates","pickerInstance","pageContextId","renderCompetencies","currentCompetencies","val","requests","i","split","length","methodname","args","id","when","apply","call","then","competencies","arguments","context","render","html","js","replaceNode","fail","exception","unpickCompetenciesHandler","e","newCompetencies","toRemove","currentTarget","data","join","pickCompetenciesHandler","on","before","compIds","competencyIds","concat","value","setDisallowedCompetencyIDs","display","init","contextId"],"mappings":";;;;;;;AAsBAA,OAAM,kC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AAW,IAC9CgC,GAAG,QAAQ,SAASP,EAAGI,MAClC,IAAII,OAASvC,EAAE,gCAAgCS,MAC3C+B,QAAUL,KAAKM,cACL,IAAVF,SACAC,QAAUA,QAAQE,OAAOH,OAAO3B,MAAM,OAE1C,IAAI+B,MAAQH,QAAQJ,KAAK,KAIzB,OAFApC,EAAE,gCAAgCS,IAAIkC,OAE/BpC,oBACX,IAGJF,eAAeuC,2BAA2BpC,qBAC1CH,eAAewC,WAGnB,MAA4D,CAOxDC,KAAM,SAASC,WACXzC,cAAgByC,UAChBxC,qBACAP,EAAE,uCAAuCsC,GAAG,QAASD,yBACrDrC,EAAE,QAAQsC,GAAG,QAAS,sCAAuCR,0BACjE,EAER"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/frameworkactions.min.js.map b/admin/tool/lp/amd/build/frameworkactions.min.js.map index 96e2bbfc0ee..82454831a9f 100644 --- a/admin/tool/lp/amd/build/frameworkactions.min.js.map +++ b/admin/tool/lp/amd/build/frameworkactions.min.js.map @@ -1 +1 @@ -{"version":3,"file":"frameworkactions.min.js","sources":["../src/frameworkactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency frameworks actions via ajax.\n *\n * @module tool_lp/frameworkactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'], function($, templates, ajax, notification, str) {\n // Private variables and functions.\n\n /** @var {Number} pagecontextid The id of the context */\n var pagecontextid = 0;\n\n /** @var {Number} frameworkid The id of the framework */\n var frameworkid = 0;\n\n /**\n * Callback to replace the dom element with the rendered template.\n *\n * @param {String} newhtml The new html to insert.\n * @param {String} newjs The new js to run.\n */\n var updatePage = function(newhtml, newjs) {\n $('[data-region=\"managecompetencies\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n };\n\n /**\n * Callback to render the page template again and update the page.\n *\n * @param {Object} context The context for the template.\n */\n var reloadList = function(context) {\n templates.render('tool_lp/manage_competency_frameworks_page', context)\n .done(updatePage)\n .fail(notification.exception);\n };\n\n /**\n * Duplicate a framework and reload the page.\n * @method doDuplicate\n * @param {Event} e\n */\n var doDuplicate = function(e) {\n e.preventDefault();\n\n frameworkid = $(this).attr('data-frameworkid');\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_duplicate_competency_framework',\n args: {id: frameworkid}\n }, {\n methodname: 'tool_lp_data_for_competency_frameworks_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n /**\n * Delete a framework and reload the page.\n */\n var doDelete = function() {\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_delete_competency_framework',\n args: {id: frameworkid}\n }, {\n methodname: 'tool_lp_data_for_competency_frameworks_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[0].done(function(success) {\n if (success === false) {\n var req = ajax.call([{\n methodname: 'core_competency_read_competency_framework',\n args: {id: frameworkid}\n }]);\n req[0].done(function(framework) {\n str.get_strings([\n {key: 'frameworkcannotbedeleted', component: 'tool_lp', param: framework.shortname},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.alert(\n null,\n strings[0]\n );\n }).fail(notification.exception);\n });\n }\n }).fail(notification.exception);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Handler for \"Delete competency framework\" actions.\n * @param {Event} e\n */\n var confirmDelete = function(e) {\n e.preventDefault();\n\n var id = $(this).attr('data-frameworkid');\n frameworkid = id;\n\n var requests = ajax.call([{\n methodname: 'core_competency_read_competency_framework',\n args: {id: frameworkid}\n }]);\n\n requests[0].done(function(framework) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deletecompetencyframework', component: 'tool_lp', param: framework.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency framework X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n\n return /** @alias module:tool_lp/frameworkactions */ {\n // Public variables and functions.\n\n /**\n * Expose the event handler for delete.\n * @method deleteHandler\n * @param {Event} e\n */\n deleteHandler: confirmDelete,\n\n /**\n * Expose the event handler for duplicate.\n * @method duplicateHandler\n * @param {Event} e\n */\n duplicateHandler: doDuplicate,\n\n /**\n * Initialise the module.\n * @method init\n * @param {Number} contextid The context id of the page.\n */\n init: function(contextid) {\n pagecontextid = contextid;\n }\n };\n});\n"],"names":["define","$","templates","ajax","notification","str","pagecontextid","frameworkid","updatePage","newhtml","newjs","replaceWith","runTemplateJS","reloadList","context","render","done","fail","exception","doDelete","requests","call","methodname","args","id","pagecontext","contextid","success","framework","get_strings","key","component","param","shortname","strings","alert","deleteHandler","e","preventDefault","this","attr","confirm","duplicateHandler","init"],"mappings":";;;;;;;AAsBAA,kCAAO,CAAC,SAAU,iBAAkB,YAAa,oBAAqB,aAAa,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,SAItHC,cAAgB,EAGhBC,YAAc,EAQdC,WAAa,SAASC,QAASC,OAC/BT,EAAE,sCAAsCU,YAAYF,SACpDP,UAAUU,cAAcF,QAQxBG,WAAa,SAASC,SACtBZ,UAAUa,OAAO,4CAA6CD,SACzDE,KAAKR,YACLS,KAAKb,aAAac,YA8BvBC,SAAW,eAGPC,SAAW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CACTC,UAAWpB,mBAId,GAAGU,KAAKH,YAAYI,KAAKb,aAAac,YAkG/CyB,KAAM,SAASjB,WACXpB,cAAgBoB"} \ No newline at end of file +{"version":3,"file":"frameworkactions.min.js","sources":["../src/frameworkactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency frameworks actions via ajax.\n *\n * @module tool_lp/frameworkactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'], function($, templates, ajax, notification, str) {\n // Private variables and functions.\n\n /** @var {Number} pagecontextid The id of the context */\n var pagecontextid = 0;\n\n /** @var {Number} frameworkid The id of the framework */\n var frameworkid = 0;\n\n /**\n * Callback to replace the dom element with the rendered template.\n *\n * @param {String} newhtml The new html to insert.\n * @param {String} newjs The new js to run.\n */\n var updatePage = function(newhtml, newjs) {\n $('[data-region=\"managecompetencies\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n };\n\n /**\n * Callback to render the page template again and update the page.\n *\n * @param {Object} context The context for the template.\n */\n var reloadList = function(context) {\n templates.render('tool_lp/manage_competency_frameworks_page', context)\n .done(updatePage)\n .fail(notification.exception);\n };\n\n /**\n * Duplicate a framework and reload the page.\n * @method doDuplicate\n * @param {Event} e\n */\n var doDuplicate = function(e) {\n e.preventDefault();\n\n frameworkid = $(this).attr('data-frameworkid');\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_duplicate_competency_framework',\n args: {id: frameworkid}\n }, {\n methodname: 'tool_lp_data_for_competency_frameworks_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n /**\n * Delete a framework and reload the page.\n */\n var doDelete = function() {\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_delete_competency_framework',\n args: {id: frameworkid}\n }, {\n methodname: 'tool_lp_data_for_competency_frameworks_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[0].done(function(success) {\n if (success === false) {\n var req = ajax.call([{\n methodname: 'core_competency_read_competency_framework',\n args: {id: frameworkid}\n }]);\n req[0].done(function(framework) {\n str.get_strings([\n {key: 'frameworkcannotbedeleted', component: 'tool_lp', param: framework.shortname},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.alert(\n null,\n strings[0]\n );\n }).fail(notification.exception);\n });\n }\n }).fail(notification.exception);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Handler for \"Delete competency framework\" actions.\n * @param {Event} e\n */\n var confirmDelete = function(e) {\n e.preventDefault();\n\n var id = $(this).attr('data-frameworkid');\n frameworkid = id;\n\n var requests = ajax.call([{\n methodname: 'core_competency_read_competency_framework',\n args: {id: frameworkid}\n }]);\n\n requests[0].done(function(framework) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deletecompetencyframework', component: 'tool_lp', param: framework.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency framework X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n\n return /** @alias module:tool_lp/frameworkactions */ {\n // Public variables and functions.\n\n /**\n * Expose the event handler for delete.\n * @method deleteHandler\n * @param {Event} e\n */\n deleteHandler: confirmDelete,\n\n /**\n * Expose the event handler for duplicate.\n * @method duplicateHandler\n * @param {Event} e\n */\n duplicateHandler: doDuplicate,\n\n /**\n * Initialise the module.\n * @method init\n * @param {Number} contextid The context id of the page.\n */\n init: function(contextid) {\n pagecontextid = contextid;\n }\n };\n});\n"],"names":["define","$","templates","ajax","notification","str","pagecontextid","frameworkid","updatePage","newhtml","newjs","replaceWith","runTemplateJS","reloadList","context","render","done","fail","exception","doDelete","requests","call","methodname","args","id","pagecontext","contextid","success","framework","get_strings","key","component","param","shortname","strings","alert","deleteHandler","e","preventDefault","this","attr","confirm","duplicateHandler","init"],"mappings":";;;;;;;AAsBAA,OAAM,2BAAC,CAAC,SAAU,iBAAkB,YAAa,oBAAqB,aAAa,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,KAI1H,IAAIC,cAAgB,EAGhBC,YAAc,EAQdC,WAAa,SAASC,QAASC,OAC/BT,EAAE,sCAAsCU,YAAYF,SACpDP,UAAUU,cAAcF,QAQxBG,WAAa,SAASC,SACtBZ,UAAUa,OAAO,4CAA6CD,SACzDE,KAAKR,YACLS,KAAKb,aAAac,YA8BvBC,SAAW,WAGX,IAAIC,SAAWjB,KAAKkB,KAAK,CAAC,CACtBC,WAAY,8CACZC,KAAM,CAACC,GAAIjB,cACZ,CACCe,WAAY,qDACZC,KAAM,CACFE,YAAa,CACTC,UAAWpB,mBAIvBc,SAAS,GAAGJ,MAAK,SAASW,UACN,IAAZA,SACUxB,KAAKkB,KAAK,CAAC,CACjBC,WAAY,4CACZC,KAAM,CAACC,GAAIjB,gBAEX,GAAGS,MAAK,SAASY,WACjBvB,IAAIwB,YAAY,CACZ,CAACC,IAAK,2BAA4BC,UAAW,UAAWC,MAAOJ,UAAUK,WACzE,CAACH,IAAK,SAAUC,UAAW,YAC5Bf,MAAK,SAASkB,SACb9B,aAAa+B,MACT,KACAD,QAAQ,GAEf,IAAEjB,KAAKb,aAAac,UACzB,GAEP,IAAED,KAAKb,aAAac,WACrBE,SAAS,GAAGJ,KAAKH,YAAYI,KAAKb,aAAac,YAsCnD,MAAqD,CAQjDkB,cAvCgB,SAASC,GACzBA,EAAEC,iBAEF,IAAId,GAAKvB,EAAEsC,MAAMC,KAAK,oBACtBjC,YAAciB,GAECrB,KAAKkB,KAAK,CAAC,CACtBC,WAAY,4CACZC,KAAM,CAACC,GAAIjB,gBAGN,GAAGS,MAAK,SAASY,WACtBvB,IAAIwB,YAAY,CACZ,CAACC,IAAK,UAAWC,UAAW,UAC5B,CAACD,IAAK,4BAA6BC,UAAW,UAAWC,MAAOJ,UAAUK,WAC1E,CAACH,IAAK,SAAUC,UAAW,UAC3B,CAACD,IAAK,SAAUC,UAAW,YAC5Bf,MAAK,SAASkB,SACb9B,aAAaqC,QACTP,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRf,SAEP,IAAEF,KAAKb,aAAac,UACxB,IAAED,KAAKb,aAAac,YAoBrBwB,iBA5Gc,SAASL,GACvBA,EAAEC,iBAEF/B,YAAcN,EAAEsC,MAAMC,KAAK,oBAGZrC,KAAKkB,KAAK,CAAC,CACtBC,WAAY,iDACZC,KAAM,CAACC,GAAIjB,cACZ,CACCe,WAAY,qDACZC,KAAM,CACFE,YAAa,CACTC,UAAWpB,mBAId,GAAGU,KAAKH,YAAYI,KAAKb,aAAac,YAkG/CyB,KAAM,SAASjB,WACXpB,cAAgBoB,SACpB,EAER"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/frameworks_datasource.min.js.map b/admin/tool/lp/amd/build/frameworks_datasource.min.js.map index 26a6873f93f..a124c0a32d7 100644 --- a/admin/tool/lp/amd/build/frameworks_datasource.min.js.map +++ b/admin/tool/lp/amd/build/frameworks_datasource.min.js.map @@ -1 +1 @@ -{"version":3,"file":"frameworks_datasource.min.js","sources":["../src/frameworks_datasource.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Frameworks datasource.\n *\n * This module is compatible with core/form-autocomplete.\n *\n * @module tool_lp/frameworks_datasource\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {\n\n return /** @alias module:tool_lpmigrate/frameworks_datasource */ {\n\n /**\n * List frameworks.\n *\n * @param {Number} contextId The context ID.\n * @param {Object} options Additional parameters to pass to the external function.\n * @return {Promise}\n */\n list: function(contextId, options) {\n var args = {\n context: {\n contextid: contextId\n }\n };\n\n $.extend(args, typeof options === 'undefined' ? {} : options);\n return Ajax.call([{\n methodname: 'core_competency_list_competency_frameworks',\n args: args\n }])[0];\n },\n\n /**\n * Process the results for auto complete elements.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {Array} results An array or results.\n * @return {Array} New array of results.\n */\n processResults: function(selector, results) {\n var options = [];\n $.each(results, function(index, data) {\n options.push({\n value: data.id,\n label: data.shortname + ' ' + data.idnumber\n });\n });\n return options;\n },\n\n /**\n * Source of data for Ajax element.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {String} query The query string.\n * @param {Function} callback A callback function receiving an array of results.\n */\n /* eslint-disable promise/no-callback-in-promise */\n transport: function(selector, query, callback) {\n var el = $(selector),\n contextId = el.data('contextid'),\n onlyVisible = el.data('onlyvisible');\n\n if (!contextId) {\n throw new Error('The attribute data-contextid is required on ' + selector);\n }\n this.list(contextId, {\n query: query,\n onlyvisible: onlyVisible,\n }).then(callback).catch(Notification.exception);\n }\n };\n\n});\n"],"names":["define","$","Ajax","Notification","list","contextId","options","args","context","contextid","extend","call","methodname","processResults","selector","results","each","index","data","push","value","id","label","shortname","idnumber","transport","query","callback","el","onlyVisible","Error","onlyvisible","then","catch","exception"],"mappings":";;;;;;;;;AAyBAA,uCAAO,CAAC,SAAU,YAAa,sBAAsB,SAASC,EAAGC,KAAMC,oBAEF,CAS7DC,KAAM,SAASC,UAAWC,aAClBC,KAAO,CACHC,QAAS,CACLC,UAAWJ,mBAIvBJ,EAAES,OAAOH,UAAyB,IAAZD,QAA0B,GAAKA,SAC9CJ,KAAKS,KAAK,CAAC,CACdC,WAAY,6CACZL,KAAMA,QACN,IAURM,eAAgB,SAASC,SAAUC,aAC3BT,QAAU,UACdL,EAAEe,KAAKD,SAAS,SAASE,MAAOC,MAC5BZ,QAAQa,KAAK,CACTC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,UAAY,IAAML,KAAKM,cAGpClB,SAWXmB,UAAW,SAASX,SAAUY,MAAOC,cAC7BC,GAAK3B,EAAEa,UACPT,UAAYuB,GAAGV,KAAK,aACpBW,YAAcD,GAAGV,KAAK,mBAErBb,gBACK,IAAIyB,MAAM,+CAAiDhB,eAEhEV,KAAKC,UAAW,CACjBqB,MAAOA,MACPK,YAAaF,cACdG,KAAKL,UAAUM,MAAM9B,aAAa+B"} \ No newline at end of file +{"version":3,"file":"frameworks_datasource.min.js","sources":["../src/frameworks_datasource.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Frameworks datasource.\n *\n * This module is compatible with core/form-autocomplete.\n *\n * @module tool_lp/frameworks_datasource\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {\n\n return /** @alias module:tool_lpmigrate/frameworks_datasource */ {\n\n /**\n * List frameworks.\n *\n * @param {Number} contextId The context ID.\n * @param {Object} options Additional parameters to pass to the external function.\n * @return {Promise}\n */\n list: function(contextId, options) {\n var args = {\n context: {\n contextid: contextId\n }\n };\n\n $.extend(args, typeof options === 'undefined' ? {} : options);\n return Ajax.call([{\n methodname: 'core_competency_list_competency_frameworks',\n args: args\n }])[0];\n },\n\n /**\n * Process the results for auto complete elements.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {Array} results An array or results.\n * @return {Array} New array of results.\n */\n processResults: function(selector, results) {\n var options = [];\n $.each(results, function(index, data) {\n options.push({\n value: data.id,\n label: data.shortname + ' ' + data.idnumber\n });\n });\n return options;\n },\n\n /**\n * Source of data for Ajax element.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {String} query The query string.\n * @param {Function} callback A callback function receiving an array of results.\n */\n /* eslint-disable promise/no-callback-in-promise */\n transport: function(selector, query, callback) {\n var el = $(selector),\n contextId = el.data('contextid'),\n onlyVisible = el.data('onlyvisible');\n\n if (!contextId) {\n throw new Error('The attribute data-contextid is required on ' + selector);\n }\n this.list(contextId, {\n query: query,\n onlyvisible: onlyVisible,\n }).then(callback).catch(Notification.exception);\n }\n };\n\n});\n"],"names":["define","$","Ajax","Notification","list","contextId","options","args","context","contextid","extend","call","methodname","processResults","selector","results","each","index","data","push","value","id","label","shortname","idnumber","transport","query","callback","el","onlyVisible","Error","this","onlyvisible","then","catch","exception"],"mappings":";;;;;;;;;AAyBAA,OAAO,gCAAA,CAAC,SAAU,YAAa,sBAAsB,SAASC,EAAGC,KAAMC,cAEnE,MAAiE,CAS7DC,KAAM,SAASC,UAAWC,SACtB,IAAIC,KAAO,CACHC,QAAS,CACLC,UAAWJ,YAKvB,OADAJ,EAAES,OAAOH,UAAyB,IAAZD,QAA0B,CAAA,EAAKA,SAC9CJ,KAAKS,KAAK,CAAC,CACdC,WAAY,6CACZL,KAAMA,QACN,EACP,EASDM,eAAgB,SAASC,SAAUC,SAC/B,IAAIT,QAAU,GAOd,OANAL,EAAEe,KAAKD,SAAS,SAASE,MAAOC,MAC5BZ,QAAQa,KAAK,CACTC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,UAAY,IAAML,KAAKM,UAE3C,IACOlB,OACV,EAUDmB,UAAW,SAASX,SAAUY,MAAOC,UACjC,IAAIC,GAAK3B,EAAEa,UACPT,UAAYuB,GAAGV,KAAK,aACpBW,YAAcD,GAAGV,KAAK,eAE1B,IAAKb,UACD,MAAM,IAAIyB,MAAM,+CAAiDhB,UAErEiB,KAAK3B,KAAKC,UAAW,CACjBqB,MAAOA,MACPM,YAAaH,cACdI,KAAKN,UAAUO,MAAM/B,aAAagC,UACzC,EAGR"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/grade_dialogue.min.js.map b/admin/tool/lp/amd/build/grade_dialogue.min.js.map index 52764f4e8fe..64af8431358 100644 --- a/admin/tool/lp/amd/build/grade_dialogue.min.js.map +++ b/admin/tool/lp/amd/build/grade_dialogue.min.js.map @@ -1 +1 @@ -{"version":3,"file":"grade_dialogue.min.js","sources":["../src/grade_dialogue.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Grade dialogue.\n *\n * @module tool_lp/grade_dialogue\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base',\n 'core/str'],\n function($, Notification, Templates, Dialogue, EventBase, Str) {\n\n /**\n * Grade dialogue class.\n *\n * @class tool_lp/grade_dialogue\n * @param {Array} ratingOptions\n */\n var Grade = function(ratingOptions) {\n EventBase.prototype.constructor.apply(this, []);\n this._ratingOptions = ratingOptions;\n };\n Grade.prototype = Object.create(EventBase.prototype);\n\n /** @property {Dialogue} The dialogue. */\n Grade.prototype._popup = null;\n /** @property {Array} Array of objects containing, 'value', 'name' and optionally 'selected'. */\n Grade.prototype._ratingOptions = null;\n\n /**\n * After render hook.\n *\n * @method _afterRender\n * @protected\n */\n Grade.prototype._afterRender = function() {\n var btnRate = this._find('[data-action=\"rate\"]'),\n lstRating = this._find('[name=\"rating\"]'),\n txtComment = this._find('[name=\"comment\"]');\n\n this._find('[data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n this._trigger('cancelled');\n this.close();\n }.bind(this));\n\n lstRating.change(function() {\n var node = $(this);\n if (!node.val()) {\n btnRate.prop('disabled', true);\n } else {\n btnRate.prop('disabled', false);\n }\n }).change();\n\n btnRate.click(function(e) {\n e.preventDefault();\n var val = lstRating.val();\n if (!val) {\n return;\n }\n this._trigger('rated', {\n 'rating': val,\n 'note': txtComment.val()\n });\n this.close();\n }.bind(this));\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Grade.prototype.close = function() {\n this._popup.close();\n this._popup = null;\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @return {Promise}\n */\n Grade.prototype.display = function() {\n M.util.js_pending('tool_lp/grade_dialogue:display');\n return $.when(\n Str.get_string('rate', 'tool_lp'),\n this._render()\n )\n .then(function(title, templateResult) {\n this._popup = new Dialogue(\n title,\n templateResult[0],\n function() {\n this._afterRender();\n M.util.js_complete('tool_lp/grade_dialogue:display');\n }.bind(this)\n );\n\n return this._popup;\n }.bind(this))\n .catch(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @method _find\n * @returns {node} The node\n * @protected\n */\n Grade.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @protected\n * @return {Promise}\n */\n Grade.prototype._render = function() {\n var context = {\n cangrade: this._canGrade,\n ratings: this._ratingOptions\n };\n return Templates.render('tool_lp/competency_grader', context);\n };\n\n return Grade;\n});\n"],"names":["define","$","Notification","Templates","Dialogue","EventBase","Str","Grade","ratingOptions","prototype","constructor","apply","this","_ratingOptions","Object","create","_popup","_afterRender","btnRate","_find","lstRating","txtComment","click","e","preventDefault","_trigger","close","bind","change","val","prop","display","M","util","js_pending","when","get_string","_render","then","title","templateResult","js_complete","catch","exception","selector","getContent","find","context","cangrade","_canGrade","ratings","render"],"mappings":";;;;;;;AAuBAA,gCAAO,CAAC,SACA,oBACA,iBACA,mBACA,qBACA,aACA,SAASC,EAAGC,aAAcC,UAAWC,SAAUC,UAAWC,SAQ1DC,MAAQ,SAASC,eACjBH,UAAUI,UAAUC,YAAYC,MAAMC,KAAM,SACvCC,eAAiBL,sBAE1BD,MAAME,UAAYK,OAAOC,OAAOV,UAAUI,YAG1BO,OAAS,KAEzBT,MAAME,UAAUI,eAAiB,KAQjCN,MAAME,UAAUQ,aAAe,eACvBC,QAAUN,KAAKO,MAAM,wBACrBC,UAAYR,KAAKO,MAAM,mBACvBE,WAAaT,KAAKO,MAAM,yBAEvBA,MAAM,0BAA0BG,MAAM,SAASC,GAChDA,EAAEC,sBACGC,SAAS,kBACTC,SACPC,KAAKf,OAEPQ,UAAUQ,QAAO,WACF3B,EAAEW,MACHiB,MAGNX,QAAQY,KAAK,YAAY,GAFzBZ,QAAQY,KAAK,YAAY,MAI9BF,SAEHV,QAAQI,MAAM,SAASC,GACnBA,EAAEC,qBACEK,IAAMT,UAAUS,MACfA,WAGAJ,SAAS,QAAS,QACTI,SACFR,WAAWQ,aAElBH,UACPC,KAAKf,QAQXL,MAAME,UAAUiB,MAAQ,gBACfV,OAAOU,aACPV,OAAS,MASlBT,MAAME,UAAUsB,QAAU,kBACtBC,EAAEC,KAAKC,WAAW,kCACXjC,EAAEkC,KACL7B,IAAI8B,WAAW,OAAQ,WACvBxB,KAAKyB,WAERC,KAAK,SAASC,MAAOC,4BACbxB,OAAS,IAAIZ,SACdmC,MACAC,eAAe,GACf,gBACSvB,eACLe,EAAEC,KAAKQ,YAAY,mCACrBd,KAAKf,OAGJA,KAAKI,QACdW,KAAKf,OACN8B,MAAMxC,aAAayC,YAWxBpC,MAAME,UAAUU,MAAQ,SAASyB,iBACtB3C,EAAEW,KAAKI,OAAO6B,cAAcC,KAAKF,WAU5CrC,MAAME,UAAU4B,QAAU,eAClBU,QAAU,CACVC,SAAUpC,KAAKqC,UACfC,QAAStC,KAAKC,uBAEXV,UAAUgD,OAAO,4BAA6BJ,UAGlDxC"} \ No newline at end of file +{"version":3,"file":"grade_dialogue.min.js","sources":["../src/grade_dialogue.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Grade dialogue.\n *\n * @module tool_lp/grade_dialogue\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base',\n 'core/str'],\n function($, Notification, Templates, Dialogue, EventBase, Str) {\n\n /**\n * Grade dialogue class.\n *\n * @class tool_lp/grade_dialogue\n * @param {Array} ratingOptions\n */\n var Grade = function(ratingOptions) {\n EventBase.prototype.constructor.apply(this, []);\n this._ratingOptions = ratingOptions;\n };\n Grade.prototype = Object.create(EventBase.prototype);\n\n /** @property {Dialogue} The dialogue. */\n Grade.prototype._popup = null;\n /** @property {Array} Array of objects containing, 'value', 'name' and optionally 'selected'. */\n Grade.prototype._ratingOptions = null;\n\n /**\n * After render hook.\n *\n * @method _afterRender\n * @protected\n */\n Grade.prototype._afterRender = function() {\n var btnRate = this._find('[data-action=\"rate\"]'),\n lstRating = this._find('[name=\"rating\"]'),\n txtComment = this._find('[name=\"comment\"]');\n\n this._find('[data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n this._trigger('cancelled');\n this.close();\n }.bind(this));\n\n lstRating.change(function() {\n var node = $(this);\n if (!node.val()) {\n btnRate.prop('disabled', true);\n } else {\n btnRate.prop('disabled', false);\n }\n }).change();\n\n btnRate.click(function(e) {\n e.preventDefault();\n var val = lstRating.val();\n if (!val) {\n return;\n }\n this._trigger('rated', {\n 'rating': val,\n 'note': txtComment.val()\n });\n this.close();\n }.bind(this));\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Grade.prototype.close = function() {\n this._popup.close();\n this._popup = null;\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @return {Promise}\n */\n Grade.prototype.display = function() {\n M.util.js_pending('tool_lp/grade_dialogue:display');\n return $.when(\n Str.get_string('rate', 'tool_lp'),\n this._render()\n )\n .then(function(title, templateResult) {\n this._popup = new Dialogue(\n title,\n templateResult[0],\n function() {\n this._afterRender();\n M.util.js_complete('tool_lp/grade_dialogue:display');\n }.bind(this)\n );\n\n return this._popup;\n }.bind(this))\n .catch(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @method _find\n * @returns {node} The node\n * @protected\n */\n Grade.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @protected\n * @return {Promise}\n */\n Grade.prototype._render = function() {\n var context = {\n cangrade: this._canGrade,\n ratings: this._ratingOptions\n };\n return Templates.render('tool_lp/competency_grader', context);\n };\n\n return Grade;\n});\n"],"names":["define","$","Notification","Templates","Dialogue","EventBase","Str","Grade","ratingOptions","prototype","constructor","apply","this","_ratingOptions","Object","create","_popup","_afterRender","btnRate","_find","lstRating","txtComment","click","e","preventDefault","_trigger","close","bind","change","val","prop","rating","note","display","M","util","js_pending","when","get_string","_render","then","title","templateResult","js_complete","catch","exception","selector","getContent","find","context","cangrade","_canGrade","ratings","render"],"mappings":";;;;;;;AAuBAA,OAAM,yBAAC,CAAC,SACA,oBACA,iBACA,mBACA,qBACA,aACA,SAASC,EAAGC,aAAcC,UAAWC,SAAUC,UAAWC,KAQ9D,IAAIC,MAAQ,SAASC,eACjBH,UAAUI,UAAUC,YAAYC,MAAMC,KAAM,IAC5CA,KAAKC,eAAiBL,eAiH1B,OA/GAD,MAAME,UAAYK,OAAOC,OAAOV,UAAUI,YAG1BO,OAAS,KAEzBT,MAAME,UAAUI,eAAiB,KAQjCN,MAAME,UAAUQ,aAAe,WAC3B,IAAIC,QAAUN,KAAKO,MAAM,wBACrBC,UAAYR,KAAKO,MAAM,mBACvBE,WAAaT,KAAKO,MAAM,oBAE5BP,KAAKO,MAAM,0BAA0BG,MAAM,SAASC,GAChDA,EAAEC,iBACFZ,KAAKa,SAAS,aACdb,KAAKc,OACT,EAAEC,KAAKf,OAEPQ,UAAUQ,QAAO,WACF3B,EAAEW,MACHiB,MAGNX,QAAQY,KAAK,YAAY,GAFzBZ,QAAQY,KAAK,YAAY,MAI9BF,SAEHV,QAAQI,MAAM,SAASC,GACnBA,EAAEC,iBACF,IAAIK,IAAMT,UAAUS,MACfA,MAGLjB,KAAKa,SAAS,QAAS,CACnBM,OAAUF,IACVG,KAAQX,WAAWQ,QAEvBjB,KAAKc,QACT,EAAEC,KAAKf,QAQXL,MAAME,UAAUiB,MAAQ,WACpBd,KAAKI,OAAOU,QACZd,KAAKI,OAAS,MASlBT,MAAME,UAAUwB,QAAU,WAEtB,OADAC,EAAEC,KAAKC,WAAW,kCACXnC,EAAEoC,KACL/B,IAAIgC,WAAW,OAAQ,WACvB1B,KAAK2B,WAERC,KAAK,SAASC,MAAOC,gBAUlB,OATA9B,KAAKI,OAAS,IAAIZ,SACdqC,MACAC,eAAe,GACf,WACI9B,KAAKK,eACLiB,EAAEC,KAAKQ,YAAY,iCACvB,EAAEhB,KAAKf,OAGJA,KAAKI,MAChB,EAAEW,KAAKf,OACNgC,MAAM1C,aAAa2C,YAWxBtC,MAAME,UAAUU,MAAQ,SAAS2B,UAC7B,OAAO7C,EAAEW,KAAKI,OAAO+B,cAAcC,KAAKF,WAU5CvC,MAAME,UAAU8B,QAAU,WACtB,IAAIU,QAAU,CACVC,SAAUtC,KAAKuC,UACfC,QAASxC,KAAKC,gBAElB,OAAOV,UAAUkD,OAAO,4BAA6BJ,UAGlD1C,KACX"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/grade_user_competency_inline.min.js.map b/admin/tool/lp/amd/build/grade_user_competency_inline.min.js.map index 180d674de1a..ab0a1e7bf7d 100644 --- a/admin/tool/lp/amd/build/grade_user_competency_inline.min.js.map +++ b/admin/tool/lp/amd/build/grade_user_competency_inline.min.js.map @@ -1 +1 @@ -{"version":3,"file":"grade_user_competency_inline.min.js","sources":["../src/grade_user_competency_inline.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to enable inline editing of a comptency grade.\n *\n * @module tool_lp/grade_user_competency_inline\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/log',\n 'tool_lp/grade_dialogue',\n 'tool_lp/event_base',\n 'tool_lp/scalevalues',\n ], function($, notification, ajax, log, GradeDialogue, EventBase, ScaleValues) {\n\n /**\n * InlineEditor\n *\n * @class tool_lp/grade_user_competency_inline\n * @param {String} selector The selector to trigger the grading.\n * @param {Number} scaleId The id of the scale for this competency.\n * @param {Number} competencyId The id of the competency.\n * @param {Number} userId The id of the user.\n * @param {Number} planId The id of the plan.\n * @param {Number} courseId The id of the course.\n * @param {String} chooseStr Language string for choose a rating.\n */\n var InlineEditor = function(selector, scaleId, competencyId, userId, planId, courseId, chooseStr) {\n EventBase.prototype.constructor.apply(this, []);\n\n var trigger = $(selector);\n if (!trigger.length) {\n throw new Error('Could not find the trigger');\n }\n\n this._scaleId = scaleId;\n this._competencyId = competencyId;\n this._userId = userId;\n this._planId = planId;\n this._courseId = courseId;\n this._chooseStr = chooseStr;\n this._setUp();\n\n trigger.click(function(e) {\n e.preventDefault();\n this._dialogue.display();\n }.bind(this));\n\n if (this._planId) {\n this._methodName = 'core_competency_grade_competency_in_plan';\n this._args = {\n competencyid: this._competencyId,\n planid: this._planId\n };\n } else if (this._courseId) {\n this._methodName = 'core_competency_grade_competency_in_course';\n this._args = {\n competencyid: this._competencyId,\n courseid: this._courseId,\n userid: this._userId\n };\n } else {\n this._methodName = 'core_competency_grade_competency';\n this._args = {\n userid: this._userId,\n competencyid: this._competencyId\n };\n }\n };\n InlineEditor.prototype = Object.create(EventBase.prototype);\n\n /**\n * Setup.\n *\n * @method _setUp\n */\n InlineEditor.prototype._setUp = function() {\n var options = [],\n self = this;\n\n M.util.js_pending('tool_lp/grade_user_competency_inline:_setUp');\n var promise = ScaleValues.get_values(self._scaleId);\n promise.then(function(scalevalues) {\n options.push({\n value: '',\n name: self._chooseStr\n });\n\n for (var i = 0; i < scalevalues.length; i++) {\n var optionConfig = scalevalues[i];\n options.push({\n value: optionConfig.id,\n name: optionConfig.name\n });\n }\n\n return options;\n })\n .then(function(options) {\n return new GradeDialogue(options);\n })\n .then(function(dialogue) {\n dialogue.on('rated', function(e, data) {\n var args = self._args;\n args.grade = data.rating;\n args.note = data.note;\n ajax.call([{\n methodname: self._methodName,\n args: args,\n done: function(evidence) {\n self._trigger('competencyupdated', {args: args, evidence: evidence});\n },\n fail: notification.exception\n }]);\n });\n\n return dialogue;\n })\n .then(function(dialogue) {\n self._dialogue = dialogue;\n\n M.util.js_complete('tool_lp/grade_user_competency_inline:_setUp');\n return;\n })\n .fail(notification.exception);\n };\n\n /** @property {Number} The scale id for this competency. */\n InlineEditor.prototype._scaleId = null;\n /** @property {Number} The id of the competency. */\n InlineEditor.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n InlineEditor.prototype._userId = null;\n /** @property {Number} The id of the plan. */\n InlineEditor.prototype._planId = null;\n /** @property {Number} The id of the course. */\n InlineEditor.prototype._courseId = null;\n /** @property {String} The text for Choose rating. */\n InlineEditor.prototype._chooseStr = null;\n /** @property {GradeDialogue} The grading dialogue. */\n InlineEditor.prototype._dialogue = null;\n\n return InlineEditor;\n});\n"],"names":["define","$","notification","ajax","log","GradeDialogue","EventBase","ScaleValues","InlineEditor","selector","scaleId","competencyId","userId","planId","courseId","chooseStr","prototype","constructor","apply","this","trigger","length","Error","_scaleId","_competencyId","_userId","_planId","_courseId","_chooseStr","_setUp","click","e","preventDefault","_dialogue","display","bind","_methodName","_args","competencyid","planid","courseid","userid","Object","create","options","self","M","util","js_pending","get_values","then","scalevalues","push","value","name","i","optionConfig","id","dialogue","on","data","args","grade","rating","note","call","methodname","done","evidence","_trigger","fail","exception","js_complete"],"mappings":";;;;;;;AAuBAA,8CAAO,CAAC,SACA,oBACA,YACA,WACA,yBACA,qBACA,wBACD,SAASC,EAAGC,aAAcC,KAAM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,KAAKT,YACjByB,KAAMA,KACNM,KAAM,SAASC,UACXvB,KAAKwB,SAAS,oBAAqB,CAACR,KAAMA,KAAMO,SAAUA,YAE9DE,KAAMpE,aAAaqE,gBAIpBb,YAEVR,MAAK,SAASQ,UACXb,KAAKZ,UAAYyB,SAEjBZ,EAAEC,KAAKyB,YAAY,kDAGtBF,KAAKpE,aAAaqE,YAIvB/D,aAAaQ,UAAUO,SAAW,KAElCf,aAAaQ,UAAUQ,cAAgB,KAEvChB,aAAaQ,UAAUS,QAAU,KAEjCjB,aAAaQ,UAAUU,QAAU,KAEjClB,aAAaQ,UAAUW,UAAY,KAEnCnB,aAAaQ,UAAUY,WAAa,KAEpCpB,aAAaQ,UAAUiB,UAAY,KAE5BzB"} \ No newline at end of file +{"version":3,"file":"grade_user_competency_inline.min.js","sources":["../src/grade_user_competency_inline.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to enable inline editing of a comptency grade.\n *\n * @module tool_lp/grade_user_competency_inline\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/log',\n 'tool_lp/grade_dialogue',\n 'tool_lp/event_base',\n 'tool_lp/scalevalues',\n ], function($, notification, ajax, log, GradeDialogue, EventBase, ScaleValues) {\n\n /**\n * InlineEditor\n *\n * @class tool_lp/grade_user_competency_inline\n * @param {String} selector The selector to trigger the grading.\n * @param {Number} scaleId The id of the scale for this competency.\n * @param {Number} competencyId The id of the competency.\n * @param {Number} userId The id of the user.\n * @param {Number} planId The id of the plan.\n * @param {Number} courseId The id of the course.\n * @param {String} chooseStr Language string for choose a rating.\n */\n var InlineEditor = function(selector, scaleId, competencyId, userId, planId, courseId, chooseStr) {\n EventBase.prototype.constructor.apply(this, []);\n\n var trigger = $(selector);\n if (!trigger.length) {\n throw new Error('Could not find the trigger');\n }\n\n this._scaleId = scaleId;\n this._competencyId = competencyId;\n this._userId = userId;\n this._planId = planId;\n this._courseId = courseId;\n this._chooseStr = chooseStr;\n this._setUp();\n\n trigger.click(function(e) {\n e.preventDefault();\n this._dialogue.display();\n }.bind(this));\n\n if (this._planId) {\n this._methodName = 'core_competency_grade_competency_in_plan';\n this._args = {\n competencyid: this._competencyId,\n planid: this._planId\n };\n } else if (this._courseId) {\n this._methodName = 'core_competency_grade_competency_in_course';\n this._args = {\n competencyid: this._competencyId,\n courseid: this._courseId,\n userid: this._userId\n };\n } else {\n this._methodName = 'core_competency_grade_competency';\n this._args = {\n userid: this._userId,\n competencyid: this._competencyId\n };\n }\n };\n InlineEditor.prototype = Object.create(EventBase.prototype);\n\n /**\n * Setup.\n *\n * @method _setUp\n */\n InlineEditor.prototype._setUp = function() {\n var options = [],\n self = this;\n\n M.util.js_pending('tool_lp/grade_user_competency_inline:_setUp');\n var promise = ScaleValues.get_values(self._scaleId);\n promise.then(function(scalevalues) {\n options.push({\n value: '',\n name: self._chooseStr\n });\n\n for (var i = 0; i < scalevalues.length; i++) {\n var optionConfig = scalevalues[i];\n options.push({\n value: optionConfig.id,\n name: optionConfig.name\n });\n }\n\n return options;\n })\n .then(function(options) {\n return new GradeDialogue(options);\n })\n .then(function(dialogue) {\n dialogue.on('rated', function(e, data) {\n var args = self._args;\n args.grade = data.rating;\n args.note = data.note;\n ajax.call([{\n methodname: self._methodName,\n args: args,\n done: function(evidence) {\n self._trigger('competencyupdated', {args: args, evidence: evidence});\n },\n fail: notification.exception\n }]);\n });\n\n return dialogue;\n })\n .then(function(dialogue) {\n self._dialogue = dialogue;\n\n M.util.js_complete('tool_lp/grade_user_competency_inline:_setUp');\n return;\n })\n .fail(notification.exception);\n };\n\n /** @property {Number} The scale id for this competency. */\n InlineEditor.prototype._scaleId = null;\n /** @property {Number} The id of the competency. */\n InlineEditor.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n InlineEditor.prototype._userId = null;\n /** @property {Number} The id of the plan. */\n InlineEditor.prototype._planId = null;\n /** @property {Number} The id of the course. */\n InlineEditor.prototype._courseId = null;\n /** @property {String} The text for Choose rating. */\n InlineEditor.prototype._chooseStr = null;\n /** @property {GradeDialogue} The grading dialogue. */\n InlineEditor.prototype._dialogue = null;\n\n return InlineEditor;\n});\n"],"names":["define","$","notification","ajax","log","GradeDialogue","EventBase","ScaleValues","InlineEditor","selector","scaleId","competencyId","userId","planId","courseId","chooseStr","prototype","constructor","apply","this","trigger","length","Error","_scaleId","_competencyId","_userId","_planId","_courseId","_chooseStr","_setUp","click","e","preventDefault","_dialogue","display","bind","_methodName","_args","competencyid","planid","courseid","userid","Object","create","options","self","M","util","js_pending","get_values","then","scalevalues","push","value","name","i","optionConfig","id","dialogue","on","data","args","grade","rating","note","call","methodname","done","evidence","_trigger","fail","exception","js_complete"],"mappings":";;;;;;;AAuBAA,OAAO,uCAAA,CAAC,SACA,oBACA,YACA,WACA,yBACA,qBACA,wBACD,SAASC,EAAGC,aAAcC,KAAMC,IAAKC,cAAeC,UAAWC,aAclE,IAAIC,aAAe,SAASC,SAAUC,QAASC,aAAcC,OAAQC,OAAQC,SAAUC,WACnFT,UAAUU,UAAUC,YAAYC,MAAMC,KAAM,IAE5C,IAAIC,QAAUnB,EAAEQ,UAChB,IAAKW,QAAQC,OACT,MAAM,IAAIC,MAAM,8BAGpBH,KAAKI,SAAWb,QAChBS,KAAKK,cAAgBb,aACrBQ,KAAKM,QAAUb,OACfO,KAAKO,QAAUb,OACfM,KAAKQ,UAAYb,SACjBK,KAAKS,WAAab,UAClBI,KAAKU,SAELT,QA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CR,MAAK,SAASQ,UACXb,KAAKZ,UAAYyB,SAEjBZ,EAAEC,KAAKyB,YAAY,8CAEtB,IACAF,KAAKpE,aAAaqE,YAIvB/D,aAAaQ,UAAUO,SAAW,KAElCf,aAAaQ,UAAUQ,cAAgB,KAEvChB,aAAaQ,UAAUS,QAAU,KAEjCjB,aAAaQ,UAAUU,QAAU,KAEjClB,aAAaQ,UAAUW,UAAY,KAEnCnB,aAAaQ,UAAUY,WAAa,KAEpCpB,aAAaQ,UAAUiB,UAAY,KAE5BzB,YACX"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/menubar.min.js.map b/admin/tool/lp/amd/build/menubar.min.js.map index 01dbfe4212f..9b8268c505f 100644 --- a/admin/tool/lp/amd/build/menubar.min.js.map +++ b/admin/tool/lp/amd/build/menubar.min.js.map @@ -1 +1 @@ -{"version":3,"file":"menubar.min.js","sources":["../src/menubar.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Aria menubar functionality. Enhances a simple nested list structure into a full aria widget.\n * Based on the open ajax example: http://oaa-accessibility.org/example/26/\n *\n * @module tool_lp/menubar\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'], function($) {\n\n /** @property {boolean} Flag to indicate if we have already registered a click event handler for the document. */\n var documentClickHandlerRegistered = false;\n\n /** @property {boolean} Flag to indicate whether there's an active, open menu. */\n var menuActive = false;\n\n /**\n * Close all open submenus anywhere in the page (there should only ever be one open at a time).\n *\n * @method closeAllSubMenus\n */\n var closeAllSubMenus = function() {\n $('.tool-lp-menu .tool-lp-sub-menu').attr('aria-hidden', 'true');\n // Every menu's closed at this point, so set the menu active flag to false.\n menuActive = false;\n };\n\n /**\n * Constructor\n *\n * @param {jQuery} menuRoot Jquery collection matching the root of the menu.\n * @param {Function[]} handlers called when a menu item is chosen.\n */\n var Menubar = function(menuRoot, handlers) {\n // Setup private class variables.\n this.menuRoot = menuRoot;\n this.handlers = handlers;\n this.rootMenus = this.menuRoot.children('li');\n this.subMenus = this.rootMenus.children('ul');\n this.subMenuItems = this.subMenus.children('li');\n this.allItems = this.rootMenus.add(this.subMenuItems);\n this.activeItem = null;\n this.isChildOpen = false;\n\n this.keys = {\n tab: 9,\n enter: 13,\n esc: 27,\n space: 32,\n left: 37,\n up: 38,\n right: 39,\n down: 40\n };\n\n this.addAriaAttributes();\n // Add the event listeners.\n this.addEventListeners();\n };\n\n /**\n * Open a submenu, first it closes all other sub-menus and sets the open direction.\n * @method openSubMenu\n * @param {Node} menu\n */\n Menubar.prototype.openSubMenu = function(menu) {\n this.setOpenDirection();\n closeAllSubMenus();\n menu.attr('aria-hidden', 'false');\n // Set menu active flag to true when a menu is opened.\n menuActive = true;\n };\n\n\n /**\n * Bind the event listeners to the DOM\n * @method addEventListeners\n */\n Menubar.prototype.addEventListeners = function() {\n var currentThis = this;\n\n // When clicking outside the menubar.\n if (documentClickHandlerRegistered === false) {\n $(document).click(function() {\n // Check if a menu is opened.\n if (menuActive) {\n // Close menu.\n closeAllSubMenus();\n }\n });\n // Set this flag to true so that we won't need to add a document click handler for the other Menubar instances.\n documentClickHandlerRegistered = true;\n }\n\n // Hovers.\n this.subMenuItems.mouseenter(function() {\n $(this).addClass('menu-hover');\n return true;\n });\n\n this.subMenuItems.mouseout(function() {\n $(this).removeClass('menu-hover');\n return true;\n });\n\n // Mouse listeners.\n this.allItems.click(function(e) {\n return currentThis.handleClick($(this), e);\n });\n\n // Key listeners.\n this.allItems.keydown(function(e) {\n return currentThis.handleKeyDown($(this), e);\n });\n\n this.allItems.focus(function() {\n return currentThis.handleFocus($(this));\n });\n\n this.allItems.blur(function() {\n return currentThis.handleBlur($(this));\n });\n };\n\n /**\n * Process click events for the top menus.\n *\n * @method handleClick\n * @param {Object} item is the jquery object of the item firing the event\n * @param {Event} e is the associated event object\n * @return {boolean} Returns false\n */\n Menubar.prototype.handleClick = function(item, e) {\n e.stopPropagation();\n\n var parentUL = item.parent();\n\n if (parentUL.is('.tool-lp-menu')) {\n // Toggle the child menu open/closed.\n if (item.children('ul').first().attr('aria-hidden') == 'true') {\n this.openSubMenu(item.children('ul').first());\n } else {\n item.children('ul').first().attr('aria-hidden', 'true');\n }\n } else {\n // Remove hover and focus styling.\n this.allItems.removeClass('menu-hover menu-focus');\n\n // Clear the active item.\n this.activeItem = null;\n\n // Close the menu.\n this.menuRoot.find('ul').not('.root-level').attr('aria-hidden', 'true');\n // Follow any link, or call the click handlers.\n var anchor = item.find('a').first();\n var clickEvent = new $.Event('click');\n clickEvent.target = anchor;\n var eventHandled = false;\n if (this.handlers) {\n $.each(this.handlers, function(selector, handler) {\n if (eventHandled) {\n return;\n }\n if (item.find(selector).length > 0) {\n var callable = $.proxy(handler, anchor);\n // False means stop propogatting events.\n eventHandled = (callable(clickEvent) === false) || clickEvent.isDefaultPrevented();\n }\n });\n }\n // If we didn't find a handler, and the HREF is # that probably means that\n // we are handling it from somewhere else. Let's just do nothing in that case.\n if (!eventHandled && anchor.attr('href') !== '#') {\n window.location.href = anchor.attr('href');\n }\n }\n return false;\n };\n\n /*\n * Process focus events for the menu.\n *\n * @method handleFocus\n * @param {Object} item is the jquery object of the item firing the event\n * @return boolean Returns false\n */\n Menubar.prototype.handleFocus = function(item) {\n\n // If activeItem is null, we are getting focus from outside the menu. Store\n // the item that triggered the event.\n if (this.activeItem === null) {\n this.activeItem = item;\n } else if (item[0] != this.activeItem[0]) {\n return true;\n }\n\n // Get the set of jquery objects for all the parent items of the active item.\n var parentItems = this.activeItem.parentsUntil('ul.tool-lp-menu').filter('li');\n\n // Remove focus styling from all other menu items.\n this.allItems.removeClass('menu-focus');\n\n // Add focus styling to the active item.\n this.activeItem.addClass('menu-focus');\n\n // Add focus styling to all parent items.\n parentItems.addClass('menu-focus');\n\n // If the bChildOpen flag has been set, open the active item's child menu (if applicable).\n if (this.isChildOpen === true) {\n\n var itemUL = item.parent();\n\n // If the itemUL is a root-level menu and item is a parent item,\n // show the child menu.\n if (itemUL.is('.tool-lp-menu') && (item.attr('aria-haspopup') == 'true')) {\n this.openSubMenu(item.children('ul').first());\n }\n }\n\n return true;\n };\n\n /*\n * Process blur events for the menu.\n *\n * @method handleBlur\n * @param {Object} item is the jquery object of the item firing the event\n * @return boolean Returns false\n */\n Menubar.prototype.handleBlur = function(item) {\n item.removeClass('menu-focus');\n\n return true;\n };\n\n /*\n * Determine if the menu should open to the left, or the right,\n * based on the screen size and menu position.\n * @method setOpenDirection\n */\n Menubar.prototype.setOpenDirection = function() {\n var pos = this.menuRoot.offset();\n var isRTL = $(document.body).hasClass('dir-rtl');\n var openLeft = true;\n var heightmenuRoot = this.rootMenus.outerHeight();\n var widthmenuRoot = this.rootMenus.outerWidth();\n // Sometimes the menuMinWidth is not enough to figure out if menu exceeds the window width.\n // So we have to calculate the real menu width.\n var subMenuContainer = this.rootMenus.find('ul.tool-lp-sub-menu');\n\n // Reset margins.\n subMenuContainer.css('margin-right', '');\n subMenuContainer.css('margin-left', '');\n subMenuContainer.css('margin-top', '');\n\n subMenuContainer.attr('aria-hidden', false);\n var menuRealWidth = subMenuContainer.outerWidth(),\n menuRealHeight = subMenuContainer.outerHeight();\n\n var margintop = null,\n marginright = null,\n marginleft = null;\n var top = pos.top - $(window).scrollTop();\n // Top is the same for RTL and LTR.\n if (top + menuRealHeight > $(window).height()) {\n margintop = menuRealHeight + heightmenuRoot;\n subMenuContainer.css('margin-top', '-' + margintop + 'px');\n }\n\n if (isRTL) {\n if (pos.left - menuRealWidth < 0) {\n marginright = menuRealWidth - widthmenuRoot;\n subMenuContainer.css('margin-right', '-' + marginright + 'px');\n }\n } else {\n if (pos.left + menuRealWidth > $(window).width()) {\n marginleft = menuRealWidth - widthmenuRoot;\n subMenuContainer.css('margin-left', '-' + marginleft + 'px');\n }\n }\n\n if (openLeft) {\n this.menuRoot.addClass('tool-lp-menu-open-left');\n } else {\n this.menuRoot.removeClass('tool-lp-menu-open-left');\n }\n\n };\n\n /*\n * Process keyDown events for the menu.\n *\n * @method handleKeyDown\n * @param {Object} item is the jquery object of the item firing the event\n * @param {Event} e is the associated event object\n * @return boolean Returns false if consuming the event\n */\n Menubar.prototype.handleKeyDown = function(item, e) {\n\n if (e.altKey || e.ctrlKey) {\n // Modifier key pressed: Do not process.\n return true;\n }\n\n switch (e.keyCode) {\n case this.keys.tab: {\n\n // Hide all menu items and update their aria attributes.\n this.menuRoot.find('ul').attr('aria-hidden', 'true');\n\n // Remove focus styling from all menu items.\n this.allItems.removeClass('menu-focus');\n\n this.activeItem = null;\n\n this.isChildOpen = false;\n\n break;\n }\n case this.keys.esc: {\n var itemUL = item.parent();\n\n if (itemUL.is('.tool-lp-menu')) {\n // Hide the child menu and update the aria attributes.\n item.children('ul').first().attr('aria-hidden', 'true');\n } else {\n\n // Move up one level.\n this.activeItem = itemUL.parent();\n\n // Reset the isChildOpen flag.\n this.isChildOpen = false;\n\n // Set focus on the new item.\n this.activeItem.focus();\n\n // Hide the active menu and update the aria attributes.\n itemUL.attr('aria-hidden', 'true');\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.enter:\n case this.keys.space: {\n // Trigger click handler.\n return this.handleClick(item, e);\n }\n\n case this.keys.left: {\n\n this.activeItem = this.moveToPrevious(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.right: {\n\n this.activeItem = this.moveToNext(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.up: {\n\n this.activeItem = this.moveUp(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.down: {\n\n this.activeItem = this.moveDown(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n }\n\n return true;\n\n };\n\n\n /**\n * Move to the next menu level.\n * This will be either the next root-level menu or the child of a menu parent. If\n * at the root level and the active item is the last in the menu, this function will loop\n * to the first menu item.\n *\n * If the menu is a horizontal menu, the first child element of the newly selected menu will\n * be selected\n *\n * @method moveToNext\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveToNext = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n\n // The items in the currently active menu.\n var menuItems = itemUL.children('li');\n\n // The number of items in the active menu.\n var menuNum = menuItems.length;\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var childMenu = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level move to next sibling. This will require closing\n // the current child menu and opening the new one.\n\n if (menuIndex < menuNum - 1) {\n // Not the last root menu.\n newItem = item.next();\n } else { // Wrap to first item.\n newItem = menuItems.first();\n }\n\n // Close the current child menu (if applicable).\n if (item.attr('aria-haspopup') == 'true') {\n\n childMenu = item.children('ul').first();\n\n if (childMenu.attr('aria-hidden') == 'false') {\n // Update the child menu's aria-hidden attribute.\n childMenu.attr('aria-hidden', 'true');\n this.isChildOpen = true;\n }\n }\n\n // Remove the focus styling from the current menu.\n item.removeClass('menu-focus');\n\n // Open the new child menu (if applicable).\n if ((newItem.attr('aria-haspopup') === 'true') && (this.isChildOpen === true)) {\n\n childMenu = newItem.children('ul').first();\n\n // Update the child's aria-hidden attribute.\n this.openSubMenu(childMenu);\n }\n } else {\n // This is not the root level. If there is a child menu to be moved into, do that;\n // otherwise, move to the next root-level menu if there is one.\n if (item.attr('aria-haspopup') == 'true') {\n\n childMenu = item.children('ul').first();\n\n newItem = childMenu.children('li').first();\n\n // Show the child menu and update its aria attributes.\n this.openSubMenu(childMenu);\n } else {\n // At deepest level, move to the next root-level menu.\n\n var parentMenus = null;\n var rootItem = null;\n\n // Get list of all parent menus for item, up to the root level.\n parentMenus = item.parentsUntil('ul.tool-lp-menu').filter('ul').not('.tool-lp-menu');\n\n // Hide the current menu and update its aria attributes accordingly.\n parentMenus.attr('aria-hidden', 'true');\n\n // Remove the focus styling from the active menu.\n parentMenus.find('li').removeClass('menu-focus');\n parentMenus.last().parent().removeClass('menu-focus');\n\n // The containing root for the menu.\n rootItem = parentMenus.last().parent();\n\n menuIndex = this.rootMenus.index(rootItem);\n\n // If this is not the last root menu item, move to the next one.\n if (menuIndex < this.rootMenus.length - 1) {\n newItem = rootItem.next();\n } else {\n // Loop.\n newItem = this.rootMenus.first();\n }\n\n // Add the focus styling to the new menu.\n newItem.addClass('menu-focus');\n\n if (newItem.attr('aria-haspopup') == 'true') {\n childMenu = newItem.children('ul').first();\n\n newItem = childMenu.children('li').first();\n\n // Show the child menu and update it's aria attributes.\n this.openSubMenu(childMenu);\n this.isChildOpen = true;\n }\n }\n }\n\n return newItem;\n };\n\n /**\n * Member function to move to the previous menu level.\n * This will be either the previous root-level menu or the child of a menu parent. If\n * at the root level and the active item is the first in the menu, this function will loop\n * to the last menu item.\n *\n * If the menu is a horizontal menu, the first child element of the newly selected menu will\n * be selected\n *\n * @method moveToPrevious\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveToPrevious = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li');\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var childMenu = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level move to previous sibling. This will require closing\n // the current child menu and opening the new one.\n\n if (menuIndex > 0) {\n // Not the first root menu.\n newItem = item.prev();\n } else {\n // Wrap to last item.\n newItem = menuItems.last();\n }\n\n // Close the current child menu (if applicable).\n if (item.attr('aria-haspopup') == 'true') {\n childMenu = item.children('ul').first();\n\n if (childMenu.attr('aria-hidden') == 'false') {\n // Update the child menu's aria-hidden attribute.\n childMenu.attr('aria-hidden', 'true');\n this.isChildOpen = true;\n }\n }\n\n // Remove the focus styling from the current menu.\n item.removeClass('menu-focus');\n\n // Open the new child menu (if applicable).\n if ((newItem.attr('aria-haspopup') === 'true') && (this.isChildOpen === true)) {\n\n childMenu = newItem.children('ul').first();\n\n // Update the child's aria-hidden attribute.\n this.openSubMenu(childMenu);\n\n }\n } else {\n // This is not the root level. If there is a parent menu that is not the\n // root menu, move up one level; otherwise, move to first item of the previous\n // root menu.\n\n var parentLI = itemUL.parent();\n var parentUL = parentLI.parent();\n\n // If this is a vertical menu or is not the first child menu\n // of the root-level menu, move up one level.\n if (!parentUL.is('.tool-lp-menu')) {\n\n newItem = itemUL.parent();\n\n // Hide the active menu and update aria-hidden.\n itemUL.attr('aria-hidden', 'true');\n\n // Remove the focus highlight from the item.\n item.removeClass('menu-focus');\n\n } else {\n // Move to previous root-level menu.\n\n // Hide the current menu and update the aria attributes accordingly.\n itemUL.attr('aria-hidden', 'true');\n\n // Remove the focus styling from the active menu.\n item.removeClass('menu-focus');\n parentLI.removeClass('menu-focus');\n\n menuIndex = this.rootMenus.index(parentLI);\n\n if (menuIndex > 0) {\n // Move to the previous root-level menu.\n newItem = parentLI.prev();\n } else {\n // Loop to last root-level menu.\n newItem = this.rootMenus.last();\n }\n\n // Add the focus styling to the new menu.\n newItem.addClass('menu-focus');\n\n if (newItem.attr('aria-haspopup') == 'true') {\n childMenu = newItem.children('ul').first();\n\n // Show the child menu and update it's aria attributes.\n this.openSubMenu(childMenu);\n this.isChildOpen = true;\n\n newItem = childMenu.children('li').first();\n }\n }\n }\n\n return newItem;\n };\n\n /**\n * Member function to select the next item in a menu.\n * If the active item is the last in the menu, this function will loop to the\n * first menu item.\n *\n * @method moveDown\n * @param {Object} item is the active menu item\n * @param {String} startChr is the character to attempt to match against the beginning of the\n * menu item titles. If found, focus moves to the next menu item beginning with that character.\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveDown = function(item, startChr) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li').not('.separator');\n // The number of items in the active menu.\n var menuNum = menuItems.length;\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var newItemUL = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level menu.\n\n if (item.attr('aria-haspopup') != 'true') {\n // No child menu to move to.\n return item;\n }\n\n // Move to the first item in the child menu.\n newItemUL = item.children('ul').first();\n newItem = newItemUL.children('li').first();\n\n // Make sure the child menu is visible.\n this.openSubMenu(newItemUL);\n\n return newItem;\n }\n\n // If $item is not the last item in its menu, move to the next item. If startChr is specified, move\n // to the next item with a title that begins with that character.\n if (startChr) {\n var match = false;\n var curNdx = menuIndex + 1;\n\n // Check if the active item was the last one on the list.\n if (curNdx == menuNum) {\n curNdx = 0;\n }\n\n // Iterate through the menu items (starting from the current item and wrapping) until a match is found\n // or the loop returns to the current menu item.\n while (curNdx != menuIndex) {\n\n var titleChr = menuItems.eq(curNdx).html().charAt(0);\n\n if (titleChr.toLowerCase() == startChr) {\n match = true;\n break;\n }\n\n curNdx = curNdx + 1;\n\n if (curNdx == menuNum) {\n // Reached the end of the list, start again at the beginning.\n curNdx = 0;\n }\n }\n\n if (match === true) {\n newItem = menuItems.eq(curNdx);\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n } else {\n return item;\n }\n } else {\n if (menuIndex < menuNum - 1) {\n newItem = menuItems.eq(menuIndex + 1);\n } else {\n newItem = menuItems.first();\n }\n }\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n };\n\n /**\n * Function moveUp() is a member function to select the previous item in a menu.\n * If the active item is the first in the menu, this function will loop to the\n * last menu item.\n *\n * @method moveUp\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveUp = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li').not('.separator');\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level menu.\n // Nothing to do.\n return item;\n }\n\n // If item is not the first item in its menu, move to the previous item.\n if (menuIndex > 0) {\n newItem = menuItems.eq(menuIndex - 1);\n } else {\n // Loop to top of menu.\n newItem = menuItems.last();\n }\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n };\n\n /**\n * Enhance the dom with aria attributes.\n * @method addAriaAttributes\n */\n Menubar.prototype.addAriaAttributes = function() {\n this.menuRoot.attr('role', 'menubar');\n this.rootMenus.attr('role', 'menuitem');\n this.rootMenus.attr('tabindex', '0');\n this.rootMenus.attr('aria-haspopup', 'true');\n this.subMenus.attr('role', 'menu');\n this.subMenus.attr('aria-hidden', 'true');\n this.subMenuItems.attr('role', 'menuitem');\n this.subMenuItems.attr('tabindex', '-1');\n\n // For CSS styling and effects.\n this.menuRoot.addClass('tool-lp-menu');\n this.allItems.addClass('tool-lp-menu-item');\n this.rootMenus.addClass('tool-lp-root-menu');\n this.subMenus.addClass('tool-lp-sub-menu');\n this.subMenuItems.addClass('dropdown-item');\n };\n\n return /** @alias module:tool_lp/menubar */ {\n /**\n * Create a menu bar object for every node matching the selector.\n *\n * The expected DOM structure is shown below.\n *
    <- This is the target of the selector parameter.\n *
  • <- This is repeated for each top level menu.\n * Text <- This is the text for the top level menu.\n *
      <- This is a list of the entries in this top level menu.\n *
    • <- This is repeated for each menu entry.\n * Choice 1 <- The anchor for the menu.\n *
    • \n *
    \n *
  • \n *
\n *\n * @method enhance\n * @param {String} selector - The selector for the outer most menu node.\n * @param {Function} handler - Javascript handler for when a menu item was chosen. If the\n * handler returns true (or does not exist), the\n * menu will look for an anchor with a link to follow.\n * For example, if the menu entry has a \"data-action\" attribute\n * and we want to call a javascript function when that entry is chosen,\n * we could pass a list of handlers like this:\n * { \"[data-action='add']\" : callAddFunction }\n */\n enhance: function(selector, handler) {\n $(selector).each(function(index, element) {\n var menuRoot = $(element);\n // Don't enhance the same menu twice.\n if (menuRoot.data(\"menubarEnhanced\") !== true) {\n (new Menubar(menuRoot, handler));\n menuRoot.data(\"menubarEnhanced\", true);\n }\n });\n },\n\n /**\n * Handy function to close all open menus anywhere on the page.\n * @method closeAll\n */\n closeAll: closeAllSubMenus\n };\n});\n"],"names":["define","$","documentClickHandlerRegistered","menuActive","closeAllSubMenus","attr","Menubar","menuRoot","handlers","rootMenus","this","children","subMenus","subMenuItems","allItems","add","activeItem","isChildOpen","keys","tab","enter","esc","space","left","up","right","down","addAriaAttributes","addEventListeners","prototype","openSubMenu","menu","setOpenDirection","currentThis","document","click","mouseenter","addClass","mouseout","removeClass","e","handleClick","keydown","handleKeyDown","focus","handleFocus","blur","handleBlur","item","stopPropagation","parent","is","first","find","not","anchor","clickEvent","Event","target","eventHandled","each","selector","handler","length","callable","proxy","isDefaultPrevented","window","location","href","parentItems","parentsUntil","filter","pos","offset","isRTL","body","hasClass","heightmenuRoot","outerHeight","widthmenuRoot","outerWidth","subMenuContainer","css","menuRealWidth","menuRealHeight","margintop","marginright","marginleft","top","scrollTop","height","width","altKey","ctrlKey","keyCode","itemUL","moveToPrevious","moveToNext","moveUp","moveDown","menuItems","menuNum","menuIndex","index","newItem","childMenu","next","parentMenus","rootItem","last","prev","parentLI","startChr","newItemUL","match","curNdx","eq","html","charAt","toLowerCase","enhance","element","data","closeAll"],"mappings":";;;;;;;;AAuBAA,yBAAO,CAAC,WAAW,SAASC,OAGpBC,gCAAiC,EAGjCC,YAAa,EAObC,iBAAmB,WACnBH,EAAE,mCAAmCI,KAAK,cAAe,QAEzDF,YAAa,GASbG,QAAU,SAASC,SAAUC,eAExBD,SAAWA,cACXC,SAAWA,cACXC,UAAYC,KAAKH,SAASI,SAAS,WACnCC,SAAWF,KAAKD,UAAUE,SAAS,WACn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H,SAASoH,KAAK,yBACTrH,QAAQC,SAAUuD,SACvBvD,SAASoH,KAAK,mBAAmB,QAS7CC,SAAUxH"} \ No newline at end of file +{"version":3,"file":"menubar.min.js","sources":["../src/menubar.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Aria menubar functionality. Enhances a simple nested list structure into a full aria widget.\n * Based on the open ajax example: http://oaa-accessibility.org/example/26/\n *\n * @module tool_lp/menubar\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'], function($) {\n\n /** @property {boolean} Flag to indicate if we have already registered a click event handler for the document. */\n var documentClickHandlerRegistered = false;\n\n /** @property {boolean} Flag to indicate whether there's an active, open menu. */\n var menuActive = false;\n\n /**\n * Close all open submenus anywhere in the page (there should only ever be one open at a time).\n *\n * @method closeAllSubMenus\n */\n var closeAllSubMenus = function() {\n $('.tool-lp-menu .tool-lp-sub-menu').attr('aria-hidden', 'true');\n // Every menu's closed at this point, so set the menu active flag to false.\n menuActive = false;\n };\n\n /**\n * Constructor\n *\n * @param {jQuery} menuRoot Jquery collection matching the root of the menu.\n * @param {Function[]} handlers called when a menu item is chosen.\n */\n var Menubar = function(menuRoot, handlers) {\n // Setup private class variables.\n this.menuRoot = menuRoot;\n this.handlers = handlers;\n this.rootMenus = this.menuRoot.children('li');\n this.subMenus = this.rootMenus.children('ul');\n this.subMenuItems = this.subMenus.children('li');\n this.allItems = this.rootMenus.add(this.subMenuItems);\n this.activeItem = null;\n this.isChildOpen = false;\n\n this.keys = {\n tab: 9,\n enter: 13,\n esc: 27,\n space: 32,\n left: 37,\n up: 38,\n right: 39,\n down: 40\n };\n\n this.addAriaAttributes();\n // Add the event listeners.\n this.addEventListeners();\n };\n\n /**\n * Open a submenu, first it closes all other sub-menus and sets the open direction.\n * @method openSubMenu\n * @param {Node} menu\n */\n Menubar.prototype.openSubMenu = function(menu) {\n this.setOpenDirection();\n closeAllSubMenus();\n menu.attr('aria-hidden', 'false');\n // Set menu active flag to true when a menu is opened.\n menuActive = true;\n };\n\n\n /**\n * Bind the event listeners to the DOM\n * @method addEventListeners\n */\n Menubar.prototype.addEventListeners = function() {\n var currentThis = this;\n\n // When clicking outside the menubar.\n if (documentClickHandlerRegistered === false) {\n $(document).click(function() {\n // Check if a menu is opened.\n if (menuActive) {\n // Close menu.\n closeAllSubMenus();\n }\n });\n // Set this flag to true so that we won't need to add a document click handler for the other Menubar instances.\n documentClickHandlerRegistered = true;\n }\n\n // Hovers.\n this.subMenuItems.mouseenter(function() {\n $(this).addClass('menu-hover');\n return true;\n });\n\n this.subMenuItems.mouseout(function() {\n $(this).removeClass('menu-hover');\n return true;\n });\n\n // Mouse listeners.\n this.allItems.click(function(e) {\n return currentThis.handleClick($(this), e);\n });\n\n // Key listeners.\n this.allItems.keydown(function(e) {\n return currentThis.handleKeyDown($(this), e);\n });\n\n this.allItems.focus(function() {\n return currentThis.handleFocus($(this));\n });\n\n this.allItems.blur(function() {\n return currentThis.handleBlur($(this));\n });\n };\n\n /**\n * Process click events for the top menus.\n *\n * @method handleClick\n * @param {Object} item is the jquery object of the item firing the event\n * @param {Event} e is the associated event object\n * @return {boolean} Returns false\n */\n Menubar.prototype.handleClick = function(item, e) {\n e.stopPropagation();\n\n var parentUL = item.parent();\n\n if (parentUL.is('.tool-lp-menu')) {\n // Toggle the child menu open/closed.\n if (item.children('ul').first().attr('aria-hidden') == 'true') {\n this.openSubMenu(item.children('ul').first());\n } else {\n item.children('ul').first().attr('aria-hidden', 'true');\n }\n } else {\n // Remove hover and focus styling.\n this.allItems.removeClass('menu-hover menu-focus');\n\n // Clear the active item.\n this.activeItem = null;\n\n // Close the menu.\n this.menuRoot.find('ul').not('.root-level').attr('aria-hidden', 'true');\n // Follow any link, or call the click handlers.\n var anchor = item.find('a').first();\n var clickEvent = new $.Event('click');\n clickEvent.target = anchor;\n var eventHandled = false;\n if (this.handlers) {\n $.each(this.handlers, function(selector, handler) {\n if (eventHandled) {\n return;\n }\n if (item.find(selector).length > 0) {\n var callable = $.proxy(handler, anchor);\n // False means stop propogatting events.\n eventHandled = (callable(clickEvent) === false) || clickEvent.isDefaultPrevented();\n }\n });\n }\n // If we didn't find a handler, and the HREF is # that probably means that\n // we are handling it from somewhere else. Let's just do nothing in that case.\n if (!eventHandled && anchor.attr('href') !== '#') {\n window.location.href = anchor.attr('href');\n }\n }\n return false;\n };\n\n /*\n * Process focus events for the menu.\n *\n * @method handleFocus\n * @param {Object} item is the jquery object of the item firing the event\n * @return boolean Returns false\n */\n Menubar.prototype.handleFocus = function(item) {\n\n // If activeItem is null, we are getting focus from outside the menu. Store\n // the item that triggered the event.\n if (this.activeItem === null) {\n this.activeItem = item;\n } else if (item[0] != this.activeItem[0]) {\n return true;\n }\n\n // Get the set of jquery objects for all the parent items of the active item.\n var parentItems = this.activeItem.parentsUntil('ul.tool-lp-menu').filter('li');\n\n // Remove focus styling from all other menu items.\n this.allItems.removeClass('menu-focus');\n\n // Add focus styling to the active item.\n this.activeItem.addClass('menu-focus');\n\n // Add focus styling to all parent items.\n parentItems.addClass('menu-focus');\n\n // If the bChildOpen flag has been set, open the active item's child menu (if applicable).\n if (this.isChildOpen === true) {\n\n var itemUL = item.parent();\n\n // If the itemUL is a root-level menu and item is a parent item,\n // show the child menu.\n if (itemUL.is('.tool-lp-menu') && (item.attr('aria-haspopup') == 'true')) {\n this.openSubMenu(item.children('ul').first());\n }\n }\n\n return true;\n };\n\n /*\n * Process blur events for the menu.\n *\n * @method handleBlur\n * @param {Object} item is the jquery object of the item firing the event\n * @return boolean Returns false\n */\n Menubar.prototype.handleBlur = function(item) {\n item.removeClass('menu-focus');\n\n return true;\n };\n\n /*\n * Determine if the menu should open to the left, or the right,\n * based on the screen size and menu position.\n * @method setOpenDirection\n */\n Menubar.prototype.setOpenDirection = function() {\n var pos = this.menuRoot.offset();\n var isRTL = $(document.body).hasClass('dir-rtl');\n var openLeft = true;\n var heightmenuRoot = this.rootMenus.outerHeight();\n var widthmenuRoot = this.rootMenus.outerWidth();\n // Sometimes the menuMinWidth is not enough to figure out if menu exceeds the window width.\n // So we have to calculate the real menu width.\n var subMenuContainer = this.rootMenus.find('ul.tool-lp-sub-menu');\n\n // Reset margins.\n subMenuContainer.css('margin-right', '');\n subMenuContainer.css('margin-left', '');\n subMenuContainer.css('margin-top', '');\n\n subMenuContainer.attr('aria-hidden', false);\n var menuRealWidth = subMenuContainer.outerWidth(),\n menuRealHeight = subMenuContainer.outerHeight();\n\n var margintop = null,\n marginright = null,\n marginleft = null;\n var top = pos.top - $(window).scrollTop();\n // Top is the same for RTL and LTR.\n if (top + menuRealHeight > $(window).height()) {\n margintop = menuRealHeight + heightmenuRoot;\n subMenuContainer.css('margin-top', '-' + margintop + 'px');\n }\n\n if (isRTL) {\n if (pos.left - menuRealWidth < 0) {\n marginright = menuRealWidth - widthmenuRoot;\n subMenuContainer.css('margin-right', '-' + marginright + 'px');\n }\n } else {\n if (pos.left + menuRealWidth > $(window).width()) {\n marginleft = menuRealWidth - widthmenuRoot;\n subMenuContainer.css('margin-left', '-' + marginleft + 'px');\n }\n }\n\n if (openLeft) {\n this.menuRoot.addClass('tool-lp-menu-open-left');\n } else {\n this.menuRoot.removeClass('tool-lp-menu-open-left');\n }\n\n };\n\n /*\n * Process keyDown events for the menu.\n *\n * @method handleKeyDown\n * @param {Object} item is the jquery object of the item firing the event\n * @param {Event} e is the associated event object\n * @return boolean Returns false if consuming the event\n */\n Menubar.prototype.handleKeyDown = function(item, e) {\n\n if (e.altKey || e.ctrlKey) {\n // Modifier key pressed: Do not process.\n return true;\n }\n\n switch (e.keyCode) {\n case this.keys.tab: {\n\n // Hide all menu items and update their aria attributes.\n this.menuRoot.find('ul').attr('aria-hidden', 'true');\n\n // Remove focus styling from all menu items.\n this.allItems.removeClass('menu-focus');\n\n this.activeItem = null;\n\n this.isChildOpen = false;\n\n break;\n }\n case this.keys.esc: {\n var itemUL = item.parent();\n\n if (itemUL.is('.tool-lp-menu')) {\n // Hide the child menu and update the aria attributes.\n item.children('ul').first().attr('aria-hidden', 'true');\n } else {\n\n // Move up one level.\n this.activeItem = itemUL.parent();\n\n // Reset the isChildOpen flag.\n this.isChildOpen = false;\n\n // Set focus on the new item.\n this.activeItem.focus();\n\n // Hide the active menu and update the aria attributes.\n itemUL.attr('aria-hidden', 'true');\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.enter:\n case this.keys.space: {\n // Trigger click handler.\n return this.handleClick(item, e);\n }\n\n case this.keys.left: {\n\n this.activeItem = this.moveToPrevious(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.right: {\n\n this.activeItem = this.moveToNext(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.up: {\n\n this.activeItem = this.moveUp(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n case this.keys.down: {\n\n this.activeItem = this.moveDown(item);\n\n this.activeItem.focus();\n\n e.stopPropagation();\n return false;\n }\n }\n\n return true;\n\n };\n\n\n /**\n * Move to the next menu level.\n * This will be either the next root-level menu or the child of a menu parent. If\n * at the root level and the active item is the last in the menu, this function will loop\n * to the first menu item.\n *\n * If the menu is a horizontal menu, the first child element of the newly selected menu will\n * be selected\n *\n * @method moveToNext\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveToNext = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n\n // The items in the currently active menu.\n var menuItems = itemUL.children('li');\n\n // The number of items in the active menu.\n var menuNum = menuItems.length;\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var childMenu = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level move to next sibling. This will require closing\n // the current child menu and opening the new one.\n\n if (menuIndex < menuNum - 1) {\n // Not the last root menu.\n newItem = item.next();\n } else { // Wrap to first item.\n newItem = menuItems.first();\n }\n\n // Close the current child menu (if applicable).\n if (item.attr('aria-haspopup') == 'true') {\n\n childMenu = item.children('ul').first();\n\n if (childMenu.attr('aria-hidden') == 'false') {\n // Update the child menu's aria-hidden attribute.\n childMenu.attr('aria-hidden', 'true');\n this.isChildOpen = true;\n }\n }\n\n // Remove the focus styling from the current menu.\n item.removeClass('menu-focus');\n\n // Open the new child menu (if applicable).\n if ((newItem.attr('aria-haspopup') === 'true') && (this.isChildOpen === true)) {\n\n childMenu = newItem.children('ul').first();\n\n // Update the child's aria-hidden attribute.\n this.openSubMenu(childMenu);\n }\n } else {\n // This is not the root level. If there is a child menu to be moved into, do that;\n // otherwise, move to the next root-level menu if there is one.\n if (item.attr('aria-haspopup') == 'true') {\n\n childMenu = item.children('ul').first();\n\n newItem = childMenu.children('li').first();\n\n // Show the child menu and update its aria attributes.\n this.openSubMenu(childMenu);\n } else {\n // At deepest level, move to the next root-level menu.\n\n var parentMenus = null;\n var rootItem = null;\n\n // Get list of all parent menus for item, up to the root level.\n parentMenus = item.parentsUntil('ul.tool-lp-menu').filter('ul').not('.tool-lp-menu');\n\n // Hide the current menu and update its aria attributes accordingly.\n parentMenus.attr('aria-hidden', 'true');\n\n // Remove the focus styling from the active menu.\n parentMenus.find('li').removeClass('menu-focus');\n parentMenus.last().parent().removeClass('menu-focus');\n\n // The containing root for the menu.\n rootItem = parentMenus.last().parent();\n\n menuIndex = this.rootMenus.index(rootItem);\n\n // If this is not the last root menu item, move to the next one.\n if (menuIndex < this.rootMenus.length - 1) {\n newItem = rootItem.next();\n } else {\n // Loop.\n newItem = this.rootMenus.first();\n }\n\n // Add the focus styling to the new menu.\n newItem.addClass('menu-focus');\n\n if (newItem.attr('aria-haspopup') == 'true') {\n childMenu = newItem.children('ul').first();\n\n newItem = childMenu.children('li').first();\n\n // Show the child menu and update it's aria attributes.\n this.openSubMenu(childMenu);\n this.isChildOpen = true;\n }\n }\n }\n\n return newItem;\n };\n\n /**\n * Member function to move to the previous menu level.\n * This will be either the previous root-level menu or the child of a menu parent. If\n * at the root level and the active item is the first in the menu, this function will loop\n * to the last menu item.\n *\n * If the menu is a horizontal menu, the first child element of the newly selected menu will\n * be selected\n *\n * @method moveToPrevious\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveToPrevious = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li');\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var childMenu = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level move to previous sibling. This will require closing\n // the current child menu and opening the new one.\n\n if (menuIndex > 0) {\n // Not the first root menu.\n newItem = item.prev();\n } else {\n // Wrap to last item.\n newItem = menuItems.last();\n }\n\n // Close the current child menu (if applicable).\n if (item.attr('aria-haspopup') == 'true') {\n childMenu = item.children('ul').first();\n\n if (childMenu.attr('aria-hidden') == 'false') {\n // Update the child menu's aria-hidden attribute.\n childMenu.attr('aria-hidden', 'true');\n this.isChildOpen = true;\n }\n }\n\n // Remove the focus styling from the current menu.\n item.removeClass('menu-focus');\n\n // Open the new child menu (if applicable).\n if ((newItem.attr('aria-haspopup') === 'true') && (this.isChildOpen === true)) {\n\n childMenu = newItem.children('ul').first();\n\n // Update the child's aria-hidden attribute.\n this.openSubMenu(childMenu);\n\n }\n } else {\n // This is not the root level. If there is a parent menu that is not the\n // root menu, move up one level; otherwise, move to first item of the previous\n // root menu.\n\n var parentLI = itemUL.parent();\n var parentUL = parentLI.parent();\n\n // If this is a vertical menu or is not the first child menu\n // of the root-level menu, move up one level.\n if (!parentUL.is('.tool-lp-menu')) {\n\n newItem = itemUL.parent();\n\n // Hide the active menu and update aria-hidden.\n itemUL.attr('aria-hidden', 'true');\n\n // Remove the focus highlight from the item.\n item.removeClass('menu-focus');\n\n } else {\n // Move to previous root-level menu.\n\n // Hide the current menu and update the aria attributes accordingly.\n itemUL.attr('aria-hidden', 'true');\n\n // Remove the focus styling from the active menu.\n item.removeClass('menu-focus');\n parentLI.removeClass('menu-focus');\n\n menuIndex = this.rootMenus.index(parentLI);\n\n if (menuIndex > 0) {\n // Move to the previous root-level menu.\n newItem = parentLI.prev();\n } else {\n // Loop to last root-level menu.\n newItem = this.rootMenus.last();\n }\n\n // Add the focus styling to the new menu.\n newItem.addClass('menu-focus');\n\n if (newItem.attr('aria-haspopup') == 'true') {\n childMenu = newItem.children('ul').first();\n\n // Show the child menu and update it's aria attributes.\n this.openSubMenu(childMenu);\n this.isChildOpen = true;\n\n newItem = childMenu.children('li').first();\n }\n }\n }\n\n return newItem;\n };\n\n /**\n * Member function to select the next item in a menu.\n * If the active item is the last in the menu, this function will loop to the\n * first menu item.\n *\n * @method moveDown\n * @param {Object} item is the active menu item\n * @param {String} startChr is the character to attempt to match against the beginning of the\n * menu item titles. If found, focus moves to the next menu item beginning with that character.\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveDown = function(item, startChr) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li').not('.separator');\n // The number of items in the active menu.\n var menuNum = menuItems.length;\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n var newItemUL = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level menu.\n\n if (item.attr('aria-haspopup') != 'true') {\n // No child menu to move to.\n return item;\n }\n\n // Move to the first item in the child menu.\n newItemUL = item.children('ul').first();\n newItem = newItemUL.children('li').first();\n\n // Make sure the child menu is visible.\n this.openSubMenu(newItemUL);\n\n return newItem;\n }\n\n // If $item is not the last item in its menu, move to the next item. If startChr is specified, move\n // to the next item with a title that begins with that character.\n if (startChr) {\n var match = false;\n var curNdx = menuIndex + 1;\n\n // Check if the active item was the last one on the list.\n if (curNdx == menuNum) {\n curNdx = 0;\n }\n\n // Iterate through the menu items (starting from the current item and wrapping) until a match is found\n // or the loop returns to the current menu item.\n while (curNdx != menuIndex) {\n\n var titleChr = menuItems.eq(curNdx).html().charAt(0);\n\n if (titleChr.toLowerCase() == startChr) {\n match = true;\n break;\n }\n\n curNdx = curNdx + 1;\n\n if (curNdx == menuNum) {\n // Reached the end of the list, start again at the beginning.\n curNdx = 0;\n }\n }\n\n if (match === true) {\n newItem = menuItems.eq(curNdx);\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n } else {\n return item;\n }\n } else {\n if (menuIndex < menuNum - 1) {\n newItem = menuItems.eq(menuIndex + 1);\n } else {\n newItem = menuItems.first();\n }\n }\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n };\n\n /**\n * Function moveUp() is a member function to select the previous item in a menu.\n * If the active item is the first in the menu, this function will loop to the\n * last menu item.\n *\n * @method moveUp\n * @param {Object} item is the active menu item\n * @return {Object} Returns the item to move to. Returns item is no move is possible\n */\n Menubar.prototype.moveUp = function(item) {\n // Item's containing menu.\n var itemUL = item.parent();\n // The items in the currently active menu.\n var menuItems = itemUL.children('li').not('.separator');\n // The items index in its menu.\n var menuIndex = menuItems.index(item);\n var newItem = null;\n\n if (itemUL.is('.tool-lp-menu')) {\n // This is the root level menu.\n // Nothing to do.\n return item;\n }\n\n // If item is not the first item in its menu, move to the previous item.\n if (menuIndex > 0) {\n newItem = menuItems.eq(menuIndex - 1);\n } else {\n // Loop to top of menu.\n newItem = menuItems.last();\n }\n\n // Remove the focus styling from the current item.\n item.removeClass('menu-focus');\n\n return newItem;\n };\n\n /**\n * Enhance the dom with aria attributes.\n * @method addAriaAttributes\n */\n Menubar.prototype.addAriaAttributes = function() {\n this.menuRoot.attr('role', 'menubar');\n this.rootMenus.attr('role', 'menuitem');\n this.rootMenus.attr('tabindex', '0');\n this.rootMenus.attr('aria-haspopup', 'true');\n this.subMenus.attr('role', 'menu');\n this.subMenus.attr('aria-hidden', 'true');\n this.subMenuItems.attr('role', 'menuitem');\n this.subMenuItems.attr('tabindex', '-1');\n\n // For CSS styling and effects.\n this.menuRoot.addClass('tool-lp-menu');\n this.allItems.addClass('tool-lp-menu-item');\n this.rootMenus.addClass('tool-lp-root-menu');\n this.subMenus.addClass('tool-lp-sub-menu');\n this.subMenuItems.addClass('dropdown-item');\n };\n\n return /** @alias module:tool_lp/menubar */ {\n /**\n * Create a menu bar object for every node matching the selector.\n *\n * The expected DOM structure is shown below.\n *
    <- This is the target of the selector parameter.\n *
  • <- This is repeated for each top level menu.\n * Text <- This is the text for the top level menu.\n *
      <- This is a list of the entries in this top level menu.\n *
    • <- This is repeated for each menu entry.\n * Choice 1 <- The anchor for the menu.\n *
    • \n *
    \n *
  • \n *
\n *\n * @method enhance\n * @param {String} selector - The selector for the outer most menu node.\n * @param {Function} handler - Javascript handler for when a menu item was chosen. If the\n * handler returns true (or does not exist), the\n * menu will look for an anchor with a link to follow.\n * For example, if the menu entry has a \"data-action\" attribute\n * and we want to call a javascript function when that entry is chosen,\n * we could pass a list of handlers like this:\n * { \"[data-action='add']\" : callAddFunction }\n */\n enhance: function(selector, handler) {\n $(selector).each(function(index, element) {\n var menuRoot = $(element);\n // Don't enhance the same menu twice.\n if (menuRoot.data(\"menubarEnhanced\") !== true) {\n (new Menubar(menuRoot, handler));\n menuRoot.data(\"menubarEnhanced\", true);\n }\n });\n },\n\n /**\n * Handy function to close all open menus anywhere on the page.\n * @method closeAll\n */\n closeAll: closeAllSubMenus\n };\n});\n"],"names":["define","$","documentClickHandlerRegistered","menuActive","closeAllSubMenus","attr","Menubar","menuRoot","handlers","this","rootMenus","children","subMenus","subMenuItems","allItems","add","activeItem","isChildOpen","keys","tab","enter","esc","space","left","up","right","down","addAriaAttributes","addEventListeners","prototype","openSubMenu","menu","setOpenDirection","currentThis","document","click","mouseenter","addClass","mouseout","removeClass","e","handleClick","keydown","handleKeyDown","focus","handleFocus","blur","handleBlur","item","stopPropagation","parent","is","first","find","not","anchor","clickEvent","Event","target","eventHandled","each","selector","handler","length","callable","proxy","isDefaultPrevented","window","location","href","parentItems","parentsUntil","filter","pos","offset","isRTL","body","hasClass","heightmenuRoot","outerHeight","widthmenuRoot","outerWidth","subMenuContainer","css","menuRealWidth","menuRealHeight","margintop","marginright","marginleft","top","scrollTop","height","width","altKey","ctrlKey","keyCode","itemUL","moveToPrevious","moveToNext","moveUp","moveDown","menuItems","menuNum","menuIndex","index","newItem","childMenu","next","parentMenus","rootItem","last","prev","parentLI","startChr","newItemUL","match","curNdx","eq","html","charAt","toLowerCase","enhance","element","data","closeAll"],"mappings":";;;;;;;;AAuBAA,yBAAO,CAAC,WAAW,SAASC,GAGxB,IAAIC,gCAAiC,EAGjCC,YAAa,EAObC,iBAAmB,WACnBH,EAAE,mCAAmCI,KAAK,cAAe,QAEzDF,YAAa,GASbG,QAAU,SAASC,SAAUC,UAE7BC,KAAKF,SAAWA,SAChBE,KAAKD,SAAWA,SAChBC,KAAKC,UAAYD,KAAKF,SAASI,SAAS,MACxCF,KAAKG,SAAWH,KAAKC,UAAUC,SAAS,MACxCF,KAAKI,aAAeJ,KAAKG,SAASD,SAAS,MAC3CF,KAAKK,SAAWL,KAAKC,UAAUK,IAAIN,KAAKI,cACxCJ,KAAKO,WAAa,KAClBP,KAAKQ,aAAc,EAEnBR,KAAKS,KAAO,CACRC,IAAQ,EACRC,MAAQ,GACRC,IAAQ,GACRC,MAAQ,GACRC,KAAQ,GACRC,GAAQ,GACRC,MAAQ,GACRC,KAAQ,IAGZjB,KAAKkB,oBAELlB,KAAKmB,qBAstBT,OA9sBAtB,QAAQuB,UAAUC,YAAc,SAASC,MACrCtB,KAAKuB,mBACL5B,mBACA2B,KAAK1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SAASF,KAAK,OAAQ,WAC3BI,KAAKC,UAAUL,KAAK,OAAQ,YAC5BI,KAAKC,UAAUL,KAAK,WAAY,KAChCI,KAAKC,UAAUL,KAAK,gBAAiB,QACrCI,KAAKG,SAASP,KAAK,OAAQ,QAC3BI,KAAKG,SAASP,KAAK,cAAe,QAClCI,KAAKI,aAAaR,KAAK,OAAQ,YAC/BI,KAAKI,aAAaR,KAAK,WAAY,MAGnCI,KAAKF,SAAS8B,SAAS,gBACvB5B,KAAKK,SAASuB,SAAS,qBACvB5B,KAAKC,UAAU2B,SAAS,qBACxB5B,KAAKG,SAASyB,SAAS,oBACvB5B,KAAKI,aAAawB,SAAS,kBAGa,CA0BxCoF,QAAS,SAAS5D,SAAUC,SACxB7D,EAAE4D,UAAUD,MAAK,SAAS4C,MAAOkB,SAC7B,IAAInH,SAAWN,EAAEyH,UAEwB,IAArCnH,SAASoH,KAAK,qBACb,IAAIrH,QAAQC,SAAUuD,SACvBvD,SAASoH,KAAK,mBAAmB,GAEzC,GACH,EAMDC,SAAUxH,iBAElB"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/module_navigation.min.js.map b/admin/tool/lp/amd/build/module_navigation.min.js.map index adddb1a552d..a07297f8603 100644 --- a/admin/tool/lp/amd/build/module_navigation.min.js.map +++ b/admin/tool/lp/amd/build/module_navigation.min.js.map @@ -1 +1 @@ -{"version":3,"file":"module_navigation.min.js","sources":["../src/module_navigation.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to navigation between users in a course.\n *\n * @module tool_lp/module_navigation\n * @copyright 2019 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * ModuleNavigation\n *\n * @class tool_lp/module_navigation\n * @param {String} moduleSelector The selector of the module element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} courseId The course id\n * @param {Number} moduleId The activity module (filter)\n */\n var ModuleNavigation = function(moduleSelector, baseUrl, courseId, moduleId) {\n this._baseUrl = baseUrl;\n this._moduleId = moduleId;\n this._courseId = courseId;\n\n $(moduleSelector).on('change', this._moduleChanged.bind(this));\n };\n\n /**\n * The module was changed in the select list.\n *\n * @method _moduleChanged\n * @param {Event} e the event\n */\n ModuleNavigation.prototype._moduleChanged = function(e) {\n var newModuleId = $(e.target).val();\n var queryStr = '?mod=' + newModuleId + '&courseid=' + this._courseId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the course. */\n ModuleNavigation.prototype._courseId = null;\n /** @property {Number} The id of the module. */\n ModuleNavigation.prototype._moduleId = null;\n /** @property {String} Plugin base url. */\n ModuleNavigation.prototype._baseUrl = null;\n\n return ModuleNavigation;\n});\n"],"names":["define","$","ModuleNavigation","moduleSelector","baseUrl","courseId","moduleId","_baseUrl","_moduleId","_courseId","on","this","_moduleChanged","bind","prototype","e","queryStr","target","val","document","location"],"mappings":";;;;;;;AAuBAA,mCAAO,CAAC,WAAW,SAASC,OAWpBC,iBAAmB,SAASC,eAAgBC,QAASC,SAAUC,eAC1DC,SAAWH,aACXI,UAAYF,cACZG,UAAYJ,SAEjBJ,EAAEE,gBAAgBO,GAAG,SAAUC,KAAKC,eAAeC,KAAKF,eAS5DT,iBAAiBY,UAAUF,eAAiB,SAASG,OAE7CC,SAAW,QADGf,EAAEc,EAAEE,QAAQC,MACS,aAAeP,KAAKF,UAC3DU,SAASC,SAAWT,KAAKJ,SAAWS,UAIxCd,iBAAiBY,UAAUL,UAAY,KAEvCP,iBAAiBY,UAAUN,UAAY,KAEvCN,iBAAiBY,UAAUP,SAAW,KAE/BL"} \ No newline at end of file +{"version":3,"file":"module_navigation.min.js","sources":["../src/module_navigation.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to navigation between users in a course.\n *\n * @module tool_lp/module_navigation\n * @copyright 2019 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * ModuleNavigation\n *\n * @class tool_lp/module_navigation\n * @param {String} moduleSelector The selector of the module element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} courseId The course id\n * @param {Number} moduleId The activity module (filter)\n */\n var ModuleNavigation = function(moduleSelector, baseUrl, courseId, moduleId) {\n this._baseUrl = baseUrl;\n this._moduleId = moduleId;\n this._courseId = courseId;\n\n $(moduleSelector).on('change', this._moduleChanged.bind(this));\n };\n\n /**\n * The module was changed in the select list.\n *\n * @method _moduleChanged\n * @param {Event} e the event\n */\n ModuleNavigation.prototype._moduleChanged = function(e) {\n var newModuleId = $(e.target).val();\n var queryStr = '?mod=' + newModuleId + '&courseid=' + this._courseId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the course. */\n ModuleNavigation.prototype._courseId = null;\n /** @property {Number} The id of the module. */\n ModuleNavigation.prototype._moduleId = null;\n /** @property {String} Plugin base url. */\n ModuleNavigation.prototype._baseUrl = null;\n\n return ModuleNavigation;\n});\n"],"names":["define","$","ModuleNavigation","moduleSelector","baseUrl","courseId","moduleId","this","_baseUrl","_moduleId","_courseId","on","_moduleChanged","bind","prototype","e","queryStr","target","val","document","location"],"mappings":";;;;;;;AAuBAA,mCAAO,CAAC,WAAW,SAASC,GAWxB,IAAIC,iBAAmB,SAASC,eAAgBC,QAASC,SAAUC,UAC/DC,KAAKC,SAAWJ,QAChBG,KAAKE,UAAYH,SACjBC,KAAKG,UAAYL,SAEjBJ,EAAEE,gBAAgBQ,GAAG,SAAUJ,KAAKK,eAAeC,KAAKN,QAsB5D,OAbAL,iBAAiBY,UAAUF,eAAiB,SAASG,GACjD,IACIC,SAAW,QADGf,EAAEc,EAAEE,QAAQC,MACS,aAAeX,KAAKG,UAC3DS,SAASC,SAAWb,KAAKC,SAAWQ,UAIxCd,iBAAiBY,UAAUJ,UAAY,KAEvCR,iBAAiBY,UAAUL,UAAY,KAEvCP,iBAAiBY,UAAUN,SAAW,KAE/BN,gBACX"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/parentcompetency_form.min.js.map b/admin/tool/lp/amd/build/parentcompetency_form.min.js.map index 0b2c3238c2b..9d1cb026805 100644 --- a/admin/tool/lp/amd/build/parentcompetency_form.min.js.map +++ b/admin/tool/lp/amd/build/parentcompetency_form.min.js.map @@ -1 +1 @@ -{"version":3,"file":"parentcompetency_form.min.js","sources":["../src/parentcompetency_form.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle selecting parent competency in competency form.\n *\n * @module tool_lp/parentcompetency_form\n * @copyright 2015 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'tool_lp/competencypicker', 'core/templates', 'core/notification'],\n function($, ajax, Str, Picker, Templates, Notification) {\n\n /**\n * Parent Competency Form object.\n * @param {String} buttonSelector The parent competency button selector.\n * @param {String} inputHiddenSelector The hidden input field selector.\n * @param {String} staticElementSelector The static element displaying the parent competency.\n * @param {Number} frameworkId The competency framework ID.\n * @param {Number} pageContextId The page context ID.\n */\n var ParentCompetencyForm = function(buttonSelector,\n inputHiddenSelector,\n staticElementSelector,\n frameworkId,\n pageContextId) {\n this.buttonSelector = buttonSelector;\n this.inputHiddenSelector = inputHiddenSelector;\n this.staticElementSelector = staticElementSelector;\n this.frameworkId = frameworkId;\n this.pageContextId = pageContextId;\n\n // Register the events.\n this.registerEvents();\n };\n\n /** @var {String} The parent competency button selector. */\n ParentCompetencyForm.prototype.buttonSelector = null;\n /** @var {String} The hidden input field selector. */\n ParentCompetencyForm.prototype.inputHiddenSelector = null;\n /** @var {String} The static element displaying the parent competency. */\n ParentCompetencyForm.prototype.staticElementSelector = null;\n /** @var {Number} The competency framework ID. */\n ParentCompetencyForm.prototype.frameworkId = null;\n /** @var {Number} The page context ID. */\n ParentCompetencyForm.prototype.pageContextId = null;\n\n /**\n * Set the parent competency in the competency form.\n *\n * @param {Object} data Data containing selected competency.\n * @method setParent\n */\n ParentCompetencyForm.prototype.setParent = function(data) {\n var self = this;\n\n if (data.competencyId !== 0) {\n ajax.call([\n {methodname: 'core_competency_read_competency', args: {\n id: data.competencyId\n }}\n ])[0].done(function(competency) {\n $(self.staticElementSelector).html(competency.shortname);\n $(self.inputHiddenSelector).val(competency.id);\n }).fail(Notification.exception);\n } else {\n // Root of competency framework selected.\n Str.get_string('competencyframeworkroot', 'tool_lp').then(function(rootframework) {\n $(self.staticElementSelector).html(rootframework);\n $(self.inputHiddenSelector).val(data.competencyId);\n return;\n }).fail(Notification.exception);\n }\n };\n\n /**\n * Register the events of parent competency button click.\n *\n * @method registerEvents\n */\n ParentCompetencyForm.prototype.registerEvents = function() {\n var self = this;\n\n // Event on edit parent button.\n $(self.buttonSelector).on('click', function(e) {\n e.preventDefault();\n\n var picker = new Picker(self.pageContextId, self.frameworkId, 'self', false);\n\n // Override the render method to make framework selectable.\n picker._render = function() {\n var self = this;\n return self._preRender().then(function() {\n var context = {\n competencies: self._competencies,\n framework: self._getFramework(self._frameworkId),\n frameworks: self._frameworks,\n search: self._searchText,\n singleFramework: self._singleFramework,\n };\n\n return Templates.render('tool_lp/competency_picker_competencyform', context);\n });\n };\n\n // On selected competency.\n picker.on('save', function(e, data) {\n self.setParent(data);\n });\n\n picker.display();\n });\n };\n\n return {\n\n /**\n * Main initialisation.\n * @param {String} buttonSelector The parent competency button selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} staticElementSelector The static element displaying the parent competency.\n * @param {Number} frameworkId The competency framework ID.\n * @param {Number} pageContextId The page context ID.\n * @method init\n */\n init: function(buttonSelector,\n inputSelector,\n staticElementSelector,\n frameworkId,\n pageContextId) {\n // Create instance.\n new ParentCompetencyForm(buttonSelector,\n inputSelector,\n staticElementSelector,\n frameworkId,\n pageContextId);\n }\n };\n});\n"],"names":["define","$","ajax","Str","Picker","Templates","Notification","ParentCompetencyForm","buttonSelector","inputHiddenSelector","staticElementSelector","frameworkId","pageContextId","registerEvents","prototype","setParent","data","self","this","competencyId","call","methodname","args","id","done","competency","html","shortname","val","fail","exception","get_string","then","rootframework","on","e","preventDefault","picker","_render","_preRender","context","competencies","_competencies","framework","_getFramework","_frameworkId","frameworks","_frameworks","search","_searchText","singleFramework","_singleFramework","render","display","init","inputSelector"],"mappings":";;;;;;;AAsBAA,uCAAO,CAAC,SAAU,YAAa,WAAY,2BAA4B,iBAAkB,sBACrF,SAASC,EAAGC,KAAMC,IAAKC,OAAQC,UAAWC,kBAUtCC,qBAAuB,SAASC,eACAC,oBACAC,sBACAC,YACAC,oBAC3BJ,eAAiBA,oBACjBC,oBAAsBA,yBACtBC,sBAAwBA,2BACxBC,Y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C,YACAC,mBAERL,qBAAqBC,eACD+C,cACA7C,sBACAC,YACAC"} \ No newline at end of file +{"version":3,"file":"parentcompetency_form.min.js","sources":["../src/parentcompetency_form.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle selecting parent competency in competency form.\n *\n * @module tool_lp/parentcompetency_form\n * @copyright 2015 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'tool_lp/competencypicker', 'core/templates', 'core/notification'],\n function($, ajax, Str, Picker, Templates, Notification) {\n\n /**\n * Parent Competency Form object.\n * @param {String} buttonSelector The parent competency button selector.\n * @param {String} inputHiddenSelector The hidden input field selector.\n * @param {String} staticElementSelector The static element displaying the parent competency.\n * @param {Number} frameworkId The competency framework ID.\n * @param {Number} pageContextId The page context ID.\n */\n var ParentCompetencyForm = function(buttonSelector,\n inputHiddenSelector,\n staticElementSelector,\n frameworkId,\n pageContextId) {\n this.buttonSelector = buttonSelector;\n this.inputHiddenSelector = inputHiddenSelector;\n this.staticElementSelector = staticElementSelector;\n this.frameworkId = frameworkId;\n this.pageContextId = pageContextId;\n\n // Register the events.\n this.registerEvents();\n };\n\n /** @var {String} The parent competency button selector. */\n ParentCompetencyForm.prototype.buttonSelector = null;\n /** @var {String} The hidden input field selector. */\n ParentCompetencyForm.prototype.inputHiddenSelector = null;\n /** @var {String} The static element displaying the parent competency. */\n ParentCompetencyForm.prototype.staticElementSelector = null;\n /** @var {Number} The competency framework ID. */\n ParentCompetencyForm.prototype.frameworkId = null;\n /** @var {Number} The page context ID. */\n ParentCompetencyForm.prototype.pageContextId = null;\n\n /**\n * Set the parent competency in the competency form.\n *\n * @param {Object} data Data containing selected competency.\n * @method setParent\n */\n ParentCompetencyForm.prototype.setParent = function(data) {\n var self = this;\n\n if (data.competencyId !== 0) {\n ajax.call([\n {methodname: 'core_competency_read_competency', args: {\n id: data.competencyId\n }}\n ])[0].done(function(competency) {\n $(self.staticElementSelector).html(competency.shortname);\n $(self.inputHiddenSelector).val(competency.id);\n }).fail(Notification.exception);\n } else {\n // Root of competency framework selected.\n Str.get_string('competencyframeworkroot', 'tool_lp').then(function(rootframework) {\n $(self.staticElementSelector).html(rootframework);\n $(self.inputHiddenSelector).val(data.competencyId);\n return;\n }).fail(Notification.exception);\n }\n };\n\n /**\n * Register the events of parent competency button click.\n *\n * @method registerEvents\n */\n ParentCompetencyForm.prototype.registerEvents = function() {\n var self = this;\n\n // Event on edit parent button.\n $(self.buttonSelector).on('click', function(e) {\n e.preventDefault();\n\n var picker = new Picker(self.pageContextId, self.frameworkId, 'self', false);\n\n // Override the render method to make framework selectable.\n picker._render = function() {\n var self = this;\n return self._preRender().then(function() {\n var context = {\n competencies: self._competencies,\n framework: self._getFramework(self._frameworkId),\n frameworks: self._frameworks,\n search: self._searchText,\n singleFramework: self._singleFramework,\n };\n\n return Templates.render('tool_lp/competency_picker_competencyform', context);\n });\n };\n\n // On selected competency.\n picker.on('save', function(e, data) {\n self.setParent(data);\n });\n\n picker.display();\n });\n };\n\n return {\n\n /**\n * Main initialisation.\n * @param {String} buttonSelector The parent competency button selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} staticElementSelector The static element displaying the parent competency.\n * @param {Number} frameworkId The competency framework ID.\n * @param {Number} pageContextId The page context ID.\n * @method init\n */\n init: function(buttonSelector,\n inputSelector,\n staticElementSelector,\n frameworkId,\n pageContextId) {\n // Create instance.\n new ParentCompetencyForm(buttonSelector,\n inputSelector,\n staticElementSelector,\n frameworkId,\n pageContextId);\n }\n };\n});\n"],"names":["define","$","ajax","Str","Picker","Templates","Notification","ParentCompetencyForm","buttonSelector","inputHiddenSelector","staticElementSelector","frameworkId","pageContextId","this","registerEvents","prototype","setParent","data","self","competencyId","call","methodname","args","id","done","competency","html","shortname","val","fail","exception","get_string","then","rootframework","on","e","preventDefault","picker","_render","_preRender","context","competencies","_competencies","framework","_getFramework","_frameworkId","frameworks","_frameworks","search","_searchText","singleFramework","_singleFramework","render","display","init","inputSelector"],"mappings":";;;;;;;AAsBAA,OAAM,gCAAC,CAAC,SAAU,YAAa,WAAY,2BAA4B,iBAAkB,sBACrF,SAASC,EAAGC,KAAMC,IAAKC,OAAQC,UAAWC,cAU1C,IAAIC,qBAAuB,SAASC,eACAC,oBACAC,sBACAC,YACAC,eAChCC,KAAKL,eAAiBA,eACtBK,KAAKJ,oBAAsBA,oBAC3BI,KAAKH,sBAAwBA,sBAC7BG,KAAKF,YAAcA,YACnBE,KAAKD,cAAgBA,cAGrBC,KAAKC,kBAiFT,OA7EAP,qBAAqBQ,UAAUP,eAAiB,KAEhDD,qBAAqBQ,UAAUN,oBAAsB,KAErDF,qBAAqBQ,UAAUL,sBAAwB,KAEvDH,qBAAqBQ,UAAUJ,YAAc,KAE7CJ,qBAAqBQ,UAAUH,cAAgB,KAQ/CL,qBAAqBQ,UAAUC,UAAY,SAASC,MAChD,IAAIC,KAAOL,KAEe,IAAtBI,KAAKE,aACLjB,KAAKkB,KAAK,CACN,CAACC,WAAY,kCAAmCC,KAAM,CAClDC,GAAIN,KAAKE,iBAEd,GAAGK,MAAK,SAASC,YAChBxB,EAAEiB,KAAKR,uBAAuBgB,KAAKD,WAAWE,WAC9C1B,EAAEiB,KAAKT,qBAAqBmB,IAAIH,WAAWF,GAC9C,IAAEM,KAAKvB,aAAawB,WAGrB3B,IAAI4B,WAAW,0BAA2B,WAAWC,MAAK,SAASC,eAC/DhC,EAAEiB,KAAKR,uBAAuBgB,KAAKO,eACnChC,EAAEiB,KAAKT,qBAAqBmB,IAAIX,KAAKE,aAExC,IAAEU,KAAKvB,aAAawB,YAS7BvB,qBAAqBQ,UAAUD,eAAiB,WAC5C,IAAII,KAAOL,KAGXZ,EAAEiB,KAAKV,gBAAgB0B,GAAG,SAAS,SAASC,GACxCA,EAAEC,iBAEF,IAAIC,OAAS,IAAIjC,OAAOc,KAAKN,cAAeM,KAAKP,YAAa,QAAQ,GAGtE0B,OAAOC,QAAU,WACb,IAAIpB,KAAOL,KACX,OAAOK,KAAKqB,aAAaP,MAAK,WAC1B,IAAIQ,QAAU,CACVC,aAAcvB,KAAKwB,cACnBC,UAAWzB,KAAK0B,cAAc1B,KAAK2B,cACnCC,WAAY5B,KAAK6B,YACjBC,OAAQ9B,KAAK+B,YACbC,gBAAiBhC,KAAKiC,kBAG1B,OAAO9C,UAAU+C,OAAO,2CAA4CZ,QACxE,KAIJH,OAAOH,GAAG,QAAQ,SAASC,EAAGlB,MAC1BC,KAAKF,UAAUC,KACnB,IAEAoB,OAAOgB,SACX,KAGG,CAWHC,KAAM,SAAS9C,eACC+C,cACA7C,sBACAC,YACAC,eAEZ,IAAIL,qBAAqBC,eACD+C,cACA7C,sBACAC,YACAC,cAC5B,EAER"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/planactions.min.js.map b/admin/tool/lp/amd/build/planactions.min.js.map index 9ef56027339..24172b0ba15 100644 --- a/admin/tool/lp/amd/build/planactions.min.js.map +++ b/admin/tool/lp/amd/build/planactions.min.js.map @@ -1 +1 @@ -{"version":3,"file":"planactions.min.js","sources":["../src/planactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Plan actions via ajax.\n *\n * @module tool_lp/planactions\n * @copyright 2015 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/dialogue'],\n function($, templates, ajax, notification, str, Menubar, Dialogue) {\n\n /**\n * PlanActions class.\n *\n * Note that presently this cannot be instantiated more than once per page.\n *\n * @param {String} type The type of page we're in.\n */\n var PlanActions = function(type) {\n this._type = type;\n\n if (type === 'plan') {\n // This is the page to view one plan.\n this._region = '[data-region=\"plan-page\"]';\n this._planNode = '[data-region=\"plan-page\"]';\n this._template = 'tool_lp/plan_page';\n this._contextMethod = 'tool_lp_data_for_plan_page';\n\n } else if (type === 'plans') {\n // This is the page to view a list of plans.\n this._region = '[data-region=\"plans\"]';\n this._planNode = '[data-region=\"plan-node\"]';\n this._template = 'tool_lp/plans_page';\n this._contextMethod = 'tool_lp_data_for_plans_page';\n\n } else {\n throw new TypeError('Unexpected type.');\n }\n };\n\n /** @property {String} Ajax method to fetch the page data from. */\n PlanActions.prototype._contextMethod = null;\n /** @property {String} Selector to find the node describing the plan. */\n PlanActions.prototype._planNode = null;\n /** @property {String} Selector mapping to the region to update. Usually similar to wrapper. */\n PlanActions.prototype._region = null;\n /** @property {String} Name of the template used to render the region. */\n PlanActions.prototype._template = null;\n /** @property {String} Type of page/region we're in. */\n PlanActions.prototype._type = null;\n\n /**\n * Resolve the arguments to refresh the region.\n *\n * @param {Object} planData Plan data from plan node.\n * @return {Object} List of arguments.\n */\n PlanActions.prototype._getContextArgs = function(planData) {\n var self = this,\n args = {};\n\n if (self._type === 'plan') {\n args = {\n planid: planData.id\n };\n\n } else if (self._type === 'plans') {\n args = {\n userid: planData.userid\n };\n }\n\n return args;\n };\n\n /**\n * Refresh the plan view.\n *\n * This is useful when you only want to refresh the view.\n *\n * @param {String} selector The node to search the plan data from.\n */\n PlanActions.prototype.refresh = function(selector) {\n var planData = this._findPlanData($(selector));\n this._callAndRefresh([], planData);\n };\n\n /**\n * Callback to render the region template.\n *\n * @param {Object} context The context for the template.\n * @return {Promise}\n */\n PlanActions.prototype._renderView = function(context) {\n var self = this;\n return templates.render(self._template, context)\n .then(function(newhtml, newjs) {\n $(self._region).replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n return;\n });\n };\n\n /**\n * Call multiple ajax methods, and refresh.\n *\n * @param {Array} calls List of Ajax calls.\n * @param {Object} planData Plan data from plan node.\n * @return {Promise}\n */\n PlanActions.prototype._callAndRefresh = function(calls, planData) {\n // Because this function causes a refresh, we must track the JS completion from start to finish to prevent\n // stale reference issues in Behat.\n var callKey = 'tool_lp/planactions:_callAndRefresh-' + Math.floor(Math.random() * Math.floor(1000));\n M.util.js_pending(callKey);\n\n var self = this;\n calls.push({\n methodname: self._contextMethod,\n args: self._getContextArgs(planData)\n });\n\n // Apply all the promises, and refresh when the last one is resolved.\n return $.when.apply($, ajax.call(calls))\n .then(function() {\n return self._renderView(arguments[arguments.length - 1]);\n })\n .fail(notification.exception)\n .always(function() {\n return M.util.js_complete(callKey);\n });\n };\n\n /**\n * Delete a plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doDelete = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_delete_plan',\n args: {id: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Delete a plan.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.deletePlan = function(planData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deleteplan', component: 'tool_lp', param: plan.name},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete plan X?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n self._doDelete(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Reopen plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doReopenPlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_reopen_plan',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Reopen a plan.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.reopenPlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'reopenplanconfirm', component: 'tool_lp', param: plan.name},\n {key: 'reopenplan', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Reopen plan X?\n strings[2], // Reopen.\n strings[3], // Cancel.\n function() {\n self._doReopenPlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Complete plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doCompletePlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_complete_plan',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Complete a plan process.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.completePlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'completeplanconfirm', component: 'tool_lp', param: plan.name},\n {key: 'completeplan', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Complete plan X?\n strings[2], // Complete.\n strings[3], // Cancel.\n function() {\n self._doCompletePlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Unlink plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doUnlinkPlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_unlink_plan_from_template',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Unlink a plan process.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.unlinkPlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'unlinkplantemplateconfirm', component: 'tool_lp', param: plan.name},\n {key: 'unlinkplantemplate', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Unlink plan X?\n strings[2], // Unlink.\n strings[3], // Cancel.\n function() {\n self._doUnlinkPlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Request review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doRequestReview\n */\n PlanActions.prototype._doRequestReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_request_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Request review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method requestReview\n */\n PlanActions.prototype.requestReview = function(planData) {\n this._doRequestReview(planData);\n };\n\n /**\n * Cancel review request of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doCancelReviewRequest\n */\n PlanActions.prototype._doCancelReviewRequest = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_cancel_review_request',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Cancel review request of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method cancelReviewRequest\n */\n PlanActions.prototype.cancelReviewRequest = function(planData) {\n this._doCancelReviewRequest(planData);\n };\n\n /**\n * Start review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doStartReview\n */\n PlanActions.prototype._doStartReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_start_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Start review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method startReview\n */\n PlanActions.prototype.startReview = function(planData) {\n this._doStartReview(planData);\n };\n\n /**\n * Stop review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doStopReview\n */\n PlanActions.prototype._doStopReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_stop_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Stop review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method stopReview\n */\n PlanActions.prototype.stopReview = function(planData) {\n this._doStopReview(planData);\n };\n\n /**\n * Approve a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doApprove\n */\n PlanActions.prototype._doApprove = function(planData) {\n var calls = [{\n methodname: 'core_competency_approve_plan',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Approve a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method approve\n */\n PlanActions.prototype.approve = function(planData) {\n this._doApprove(planData);\n };\n\n /**\n * Unapprove a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doUnapprove\n */\n PlanActions.prototype._doUnapprove = function(planData) {\n var calls = [{\n methodname: 'core_competency_unapprove_plan',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Unapprove a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method unapprove\n */\n PlanActions.prototype.unapprove = function(planData) {\n this._doUnapprove(planData);\n };\n\n /**\n * Display list of linked courses on a modal dialogue.\n *\n * @param {Event} e The event.\n */\n PlanActions.prototype._showLinkedCoursesHandler = function(e) {\n e.preventDefault();\n\n var competencyid = $(e.target).data('id');\n var requests = ajax.call([{\n methodname: 'tool_lp_list_courses_using_competency',\n args: {id: competencyid}\n }]);\n\n requests[0].done(function(courses) {\n var context = {\n courses: courses\n };\n templates.render('tool_lp/linked_courses_summary', context).done(function(html) {\n str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {\n new Dialogue(\n linkedcourses, // Title.\n html // The linked courses.\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Plan event handler.\n *\n * @param {String} method The method to call.\n * @param {Event} e The event.\n * @method _eventHandler\n */\n PlanActions.prototype._eventHandler = function(method, e) {\n e.preventDefault();\n var data = this._findPlanData($(e.target));\n this[method](data);\n };\n\n /**\n * Find the plan data from the plan node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} Plan data.\n */\n PlanActions.prototype._findPlanData = function(node) {\n var parent = node.parentsUntil($(this._region).parent(), this._planNode),\n data;\n\n if (parent.length != 1) {\n throw new Error('The plan node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.id === 'undefined') {\n throw new Error('Plan data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n PlanActions.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"plan-delete\"]': this._eventHandler.bind(this, 'deletePlan'),\n '[data-action=\"plan-complete\"]': this._eventHandler.bind(this, 'completePlan'),\n '[data-action=\"plan-reopen\"]': this._eventHandler.bind(this, 'reopenPlan'),\n '[data-action=\"plan-unlink\"]': this._eventHandler.bind(this, 'unlinkPlan'),\n '[data-action=\"plan-request-review\"]': this._eventHandler.bind(this, 'requestReview'),\n '[data-action=\"plan-cancel-review-request\"]': this._eventHandler.bind(this, 'cancelReviewRequest'),\n '[data-action=\"plan-start-review\"]': this._eventHandler.bind(this, 'startReview'),\n '[data-action=\"plan-stop-review\"]': this._eventHandler.bind(this, 'stopReview'),\n '[data-action=\"plan-approve\"]': this._eventHandler.bind(this, 'approve'),\n '[data-action=\"plan-unapprove\"]': this._eventHandler.bind(this, 'unapprove'),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * At this stage this cannot be used with enhanceMenubar or multiple handlers\n * will be added to the same node.\n */\n PlanActions.prototype.registerEvents = function() {\n var wrapper = $(this._region);\n\n wrapper.find('[data-action=\"plan-delete\"]').click(this._eventHandler.bind(this, 'deletePlan'));\n wrapper.find('[data-action=\"plan-complete\"]').click(this._eventHandler.bind(this, 'completePlan'));\n wrapper.find('[data-action=\"plan-reopen\"]').click(this._eventHandler.bind(this, 'reopenPlan'));\n wrapper.find('[data-action=\"plan-unlink\"]').click(this._eventHandler.bind(this, 'unlinkPlan'));\n\n wrapper.find('[data-action=\"plan-request-review\"]').click(this._eventHandler.bind(this, 'requestReview'));\n wrapper.find('[data-action=\"plan-cancel-review-request\"]').click(this._eventHandler.bind(this, 'cancelReviewRequest'));\n wrapper.find('[data-action=\"plan-start-review\"]').click(this._eventHandler.bind(this, 'startReview'));\n wrapper.find('[data-action=\"plan-stop-review\"]').click(this._eventHandler.bind(this, 'stopReview'));\n wrapper.find('[data-action=\"plan-approve\"]').click(this._eventHandler.bind(this, 'approve'));\n wrapper.find('[data-action=\"plan-unapprove\"]').click(this._eventHandler.bind(this, 'unapprove'));\n\n wrapper.find('[data-action=\"find-courses-link\"]').click(this._showLinkedCoursesHandler.bind(this));\n };\n\n return PlanActions;\n});\n"],"names":["define","$","templates","ajax","notification","str","Menubar","Dialogue","PlanActions","type","_type","_region","_planNode","_template","_contextMethod","TypeError","prototype","_getContextArgs","planData","args","this","planid","id","userid","refresh","selector","_findPlanData","_callAndRefresh","_renderView","context","self","render","then","newhtml","newjs","replaceWith","runTemplateJS","calls","callKey","Math","floor","random","M","util","js_pending","push","methodname","when","apply","call","arguments","length","fail","exception","always","js_complete","_doDelete","deletePlan","done","plan","get_strings","key","component","param","name","strings","confirm","_doReopenPlan","reopenPlan","_doCompletePlan","completePlan","_doUnlinkPlan","unlinkPlan","_doRequestReview","requestReview","_doCancelReviewRequest","cancelReviewRequest","_doStartReview","startReview","_doStopReview","stopReview","_doApprove","approve","_doUnapprove","unapprove","_showLinkedCoursesHandler","e","preventDefault","competencyid","target","data","courses","html","get_string","linkedcourses","_eventHandler","method","node","parent","parentsUntil","Error","enhanceMenubar","enhance","bind","registerEvents","wrapper","find","click"],"mappings":";;;;;;;AAsBAA,6BAAO,CAAC,SACA,iBACA,YACA,oBACA,WACA,kBACA,qBACA,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,QAASC,cASzDC,YAAc,SAASC,cAClBC,MAAQD,KAEA,SAATA,UAEKE,QAAU,iCACVC,UAAY,iCACZC,UAAY,yBACZC,eAAiB,iCAEnB,CAAA,GAAa,UAATL,WAQD,IAAIM,UAAU,yBANfJ,QAAU,6BACVC,UAAY,iCACZC,UAAY,0BACZC,eAAiB,uCAQ9BN,YAAYQ,UAAUF,eAAiB,KAEvCN,YAAYQ,UAAUJ,UAAY,KAElCJ,YAAYQ,UAAUL,QAAU,KAEhCH,YAAYQ,UAAUH,UAAY,KAElCL,YAAYQ,UAAUN,MAAQ,KAQ9BF,YAAYQ,UAAUC,gBAAkB,SAASC,cAEzCC,KAAO,SAEQ,SAHRC,KAGFV,MACLS,KAAO,CACHE,OAAQH,SAASI,IAGC,UARfF,KAQKV,QACZS,KAAO,CACHI,OAAQL,SAASK,SAIlBJ,MAUXX,YAAYQ,UAAUQ,QAAU,SAASC,cACjCP,SAAWE,KAAKM,cAAczB,EAAEwB,gBAC/BE,gBAAgB,GAAIT,WAS7BV,YAAYQ,UAAUY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tFqF,QAAQC,KAAK,oCAAoCC,MAAMvF,KAAK2E,cAAcQ,KAAKnF,KAAM,eACrFqF,QAAQC,KAAK,gCAAgCC,MAAMvF,KAAK2E,cAAcQ,KAAKnF,KAAM,YACjFqF,QAAQC,KAAK,kCAAkCC,MAAMvF,KAAK2E,cAAcQ,KAAKnF,KAAM,cAEnFqF,QAAQC,KAAK,qCAAqCC,MAAMvF,KAAKiE,0BAA0BkB,KAAKnF,QAGzFZ"} \ No newline at end of file +{"version":3,"file":"planactions.min.js","sources":["../src/planactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Plan actions via ajax.\n *\n * @module tool_lp/planactions\n * @copyright 2015 David Monllao\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/dialogue'],\n function($, templates, ajax, notification, str, Menubar, Dialogue) {\n\n /**\n * PlanActions class.\n *\n * Note that presently this cannot be instantiated more than once per page.\n *\n * @param {String} type The type of page we're in.\n */\n var PlanActions = function(type) {\n this._type = type;\n\n if (type === 'plan') {\n // This is the page to view one plan.\n this._region = '[data-region=\"plan-page\"]';\n this._planNode = '[data-region=\"plan-page\"]';\n this._template = 'tool_lp/plan_page';\n this._contextMethod = 'tool_lp_data_for_plan_page';\n\n } else if (type === 'plans') {\n // This is the page to view a list of plans.\n this._region = '[data-region=\"plans\"]';\n this._planNode = '[data-region=\"plan-node\"]';\n this._template = 'tool_lp/plans_page';\n this._contextMethod = 'tool_lp_data_for_plans_page';\n\n } else {\n throw new TypeError('Unexpected type.');\n }\n };\n\n /** @property {String} Ajax method to fetch the page data from. */\n PlanActions.prototype._contextMethod = null;\n /** @property {String} Selector to find the node describing the plan. */\n PlanActions.prototype._planNode = null;\n /** @property {String} Selector mapping to the region to update. Usually similar to wrapper. */\n PlanActions.prototype._region = null;\n /** @property {String} Name of the template used to render the region. */\n PlanActions.prototype._template = null;\n /** @property {String} Type of page/region we're in. */\n PlanActions.prototype._type = null;\n\n /**\n * Resolve the arguments to refresh the region.\n *\n * @param {Object} planData Plan data from plan node.\n * @return {Object} List of arguments.\n */\n PlanActions.prototype._getContextArgs = function(planData) {\n var self = this,\n args = {};\n\n if (self._type === 'plan') {\n args = {\n planid: planData.id\n };\n\n } else if (self._type === 'plans') {\n args = {\n userid: planData.userid\n };\n }\n\n return args;\n };\n\n /**\n * Refresh the plan view.\n *\n * This is useful when you only want to refresh the view.\n *\n * @param {String} selector The node to search the plan data from.\n */\n PlanActions.prototype.refresh = function(selector) {\n var planData = this._findPlanData($(selector));\n this._callAndRefresh([], planData);\n };\n\n /**\n * Callback to render the region template.\n *\n * @param {Object} context The context for the template.\n * @return {Promise}\n */\n PlanActions.prototype._renderView = function(context) {\n var self = this;\n return templates.render(self._template, context)\n .then(function(newhtml, newjs) {\n $(self._region).replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n return;\n });\n };\n\n /**\n * Call multiple ajax methods, and refresh.\n *\n * @param {Array} calls List of Ajax calls.\n * @param {Object} planData Plan data from plan node.\n * @return {Promise}\n */\n PlanActions.prototype._callAndRefresh = function(calls, planData) {\n // Because this function causes a refresh, we must track the JS completion from start to finish to prevent\n // stale reference issues in Behat.\n var callKey = 'tool_lp/planactions:_callAndRefresh-' + Math.floor(Math.random() * Math.floor(1000));\n M.util.js_pending(callKey);\n\n var self = this;\n calls.push({\n methodname: self._contextMethod,\n args: self._getContextArgs(planData)\n });\n\n // Apply all the promises, and refresh when the last one is resolved.\n return $.when.apply($, ajax.call(calls))\n .then(function() {\n return self._renderView(arguments[arguments.length - 1]);\n })\n .fail(notification.exception)\n .always(function() {\n return M.util.js_complete(callKey);\n });\n };\n\n /**\n * Delete a plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doDelete = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_delete_plan',\n args: {id: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Delete a plan.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.deletePlan = function(planData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deleteplan', component: 'tool_lp', param: plan.name},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete plan X?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n self._doDelete(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Reopen plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doReopenPlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_reopen_plan',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Reopen a plan.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.reopenPlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'reopenplanconfirm', component: 'tool_lp', param: plan.name},\n {key: 'reopenplan', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Reopen plan X?\n strings[2], // Reopen.\n strings[3], // Cancel.\n function() {\n self._doReopenPlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Complete plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doCompletePlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_complete_plan',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Complete a plan process.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.completePlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'completeplanconfirm', component: 'tool_lp', param: plan.name},\n {key: 'completeplan', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Complete plan X?\n strings[2], // Complete.\n strings[3], // Cancel.\n function() {\n self._doCompletePlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Unlink plan and reload the region.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype._doUnlinkPlan = function(planData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_unlink_plan_from_template',\n args: {planid: planData.id}\n }];\n self._callAndRefresh(calls, planData);\n };\n\n /**\n * Unlink a plan process.\n *\n * @param {Object} planData Plan data from plan node.\n */\n PlanActions.prototype.unlinkPlan = function(planData) {\n var self = this,\n requests = ajax.call([{\n methodname: 'core_competency_read_plan',\n args: {id: planData.id}\n }]);\n\n requests[0].done(function(plan) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'unlinkplantemplateconfirm', component: 'tool_lp', param: plan.name},\n {key: 'unlinkplantemplate', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Unlink plan X?\n strings[2], // Unlink.\n strings[3], // Cancel.\n function() {\n self._doUnlinkPlan(planData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Request review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doRequestReview\n */\n PlanActions.prototype._doRequestReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_request_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Request review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method requestReview\n */\n PlanActions.prototype.requestReview = function(planData) {\n this._doRequestReview(planData);\n };\n\n /**\n * Cancel review request of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doCancelReviewRequest\n */\n PlanActions.prototype._doCancelReviewRequest = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_cancel_review_request',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Cancel review request of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method cancelReviewRequest\n */\n PlanActions.prototype.cancelReviewRequest = function(planData) {\n this._doCancelReviewRequest(planData);\n };\n\n /**\n * Start review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doStartReview\n */\n PlanActions.prototype._doStartReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_start_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Start review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method startReview\n */\n PlanActions.prototype.startReview = function(planData) {\n this._doStartReview(planData);\n };\n\n /**\n * Stop review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doStopReview\n */\n PlanActions.prototype._doStopReview = function(planData) {\n var calls = [{\n methodname: 'core_competency_plan_stop_review',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Stop review of a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method stopReview\n */\n PlanActions.prototype.stopReview = function(planData) {\n this._doStopReview(planData);\n };\n\n /**\n * Approve a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doApprove\n */\n PlanActions.prototype._doApprove = function(planData) {\n var calls = [{\n methodname: 'core_competency_approve_plan',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Approve a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method approve\n */\n PlanActions.prototype.approve = function(planData) {\n this._doApprove(planData);\n };\n\n /**\n * Unapprove a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method _doUnapprove\n */\n PlanActions.prototype._doUnapprove = function(planData) {\n var calls = [{\n methodname: 'core_competency_unapprove_plan',\n args: {\n id: planData.id\n }\n }];\n this._callAndRefresh(calls, planData);\n };\n\n /**\n * Unapprove a plan.\n *\n * @param {Object} planData Plan data from plan node.\n * @method unapprove\n */\n PlanActions.prototype.unapprove = function(planData) {\n this._doUnapprove(planData);\n };\n\n /**\n * Display list of linked courses on a modal dialogue.\n *\n * @param {Event} e The event.\n */\n PlanActions.prototype._showLinkedCoursesHandler = function(e) {\n e.preventDefault();\n\n var competencyid = $(e.target).data('id');\n var requests = ajax.call([{\n methodname: 'tool_lp_list_courses_using_competency',\n args: {id: competencyid}\n }]);\n\n requests[0].done(function(courses) {\n var context = {\n courses: courses\n };\n templates.render('tool_lp/linked_courses_summary', context).done(function(html) {\n str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {\n new Dialogue(\n linkedcourses, // Title.\n html // The linked courses.\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Plan event handler.\n *\n * @param {String} method The method to call.\n * @param {Event} e The event.\n * @method _eventHandler\n */\n PlanActions.prototype._eventHandler = function(method, e) {\n e.preventDefault();\n var data = this._findPlanData($(e.target));\n this[method](data);\n };\n\n /**\n * Find the plan data from the plan node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} Plan data.\n */\n PlanActions.prototype._findPlanData = function(node) {\n var parent = node.parentsUntil($(this._region).parent(), this._planNode),\n data;\n\n if (parent.length != 1) {\n throw new Error('The plan node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.id === 'undefined') {\n throw new Error('Plan data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n PlanActions.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"plan-delete\"]': this._eventHandler.bind(this, 'deletePlan'),\n '[data-action=\"plan-complete\"]': this._eventHandler.bind(this, 'completePlan'),\n '[data-action=\"plan-reopen\"]': this._eventHandler.bind(this, 'reopenPlan'),\n '[data-action=\"plan-unlink\"]': this._eventHandler.bind(this, 'unlinkPlan'),\n '[data-action=\"plan-request-review\"]': this._eventHandler.bind(this, 'requestReview'),\n '[data-action=\"plan-cancel-review-request\"]': this._eventHandler.bind(this, 'cancelReviewRequest'),\n '[data-action=\"plan-start-review\"]': this._eventHandler.bind(this, 'startReview'),\n '[data-action=\"plan-stop-review\"]': this._eventHandler.bind(this, 'stopReview'),\n '[data-action=\"plan-approve\"]': this._eventHandler.bind(this, 'approve'),\n '[data-action=\"plan-unapprove\"]': this._eventHandler.bind(this, 'unapprove'),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * At this stage this cannot be used with enhanceMenubar or multiple handlers\n * will be added to the same node.\n */\n PlanActions.prototype.registerEvents = function() {\n var wrapper = $(this._region);\n\n wrapper.find('[data-action=\"plan-delete\"]').click(this._eventHandler.bind(this, 'deletePlan'));\n wrapper.find('[data-action=\"plan-complete\"]').click(this._eventHandler.bind(this, 'completePlan'));\n wrapper.find('[data-action=\"plan-reopen\"]').click(this._eventHandler.bind(this, 'reopenPlan'));\n wrapper.find('[data-action=\"plan-unlink\"]').click(this._eventHandler.bind(this, 'unlinkPlan'));\n\n wrapper.find('[data-action=\"plan-request-review\"]').click(this._eventHandler.bind(this, 'requestReview'));\n wrapper.find('[data-action=\"plan-cancel-review-request\"]').click(this._eventHandler.bind(this, 'cancelReviewRequest'));\n wrapper.find('[data-action=\"plan-start-review\"]').click(this._eventHandler.bind(this, 'startReview'));\n wrapper.find('[data-action=\"plan-stop-review\"]').click(this._eventHandler.bind(this, 'stopReview'));\n wrapper.find('[data-action=\"plan-approve\"]').click(this._eventHandler.bind(this, 'approve'));\n wrapper.find('[data-action=\"plan-unapprove\"]').click(this._eventHandler.bind(this, 'unapprove'));\n\n wrapper.find('[data-action=\"find-courses-link\"]').click(this._showLinkedCoursesHandler.bind(this));\n };\n\n return PlanActions;\n});\n"],"names":["define","$","templates","ajax","notification","str","Menubar","Dialogue","PlanActions","type","this","_type","_region","_planNode","_template","_contextMethod","TypeError","prototype","_getContextArgs","planData","args","planid","id","userid","refresh","selector","_findPlanData","_callAndRefresh","_renderView","context","self","render","then","newhtml","newjs","replaceWith","runTemplateJS","calls","callKey","Math","floor","random","M","util","js_pending","push","methodname","when","apply","call","arguments","length","fail","exception","always","js_complete","_doDelete","deletePlan","done","plan","get_strings","key","component","param","name","strings","confirm","_doReopenPlan","reopenPlan","_doCompletePlan","completePlan","_doUnlinkPlan","unlinkPlan","_doRequestReview","requestReview","_doCancelReviewRequest","cancelReviewRequest","_doStartReview","startReview","_doStopReview","stopReview","_doApprove","approve","_doUnapprove","unapprove","_showLinkedCoursesHandler","e","preventDefault","competencyid","target","data","courses","html","get_string","linkedcourses","_eventHandler","method","node","parent","parentsUntil","Error","enhanceMenubar","enhance","bind","registerEvents","wrapper","find","click"],"mappings":";;;;;;;AAsBAA,OAAO,sBAAA,CAAC,SACA,iBACA,YACA,oBACA,WACA,kBACA,qBACA,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,QAASC,UAS7D,IAAIC,YAAc,SAASC,MAGvB,GAFAC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ACrF+F,QAAQC,KAAK,gCAAgCC,MAAMjG,KAAKqF,cAAcQ,KAAK7F,KAAM,YACjF+F,QAAQC,KAAK,kCAAkCC,MAAMjG,KAAKqF,cAAcQ,KAAK7F,KAAM,cAEnF+F,QAAQC,KAAK,qCAAqCC,MAAMjG,KAAK2E,0BAA0BkB,KAAK7F,QAGzFF,WACX"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/scaleconfig.min.js.map b/admin/tool/lp/amd/build/scaleconfig.min.js.map index 3a709b50add..d6e8d7d7336 100644 --- a/admin/tool/lp/amd/build/scaleconfig.min.js.map +++ b/admin/tool/lp/amd/build/scaleconfig.min.js.map @@ -1 +1 @@ -{"version":3,"file":"scaleconfig.min.js","sources":["../src/scaleconfig.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle opening a dialogue to configure scale data.\n *\n * @module tool_lp/scaleconfig\n * @copyright 2015 Adrian Greeve \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/notification', 'core/templates', 'core/ajax', 'tool_lp/dialogue', 'tool_lp/scalevalues'],\n function($, notification, templates, ajax, Dialogue, ModScaleValues) {\n\n /**\n * Scale config object.\n * @param {String} selectSelector The select box selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} triggerSelector The trigger selector.\n */\n var ScaleConfig = function(selectSelector, inputSelector, triggerSelector) {\n this.selectSelector = selectSelector;\n this.inputSelector = inputSelector;\n this.triggerSelector = triggerSelector;\n\n // Get the current scale ID.\n this.originalscaleid = $(selectSelector).val();\n $(selectSelector).on('change', this.scaleChangeHandler.bind(this)).change();\n $(triggerSelector).click(this.showConfig.bind(this));\n };\n\n /** @var {String} The select box selector. */\n ScaleConfig.prototype.selectSelector = null;\n /** @var {String} The hidden field selector. */\n ScaleConfig.prototype.inputSelector = null;\n /** @var {String} The trigger selector. */\n ScaleConfig.prototype.triggerSelector = null;\n /** @var {Array} scalevalues ID and name of the scales. */\n ScaleConfig.prototype.scalevalues = null;\n /** @var {Number) originalscaleid Original scale ID when the page loads. */\n ScaleConfig.prototype.originalscaleid = 0;\n /** @var {Number} scaleid Current scale ID. */\n ScaleConfig.prototype.scaleid = 0;\n /** @var {Dialogue} Reference to the popup. */\n ScaleConfig.prototype.popup = null;\n\n /**\n * Displays the scale configuration dialogue.\n *\n * @method showConfig\n */\n ScaleConfig.prototype.showConfig = function() {\n var self = this;\n\n this.scaleid = $(this.selectSelector).val();\n if (this.scaleid <= 0) {\n // This should not happen.\n return;\n }\n\n var scalename = $(this.selectSelector).find(\"option:selected\").text();\n this.getScaleValues(this.scaleid).done(function() {\n\n var context = {\n scalename: scalename,\n scales: self.scalevalues\n };\n\n // Dish up the form.\n templates.render('tool_lp/scale_configuration_page', context)\n .done(function(html) {\n new Dialogue(\n scalename,\n html,\n self.initScaleConfig.bind(self)\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Gets the original scale configuration if it was set.\n *\n * @method retrieveOriginalScaleConfig\n * @return {Object|String} scale configuration or empty string.\n */\n ScaleConfig.prototype.retrieveOriginalScaleConfig = function() {\n var jsonstring = $(this.inputSelector).val();\n if (jsonstring !== '') {\n var scaleconfiguration = $.parseJSON(jsonstring);\n // The first object should contain the scale ID for the configuration.\n var scaledetail = scaleconfiguration.shift();\n // Check that this scale id matches the one from the page before returning the configuration.\n if (scaledetail.scaleid === this.originalscaleid) {\n return scaleconfiguration;\n }\n }\n return '';\n };\n\n /**\n * Initialises the scale configuration dialogue.\n *\n * @method initScaleConfig\n * @param {Dialogue} popup Dialogue object to initialise.\n */\n ScaleConfig.prototype.initScaleConfig = function(popup) {\n this.popup = popup;\n var body = $(popup.getContent());\n if (this.originalscaleid === this.scaleid) {\n // Set up the popup to show the current configuration.\n var currentconfig = this.retrieveOriginalScaleConfig();\n // Set up the form only if there is configuration settings to set.\n if (currentconfig !== '') {\n currentconfig.forEach(function(value) {\n if (value.scaledefault === 1) {\n body.find('[data-field=\"tool_lp_scale_default_' + value.id + '\"]').attr('checked', true);\n }\n if (value.proficient === 1) {\n body.find('[data-field=\"tool_lp_scale_proficient_' + value.id + '\"]').attr('checked', true);\n }\n });\n }\n }\n body.on('click', '[data-action=\"close\"]', function() {\n this.setScaleConfig();\n popup.close();\n }.bind(this));\n body.on('click', '[data-action=\"cancel\"]', function() {\n popup.close();\n });\n };\n\n /**\n * Set the scale configuration back into a JSON string in the hidden element.\n *\n * @method setScaleConfig\n */\n ScaleConfig.prototype.setScaleConfig = function() {\n var body = $(this.popup.getContent());\n // Get the data.\n var data = [{scaleid: this.scaleid}];\n this.scalevalues.forEach(function(value) {\n var scaledefault = 0;\n var proficient = 0;\n if (body.find('[data-field=\"tool_lp_scale_default_' + value.id + '\"]').is(':checked')) {\n scaledefault = 1;\n }\n if (body.find('[data-field=\"tool_lp_scale_proficient_' + value.id + '\"]').is(':checked')) {\n proficient = 1;\n }\n\n if (!scaledefault && !proficient) {\n return;\n }\n\n data.push({\n id: value.id,\n scaledefault: scaledefault,\n proficient: proficient\n });\n });\n var datastring = JSON.stringify(data);\n // Send to the hidden field on the form.\n $(this.inputSelector).val(datastring);\n // Once the configuration has been saved then the original scale ID is set to the current scale ID.\n this.originalscaleid = this.scaleid;\n };\n\n /**\n * Get the scale values for the selected scale.\n *\n * @method getScaleValues\n * @param {Number} scaleid The scale ID of the selected scale.\n * @return {Promise} A deffered object with the scale values.\n */\n ScaleConfig.prototype.getScaleValues = function(scaleid) {\n return ModScaleValues.get_values(scaleid).then(function(values) {\n this.scalevalues = values;\n return values;\n }.bind(this));\n };\n\n /**\n * Triggered when a scale is selected.\n *\n * @name scaleChangeHandler\n * @param {Event} e\n * @function\n */\n ScaleConfig.prototype.scaleChangeHandler = function(e) {\n if ($(e.target).val() <= 0) {\n $(this.triggerSelector).prop('disabled', true);\n } else {\n $(this.triggerSelector).prop('disabled', false);\n }\n\n };\n\n return {\n\n /**\n * Main initialisation.\n *\n * @param {String} selectSelector The select box selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} triggerSelector The trigger selector.\n * @return {ScaleConfig} A new instance of ScaleConfig.\n * @method init\n */\n init: function(selectSelector, inputSelector, triggerSelector) {\n return new ScaleConfig(selectSelector, inputSelector, triggerSelector);\n }\n };\n});\n"],"names":["define","$","notification","templates","ajax","Dialogue","ModScaleValues","ScaleConfig","selectSelector","inputSelector","triggerSelector","originalscaleid","val","on","this","scaleChangeHandler","bind","change","click","showConfig","prototype","scalevalues","scaleid","popup","self","scalename","find","text","getScaleValues","done","context","scales","render","html","initScaleConfig","fail","exception","retrieveOriginalScaleConfig","jsonstring","scaleconfiguration","parseJSON","shift","body","getContent","currentconfig","forEach","value","scaledefault","id","attr","proficient","setScaleConfig","close","data","is","push","datastring","JSON","stringify","get_values","then","values","e","target","prop","init"],"mappings":";;;;;;;AAsBAA,6BAAO,CAAC,SAAU,oBAAqB,iBAAkB,YAAa,mBAAoB,wBACtF,SAASC,EAAGC,aAAcC,UAAWC,KAAMC,SAAUC,oBAQjDC,YAAc,SAASC,eAAgBC,cAAeC,sBACjDF,eAAiBA,oBACjBC,cAAgBA,mBAChBC,gBAAkBA,qBAGlBC,gBAAkBV,EAAEO,gBAAgBI,MACzCX,EAAEO,gBAAgBK,GAAG,SAAUC,KAAKC,mBAAmBC,KAAKF,OAAOG,SACnEhB,EAAES,iBAAiBQ,MAAMJ,KAAKK,WAAWH,KAAKF,eAIlDP,YAAYa,UAAUZ,eAAiB,KAEvCD,YAAYa,UAAUX,cAAgB,KAEtCF,YAAYa,UAAUV,gBAAkB,KAEx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zC,EAAEa,KAAKS,MAAMoB,cAEpBU,KAAO,CAAC,CAAC/B,QAASR,KAAKQ,eACtBD,YAAYwB,SAAQ,SAASC,WAC1BC,aAAe,EACfG,WAAa,EACbR,KAAKhB,KAAK,sCAAwCoB,MAAME,GAAK,MAAMM,GAAG,cACtEP,aAAe,GAEfL,KAAKhB,KAAK,yCAA2CoB,MAAME,GAAK,MAAMM,GAAG,cACzEJ,WAAa,IAGZH,cAAiBG,aAItBG,KAAKE,KAAK,CACNP,GAAIF,MAAME,GACVD,aAAcA,aACdG,WAAYA,oBAGhBM,WAAaC,KAAKC,UAAUL,MAEhCpD,EAAEa,KAAKL,eAAeG,IAAI4C,iBAErB7C,gBAAkBG,KAAKQ,SAUhCf,YAAYa,UAAUQ,eAAiB,SAASN,gBACrChB,eAAeqD,WAAWrC,SAASsC,KAAK,SAASC,oBAC/CxC,YAAcwC,OACZA,QACT7C,KAAKF,QAUXP,YAAYa,UAAUL,mBAAqB,SAAS+C,GAC5C7D,EAAE6D,EAAEC,QAAQnD,OAAS,EACrBX,EAAEa,KAAKJ,iBAAiBsD,KAAK,YAAY,GAEzC/D,EAAEa,KAAKJ,iBAAiBsD,KAAK,YAAY,IAK1C,CAWHC,KAAM,SAASzD,eAAgBC,cAAeC,wBACnC,IAAIH,YAAYC,eAAgBC,cAAeC"} \ No newline at end of file +{"version":3,"file":"scaleconfig.min.js","sources":["../src/scaleconfig.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle opening a dialogue to configure scale data.\n *\n * @module tool_lp/scaleconfig\n * @copyright 2015 Adrian Greeve \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/notification', 'core/templates', 'core/ajax', 'tool_lp/dialogue', 'tool_lp/scalevalues'],\n function($, notification, templates, ajax, Dialogue, ModScaleValues) {\n\n /**\n * Scale config object.\n * @param {String} selectSelector The select box selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} triggerSelector The trigger selector.\n */\n var ScaleConfig = function(selectSelector, inputSelector, triggerSelector) {\n this.selectSelector = selectSelector;\n this.inputSelector = inputSelector;\n this.triggerSelector = triggerSelector;\n\n // Get the current scale ID.\n this.originalscaleid = $(selectSelector).val();\n $(selectSelector).on('change', this.scaleChangeHandler.bind(this)).change();\n $(triggerSelector).click(this.showConfig.bind(this));\n };\n\n /** @var {String} The select box selector. */\n ScaleConfig.prototype.selectSelector = null;\n /** @var {String} The hidden field selector. */\n ScaleConfig.prototype.inputSelector = null;\n /** @var {String} The trigger selector. */\n ScaleConfig.prototype.triggerSelector = null;\n /** @var {Array} scalevalues ID and name of the scales. */\n ScaleConfig.prototype.scalevalues = null;\n /** @var {Number) originalscaleid Original scale ID when the page loads. */\n ScaleConfig.prototype.originalscaleid = 0;\n /** @var {Number} scaleid Current scale ID. */\n ScaleConfig.prototype.scaleid = 0;\n /** @var {Dialogue} Reference to the popup. */\n ScaleConfig.prototype.popup = null;\n\n /**\n * Displays the scale configuration dialogue.\n *\n * @method showConfig\n */\n ScaleConfig.prototype.showConfig = function() {\n var self = this;\n\n this.scaleid = $(this.selectSelector).val();\n if (this.scaleid <= 0) {\n // This should not happen.\n return;\n }\n\n var scalename = $(this.selectSelector).find(\"option:selected\").text();\n this.getScaleValues(this.scaleid).done(function() {\n\n var context = {\n scalename: scalename,\n scales: self.scalevalues\n };\n\n // Dish up the form.\n templates.render('tool_lp/scale_configuration_page', context)\n .done(function(html) {\n new Dialogue(\n scalename,\n html,\n self.initScaleConfig.bind(self)\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Gets the original scale configuration if it was set.\n *\n * @method retrieveOriginalScaleConfig\n * @return {Object|String} scale configuration or empty string.\n */\n ScaleConfig.prototype.retrieveOriginalScaleConfig = function() {\n var jsonstring = $(this.inputSelector).val();\n if (jsonstring !== '') {\n var scaleconfiguration = $.parseJSON(jsonstring);\n // The first object should contain the scale ID for the configuration.\n var scaledetail = scaleconfiguration.shift();\n // Check that this scale id matches the one from the page before returning the configuration.\n if (scaledetail.scaleid === this.originalscaleid) {\n return scaleconfiguration;\n }\n }\n return '';\n };\n\n /**\n * Initialises the scale configuration dialogue.\n *\n * @method initScaleConfig\n * @param {Dialogue} popup Dialogue object to initialise.\n */\n ScaleConfig.prototype.initScaleConfig = function(popup) {\n this.popup = popup;\n var body = $(popup.getContent());\n if (this.originalscaleid === this.scaleid) {\n // Set up the popup to show the current configuration.\n var currentconfig = this.retrieveOriginalScaleConfig();\n // Set up the form only if there is configuration settings to set.\n if (currentconfig !== '') {\n currentconfig.forEach(function(value) {\n if (value.scaledefault === 1) {\n body.find('[data-field=\"tool_lp_scale_default_' + value.id + '\"]').attr('checked', true);\n }\n if (value.proficient === 1) {\n body.find('[data-field=\"tool_lp_scale_proficient_' + value.id + '\"]').attr('checked', true);\n }\n });\n }\n }\n body.on('click', '[data-action=\"close\"]', function() {\n this.setScaleConfig();\n popup.close();\n }.bind(this));\n body.on('click', '[data-action=\"cancel\"]', function() {\n popup.close();\n });\n };\n\n /**\n * Set the scale configuration back into a JSON string in the hidden element.\n *\n * @method setScaleConfig\n */\n ScaleConfig.prototype.setScaleConfig = function() {\n var body = $(this.popup.getContent());\n // Get the data.\n var data = [{scaleid: this.scaleid}];\n this.scalevalues.forEach(function(value) {\n var scaledefault = 0;\n var proficient = 0;\n if (body.find('[data-field=\"tool_lp_scale_default_' + value.id + '\"]').is(':checked')) {\n scaledefault = 1;\n }\n if (body.find('[data-field=\"tool_lp_scale_proficient_' + value.id + '\"]').is(':checked')) {\n proficient = 1;\n }\n\n if (!scaledefault && !proficient) {\n return;\n }\n\n data.push({\n id: value.id,\n scaledefault: scaledefault,\n proficient: proficient\n });\n });\n var datastring = JSON.stringify(data);\n // Send to the hidden field on the form.\n $(this.inputSelector).val(datastring);\n // Once the configuration has been saved then the original scale ID is set to the current scale ID.\n this.originalscaleid = this.scaleid;\n };\n\n /**\n * Get the scale values for the selected scale.\n *\n * @method getScaleValues\n * @param {Number} scaleid The scale ID of the selected scale.\n * @return {Promise} A deffered object with the scale values.\n */\n ScaleConfig.prototype.getScaleValues = function(scaleid) {\n return ModScaleValues.get_values(scaleid).then(function(values) {\n this.scalevalues = values;\n return values;\n }.bind(this));\n };\n\n /**\n * Triggered when a scale is selected.\n *\n * @name scaleChangeHandler\n * @param {Event} e\n * @function\n */\n ScaleConfig.prototype.scaleChangeHandler = function(e) {\n if ($(e.target).val() <= 0) {\n $(this.triggerSelector).prop('disabled', true);\n } else {\n $(this.triggerSelector).prop('disabled', false);\n }\n\n };\n\n return {\n\n /**\n * Main initialisation.\n *\n * @param {String} selectSelector The select box selector.\n * @param {String} inputSelector The hidden input field selector.\n * @param {String} triggerSelector The trigger selector.\n * @return {ScaleConfig} A new instance of ScaleConfig.\n * @method init\n */\n init: function(selectSelector, inputSelector, triggerSelector) {\n return new ScaleConfig(selectSelector, inputSelector, triggerSelector);\n }\n };\n});\n"],"names":["define","$","notification","templates","ajax","Dialogue","ModScaleValues","ScaleConfig","selectSelector","inputSelector","triggerSelector","this","originalscaleid","val","on","scaleChangeHandler","bind","change","click","showConfig","prototype","scalevalues","scaleid","popup","self","scalename","find","text","getScaleValues","done","context","scales","render","html","initScaleConfig","fail","exception","retrieveOriginalScaleConfig","jsonstring","scaleconfiguration","parseJSON","shift","body","getContent","currentconfig","forEach","value","scaledefault","id","attr","proficient","setScaleConfig","close","data","is","push","datastring","JSON","stringify","get_values","then","values","e","target","prop","init"],"mappings":";;;;;;;AAsBAA,OAAM,sBAAC,CAAC,SAAU,oBAAqB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ACZA,MACX,EAAE7C,KAAKL,QAUXJ,YAAYa,UAAUL,mBAAqB,SAAS+C,GAC5C7D,EAAE6D,EAAEC,QAAQlD,OAAS,EACrBZ,EAAEU,KAAKD,iBAAiBsD,KAAK,YAAY,GAEzC/D,EAAEU,KAAKD,iBAAiBsD,KAAK,YAAY,IAK1C,CAWHC,KAAM,SAASzD,eAAgBC,cAAeC,iBAC1C,OAAO,IAAIH,YAAYC,eAAgBC,cAAeC,gBAC1D,EAER"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/scalevalues.min.js.map b/admin/tool/lp/amd/build/scalevalues.min.js.map index f15ca392296..a4dfa805766 100644 --- a/admin/tool/lp/amd/build/scalevalues.min.js.map +++ b/admin/tool/lp/amd/build/scalevalues.min.js.map @@ -1 +1 @@ -{"version":3,"file":"scalevalues.min.js","sources":["../src/scalevalues.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to get the scale values.\n *\n * @module tool_lp/scalevalues\n * @copyright 2016 Serge Gauthier\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax'], function($, ajax) {\n var localCache = [];\n\n return {\n\n /**\n * Return a promise object that will be resolved into a string eventually (maybe immediately).\n *\n * @method get_values\n * @param {Number} scaleid The scale id\n * @return [] {Promise}\n */\n // eslint-disable-next-line camelcase\n get_values: function(scaleid) {\n\n var deferred = $.Deferred();\n\n if (typeof localCache[scaleid] === 'undefined') {\n ajax.call([{\n methodname: 'core_competency_get_scale_values',\n args: {scaleid: scaleid},\n done: function(scaleinfo) {\n localCache[scaleid] = scaleinfo;\n deferred.resolve(scaleinfo);\n },\n fail: (deferred.reject)\n }]);\n } else {\n deferred.resolve(localCache[scaleid]);\n }\n\n return deferred.promise();\n }\n };\n});\n"],"names":["define","$","ajax","localCache","get_values","scaleid","deferred","Deferred","call","methodname","args","done","scaleinfo","resolve","fail","reject","promise"],"mappings":";;;;;;;AAsBAA,6BAAO,CAAC,SAAU,cAAc,SAASC,EAAGC,UACpCC,WAAa,SAEV,CAUHC,WAAY,SAASC,aAEbC,SAAWL,EAAEM,uBAEkB,IAAxBJ,WAAWE,SAClBH,KAAKM,KAAK,CAAC,CACPC,WAAY,mCACZC,KAAM,CAACL,QAASA,SAChBM,KAAM,SAASC,WACXT,WAAWE,SAAWO,UACtBN,SAASO,QAAQD,YAErBE,KAAOR,SAASS,UAGpBT,SAASO,QAAQV,WAAWE,UAGzBC,SAASU"} \ No newline at end of file +{"version":3,"file":"scalevalues.min.js","sources":["../src/scalevalues.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to get the scale values.\n *\n * @module tool_lp/scalevalues\n * @copyright 2016 Serge Gauthier\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax'], function($, ajax) {\n var localCache = [];\n\n return {\n\n /**\n * Return a promise object that will be resolved into a string eventually (maybe immediately).\n *\n * @method get_values\n * @param {Number} scaleid The scale id\n * @return [] {Promise}\n */\n // eslint-disable-next-line camelcase\n get_values: function(scaleid) {\n\n var deferred = $.Deferred();\n\n if (typeof localCache[scaleid] === 'undefined') {\n ajax.call([{\n methodname: 'core_competency_get_scale_values',\n args: {scaleid: scaleid},\n done: function(scaleinfo) {\n localCache[scaleid] = scaleinfo;\n deferred.resolve(scaleinfo);\n },\n fail: (deferred.reject)\n }]);\n } else {\n deferred.resolve(localCache[scaleid]);\n }\n\n return deferred.promise();\n }\n };\n});\n"],"names":["define","$","ajax","localCache","get_values","scaleid","deferred","Deferred","call","methodname","args","done","scaleinfo","resolve","fail","reject","promise"],"mappings":";;;;;;;AAsBAA,OAAM,sBAAC,CAAC,SAAU,cAAc,SAASC,EAAGC,MACxC,IAAIC,WAAa,GAEjB,MAAO,CAUHC,WAAY,SAASC,SAEjB,IAAIC,SAAWL,EAAEM,WAgBjB,YAdmC,IAAxBJ,WAAWE,SAClBH,KAAKM,KAAK,CAAC,CACPC,WAAY,mCACZC,KAAM,CAACL,QAASA,SAChBM,KAAM,SAASC,WACXT,WAAWE,SAAWO,UACtBN,SAASO,QAAQD,UACpB,EACDE,KAAOR,SAASS,UAGpBT,SAASO,QAAQV,WAAWE,UAGzBC,SAASU,SACpB,EAER"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/templateactions.min.js.map b/admin/tool/lp/amd/build/templateactions.min.js.map index 6c72d2794ca..6924e9b3e83 100644 --- a/admin/tool/lp/amd/build/templateactions.min.js.map +++ b/admin/tool/lp/amd/build/templateactions.min.js.map @@ -1 +1 @@ -{"version":3,"file":"templateactions.min.js","sources":["../src/templateactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle actions on learning plan templates via ajax.\n *\n * @module tool_lp/templateactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str', 'tool_lp/actionselector'],\n function($, templates, ajax, notification, str, Actionselector) {\n // Private variables and functions.\n\n /** @var {Number} pagecontextid The id of the context */\n var pagecontextid = 0;\n\n /** @var {Number} templateid The id of the template */\n var templateid = 0;\n\n /** @var {Boolean} Action to apply to plans when deleting a template */\n var deleteplans = true;\n\n /**\n * Callback to replace the dom element with the rendered template.\n *\n * @method updatePage\n * @param {String} newhtml The new html to insert.\n * @param {String} newjs The new js to run.\n */\n var updatePage = function(newhtml, newjs) {\n $('[data-region=\"managetemplates\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n };\n\n /**\n * Callback to render the page template again and update the page.\n *\n * @method reloadList\n * @param {Object} context The context for the template.\n */\n var reloadList = function(context) {\n templates.render('tool_lp/manage_templates_page', context)\n .done(updatePage)\n .fail(notification.exception);\n };\n\n /**\n * Delete a template and reload the page.\n * @method doDelete\n */\n var doDelete = function() {\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_delete_template',\n args: {id: templateid,\n deleteplans: deleteplans}\n }, {\n methodname: 'tool_lp_data_for_templates_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Duplicate a template and reload the page.\n * @method doDuplicate\n * @param {Event} e\n */\n var doDuplicate = function(e) {\n e.preventDefault();\n\n templateid = $(this).attr('data-templateid');\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_duplicate_template',\n args: {id: templateid}\n }, {\n methodname: 'tool_lp_data_for_templates_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Handler for \"Delete learning plan template\" actions.\n * @method confirmDelete\n * @param {Event} e\n */\n var confirmDelete = function(e) {\n e.preventDefault();\n\n var id = $(this).attr('data-templateid');\n templateid = id;\n deleteplans = true;\n\n var requests = ajax.call([{\n methodname: 'core_competency_read_template',\n args: {id: templateid}\n }, {\n methodname: 'core_competency_template_has_related_data',\n args: {id: templateid}\n }]);\n\n requests[0].done(function(template) {\n requests[1].done(function(templatehasrelateddata) {\n if (templatehasrelateddata) {\n str.get_strings([\n {key: 'deletetemplate', component: 'tool_lp', param: template.shortname},\n {key: 'deletetemplatewithplans', component: 'tool_lp'},\n {key: 'deleteplans', component: 'tool_lp'},\n {key: 'unlinkplanstemplate', component: 'tool_lp'},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n var actions = [{'text': strings[2], 'value': 'delete'},\n {'text': strings[3], 'value': 'unlink'}];\n var actionselector = new Actionselector(\n strings[0], // Title.\n strings[1], // Message\n actions, // Radio button options.\n strings[4], // Confirm.\n strings[5]); // Cancel.\n actionselector.display();\n actionselector.on('save', function(e, data) {\n if (data.action != 'delete') {\n deleteplans = false;\n }\n doDelete();\n });\n }).fail(notification.exception);\n } else {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deletetemplate', component: 'tool_lp', param: template.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete learning plan template X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n }\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n return /** @alias module:tool_lp/templateactions */ {\n // Public variables and functions.\n /**\n * Expose the event handler for the delete.\n * @method deleteHandler\n * @param {Event} e\n */\n deleteHandler: confirmDelete,\n\n /**\n * Expose the event handler for the duplicate.\n * @method duplicateHandler\n * @param {Event} e\n */\n duplicateHandler: doDuplicate,\n\n /**\n * Initialise the module.\n * @method init\n * @param {Number} contextid The context id of the page.\n */\n init: function(contextid) {\n pagecontextid = contextid;\n }\n };\n});\n"],"names":["define","$","templates","ajax","notification","str","Actionselector","pagecontextid","templateid","deleteplans","updatePage","newhtml","newjs","replaceWith","runTemplateJS","reloadList","context","render","done","fail","exception","doDelete","call","methodname","args","id","pagecontext","contextid","deleteHandler","e","preventDefault","this","attr","requests","template","templatehasrelateddata","get_strings","key","component","param","shortname","strings","actions","actionselector","display","on","data","action","confirm","duplicateHandler","init"],"mappings":";;;;;;;AAsBAA,iCAAO,CAAC,SAAU,iBAAkB,YAAa,oBAAqB,WAAY,2BAC3E,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,oBAI/CC,cAAgB,EAGhBC,WAAa,EAGbC,aAAc,EASdC,WAAa,SAASC,QAASC,OAC/BX,EAAE,mCAAmCY,YAAYF,SACjDT,UAAUY,cAAcF,QASxBG,WAAa,SAASC,SACtBd,UAAUe,OAAO,gCAAiCD,SAC7CE,KAAKR,YACLS,KAAKf,aAAagB,YAOvBC,SAAW,WAGIlB,KAAKmB,KAAK,CAAC,CACtBC,WAAY,kCACZC,KAAM,CAACC,GAAIjB,WACHC,YAAaA,cACtB,CACCc,WAAY,yCACZC,KAAM,CACFE,YAAa,CACTC,UAAWpB,mBAId,GAAGW,KAAKH,YAAYI,KAAKf,aAAagB,kBAgGC,CAOhDQ,cAtEgB,SAASC,GACzBA,EAAEC,qBAEEL,GAAKxB,EAAE8B,MAAMC,KAAK,mBACtBxB,WAAaiB,GACbhB,aAAc,MAEVwB,SAAW9B,KAAKmB,KAAK,CAAC,CACtBC,WAAY,gCACZC,KAAM,CAACC,GAAIjB,aACZ,CACCe,WAAY,4CACZC,KAAM,CAACC,GAAIjB,eAGfyB,SAAS,GAAGf,MAAK,SAASgB,UACtBD,SAAS,GAAGf,MAAK,SAASiB,wBAClBA,uBACA9B,IAAI+B,YAAY,CACZ,CAACC,IAAK,iBAAkBC,UAAW,UAAWC,MAAOL,SAASM,WAC9D,CAACH,IAAK,0BAA2BC,UAAW,WAC5C,CAACD,IAAK,cAAeC,UAAW,WAChC,CAACD,IAAK,sBAAuBC,UAAW,WACxC,CAACD,IAAK,UAAWC,UAAW,UAC5B,CAACD,IAAK,SAAUC,UAAW,YAC5BpB,MAAK,SAASuB,aACTC,QAAU,CAAC,MAASD,QAAQ,SAAa,UAC9B,MAASA,QAAQ,SAAa,WACzCE,eAAiB,IAAIrC,eACjBmC,QAAQ,GACRA,QAAQ,GACRC,QACAD,QAAQ,GACRA,QAAQ,IAChBE,eAAeC,UACfD,eAAeE,GAAG,QAAQ,SAAShB,EAAGiB,MACf,UAAfA,KAAKC,SACLtC,aAAc,GAElBY,iBAELF,KAAKf,aAAagB,WAErBf,IAAI+B,YAAY,CACZ,CAACC,IAAK,UAAWC,UAAW,UAC5B,CAACD,IAAK,iBAAkBC,UAAW,UAAWC,MAAOL,SAASM,WAC9D,CAACH,IAAK,SAAUC,UAAW,UAC3B,CAACD,IAAK,SAAUC,UAAW,YAC5BpB,MAAK,SAASuB,SACbrC,aAAa4C,QACbP,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRA,QAAQ,GACRpB,aAEDF,KAAKf,aAAagB,cAE1BD,KAAKf,aAAagB,cACtBD,KAAKf,aAAagB,YAkBrB6B,iBAtGc,SAASpB,GACvBA,EAAEC,iBAEFtB,WAAaP,EAAE8B,MAAMC,KAAK,mBAGX7B,KAAKmB,KAAK,CAAC,CACtBC,WAAY,qCACZC,KAAM,CAACC,GAAIjB,aACZ,CACCe,WAAY,yCACZC,KAAM,CACFE,YAAa,CACTC,UAAWpB,mBAId,GAAGW,KAAKH,YAAYI,KAAKf,aAAagB,YA4F/C8B,KAAM,SAASvB,WACXpB,cAAgBoB"} \ No newline at end of file +{"version":3,"file":"templateactions.min.js","sources":["../src/templateactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle actions on learning plan templates via ajax.\n *\n * @module tool_lp/templateactions\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str', 'tool_lp/actionselector'],\n function($, templates, ajax, notification, str, Actionselector) {\n // Private variables and functions.\n\n /** @var {Number} pagecontextid The id of the context */\n var pagecontextid = 0;\n\n /** @var {Number} templateid The id of the template */\n var templateid = 0;\n\n /** @var {Boolean} Action to apply to plans when deleting a template */\n var deleteplans = true;\n\n /**\n * Callback to replace the dom element with the rendered template.\n *\n * @method updatePage\n * @param {String} newhtml The new html to insert.\n * @param {String} newjs The new js to run.\n */\n var updatePage = function(newhtml, newjs) {\n $('[data-region=\"managetemplates\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n };\n\n /**\n * Callback to render the page template again and update the page.\n *\n * @method reloadList\n * @param {Object} context The context for the template.\n */\n var reloadList = function(context) {\n templates.render('tool_lp/manage_templates_page', context)\n .done(updatePage)\n .fail(notification.exception);\n };\n\n /**\n * Delete a template and reload the page.\n * @method doDelete\n */\n var doDelete = function() {\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_delete_template',\n args: {id: templateid,\n deleteplans: deleteplans}\n }, {\n methodname: 'tool_lp_data_for_templates_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Duplicate a template and reload the page.\n * @method doDuplicate\n * @param {Event} e\n */\n var doDuplicate = function(e) {\n e.preventDefault();\n\n templateid = $(this).attr('data-templateid');\n\n // We are chaining ajax requests here.\n var requests = ajax.call([{\n methodname: 'core_competency_duplicate_template',\n args: {id: templateid}\n }, {\n methodname: 'tool_lp_data_for_templates_manage_page',\n args: {\n pagecontext: {\n contextid: pagecontextid\n }\n }\n }]);\n requests[1].done(reloadList).fail(notification.exception);\n };\n\n /**\n * Handler for \"Delete learning plan template\" actions.\n * @method confirmDelete\n * @param {Event} e\n */\n var confirmDelete = function(e) {\n e.preventDefault();\n\n var id = $(this).attr('data-templateid');\n templateid = id;\n deleteplans = true;\n\n var requests = ajax.call([{\n methodname: 'core_competency_read_template',\n args: {id: templateid}\n }, {\n methodname: 'core_competency_template_has_related_data',\n args: {id: templateid}\n }]);\n\n requests[0].done(function(template) {\n requests[1].done(function(templatehasrelateddata) {\n if (templatehasrelateddata) {\n str.get_strings([\n {key: 'deletetemplate', component: 'tool_lp', param: template.shortname},\n {key: 'deletetemplatewithplans', component: 'tool_lp'},\n {key: 'deleteplans', component: 'tool_lp'},\n {key: 'unlinkplanstemplate', component: 'tool_lp'},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n var actions = [{'text': strings[2], 'value': 'delete'},\n {'text': strings[3], 'value': 'unlink'}];\n var actionselector = new Actionselector(\n strings[0], // Title.\n strings[1], // Message\n actions, // Radio button options.\n strings[4], // Confirm.\n strings[5]); // Cancel.\n actionselector.display();\n actionselector.on('save', function(e, data) {\n if (data.action != 'delete') {\n deleteplans = false;\n }\n doDelete();\n });\n }).fail(notification.exception);\n } else {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deletetemplate', component: 'tool_lp', param: template.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete learning plan template X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n }\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n return /** @alias module:tool_lp/templateactions */ {\n // Public variables and functions.\n /**\n * Expose the event handler for the delete.\n * @method deleteHandler\n * @param {Event} e\n */\n deleteHandler: confirmDelete,\n\n /**\n * Expose the event handler for the duplicate.\n * @method duplicateHandler\n * @param {Event} e\n */\n duplicateHandler: doDuplicate,\n\n /**\n * Initialise the module.\n * @method init\n * @param {Number} contextid The context id of the page.\n */\n init: function(contextid) {\n pagecontextid = contextid;\n }\n };\n});\n"],"names":["define","$","templates","ajax","notification","str","Actionselector","pagecontextid","templateid","deleteplans","updatePage","newhtml","newjs","replaceWith","runTemplateJS","reloadList","context","render","done","fail","exception","doDelete","call","methodname","args","id","pagecontext","contextid","deleteHandler","e","preventDefault","this","attr","requests","template","templatehasrelateddata","get_strings","key","component","param","shortname","strings","actions","text","value","actionselector","display","on","data","action","confirm","duplicateHandler","init"],"mappings":";;;;;;;AAsBAA,OAAM,0BAAC,CAAC,SAAU,iBAAkB,YAAa,oBAAqB,WAAY,2BAC3E,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,gBAInD,IAAIC,cAAgB,EAGhBC,WAAa,EAGbC,aAAc,EASdC,WAAa,SAASC,QAASC,OAC/BX,EAAE,mCAAmCY,YAAYF,SACjDT,UAAUY,cAAcF,QASxBG,WAAa,SAASC,SACtBd,UAAUe,OAAO,gCAAiCD,SAC7CE,KAAKR,YACLS,KAAKf,aAAagB,YAOvBC,SAAW,WAGIlB,KAAKmB,KAAK,CAAC,CACtBC,WAAY,kCACZC,KAAM,CAACC,GAAIjB,WACHC,YAAaA,cACtB,CACCc,WAAY,yCACZC,KAAM,CACFE,YAAa,CACTC,UAAWpB,mBAId,GAAGW,KAAKH,YAAYI,KAAKf,aAAagB,YAgGnD,MAAoD,CAOhDQ,cAtEgB,SAASC,GACzBA,EAAEC,iBAEF,IAAIL,GAAKxB,EAAE8B,MAAMC,KAAK,mBACtBxB,WAAa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,mBAGX7B,KAAKmB,KAAK,CAAC,CACtBC,WAAY,qCACZC,KAAM,CAACC,GAAIjB,aACZ,CACCe,WAAY,yCACZC,KAAM,CACFE,YAAa,CACTC,UAAWpB,mBAId,GAAGW,KAAKH,YAAYI,KAAKf,aAAagB,YA4F/CgC,KAAM,SAASzB,WACXpB,cAAgBoB,SACpB,EAER"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/tree.min.js.map b/admin/tool/lp/amd/build/tree.min.js.map index d2b98e75cb3..b57f62fadab 100644 --- a/admin/tool/lp/amd/build/tree.min.js.map +++ b/admin/tool/lp/amd/build/tree.min.js.map @@ -1 +1 @@ -{"version":3,"file":"tree.min.js","sources":["../src/tree.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Implement an accessible aria tree widget, from a nested unordered list.\n * Based on http://oaa-accessibility.org/example/41/\n *\n * To respond to selection changed events - use tree.on(\"selectionchanged\", handler).\n * The handler will receive an array of nodes, which are the list items that are currently\n * selected. (Or a single node if multiselect is disabled).\n *\n * @module tool_lp/tree\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/url', 'core/log'], function($, url, log) {\n // Private variables and functions.\n /** @var {String} expandedImage The html for an expanded tree node twistie. */\n var expandedImage = $('\"\"');\n /** @var {String} collapsedImage The html for a collapsed tree node twistie. */\n var collapsedImage = $('\"\"');\n\n /**\n * Constructor\n *\n * @param {String} selector\n * @param {Boolean} multiSelect\n */\n var Tree = function(selector, multiSelect) {\n this.treeRoot = $(selector);\n this.multiSelect = (typeof multiSelect === 'undefined' || multiSelect === true);\n\n this.items = this.treeRoot.find('li');\n this.expandAll = this.items.length < 20;\n this.parents = this.treeRoot.find('li:has(ul)');\n\n if (multiSelect) {\n this.treeRoot.attr('aria-multiselectable', 'true');\n }\n\n this.items.attr('aria-selected', 'false');\n\n this.visibleItems = null;\n this.activeItem = null;\n this.lastActiveItem = null;\n\n this.keys = {\n tab: 9,\n enter: 13,\n space: 32,\n pageup: 33,\n pagedown: 34,\n end: 35,\n home: 36,\n left: 37,\n up: 38,\n right: 39,\n down: 40,\n eight: 56,\n asterisk: 106\n };\n\n this.init();\n\n this.bindEventHandlers();\n };\n // Public variables and functions.\n\n /**\n * Init this tree\n * @method init\n */\n Tree.prototype.init = function() {\n this.parents.attr('aria-expanded', 'true');\n this.parents.prepend(expandedImage.clone());\n\n this.items.attr('role', 'tree-item');\n this.items.attr('tabindex', '-1');\n this.parents.attr('role', 'group');\n this.treeRoot.attr('role', 'tree');\n\n this.visibleItems = this.treeRoot.find('li');\n\n var thisObj = this;\n if (!this.expandAll) {\n this.parents.each(function() {\n thisObj.collapseGroup($(this));\n });\n this.expandGroup(this.parents.first());\n }\n };\n\n /**\n * Expand a collapsed group.\n *\n * @method expandGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.expandGroup = function(item) {\n // Find the first child ul node.\n var group = item.children('ul');\n\n // Expand the group.\n group.show().attr('aria-hidden', 'false');\n\n item.attr('aria-expanded', 'true');\n\n item.children('img').attr('src', expandedImage.attr('src'));\n\n // Update the list of visible items.\n this.visibleItems = this.treeRoot.find('li:visible');\n };\n\n /**\n * Collapse an expanded group.\n *\n * @method collapseGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.collapseGroup = function(item) {\n var group = item.children('ul');\n\n // Collapse the group.\n group.hide().attr('aria-hidden', 'true');\n\n item.attr('aria-expanded', 'false');\n\n item.children('img').attr('src', collapsedImage.attr('src'));\n\n // Update the list of visible items.\n this.visibleItems = this.treeRoot.find('li:visible');\n };\n\n /**\n * Expand or collapse a group.\n *\n * @method toggleGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.toggleGroup = function(item) {\n if (item.attr('aria-expanded') == 'true') {\n this.collapseGroup(item);\n } else {\n this.expandGroup(item);\n }\n };\n\n /**\n * Whenever the currently selected node has changed, trigger an event using this function.\n *\n * @method triggerChange\n */\n Tree.prototype.triggerChange = function() {\n var allSelected = this.items.filter('[aria-selected=true]');\n if (!this.multiSelect) {\n allSelected = allSelected.first();\n }\n this.treeRoot.trigger('selectionchanged', {selected: allSelected});\n };\n\n /**\n * Select all the items between the last focused item and this currently focused item.\n *\n * @method multiSelectItem\n * @param {Object} item is the jquery id of the newly selected item.\n */\n Tree.prototype.multiSelectItem = function(item) {\n if (!this.multiSelect) {\n this.items.attr('aria-selected', 'false');\n } else if (this.lastActiveItem !== null) {\n var lastIndex = this.visibleItems.index(this.lastActiveItem);\n var currentIndex = this.visibleItems.index(this.activeItem);\n var oneItem = null;\n\n while (lastIndex < currentIndex) {\n oneItem = $(this.visibleItems.get(lastIndex));\n oneItem.attr('aria-selected', 'true');\n lastIndex++;\n }\n while (lastIndex > currentIndex) {\n oneItem = $(this.visibleItems.get(lastIndex));\n oneItem.attr('aria-selected', 'true');\n lastIndex--;\n }\n }\n\n item.attr('aria-selected', 'true');\n this.triggerChange();\n };\n\n /**\n * Select a single item. Make sure all the parents are expanded. De-select all other items.\n *\n * @method selectItem\n * @param {Object} item is the jquery id of the newly selected item.\n */\n Tree.prototype.selectItem = function(item) {\n // Expand all nodes up the tree.\n var walk = item.parent();\n while (walk.attr('role') != 'tree') {\n walk = walk.parent();\n if (walk.attr('aria-expanded') == 'false') {\n this.expandGroup(walk);\n }\n walk = walk.parent();\n }\n this.items.attr('aria-selected', 'false');\n item.attr('aria-selected', 'true');\n this.triggerChange();\n };\n\n /**\n * Toggle the selected state for an item back and forth.\n *\n * @method toggleItem\n * @param {Object} item is the jquery id of the item to toggle.\n */\n Tree.prototype.toggleItem = function(item) {\n if (!this.multiSelect) {\n this.selectItem(item);\n return;\n }\n\n var current = item.attr('aria-selected');\n if (current === 'true') {\n current = 'false';\n } else {\n current = 'true';\n }\n item.attr('aria-selected', current);\n this.triggerChange();\n };\n\n /**\n * Set the focus to this item.\n *\n * @method updateFocus\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.updateFocus = function(item) {\n this.lastActiveItem = this.activeItem;\n this.activeItem = item;\n // Expand all nodes up the tree.\n var walk = item.parent();\n while (walk.attr('role') != 'tree') {\n walk = walk.parent();\n if (walk.attr('aria-expanded') == 'false') {\n this.expandGroup(walk);\n }\n walk = walk.parent();\n }\n this.items.attr('tabindex', '-1');\n item.attr('tabindex', 0);\n };\n\n /**\n * Handle a key down event - ie navigate the tree.\n *\n * @method handleKeyDown\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n // This function should be simplified. In the meantime..\n // eslint-disable-next-line complexity\n Tree.prototype.handleKeyDown = function(item, e) {\n var currentIndex = this.visibleItems.index(item);\n var newItem = null;\n var hasKeyModifier = e.shiftKey || e.ctrlKey || e.metaKey || e.altKey;\n var thisObj = this;\n\n switch (e.keyCode) {\n case this.keys.home: {\n // Jump to first item in tree.\n newItem = this.parents.first();\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.end: {\n // Jump to last visible item.\n newItem = this.visibleItems.last();\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.enter:\n case this.keys.space: {\n\n if (e.shiftKey) {\n this.multiSelectItem(item);\n } else if (e.metaKey || e.ctrlKey) {\n this.toggleItem(item);\n } else {\n this.selectItem(item);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.left: {\n if (item.has('ul') && item.attr('aria-expanded') == 'true') {\n this.collapseGroup(item);\n } else {\n // Move up to the parent.\n var itemUL = item.parent();\n var itemParent = itemUL.parent();\n if (itemParent.is('li')) {\n itemParent.focus();\n if (e.shiftKey) {\n this.multiSelectItem(itemParent);\n } else if (!hasKeyModifier) {\n this.selectItem(itemParent);\n }\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.right: {\n if (item.has('ul') && item.attr('aria-expanded') == 'false') {\n this.expandGroup(item);\n } else {\n // Move to the first item in the child group.\n newItem = item.children('ul').children('li').first();\n if (newItem.length > 0) {\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.up: {\n\n if (currentIndex > 0) {\n var prev = this.visibleItems.eq(currentIndex - 1);\n prev.focus();\n if (e.shiftKey) {\n this.multiSelectItem(prev);\n } else if (!hasKeyModifier) {\n this.selectItem(prev);\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.down: {\n\n if (currentIndex < this.visibleItems.length - 1) {\n var next = this.visibleItems.eq(currentIndex + 1);\n next.focus();\n if (e.shiftKey) {\n this.multiSelectItem(next);\n } else if (!hasKeyModifier) {\n this.selectItem(next);\n }\n }\n e.stopPropagation();\n return false;\n }\n case this.keys.asterisk: {\n // Expand all groups.\n this.parents.each(function() {\n thisObj.expandGroup($(this));\n });\n\n e.stopPropagation();\n return false;\n }\n case this.keys.eight: {\n if (e.shiftKey) {\n // Expand all groups.\n this.parents.each(function() {\n thisObj.expandGroup($(this));\n });\n\n e.stopPropagation();\n }\n\n return false;\n }\n }\n\n return true;\n };\n\n /**\n * Handle a key press event - ie navigate the tree.\n *\n * @method handleKeyPress\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleKeyPress = function(item, e) {\n if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {\n // Do nothing.\n return true;\n }\n\n switch (e.keyCode) {\n case this.keys.tab: {\n return true;\n }\n case this.keys.enter:\n case this.keys.home:\n case this.keys.end:\n case this.keys.left:\n case this.keys.right:\n case this.keys.up:\n case this.keys.down: {\n e.stopPropagation();\n return false;\n }\n default : {\n var chr = String.fromCharCode(e.which);\n var match = false;\n var itemIndex = this.visibleItems.index(item);\n var itemCount = this.visibleItems.length;\n var currentIndex = itemIndex + 1;\n\n // Check if the active item was the last one on the list.\n if (currentIndex == itemCount) {\n currentIndex = 0;\n }\n\n // Iterate through the menu items (starting from the current item and wrapping) until a match is found\n // or the loop returns to the current menu item.\n while (currentIndex != itemIndex) {\n\n var currentItem = this.visibleItems.eq(currentIndex);\n var titleChr = currentItem.text().charAt(0);\n\n if (currentItem.has('ul')) {\n titleChr = currentItem.find('span').text().charAt(0);\n }\n\n if (titleChr.toLowerCase() == chr) {\n match = true;\n break;\n }\n\n currentIndex = currentIndex + 1;\n if (currentIndex == itemCount) {\n // Reached the end of the list, start again at the beginning.\n currentIndex = 0;\n }\n }\n\n if (match === true) {\n this.updateFocus(this.visibleItems.eq(currentIndex));\n }\n e.stopPropagation();\n return false;\n }\n }\n\n // eslint-disable-next-line no-unreachable\n return true;\n };\n\n /**\n * Attach an event listener to the tree.\n *\n * @method on\n * @param {String} eventname This is the name of the event to listen for. Only 'selectionchanged' is supported for now.\n * @param {Function} handler The function to call when the event is triggered.\n */\n Tree.prototype.on = function(eventname, handler) {\n if (eventname !== 'selectionchanged') {\n log.warning('Invalid custom event name for tree. Only \"selectionchanged\" is supported.');\n } else {\n this.treeRoot.on(eventname, handler);\n }\n };\n\n /**\n * Handle a double click (expand/collapse).\n *\n * @method handleDblClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleDblClick = function(item, e) {\n\n if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {\n // Do nothing.\n return true;\n }\n\n // Apply the focus markup.\n this.updateFocus(item);\n\n // Expand or collapse the group.\n this.toggleGroup(item);\n\n e.stopPropagation();\n return false;\n };\n\n /**\n * Handle a click (select).\n *\n * @method handleExpandCollapseClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleExpandCollapseClick = function(item, e) {\n\n // Do not shift the focus.\n this.toggleGroup(item);\n e.stopPropagation();\n return false;\n };\n\n\n /**\n * Handle a click (select).\n *\n * @method handleClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleClick = function(item, e) {\n\n if (e.shiftKey) {\n this.multiSelectItem(item);\n } else if (e.metaKey || e.ctrlKey) {\n this.toggleItem(item);\n } else {\n this.selectItem(item);\n }\n this.updateFocus(item);\n e.stopPropagation();\n return false;\n };\n\n /**\n * Handle a blur event\n *\n * @method handleBlur\n * @return {Boolean}\n */\n Tree.prototype.handleBlur = function() {\n return true;\n };\n\n /**\n * Handle a focus event\n *\n * @method handleFocus\n * @param {Object} item item is the jquery id of the parent item of the group\n * @return {Boolean}\n */\n Tree.prototype.handleFocus = function(item) {\n\n this.updateFocus(item);\n\n return true;\n };\n\n /**\n * Bind the event listeners we require.\n *\n * @method bindEventHandlers\n */\n Tree.prototype.bindEventHandlers = function() {\n var thisObj = this;\n\n // Bind a dblclick handler to the parent items.\n this.parents.dblclick(function(e) {\n return thisObj.handleDblClick($(this), e);\n });\n\n // Bind a click handler.\n this.items.click(function(e) {\n return thisObj.handleClick($(this), e);\n });\n\n // Bind a toggle handler to the expand/collapse icons.\n this.items.children('img').click(function(e) {\n return thisObj.handleExpandCollapseClick($(this).parent(), e);\n });\n\n // Bind a keydown handler.\n this.items.keydown(function(e) {\n return thisObj.handleKeyDown($(this), e);\n });\n\n // Bind a keypress handler.\n this.items.keypress(function(e) {\n return thisObj.handleKeyPress($(this), e);\n });\n\n // Bind a focus handler.\n this.items.focus(function(e) {\n return thisObj.handleFocus($(this), e);\n });\n\n // Bind a blur handler.\n this.items.blur(function(e) {\n return thisObj.handleBlur($(this), e);\n });\n\n };\n\n return /** @alias module:tool_lp/tree */ Tree;\n});\n"],"names":["define","$","url","log","expandedImage","imageUrl","collapsedImage","Tree","selector","multiSelect","treeRoot","items","this","find","expandAll","length","parents","attr","visibleItems","activeItem","lastActiveItem","keys","tab","enter","space","pageup","pagedown","end","home","left","up","right","down","eight","asterisk","init","bindEventHandlers","prototype","prepend","clone","thisObj","each","collapseGroup","expandGroup","first","item","children","show","hide","toggleGroup","triggerChange","allSelected","filter","trigger","selected","multiSelectItem","lastIndex","index","currentIndex","get","selectItem","walk","parent","toggleItem","current","updateFocus","handleKeyDown","e","newItem","hasKeyModifier","shiftKey","ctrlKey","metaKey","altKey","keyCode","focus","stopPropagation","last","has","itemParent","is","prev","eq","next","handleKeyPress","chr","String","fromCharCode","which","match","itemIndex","itemCount","currentItem","titleChr","text","charAt","toLowerCase","on","eventname","handler","warning","handleDblClick","handleExpandCollapseClick","handleClick","handleBlur","handleFocus","dblclick","click","keydown","keypress","blur"],"mappings":";;;;;;;;;;;;AA2BAA,sBAAO,CAAC,SAAU,WAAY,aAAa,SAASC,EAAGC,IAAKC,SAGpDC,cAAgBH,EAAE,oBAAsBC,IAAIG,SAAS,cAAgB,OAErEC,eAAiBL,EAAE,oBAAsBC,IAAIG,SAAS,eAAiB,OAQvEE,KAAO,SAASC,SAAUC,kBACrBC,SAAWT,EAAEO,eACbC,iBAAsC,IAAhBA,cAA+C,IAAhBA,iBAErDE,MAAQC,KAAKF,SAASG,KAAK,WAC3BC,UAAYF,KAAKD,MAAMI,OAAS,QAChCC,QAAUJ,KAAKF,SAASG,KAAK,cAE9BJ,kBACKC,SAASO,KAAK,uBAAwB,aAG1CN,MAAMM,KAAK,gBAAiB,cAE5BC,aAAe,UACfC,WAAa,UACbC,eAAiB,UAEjBC,KAAO,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QAAQ,kFAEP1F,SAASuF,GAAGC,UAAWC,UAYpC5F,KAAK8B,UAAUgE,eAAiB,SAASxD,KAAMsB,YAEvCA,EAAEM,QAAUN,EAAEI,SAAWJ,EAAEG,UAAYH,EAAEK,gBAMxCP,YAAYpB,WAGZI,YAAYJ,MAEjBsB,EAAES,mBACK,IAWXrE,KAAK8B,UAAUiE,0BAA4B,SAASzD,KAAMsB,eAGjDlB,YAAYJ,MACjBsB,EAAES,mBACK,GAYXrE,KAAK8B,UAAUkE,YAAc,SAAS1D,KAAMsB,UAEpCA,EAAEG,cACGf,gBAAgBV,MACdsB,EAAEK,SAAWL,EAAEI,aACjBR,WAAWlB,WAEXe,WAAWf,WAEfoB,YAAYpB,MACjBsB,EAAES,mBACK,GASXrE,KAAK8B,UAAUmE,WAAa,kBACjB,GAUXjG,KAAK8B,UAAUoE,YAAc,SAAS5D,kBAE7BoB,YAAYpB,OAEV,GAQXtC,KAAK8B,UAAUD,kBAAoB,eAC3BI,QAAU5B,UAGTI,QAAQ0F,UAAS,SAASvC,UACpB3B,QAAQ6D,eAAepG,EAAEW,MAAOuD,WAItCxD,MAAMgG,OAAM,SAASxC,UACf3B,QAAQ+D,YAAYtG,EAAEW,MAAOuD,WAInCxD,MAAMmC,SAAS,OAAO6D,OAAM,SAASxC,UAC/B3B,QAAQ8D,0BAA0BrG,EAAEW,MAAMkD,SAAUK,WAI1DxD,MAAMiG,SAAQ,SAASzC,UACjB3B,QAAQ0B,cAAcjE,EAAEW,MAAOuD,WAIrCxD,MAAMkG,UAAS,SAAS1C,UAClB3B,QAAQ4C,eAAenF,EAAEW,MAAOuD,WAItCxD,MAAMgE,OAAM,SAASR,UACf3B,QAAQiE,YAAYxG,EAAEW,MAAOuD,WAInCxD,MAAMmG,MAAK,SAAS3C,UACd3B,QAAQgE,WAAWvG,EAAEW,MAAOuD,OAKF5D"} \ No newline at end of file +{"version":3,"file":"tree.min.js","sources":["../src/tree.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Implement an accessible aria tree widget, from a nested unordered list.\n * Based on http://oaa-accessibility.org/example/41/\n *\n * To respond to selection changed events - use tree.on(\"selectionchanged\", handler).\n * The handler will receive an array of nodes, which are the list items that are currently\n * selected. (Or a single node if multiselect is disabled).\n *\n * @module tool_lp/tree\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/url', 'core/log'], function($, url, log) {\n // Private variables and functions.\n /** @var {String} expandedImage The html for an expanded tree node twistie. */\n var expandedImage = $('\"\"');\n /** @var {String} collapsedImage The html for a collapsed tree node twistie. */\n var collapsedImage = $('\"\"');\n\n /**\n * Constructor\n *\n * @param {String} selector\n * @param {Boolean} multiSelect\n */\n var Tree = function(selector, multiSelect) {\n this.treeRoot = $(selector);\n this.multiSelect = (typeof multiSelect === 'undefined' || multiSelect === true);\n\n this.items = this.treeRoot.find('li');\n this.expandAll = this.items.length < 20;\n this.parents = this.treeRoot.find('li:has(ul)');\n\n if (multiSelect) {\n this.treeRoot.attr('aria-multiselectable', 'true');\n }\n\n this.items.attr('aria-selected', 'false');\n\n this.visibleItems = null;\n this.activeItem = null;\n this.lastActiveItem = null;\n\n this.keys = {\n tab: 9,\n enter: 13,\n space: 32,\n pageup: 33,\n pagedown: 34,\n end: 35,\n home: 36,\n left: 37,\n up: 38,\n right: 39,\n down: 40,\n eight: 56,\n asterisk: 106\n };\n\n this.init();\n\n this.bindEventHandlers();\n };\n // Public variables and functions.\n\n /**\n * Init this tree\n * @method init\n */\n Tree.prototype.init = function() {\n this.parents.attr('aria-expanded', 'true');\n this.parents.prepend(expandedImage.clone());\n\n this.items.attr('role', 'tree-item');\n this.items.attr('tabindex', '-1');\n this.parents.attr('role', 'group');\n this.treeRoot.attr('role', 'tree');\n\n this.visibleItems = this.treeRoot.find('li');\n\n var thisObj = this;\n if (!this.expandAll) {\n this.parents.each(function() {\n thisObj.collapseGroup($(this));\n });\n this.expandGroup(this.parents.first());\n }\n };\n\n /**\n * Expand a collapsed group.\n *\n * @method expandGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.expandGroup = function(item) {\n // Find the first child ul node.\n var group = item.children('ul');\n\n // Expand the group.\n group.show().attr('aria-hidden', 'false');\n\n item.attr('aria-expanded', 'true');\n\n item.children('img').attr('src', expandedImage.attr('src'));\n\n // Update the list of visible items.\n this.visibleItems = this.treeRoot.find('li:visible');\n };\n\n /**\n * Collapse an expanded group.\n *\n * @method collapseGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.collapseGroup = function(item) {\n var group = item.children('ul');\n\n // Collapse the group.\n group.hide().attr('aria-hidden', 'true');\n\n item.attr('aria-expanded', 'false');\n\n item.children('img').attr('src', collapsedImage.attr('src'));\n\n // Update the list of visible items.\n this.visibleItems = this.treeRoot.find('li:visible');\n };\n\n /**\n * Expand or collapse a group.\n *\n * @method toggleGroup\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.toggleGroup = function(item) {\n if (item.attr('aria-expanded') == 'true') {\n this.collapseGroup(item);\n } else {\n this.expandGroup(item);\n }\n };\n\n /**\n * Whenever the currently selected node has changed, trigger an event using this function.\n *\n * @method triggerChange\n */\n Tree.prototype.triggerChange = function() {\n var allSelected = this.items.filter('[aria-selected=true]');\n if (!this.multiSelect) {\n allSelected = allSelected.first();\n }\n this.treeRoot.trigger('selectionchanged', {selected: allSelected});\n };\n\n /**\n * Select all the items between the last focused item and this currently focused item.\n *\n * @method multiSelectItem\n * @param {Object} item is the jquery id of the newly selected item.\n */\n Tree.prototype.multiSelectItem = function(item) {\n if (!this.multiSelect) {\n this.items.attr('aria-selected', 'false');\n } else if (this.lastActiveItem !== null) {\n var lastIndex = this.visibleItems.index(this.lastActiveItem);\n var currentIndex = this.visibleItems.index(this.activeItem);\n var oneItem = null;\n\n while (lastIndex < currentIndex) {\n oneItem = $(this.visibleItems.get(lastIndex));\n oneItem.attr('aria-selected', 'true');\n lastIndex++;\n }\n while (lastIndex > currentIndex) {\n oneItem = $(this.visibleItems.get(lastIndex));\n oneItem.attr('aria-selected', 'true');\n lastIndex--;\n }\n }\n\n item.attr('aria-selected', 'true');\n this.triggerChange();\n };\n\n /**\n * Select a single item. Make sure all the parents are expanded. De-select all other items.\n *\n * @method selectItem\n * @param {Object} item is the jquery id of the newly selected item.\n */\n Tree.prototype.selectItem = function(item) {\n // Expand all nodes up the tree.\n var walk = item.parent();\n while (walk.attr('role') != 'tree') {\n walk = walk.parent();\n if (walk.attr('aria-expanded') == 'false') {\n this.expandGroup(walk);\n }\n walk = walk.parent();\n }\n this.items.attr('aria-selected', 'false');\n item.attr('aria-selected', 'true');\n this.triggerChange();\n };\n\n /**\n * Toggle the selected state for an item back and forth.\n *\n * @method toggleItem\n * @param {Object} item is the jquery id of the item to toggle.\n */\n Tree.prototype.toggleItem = function(item) {\n if (!this.multiSelect) {\n this.selectItem(item);\n return;\n }\n\n var current = item.attr('aria-selected');\n if (current === 'true') {\n current = 'false';\n } else {\n current = 'true';\n }\n item.attr('aria-selected', current);\n this.triggerChange();\n };\n\n /**\n * Set the focus to this item.\n *\n * @method updateFocus\n * @param {Object} item is the jquery id of the parent item of the group\n */\n Tree.prototype.updateFocus = function(item) {\n this.lastActiveItem = this.activeItem;\n this.activeItem = item;\n // Expand all nodes up the tree.\n var walk = item.parent();\n while (walk.attr('role') != 'tree') {\n walk = walk.parent();\n if (walk.attr('aria-expanded') == 'false') {\n this.expandGroup(walk);\n }\n walk = walk.parent();\n }\n this.items.attr('tabindex', '-1');\n item.attr('tabindex', 0);\n };\n\n /**\n * Handle a key down event - ie navigate the tree.\n *\n * @method handleKeyDown\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n // This function should be simplified. In the meantime..\n // eslint-disable-next-line complexity\n Tree.prototype.handleKeyDown = function(item, e) {\n var currentIndex = this.visibleItems.index(item);\n var newItem = null;\n var hasKeyModifier = e.shiftKey || e.ctrlKey || e.metaKey || e.altKey;\n var thisObj = this;\n\n switch (e.keyCode) {\n case this.keys.home: {\n // Jump to first item in tree.\n newItem = this.parents.first();\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.end: {\n // Jump to last visible item.\n newItem = this.visibleItems.last();\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.enter:\n case this.keys.space: {\n\n if (e.shiftKey) {\n this.multiSelectItem(item);\n } else if (e.metaKey || e.ctrlKey) {\n this.toggleItem(item);\n } else {\n this.selectItem(item);\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.left: {\n if (item.has('ul') && item.attr('aria-expanded') == 'true') {\n this.collapseGroup(item);\n } else {\n // Move up to the parent.\n var itemUL = item.parent();\n var itemParent = itemUL.parent();\n if (itemParent.is('li')) {\n itemParent.focus();\n if (e.shiftKey) {\n this.multiSelectItem(itemParent);\n } else if (!hasKeyModifier) {\n this.selectItem(itemParent);\n }\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.right: {\n if (item.has('ul') && item.attr('aria-expanded') == 'false') {\n this.expandGroup(item);\n } else {\n // Move to the first item in the child group.\n newItem = item.children('ul').children('li').first();\n if (newItem.length > 0) {\n newItem.focus();\n if (e.shiftKey) {\n this.multiSelectItem(newItem);\n } else if (!hasKeyModifier) {\n this.selectItem(newItem);\n }\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.up: {\n\n if (currentIndex > 0) {\n var prev = this.visibleItems.eq(currentIndex - 1);\n prev.focus();\n if (e.shiftKey) {\n this.multiSelectItem(prev);\n } else if (!hasKeyModifier) {\n this.selectItem(prev);\n }\n }\n\n e.stopPropagation();\n return false;\n }\n case this.keys.down: {\n\n if (currentIndex < this.visibleItems.length - 1) {\n var next = this.visibleItems.eq(currentIndex + 1);\n next.focus();\n if (e.shiftKey) {\n this.multiSelectItem(next);\n } else if (!hasKeyModifier) {\n this.selectItem(next);\n }\n }\n e.stopPropagation();\n return false;\n }\n case this.keys.asterisk: {\n // Expand all groups.\n this.parents.each(function() {\n thisObj.expandGroup($(this));\n });\n\n e.stopPropagation();\n return false;\n }\n case this.keys.eight: {\n if (e.shiftKey) {\n // Expand all groups.\n this.parents.each(function() {\n thisObj.expandGroup($(this));\n });\n\n e.stopPropagation();\n }\n\n return false;\n }\n }\n\n return true;\n };\n\n /**\n * Handle a key press event - ie navigate the tree.\n *\n * @method handleKeyPress\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleKeyPress = function(item, e) {\n if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {\n // Do nothing.\n return true;\n }\n\n switch (e.keyCode) {\n case this.keys.tab: {\n return true;\n }\n case this.keys.enter:\n case this.keys.home:\n case this.keys.end:\n case this.keys.left:\n case this.keys.right:\n case this.keys.up:\n case this.keys.down: {\n e.stopPropagation();\n return false;\n }\n default : {\n var chr = String.fromCharCode(e.which);\n var match = false;\n var itemIndex = this.visibleItems.index(item);\n var itemCount = this.visibleItems.length;\n var currentIndex = itemIndex + 1;\n\n // Check if the active item was the last one on the list.\n if (currentIndex == itemCount) {\n currentIndex = 0;\n }\n\n // Iterate through the menu items (starting from the current item and wrapping) until a match is found\n // or the loop returns to the current menu item.\n while (currentIndex != itemIndex) {\n\n var currentItem = this.visibleItems.eq(currentIndex);\n var titleChr = currentItem.text().charAt(0);\n\n if (currentItem.has('ul')) {\n titleChr = currentItem.find('span').text().charAt(0);\n }\n\n if (titleChr.toLowerCase() == chr) {\n match = true;\n break;\n }\n\n currentIndex = currentIndex + 1;\n if (currentIndex == itemCount) {\n // Reached the end of the list, start again at the beginning.\n currentIndex = 0;\n }\n }\n\n if (match === true) {\n this.updateFocus(this.visibleItems.eq(currentIndex));\n }\n e.stopPropagation();\n return false;\n }\n }\n\n // eslint-disable-next-line no-unreachable\n return true;\n };\n\n /**\n * Attach an event listener to the tree.\n *\n * @method on\n * @param {String} eventname This is the name of the event to listen for. Only 'selectionchanged' is supported for now.\n * @param {Function} handler The function to call when the event is triggered.\n */\n Tree.prototype.on = function(eventname, handler) {\n if (eventname !== 'selectionchanged') {\n log.warning('Invalid custom event name for tree. Only \"selectionchanged\" is supported.');\n } else {\n this.treeRoot.on(eventname, handler);\n }\n };\n\n /**\n * Handle a double click (expand/collapse).\n *\n * @method handleDblClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleDblClick = function(item, e) {\n\n if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {\n // Do nothing.\n return true;\n }\n\n // Apply the focus markup.\n this.updateFocus(item);\n\n // Expand or collapse the group.\n this.toggleGroup(item);\n\n e.stopPropagation();\n return false;\n };\n\n /**\n * Handle a click (select).\n *\n * @method handleExpandCollapseClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleExpandCollapseClick = function(item, e) {\n\n // Do not shift the focus.\n this.toggleGroup(item);\n e.stopPropagation();\n return false;\n };\n\n\n /**\n * Handle a click (select).\n *\n * @method handleClick\n * @param {Object} item is the jquery id of the parent item of the group\n * @param {Event} e The event.\n * @return {Boolean}\n */\n Tree.prototype.handleClick = function(item, e) {\n\n if (e.shiftKey) {\n this.multiSelectItem(item);\n } else if (e.metaKey || e.ctrlKey) {\n this.toggleItem(item);\n } else {\n this.selectItem(item);\n }\n this.updateFocus(item);\n e.stopPropagation();\n return false;\n };\n\n /**\n * Handle a blur event\n *\n * @method handleBlur\n * @return {Boolean}\n */\n Tree.prototype.handleBlur = function() {\n return true;\n };\n\n /**\n * Handle a focus event\n *\n * @method handleFocus\n * @param {Object} item item is the jquery id of the parent item of the group\n * @return {Boolean}\n */\n Tree.prototype.handleFocus = function(item) {\n\n this.updateFocus(item);\n\n return true;\n };\n\n /**\n * Bind the event listeners we require.\n *\n * @method bindEventHandlers\n */\n Tree.prototype.bindEventHandlers = function() {\n var thisObj = this;\n\n // Bind a dblclick handler to the parent items.\n this.parents.dblclick(function(e) {\n return thisObj.handleDblClick($(this), e);\n });\n\n // Bind a click handler.\n this.items.click(function(e) {\n return thisObj.handleClick($(this), e);\n });\n\n // Bind a toggle handler to the expand/collapse icons.\n this.items.children('img').click(function(e) {\n return thisObj.handleExpandCollapseClick($(this).parent(), e);\n });\n\n // Bind a keydown handler.\n this.items.keydown(function(e) {\n return thisObj.handleKeyDown($(this), e);\n });\n\n // Bind a keypress handler.\n this.items.keypress(function(e) {\n return thisObj.handleKeyPress($(this), e);\n });\n\n // Bind a focus handler.\n this.items.focus(function(e) {\n return thisObj.handleFocus($(this), e);\n });\n\n // Bind a blur handler.\n this.items.blur(function(e) {\n return thisObj.handleBlur($(this), e);\n });\n\n };\n\n return /** @alias module:tool_lp/tree */ Tree;\n});\n"],"names":["define","$","url","log","expandedImage","imageUrl","collapsedImage","Tree","selector","multiSelect","this","treeRoot","items","find","expandAll","length","parents","attr","visibleItems","activeItem","lastActiveItem","keys","tab","enter","space","pageup","pagedown","end","home","left","up","right","down","eight","asterisk","init","bindEventHandlers","prototype","prepend","clone","thisObj","each","collapseGroup","expandGroup","first","item","children","show","hide","toggleGroup","triggerChange","allSelected","filter","trigger","selected","multiSelectItem","lastIndex","index","currentIndex","get","selectItem","walk","parent","toggleItem","current","updateFocus","handleKeyDown","e","newItem","hasKeyModifier","shiftKey","ctrlKey","metaKey","altKey","keyCode","focus","stopPropagation","last","has","itemParent","is","prev","eq","next","handleKeyPress","chr","String","fromCharCode","which","match","itemIndex","itemCount","currentItem","titleChr","text","charAt","toLowerCase","on","eventname","handler","warning","handleDblClick","handleExpandCollapseClick","handleClick","handleBlur","handleFocus","dblclick","click","keydown","keypress","blur"],"mappings":";;;;;;;;;;;;AA2BAA,OAAO,eAAA,CAAC,SAAU,WAAY,aAAa,SAASC,EAAGC,IAAKC,KAGxD,IAAIC,cAAgBH,EAAE,oBAAsBC,IAAIG,SAAS,cAAgB,OAErEC,eAAiBL,EAAE,oBAAsBC,IAAIG,SAAS,eAAiB,OAQvEE,KAAO,SAASC,SAAUC,aAC1BC,KAAKC,SAAWV,EAAEO,UAClBE,KAAKD,iBAAsC,IAAhBA,cAA+C,IAAhBA,YAE1DC,KAAKE,MAAQF,KAAKC,SAASE,KAAK,MAChCH,KAAKI,UAAYJ,KAAKE,MAAMG,OAAS,GACrCL,KAAKM,QAAUN,KAAKC,SAASE,KAAK,cAE9BJ,aACAC,KAAKC,SAASM,KAAK,uBAAwB,QAG/CP,KAAKE,MAAMK,KAAK,gBAAiB,SAEjCP,KAAKQ,aAAe,KACpBR,KAAKS,WAAa,KAClBT,KAAKU,eAAiB,KAEtBV,KAAKW,KAAO,CACRC,IAAU,EACVC,MAAU,GACVC,MAAU,GACVC,OAAU,GACVC,SAAU,GACVC,IAAU,GACVC,KAAU,GACVC,KAAU,GACVC,GAAU,GACVC,MAAU,GACVC,KAAU,GACVC,MAAU,GACVC,SAAU,KAGdxB,KAAKyB,OAELzB,KAAK0B,qBAqjBT,OA7iBA7B,KAAK8B,UAAUF,KAAO,WAClBzB,KAAKM,QAAQC,KAAK,gBAAiB,QACnCP,KAAKM,QAAQsB,QAAQlC,cAAcmC,SAEnC7B,KAAKE,MAAMK,KAAK,OAAQ,aACxBP,KAAKE,MAAMK,KAAK,WAA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AAS,SAASvC,GAC3B,OAAO3B,QAAQ6D,eAAepG,EAAES,MAAOyD,EAC3C,IAGAzD,KAAKE,MAAM+F,OAAM,SAASxC,GACtB,OAAO3B,QAAQ+D,YAAYtG,EAAES,MAAOyD,EACxC,IAGAzD,KAAKE,MAAMkC,SAAS,OAAO6D,OAAM,SAASxC,GACtC,OAAO3B,QAAQ8D,0BAA0BrG,EAAES,MAAMoD,SAAUK,EAC/D,IAGAzD,KAAKE,MAAMgG,SAAQ,SAASzC,GACxB,OAAO3B,QAAQ0B,cAAcjE,EAAES,MAAOyD,EAC1C,IAGAzD,KAAKE,MAAMiG,UAAS,SAAS1C,GACzB,OAAO3B,QAAQ4C,eAAenF,EAAES,MAAOyD,EAC3C,IAGAzD,KAAKE,MAAM+D,OAAM,SAASR,GACtB,OAAO3B,QAAQiE,YAAYxG,EAAES,MAAOyD,EACxC,IAGAzD,KAAKE,MAAMkG,MAAK,SAAS3C,GACrB,OAAO3B,QAAQgE,WAAWvG,EAAES,MAAOyD,EACvC,KAIqC5D,IAC7C"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_course_navigation.min.js.map b/admin/tool/lp/amd/build/user_competency_course_navigation.min.js.map index 180e7138397..1fcb3c1cd9b 100644 --- a/admin/tool/lp/amd/build/user_competency_course_navigation.min.js.map +++ b/admin/tool/lp/amd/build/user_competency_course_navigation.min.js.map @@ -1 +1 @@ -{"version":3,"file":"user_competency_course_navigation.min.js","sources":["../src/user_competency_course_navigation.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to enable inline editing of a comptency grade.\n *\n * @module tool_lp/user_competency_course_navigation\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * UserCompetencyCourseNavigation\n *\n * @class tool_lp/user_competency_course_navigation\n * @param {String} userSelector The selector of the user element.\n * @param {String} competencySelector The selector of the competency element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} userId The user id\n * @param {Number} competencyId The competency id\n * @param {Number} courseId The course id\n */\n var UserCompetencyCourseNavigation = function(userSelector, competencySelector, baseUrl, userId, competencyId, courseId) {\n this._baseUrl = baseUrl;\n this._userId = userId + '';\n this._competencyId = competencyId + '';\n this._courseId = courseId;\n\n $(userSelector).on('change', this._userChanged.bind(this));\n $(competencySelector).on('change', this._competencyChanged.bind(this));\n };\n\n /**\n * The user was changed in the select list.\n *\n * @method _userChanged\n * @param {Event} e\n */\n UserCompetencyCourseNavigation.prototype._userChanged = function(e) {\n var newUserId = $(e.target).val();\n var queryStr = '?userid=' + newUserId + '&courseid=' + this._courseId + '&competencyid=' + this._competencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /**\n * The competency was changed in the select list.\n *\n * @method _competencyChanged\n * @param {Event} e\n */\n UserCompetencyCourseNavigation.prototype._competencyChanged = function(e) {\n var newCompetencyId = $(e.target).val();\n var queryStr = '?userid=' + this._userId + '&courseid=' + this._courseId + '&competencyid=' + newCompetencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the competency. */\n UserCompetencyCourseNavigation.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n UserCompetencyCourseNavigation.prototype._userId = null;\n /** @property {Number} The id of the course. */\n UserCompetencyCourseNavigation.prototype._courseId = null;\n /** @property {String} Plugin base url. */\n UserCompetencyCourseNavigation.prototype._baseUrl = null;\n /** @property {Boolean} Ignore the first change event for competencies. */\n UserCompetencyCourseNavigation.prototype._ignoreFirstCompetency = null;\n\n return UserCompetencyCourseNavigation;\n});\n"],"names":["define","$","UserCompetencyCourseNavigation","userSelector","competencySelector","baseUrl","userId","competencyId","courseId","_baseUrl","_userId","_competencyId","_courseId","on","this","_userChanged","bind","_competencyChanged","prototype","e","queryStr","target","val","document","location","newCompetencyId","_ignoreFirstCompetency"],"mappings":";;;;;;;AAuBAA,mDAAO,CAAC,WAAW,SAASC,OAapBC,+BAAiC,SAASC,aAAcC,mBAAoBC,QAASC,OAAQC,aAAcC,eACtGC,SAAWJ,aACXK,QAAUJ,OAAS,QACnBK,cAAgBJ,aAAe,QAC/BK,UAAYJ,SAEjBP,EAAEE,cAAcU,GAAG,SAAUC,KAAKC,aAAaC,KAAKF,OACpDb,EAAEG,oBAAoBS,GAAG,SAAUC,KAAKG,mBAAmBD,KAAKF,eASpEZ,+BAA+BgB,UAAUH,aAAe,SAASI,OAEzDC,SAAW,WADCnB,EAAEkB,EAAEE,QAAQC,MACY,aAAeR,KAAKF,UAAY,iBAAmBE,KAAKH,cAChGY,SAASC,SAAWV,KAAKL,SAAWW,UASxClB,+BAA+BgB,UAAUD,mBAAqB,SAASE,OAC/DM,gBAAkBxB,EAAEkB,EAAEE,QAAQC,MAC9BF,SAAW,WAAaN,KAAKJ,QAAU,aAAeI,KAAKF,UAAY,iBAAmBa,gBAC9FF,SAASC,SAAWV,KAAKL,SAAWW,UAIxClB,+BAA+BgB,UAAUP,cAAgB,KAEzDT,+BAA+BgB,UAAUR,QAAU,KAEnDR,+BAA+BgB,UAAUN,UAAY,KAErDV,+BAA+BgB,UAAUT,SAAW,KAEpDP,+BAA+BgB,UAAUQ,uBAAyB,KAE3DxB"} \ No newline at end of file +{"version":3,"file":"user_competency_course_navigation.min.js","sources":["../src/user_competency_course_navigation.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to enable inline editing of a comptency grade.\n *\n * @module tool_lp/user_competency_course_navigation\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n\n /**\n * UserCompetencyCourseNavigation\n *\n * @class tool_lp/user_competency_course_navigation\n * @param {String} userSelector The selector of the user element.\n * @param {String} competencySelector The selector of the competency element.\n * @param {String} baseUrl The base url for the page (no params).\n * @param {Number} userId The user id\n * @param {Number} competencyId The competency id\n * @param {Number} courseId The course id\n */\n var UserCompetencyCourseNavigation = function(userSelector, competencySelector, baseUrl, userId, competencyId, courseId) {\n this._baseUrl = baseUrl;\n this._userId = userId + '';\n this._competencyId = competencyId + '';\n this._courseId = courseId;\n\n $(userSelector).on('change', this._userChanged.bind(this));\n $(competencySelector).on('change', this._competencyChanged.bind(this));\n };\n\n /**\n * The user was changed in the select list.\n *\n * @method _userChanged\n * @param {Event} e\n */\n UserCompetencyCourseNavigation.prototype._userChanged = function(e) {\n var newUserId = $(e.target).val();\n var queryStr = '?userid=' + newUserId + '&courseid=' + this._courseId + '&competencyid=' + this._competencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /**\n * The competency was changed in the select list.\n *\n * @method _competencyChanged\n * @param {Event} e\n */\n UserCompetencyCourseNavigation.prototype._competencyChanged = function(e) {\n var newCompetencyId = $(e.target).val();\n var queryStr = '?userid=' + this._userId + '&courseid=' + this._courseId + '&competencyid=' + newCompetencyId;\n document.location = this._baseUrl + queryStr;\n };\n\n /** @property {Number} The id of the competency. */\n UserCompetencyCourseNavigation.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n UserCompetencyCourseNavigation.prototype._userId = null;\n /** @property {Number} The id of the course. */\n UserCompetencyCourseNavigation.prototype._courseId = null;\n /** @property {String} Plugin base url. */\n UserCompetencyCourseNavigation.prototype._baseUrl = null;\n /** @property {Boolean} Ignore the first change event for competencies. */\n UserCompetencyCourseNavigation.prototype._ignoreFirstCompetency = null;\n\n return UserCompetencyCourseNavigation;\n});\n"],"names":["define","$","UserCompetencyCourseNavigation","userSelector","competencySelector","baseUrl","userId","competencyId","courseId","this","_baseUrl","_userId","_competencyId","_courseId","on","_userChanged","bind","_competencyChanged","prototype","e","queryStr","target","val","document","location","newCompetencyId","_ignoreFirstCompetency"],"mappings":";;;;;;;AAuBAA,mDAAO,CAAC,WAAW,SAASC,GAaxB,IAAIC,+BAAiC,SAASC,aAAcC,mBAAoBC,QAASC,OAAQC,aAAcC,UAC3GC,KAAKC,SAAWL,QAChBI,KAAKE,QAAUL,OAAS,GACxBG,KAAKG,cAAgBL,aAAe,GACpCE,KAAKI,UAAYL,SAEjBP,EAAEE,cAAcW,GAAG,SAAUL,KAAKM,aAAaC,KAAKP,OACpDR,EAAEG,oBAAoBU,GAAG,SAAUL,KAAKQ,mBAAmBD,KAAKP,QAsCpE,OA7BAP,+BAA+BgB,UAAUH,aAAe,SAASI,GAC7D,IACIC,SAAW,WADCnB,EAAEkB,EAAEE,QAAQC,MACY,aAAeb,KAAKI,UAAY,iBAAmBJ,KAAKG,cAChGW,SAASC,SAAWf,KAAKC,SAAWU,UASxClB,+BAA+BgB,UAAUD,mBAAqB,SAASE,GACnE,IAAIM,gBAAkBxB,EAAEkB,EAAEE,QAAQC,MAC9BF,SAAW,WAAaX,KAAKE,QAAU,aAAeF,KAAKI,UAAY,iBAAmBY,gBAC9FF,SAASC,SAAWf,KAAKC,SAAWU,UAIxClB,+BAA+BgB,UAAUN,cAAgB,KAEzDV,+BAA+BgB,UAAUP,QAAU,KAEnDT,+BAA+BgB,UAAUL,UAAY,KAErDX,+BAA+BgB,UAAUR,SAAW,KAEpDR,+BAA+BgB,UAAUQ,uBAAyB,KAE3DxB,8BACX"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_info.min.js.map b/admin/tool/lp/amd/build/user_competency_info.min.js.map index 6a86054a7a4..c09041b6c6d 100644 --- a/admin/tool/lp/amd/build/user_competency_info.min.js.map +++ b/admin/tool/lp/amd/build/user_competency_info.min.js.map @@ -1 +1 @@ -{"version":3,"file":"user_competency_info.min.js","sources":["../src/user_competency_info.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to refresh a user competency summary in a page.\n *\n * @module tool_lp/user_competency_info\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function($, notification, ajax, templates) {\n\n /**\n * Info\n *\n * @param {JQuery} rootElement Selector to replace when the information needs updating.\n * @param {Number} competencyId The id of the competency.\n * @param {Number} userId The id of the user.\n * @param {Number} planId The id of the plan.\n * @param {Number} courseId The id of the course.\n * @param {Boolean} displayuser If we should display the user info.\n */\n var Info = function(rootElement, competencyId, userId, planId, courseId, displayuser) {\n this._rootElement = rootElement;\n this._competencyId = competencyId;\n this._userId = userId;\n this._planId = planId;\n this._courseId = courseId;\n this._valid = true;\n this._displayuser = (typeof displayuser !== 'undefined') ? displayuser : false;\n\n if (this._planId) {\n this._methodName = 'tool_lp_data_for_user_competency_summary_in_plan';\n this._args = {competencyid: this._competencyId, planid: this._planId};\n this._templateName = 'tool_lp/user_competency_summary_in_plan';\n } else if (this._courseId) {\n this._methodName = 'tool_lp_data_for_user_competency_summary_in_course';\n this._args = {userid: this._userId, competencyid: this._competencyId, courseid: this._courseId};\n this._templateName = 'tool_lp/user_competency_summary_in_course';\n } else {\n this._methodName = 'tool_lp_data_for_user_competency_summary';\n this._args = {userid: this._userId, competencyid: this._competencyId};\n this._templateName = 'tool_lp/user_competency_summary';\n }\n };\n\n /**\n * Reload the info for this user competency.\n *\n * @method reload\n */\n Info.prototype.reload = function() {\n var self = this,\n promises = [];\n\n if (!this._valid) {\n return;\n }\n\n promises = ajax.call([{\n methodname: this._methodName,\n args: this._args\n }]);\n\n promises[0].done(function(context) {\n // Check if we should also the user info.\n if (self._displayuser) {\n context.displayuser = true;\n }\n templates.render(self._templateName, context).done(function(html, js) {\n templates.replaceNode(self._rootElement, html, js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /** @property {JQuery} The root element to replace in the DOM. */\n Info.prototype._rootElement = null;\n /** @property {Number} The id of the course. */\n Info.prototype._courseId = null;\n /** @property {Boolean} Is this module valid? */\n Info.prototype._valid = null;\n /** @property {Number} The id of the plan. */\n Info.prototype._planId = null;\n /** @property {Number} The id of the competency. */\n Info.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n Info.prototype._userId = null;\n /** @property {String} The method name to load the data. */\n Info.prototype._methodName = null;\n /** @property {Object} The arguments to load the data. */\n Info.prototype._args = null;\n /** @property {String} The template to reload the fragment. */\n Info.prototype._templateName = null;\n /** @property {Boolean} If we should display the user info? */\n Info.prototype._displayuser = false;\n\n return /** @alias module:tool_lp/user_competency_info */ Info;\n\n});\n"],"names":["define","$","notification","ajax","templates","Info","rootElement","competencyId","userId","planId","courseId","displayuser","_rootElement","_competencyId","_userId","_planId","_courseId","_valid","_displayuser","this","_methodName","_args","competencyid","planid","_templateName","userid","courseid","prototype","reload","self","call","methodname","args","done","context","render","html","js","replaceNode","fail","exception"],"mappings":";;;;;;;AAuBAA,sCAAO,CAAC,SAAU,oBAAqB,YAAa,mBAAmB,SAASC,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_info.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to refresh a user competency summary in a page.\n *\n * @module tool_lp/user_competency_info\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function($, notification, ajax, templates) {\n\n /**\n * Info\n *\n * @param {JQuery} rootElement Selector to replace when the information needs updating.\n * @param {Number} competencyId The id of the competency.\n * @param {Number} userId The id of the user.\n * @param {Number} planId The id of the plan.\n * @param {Number} courseId The id of the course.\n * @param {Boolean} displayuser If we should display the user info.\n */\n var Info = function(rootElement, competencyId, userId, planId, courseId, displayuser) {\n this._rootElement = rootElement;\n this._competencyId = competencyId;\n this._userId = userId;\n this._planId = planId;\n this._courseId = courseId;\n this._valid = true;\n this._displayuser = (typeof displayuser !== 'undefined') ? displayuser : false;\n\n if (this._planId) {\n this._methodName = 'tool_lp_data_for_user_competency_summary_in_plan';\n this._args = {competencyid: this._competencyId, planid: this._planId};\n this._templateName = 'tool_lp/user_competency_summary_in_plan';\n } else if (this._courseId) {\n this._methodName = 'tool_lp_data_for_user_competency_summary_in_course';\n this._args = {userid: this._userId, competencyid: this._competencyId, courseid: this._courseId};\n this._templateName = 'tool_lp/user_competency_summary_in_course';\n } else {\n this._methodName = 'tool_lp_data_for_user_competency_summary';\n this._args = {userid: this._userId, competencyid: this._competencyId};\n this._templateName = 'tool_lp/user_competency_summary';\n }\n };\n\n /**\n * Reload the info for this user competency.\n *\n * @method reload\n */\n Info.prototype.reload = function() {\n var self = this,\n promises = [];\n\n if (!this._valid) {\n return;\n }\n\n promises = ajax.call([{\n methodname: this._methodName,\n args: this._args\n }]);\n\n promises[0].done(function(context) {\n // Check if we should also the user info.\n if (self._displayuser) {\n context.displayuser = true;\n }\n templates.render(self._templateName, context).done(function(html, js) {\n templates.replaceNode(self._rootElement, html, js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /** @property {JQuery} The root element to replace in the DOM. */\n Info.prototype._rootElement = null;\n /** @property {Number} The id of the course. */\n Info.prototype._courseId = null;\n /** @property {Boolean} Is this module valid? */\n Info.prototype._valid = null;\n /** @property {Number} The id of the plan. */\n Info.prototype._planId = null;\n /** @property {Number} The id of the competency. */\n Info.prototype._competencyId = null;\n /** @property {Number} The id of the user. */\n Info.prototype._userId = null;\n /** @property {String} The method name to load the data. */\n Info.prototype._methodName = null;\n /** @property {Object} The arguments to load the data. */\n Info.prototype._args = null;\n /** @property {String} The template to reload the fragment. */\n Info.prototype._templateName = null;\n /** @property {Boolean} If we should display the user info? */\n Info.prototype._displayuser = false;\n\n return /** @alias module:tool_lp/user_competency_info */ Info;\n\n});\n"],"names":["define","$","notification","ajax","templates","Info","rootElement","competencyId","userId","planId","courseId","displayuser","this","_rootElement","_competencyId","_userId","_planId","_courseId","_valid","_displayuser","_methodName","_args","competencyid","planid","_templateName","userid","courseid","prototype","reload","self","call","methodname","args","done","context","render","html","js","replaceNode","fail","exception"],"mappings":";;;;;;;AAuBAA,sCAAO,CAAC,SAAU,oBAAqB,YAAa,mBAAmB,SAASC,EAAGC,aAAcC,KAAMC,WAYnG,IAAIC,KAAO,SAASC,YAAaC,aAAcC,OAAQC,OAAQC,SAAUC,aACrEC,KAAKC,aAAeP,YACpBM,KAAKE,cAAgBP,aACrBK,KAAKG,QAAUP,OACfI,KAAKI,QAAUP,OACfG,KAAKK,UAAYP,SACjBE,KAAKM,QAAS,EACdN,KAAKO,kBAAuC,IAAhBR,aAA+BA,YAEvDC,KAAKI,SACLJ,KAAKQ,YAAc,mDACnBR,KAAKS,MAAQ,CAACC,aAAcV,KAAKE,cAAeS,OAAQX,KAAKI,SAC7DJ,KAAKY,cAAgB,2CACdZ,KAAKK,WACZL,KAAKQ,YAAc,qDACnBR,KAAKS,MAAQ,CAACI,OAAQb,KAAKG,QAASO,aAAcV,KAAKE,cAAeY,SAAUd,KAAKK,WACrFL,KAAKY,cAAgB,8CAErBZ,KAAKQ,YAAc,2CACnBR,KAAKS,MAAQ,CAACI,OAAQb,KAAKG,QAASO,aAAcV,KAAKE,eACvDF,KAAKY,cAAgB,oCAsD7B,OA7CAnB,KAAKsB,UAAUC,OAAS,WACpB,IAAIC,KAAOjB,KAGNA,KAAKM,QAICf,KAAK2B,KAAK,CAAC,CAClBC,WAAYnB,KAAKQ,YACjBY,KAAMpB,KAAKS,SAGN,GAAGY,MAAK,SAASC,SAElBL,KAAKV,eACLe,QAAQvB,aAAc,GAE1BP,UAAU+B,OAAON,KAAKL,cAAeU,SAASD,MAAK,SAASG,KAAMC,IAC9DjC,UAAUkC,YAAYT,KAAKhB,aAAcuB,KAAMC,GAClD,IAAEE,KAAKrC,aAAasC,UACxB,IAAED,KAAKrC,aAAasC,YAIzBnC,KAAKsB,UAAUd,aAAe,KAE9BR,KAAKsB,UAAUV,UAAY,KAE3BZ,KAAKsB,UAAUT,OAAS,KAExBb,KAAKsB,UAAUX,QAAU,KAEzBX,KAAKsB,UAAUb,cAAgB,KAE/BT,KAAKsB,UAAUZ,QAAU,KAEzBV,KAAKsB,UAAUP,YAAc,KAE7Bf,KAAKsB,UAAUN,MAAQ,KAEvBhB,KAAKsB,UAAUH,cAAgB,KAE/BnB,KAAKsB,UAAUR,cAAe,EAE2Bd,IAE7D"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_competency_plan_popup.min.js.map b/admin/tool/lp/amd/build/user_competency_plan_popup.min.js.map index 14958c5e65c..e6b2ac15e1b 100644 --- a/admin/tool/lp/amd/build/user_competency_plan_popup.min.js.map +++ b/admin/tool/lp/amd/build/user_competency_plan_popup.min.js.map @@ -1 +1 @@ -{"version":3,"file":"user_competency_plan_popup.min.js","sources":["../src/user_competency_plan_popup.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to open user competency plan in popup\n *\n * @module tool_lp/user_competency_plan_popup\n * @copyright 2016 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates', 'tool_lp/dialogue'],\n function($, notification, str, ajax, templates, Dialogue) {\n\n /**\n * UserCompetencyPopup\n *\n * @param {String} regionSelector The regionSelector\n * @param {String} userCompetencySelector The userCompetencySelector\n * @param {Number} planId The plan ID\n */\n var UserCompetencyPopup = function(regionSelector, userCompetencySelector, planId) {\n this._regionSelector = regionSelector;\n this._userCompetencySelector = userCompetencySelector;\n this._planId = planId;\n\n $(this._regionSelector).on('click', this._userCompetencySelector, this._handleClick.bind(this));\n };\n\n /**\n * Get the data from the closest TR and open the popup.\n *\n * @method _handleClick\n * @param {Event} e\n */\n UserCompetencyPopup.prototype._handleClick = function(e) {\n e.preventDefault();\n var tr = $(e.target).closest('tr');\n var competencyId = $(tr).data('competencyid');\n var userId = $(tr).data('userid');\n var planId = this._planId;\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_user_competency_summary_in_plan',\n args: {competencyid: competencyId, planid: planId},\n done: this._contextLoaded.bind(this),\n fail: notification.exception\n }]);\n // Log the user competency viewed in plan event.\n requests[0].then(function(result) {\n var eventMethodName = 'core_competency_user_competency_viewed_in_plan';\n // Trigger core_competency_user_competency_plan_viewed event instead if plan is already completed.\n if (result.plan.iscompleted) {\n eventMethodName = 'core_competency_user_competency_plan_viewed';\n }\n return ajax.call([{\n methodname: eventMethodName,\n args: {competencyid: competencyId, userid: userId, planid: planId}\n }])[0];\n }).catch(notification.exception);\n };\n\n /**\n * We loaded the context, now render the template.\n *\n * @method _contextLoaded\n * @param {Object} context\n */\n UserCompetencyPopup.prototype._contextLoaded = function(context) {\n var self = this;\n templates.render('tool_lp/user_competency_summary_in_plan', context).done(function(html, js) {\n str.get_string('usercompetencysummary', 'report_competency').done(function(title) {\n (new Dialogue(title, html, templates.runTemplateJS.bind(templates, js), self._refresh.bind(self), true));\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Refresh the page.\n *\n * @method _refresh\n */\n UserCompetencyPopup.prototype._refresh = function() {\n var planId = this._planId;\n\n ajax.call([{\n methodname: 'tool_lp_data_for_plan_page',\n args: {planid: planId},\n done: this._pageContextLoaded.bind(this),\n fail: notification.exception\n }]);\n };\n\n /**\n * We loaded the context, now render the template.\n *\n * @method _pageContextLoaded\n * @param {Object} context\n */\n UserCompetencyPopup.prototype._pageContextLoaded = function(context) {\n var self = this;\n templates.render('tool_lp/plan_page', context).done(function(html, js) {\n templates.replaceNode(self._regionSelector, html, js);\n }).fail(notification.exception);\n };\n\n /** @property {String} The selector for the region with the user competencies */\n UserCompetencyPopup.prototype._regionSelector = null;\n /** @property {String} The selector for the region with a single user competencies */\n UserCompetencyPopup.prototype._userCompetencySelector = null;\n /** @property {Number} The plan Id */\n UserCompetencyPopup.prototype._planId = null;\n\n return /** @alias module:tool_lp/user_competency_plan_popup */ UserCompetencyPopup;\n\n});\n"],"names":["define","$","notification","str","ajax","templates","Dialogue","UserCompetencyPopup","regionSelector","userCompetencySelector","planId","_regionSelector","_userCompetencySelector","_planId","this","on","_handleClick","bind","prototype","e","preventDefault","tr","target","closest","competencyId","data","userId","call","methodname","args","competencyid","planid","done","_contextLoaded","fail","exception","then","result","eventMethodName","plan","iscompleted","userid","catch","context","self","render","html","js","get_string","title","runTemplateJS","_refresh","_pageContextLoaded","replaceNode"],"mappings":";;;;;;;AAuBAA,4CAAO,CAAC,SAAU,oBAAqB,WAAY,YAAa,iBAAkB,qBAC3E,SAASC,EAAGC,aAAcC,IAAKC,KAAMC,UAAWC,cAS/CC,oBAAsB,SAASC,eAAgBC,uBAAwBC,aAClEC,gBAAkBH,oBAClBI,wBAA0BH,4BAC1BI,QAAUH,OAEfT,EAAEa,KAAKH,iBAAiBI,GAAG,QAASD,KAAKF,wBAAyBE,KAAKE,aAAaC,KAAKH,eAS7FP,oBAAoBW,UAAUF,aAAe,SAASG,GAClDA,EAAEC,qBACEC,GAAKpB,EAAEkB,EAAEG,QAAQC,QAAQ,MACzBC,aAAevB,EAAEoB,IAAII,KAAK,gBAC1BC,OAASzB,EAAEoB,IAAII,KAAK,UACpBf,OAASI,KAAKD,QAEHT,KAAKuB,KAAK,CAAC,CACtBC,WAAY,mDACZC,KAAM,CAACC,aAAcN,aAAcO,OAAQrB,QAC3CsB,KAAMlB,KAAKmB,eAAehB,KAAKH,MAC/BoB,KAAMhC,aAAaiC,aAGd,GAAGC,MAAK,SAASC,YAClBC,gBAAkB,wDAElBD,OAAOE,KAAKC,cACZF,gBAAkB,+CAEflC,KAAKuB,KAAK,CAAC,CACdC,WAAYU,gBACZT,KAAM,CAACC,aAAcN,aAAciB,OAAQf,OAAQK,OAAQrB,WAC3D,MACLgC,MAAMxC,aAAaiC,YAS1B5B,oBAAoBW,UAAUe,eAAiB,SAASU,aAChDC,KAAO9B,KACXT,UAAUwC,OAAO,0CAA2CF,SAASX,MAAK,SAASc,KAAMC,IACrF5C,IAAI6C,WAAW,wBAAyB,qBAAqBhB,MAAK,SAASiB,WAClE3C,SAAS2C,MAAOH,KAAMzC,UAAU6C,cAAcjC,KAAKZ,UAAW0C,IAAKH,KAAKO,SAASlC,KAAK2B,OAAO,MACnGV,KAAKhC,aAAaiC,cACtBD,KAAKhC,aAAaiC,YAQzB5B,oBAAoBW,UAAUiC,SAAW,eACjCzC,OAASI,KAAKD,QAElBT,KAAKuB,KAAK,CAAC,CACPC,WAAY,6BACZC,KAAM,CAACE,OAAQrB,QACfsB,KAAMlB,KAAKsC,mBAAmBnC,KAAKH,MACnCoB,KAAMhC,aAAaiC,cAU3B5B,oBAAoBW,UAAUkC,mBAAqB,SAAST,aACpDC,KAAO9B,KACXT,UAAUwC,OAAO,oBAAqBF,SAASX,MAAK,SAASc,KAAMC,IAC/D1C,UAAUgD,YAAYT,KAAKjC,gBAAiBmC,KAAMC,OACnDb,KAAKhC,aAAaiC,YAIzB5B,oBAAoBW,UAAUP,gBAAkB,KAEhDJ,oBAAoBW,UAAUN,wBAA0B,KAExDL,oBAAoBW,UAAUL,QAAU,KAEuBN"} \ No newline at end of file +{"version":3,"file":"user_competency_plan_popup.min.js","sources":["../src/user_competency_plan_popup.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to open user competency plan in popup\n *\n * @module tool_lp/user_competency_plan_popup\n * @copyright 2016 Issam Taboubi \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates', 'tool_lp/dialogue'],\n function($, notification, str, ajax, templates, Dialogue) {\n\n /**\n * UserCompetencyPopup\n *\n * @param {String} regionSelector The regionSelector\n * @param {String} userCompetencySelector The userCompetencySelector\n * @param {Number} planId The plan ID\n */\n var UserCompetencyPopup = function(regionSelector, userCompetencySelector, planId) {\n this._regionSelector = regionSelector;\n this._userCompetencySelector = userCompetencySelector;\n this._planId = planId;\n\n $(this._regionSelector).on('click', this._userCompetencySelector, this._handleClick.bind(this));\n };\n\n /**\n * Get the data from the closest TR and open the popup.\n *\n * @method _handleClick\n * @param {Event} e\n */\n UserCompetencyPopup.prototype._handleClick = function(e) {\n e.preventDefault();\n var tr = $(e.target).closest('tr');\n var competencyId = $(tr).data('competencyid');\n var userId = $(tr).data('userid');\n var planId = this._planId;\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_user_competency_summary_in_plan',\n args: {competencyid: competencyId, planid: planId},\n done: this._contextLoaded.bind(this),\n fail: notification.exception\n }]);\n // Log the user competency viewed in plan event.\n requests[0].then(function(result) {\n var eventMethodName = 'core_competency_user_competency_viewed_in_plan';\n // Trigger core_competency_user_competency_plan_viewed event instead if plan is already completed.\n if (result.plan.iscompleted) {\n eventMethodName = 'core_competency_user_competency_plan_viewed';\n }\n return ajax.call([{\n methodname: eventMethodName,\n args: {competencyid: competencyId, userid: userId, planid: planId}\n }])[0];\n }).catch(notification.exception);\n };\n\n /**\n * We loaded the context, now render the template.\n *\n * @method _contextLoaded\n * @param {Object} context\n */\n UserCompetencyPopup.prototype._contextLoaded = function(context) {\n var self = this;\n templates.render('tool_lp/user_competency_summary_in_plan', context).done(function(html, js) {\n str.get_string('usercompetencysummary', 'report_competency').done(function(title) {\n (new Dialogue(title, html, templates.runTemplateJS.bind(templates, js), self._refresh.bind(self), true));\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Refresh the page.\n *\n * @method _refresh\n */\n UserCompetencyPopup.prototype._refresh = function() {\n var planId = this._planId;\n\n ajax.call([{\n methodname: 'tool_lp_data_for_plan_page',\n args: {planid: planId},\n done: this._pageContextLoaded.bind(this),\n fail: notification.exception\n }]);\n };\n\n /**\n * We loaded the context, now render the template.\n *\n * @method _pageContextLoaded\n * @param {Object} context\n */\n UserCompetencyPopup.prototype._pageContextLoaded = function(context) {\n var self = this;\n templates.render('tool_lp/plan_page', context).done(function(html, js) {\n templates.replaceNode(self._regionSelector, html, js);\n }).fail(notification.exception);\n };\n\n /** @property {String} The selector for the region with the user competencies */\n UserCompetencyPopup.prototype._regionSelector = null;\n /** @property {String} The selector for the region with a single user competencies */\n UserCompetencyPopup.prototype._userCompetencySelector = null;\n /** @property {Number} The plan Id */\n UserCompetencyPopup.prototype._planId = null;\n\n return /** @alias module:tool_lp/user_competency_plan_popup */ UserCompetencyPopup;\n\n});\n"],"names":["define","$","notification","str","ajax","templates","Dialogue","UserCompetencyPopup","regionSelector","userCompetencySelector","planId","this","_regionSelector","_userCompetencySelector","_planId","on","_handleClick","bind","prototype","e","preventDefault","tr","target","closest","competencyId","data","userId","call","methodname","args","competencyid","planid","done","_contextLoaded","fail","exception","then","result","eventMethodName","plan","iscompleted","userid","catch","context","self","render","html","js","get_string","title","runTemplateJS","_refresh","_pageContextLoaded","replaceNode"],"mappings":";;;;;;;AAuBAA,OAAM,qCAAC,CAAC,SAAU,oBAAqB,WAAY,YAAa,iBAAkB,qBAC3E,SAASC,EAAGC,aAAcC,IAAKC,KAAMC,UAAWC,UASnD,IAAIC,oBAAsB,SAASC,eAAgBC,uBAAwBC,QACvEC,KAAKC,gBAAkBJ,eACvBG,KAAKE,wBAA0BJ,uBAC/BE,KAAKG,QAAUJ,OAEfT,EAAEU,KAAKC,iBAAiBG,GAAG,QAASJ,KAAKE,wBAAyBF,KAAKK,aAAaC,KAAKN,QAuF7F,OA9EAJ,oBAAoBW,UAAUF,aAAe,SAASG,GAClDA,EAAEC,iBACF,IAAIC,GAAKpB,EAAEkB,EAAEG,QAAQC,QAAQ,MACzBC,aAAevB,EAAEoB,IAAII,KAAK,gBAC1BC,OAASzB,EAAEoB,IAAII,KAAK,UACpBf,OAASC,KAAKG,QAEHV,KAAKuB,KAAK,CAAC,CACtBC,WAAY,mDACZC,KAAM,C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/tool/lp/amd/build/user_competency_workflow.min.js.map index 6828088a678..b5e6fd2665d 100644 --- a/admin/tool/lp/amd/build/user_competency_workflow.min.js.map +++ b/admin/tool/lp/amd/build/user_competency_workflow.min.js.map @@ -1 +1 @@ -{"version":3,"file":"user_competency_workflow.min.js","sources":["../src/user_competency_workflow.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * User competency workflow.\n *\n * @module tool_lp/user_competency_workflow\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/event_base'],\n function($, Templates, Ajax, Notification, Str, Menubar, EventBase) {\n\n /**\n * UserCompetencyWorkflow class.\n */\n var UserCompetencyWorkflow = function() {\n EventBase.prototype.constructor.apply(this, []);\n };\n UserCompetencyWorkflow.prototype = Object.create(EventBase.prototype);\n\n /** @property {String} The selector to find the user competency data. */\n UserCompetencyWorkflow.prototype._nodeSelector = '[data-node=\"user-competency\"]';\n\n /**\n * Cancel a review request and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _cancelReviewRequest\n */\n UserCompetencyWorkflow.prototype._cancelReviewRequest = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_cancel_review_request',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-request-cancelled', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Cancel a review request an refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method cancelReviewRequest\n */\n UserCompetencyWorkflow.prototype.cancelReviewRequest = function(data) {\n this._cancelReviewRequest(data);\n };\n\n /**\n * Cancel a review request handler.\n *\n * @param {Event} e The event.\n * @method _cancelReviewRequestHandler\n */\n UserCompetencyWorkflow.prototype._cancelReviewRequestHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.cancelReviewRequest(data);\n };\n\n /**\n * Request a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _requestReview\n */\n UserCompetencyWorkflow.prototype._requestReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_request_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-requested', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Request a review.\n *\n * @param {Object} data The user competency data.\n * @method requestReview\n */\n UserCompetencyWorkflow.prototype.requestReview = function(data) {\n this._requestReview(data);\n };\n\n /**\n * Request a review handler.\n *\n * @param {Event} e The event.\n * @method _requestReviewHandler\n */\n UserCompetencyWorkflow.prototype._requestReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.requestReview(data);\n };\n\n /**\n * Start a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _startReview\n */\n UserCompetencyWorkflow.prototype._startReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_start_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n Ajax.call([call])[0].then(function() {\n this._trigger('review-started', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Start a review.\n *\n * @param {Object} data The user competency data.\n * @method startReview\n */\n UserCompetencyWorkflow.prototype.startReview = function(data) {\n this._startReview(data);\n };\n\n /**\n * Start a review handler.\n *\n * @param {Event} e The event.\n * @method _startReviewHandler\n */\n UserCompetencyWorkflow.prototype._startReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.startReview(data);\n };\n\n /**\n * Stop a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _stopReview\n */\n UserCompetencyWorkflow.prototype._stopReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_stop_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-stopped', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Stop a review.\n *\n * @param {Object} data The user competency data.\n * @method stopReview\n */\n UserCompetencyWorkflow.prototype.stopReview = function(data) {\n this._stopReview(data);\n };\n\n /**\n * Stop a review handler.\n *\n * @param {Event} e The event.\n * @method _stopReviewHandler\n */\n UserCompetencyWorkflow.prototype._stopReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.stopReview(data);\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserCompetencyWorkflow.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"request-review\"]': this._requestReviewHandler.bind(this),\n '[data-action=\"cancel-review-request\"]': this._cancelReviewRequestHandler.bind(this),\n });\n };\n\n /**\n * Find the user competency data from a node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} User competency data.\n */\n UserCompetencyWorkflow.prototype._findUserCompetencyData = function(node) {\n var parent = node.parents(this._nodeSelector),\n data;\n\n if (parent.length != 1) {\n throw new Error('The evidence node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.userid === 'undefined' || typeof data.competencyid === 'undefined') {\n throw new Error('User competency data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserCompetencyWorkflow.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"request-review\"]': this._requestReviewHandler.bind(this),\n '[data-action=\"cancel-review-request\"]': this._cancelReviewRequestHandler.bind(this),\n '[data-action=\"start-review\"]': this._startReviewHandler.bind(this),\n '[data-action=\"stop-review\"]': this._stopReviewHandler.bind(this),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * @param {String} selector The base selector to search nodes in and attach events.\n */\n UserCompetencyWorkflow.prototype.registerEvents = function(selector) {\n var wrapper = $(selector);\n\n wrapper.find('[data-action=\"request-review\"]').click(this._requestReviewHandler.bind(this));\n wrapper.find('[data-action=\"cancel-review-request\"]').click(this._cancelReviewRequestHandler.bind(this));\n wrapper.find('[data-action=\"start-review\"]').click(this._startReviewHandler.bind(this));\n wrapper.find('[data-action=\"stop-review\"]').click(this._stopReviewHandler.bind(this));\n };\n\n return /** @alias module:tool_lp/user_competency_actions */ UserCompetencyWorkflow;\n});\n"],"names":["define","$","Templates","Ajax","Notification","Str","Menubar","EventBase","UserCompetencyWorkflow","prototype","constructor","apply","this","Object","create","_nodeSelector","_cancelReviewRequest","data","call","methodname","args","userid","competencyid","then","_trigger","bind","catch","cancelReviewRequest","_cancelReviewRequestHandler","e","preventDefault","_findUserCompetencyData","target","_requestReview","requestReview","_requestReviewHandler","_startReview","startReview","_startReviewHandler","_stopReview","stopReview","_stopReviewHandler","enhanceMenubar","selector","enhance","node","parent","parents","length","Error","registerEvents","wrapper","find","click"],"mappings":";;;;;;;AAsBAA,0CAAO,CAAC,SACA,iBACA,YACA,oBACA,WACA,kBACA,uBACA,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,QAASC,eAKzDC,uBAAyB,WACzBD,UAAUE,UAAUC,YAAYC,MAAMC,KAAM,YAEhDJ,uBAAuBC,UAAYI,OAAOC,OAAOP,UAAUE,YAG1BM,cA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iB,SAASP,cACnDQ,QAAUlD,EAAE0C,UAEhBQ,QAAQC,KAAK,kCAAkCC,MAAMzC,KAAKuB,sBAAsBV,KAAKb,OACrFuC,QAAQC,KAAK,yCAAyCC,MAAMzC,KAAKgB,4BAA4BH,KAAKb,OAClGuC,QAAQC,KAAK,gCAAgCC,MAAMzC,KAAK0B,oBAAoBb,KAAKb,OACjFuC,QAAQC,KAAK,+BAA+BC,MAAMzC,KAAK6B,mBAAmBhB,KAAKb,QAGvBJ"} \ No newline at end of file +{"version":3,"file":"user_competency_workflow.min.js","sources":["../src/user_competency_workflow.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * User competency workflow.\n *\n * @module tool_lp/user_competency_workflow\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/event_base'],\n function($, Templates, Ajax, Notification, Str, Menubar, EventBase) {\n\n /**\n * UserCompetencyWorkflow class.\n */\n var UserCompetencyWorkflow = function() {\n EventBase.prototype.constructor.apply(this, []);\n };\n UserCompetencyWorkflow.prototype = Object.create(EventBase.prototype);\n\n /** @property {String} The selector to find the user competency data. */\n UserCompetencyWorkflow.prototype._nodeSelector = '[data-node=\"user-competency\"]';\n\n /**\n * Cancel a review request and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _cancelReviewRequest\n */\n UserCompetencyWorkflow.prototype._cancelReviewRequest = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_cancel_review_request',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-request-cancelled', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Cancel a review request an refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method cancelReviewRequest\n */\n UserCompetencyWorkflow.prototype.cancelReviewRequest = function(data) {\n this._cancelReviewRequest(data);\n };\n\n /**\n * Cancel a review request handler.\n *\n * @param {Event} e The event.\n * @method _cancelReviewRequestHandler\n */\n UserCompetencyWorkflow.prototype._cancelReviewRequestHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.cancelReviewRequest(data);\n };\n\n /**\n * Request a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _requestReview\n */\n UserCompetencyWorkflow.prototype._requestReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_request_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-requested', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Request a review.\n *\n * @param {Object} data The user competency data.\n * @method requestReview\n */\n UserCompetencyWorkflow.prototype.requestReview = function(data) {\n this._requestReview(data);\n };\n\n /**\n * Request a review handler.\n *\n * @param {Event} e The event.\n * @method _requestReviewHandler\n */\n UserCompetencyWorkflow.prototype._requestReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.requestReview(data);\n };\n\n /**\n * Start a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _startReview\n */\n UserCompetencyWorkflow.prototype._startReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_start_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n Ajax.call([call])[0].then(function() {\n this._trigger('review-started', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Start a review.\n *\n * @param {Object} data The user competency data.\n * @method startReview\n */\n UserCompetencyWorkflow.prototype.startReview = function(data) {\n this._startReview(data);\n };\n\n /**\n * Start a review handler.\n *\n * @param {Event} e The event.\n * @method _startReviewHandler\n */\n UserCompetencyWorkflow.prototype._startReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.startReview(data);\n };\n\n /**\n * Stop a review and refresh the view.\n *\n * @param {Object} data The user competency data.\n * @method _stopReview\n */\n UserCompetencyWorkflow.prototype._stopReview = function(data) {\n var call = {\n methodname: 'core_competency_user_competency_stop_review',\n args: {\n userid: data.userid,\n competencyid: data.competencyid\n }\n };\n\n Ajax.call([call])[0].then(function() {\n this._trigger('review-stopped', data);\n this._trigger('status-changed', data);\n }.bind(this)).catch(function() {\n this._trigger('error-occured', data);\n }.bind(this));\n };\n\n /**\n * Stop a review.\n *\n * @param {Object} data The user competency data.\n * @method stopReview\n */\n UserCompetencyWorkflow.prototype.stopReview = function(data) {\n this._stopReview(data);\n };\n\n /**\n * Stop a review handler.\n *\n * @param {Event} e The event.\n * @method _stopReviewHandler\n */\n UserCompetencyWorkflow.prototype._stopReviewHandler = function(e) {\n e.preventDefault();\n var data = this._findUserCompetencyData($(e.target));\n this.stopReview(data);\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserCompetencyWorkflow.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"request-review\"]': this._requestReviewHandler.bind(this),\n '[data-action=\"cancel-review-request\"]': this._cancelReviewRequestHandler.bind(this),\n });\n };\n\n /**\n * Find the user competency data from a node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} User competency data.\n */\n UserCompetencyWorkflow.prototype._findUserCompetencyData = function(node) {\n var parent = node.parents(this._nodeSelector),\n data;\n\n if (parent.length != 1) {\n throw new Error('The evidence node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.userid === 'undefined' || typeof data.competencyid === 'undefined') {\n throw new Error('User competency data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserCompetencyWorkflow.prototype.enhanceMenubar = function(selector) {\n Menubar.enhance(selector, {\n '[data-action=\"request-review\"]': this._requestReviewHandler.bind(this),\n '[data-action=\"cancel-review-request\"]': this._cancelReviewRequestHandler.bind(this),\n '[data-action=\"start-review\"]': this._startReviewHandler.bind(this),\n '[data-action=\"stop-review\"]': this._stopReviewHandler.bind(this),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * @param {String} selector The base selector to search nodes in and attach events.\n */\n UserCompetencyWorkflow.prototype.registerEvents = function(selector) {\n var wrapper = $(selector);\n\n wrapper.find('[data-action=\"request-review\"]').click(this._requestReviewHandler.bind(this));\n wrapper.find('[data-action=\"cancel-review-request\"]').click(this._cancelReviewRequestHandler.bind(this));\n wrapper.find('[data-action=\"start-review\"]').click(this._startReviewHandler.bind(this));\n wrapper.find('[data-action=\"stop-review\"]').click(this._stopReviewHandler.bind(this));\n };\n\n return /** @alias module:tool_lp/user_competency_actions */ UserCompetencyWorkflow;\n});\n"],"names":["define","$","Templates","Ajax","Notification","Str","Menubar","EventBase","UserCompetencyWorkflow","prototype","constructor","apply","this","Object","create","_nodeSelector","_cancelReviewRequest","data","call","methodname","args","userid","competencyid","then","_trigger","bind","catch","cancelReviewRequest","_cancelReviewRequestHandler","e","preventDefault","_findUserCompetencyData","target","_requestReview","requestReview","_requestReviewHandler","_startReview","startReview","_startReviewHandler","_stopReview","stopReview","_stopReviewHandler","enhanceMenubar","selector","enhance","node","parent","parents","length","Error","registerEvents","wrapper","find","click"],"mappings":";;;;;;;AAsBAA,OAAO,mCAAA,CAAC,SACA,iBACA,YACA,oBACA,WACA,kB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0B,SAASc,MAChE,IACI5B,KADA6B,OAASD,KAAKE,QAAQnC,KAAKG,eAG/B,GAAqB,GAAjB+B,OAAOE,OACP,MAAM,IAAIC,MAAM,sCAIpB,QAAoB,KADpBhC,KAAO6B,OAAO7B,cAC4C,IAAhBA,KAAKI,aAAuD,IAAtBJ,KAAKK,aACjF,MAAM,IAAI2B,MAAM,4CAGpB,OAAOhC,MAQXT,uBAAuBC,UAAUiC,eAAiB,SAASC,UACvDrC,QAAQsC,QAAQD,SAAU,CACtB,iCAAkC/B,KAAKuB,sBAAsBV,KAAKb,MAClE,wCAAyCA,KAAKgB,4BAA4BH,KAAKb,MAC/E,+BAAgCA,KAAK0B,oBAAoBb,KAAKb,MAC9D,8BAA+BA,KAAK6B,mBAAmBhB,KAAKb,SASpEJ,uBAAuBC,UAAUyC,eAAiB,SAASP,UACvD,IAAIQ,QAAUlD,EAAE0C,UAEhBQ,QAAQC,KAAK,kCAAkCC,MAAMzC,KAAKuB,sBAAsBV,KAAKb,OACrFuC,QAAQC,KAAK,yCAAyCC,MAAMzC,KAAKgB,4BAA4BH,KAAKb,OAClGuC,QAAQC,KAAK,gCAAgCC,MAAMzC,KAAK0B,oBAAoBb,KAAKb,OACjFuC,QAAQC,KAAK,+BAA+BC,MAAMzC,KAAK6B,mBAAmBhB,KAAKb,QAGvBJ,sBAChE"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/user_evidence_actions.min.js.map b/admin/tool/lp/amd/build/user_evidence_actions.min.js.map index 719e3f31120..a7704095990 100644 --- a/admin/tool/lp/amd/build/user_evidence_actions.min.js.map +++ b/admin/tool/lp/amd/build/user_evidence_actions.min.js.map @@ -1 +1 @@ -{"version":3,"file":"user_evidence_actions.min.js","sources":["../src/user_evidence_actions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * User evidence actions.\n *\n * @module tool_lp/user_evidence_actions\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/competencypicker_user_plans'],\n function($, templates, ajax, notification, str, Menubar, PickerUserPlans) {\n\n /**\n * UserEvidenceActions class.\n *\n * Note that presently this cannot be instantiated more than once per page.\n *\n * @param {String} type The type of page we're in.\n */\n var UserEvidenceActions = function(type) {\n this._type = type;\n\n if (type === 'evidence') {\n // This is the page to view one evidence.\n this._region = '[data-region=\"user-evidence-page\"]';\n this._evidenceNode = '[data-region=\"user-evidence-page\"]';\n this._template = 'tool_lp/user_evidence_page';\n this._contextMethod = 'tool_lp_data_for_user_evidence_page';\n\n } else if (type === 'list') {\n // This is the page to view a list of evidence.\n this._region = '[data-region=\"user-evidence-list\"]';\n this._evidenceNode = '[data-region=\"user-evidence-node\"]';\n this._template = 'tool_lp/user_evidence_list_page';\n this._contextMethod = 'tool_lp_data_for_user_evidence_list_page';\n\n } else {\n throw new TypeError('Unexpected type.');\n }\n };\n\n /** @property {String} Ajax method to fetch the page data from. */\n UserEvidenceActions.prototype._contextMethod = null;\n /** @property {String} Selector to find the node describing the evidence. */\n UserEvidenceActions.prototype._evidenceNode = null;\n /** @property {String} Selector mapping to the region to update. Usually similar to wrapper. */\n UserEvidenceActions.prototype._region = null;\n /** @property {String} Name of the template used to render the region. */\n UserEvidenceActions.prototype._template = null;\n /** @property {String} Type of page/region we're in. */\n UserEvidenceActions.prototype._type = null;\n\n /**\n * Resolve the arguments to refresh the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @return {Object} List of arguments.\n */\n UserEvidenceActions.prototype._getContextArgs = function(evidenceData) {\n var self = this,\n args = {};\n\n if (self._type === 'evidence') {\n args = {\n id: evidenceData.id\n };\n\n } else if (self._type === 'list') {\n args = {\n userid: evidenceData.userid\n };\n }\n\n return args;\n };\n\n /**\n * Callback to render the region template.\n *\n * @param {Object} context The context for the template.\n * @return {Promise}\n */\n UserEvidenceActions.prototype._renderView = function(context) {\n var self = this;\n return templates.render(self._template, context)\n .then(function(newhtml, newjs) {\n templates.replaceNode($(self._region), newhtml, newjs);\n return;\n });\n };\n\n /**\n * Call multiple ajax methods, and refresh.\n *\n * @param {Array} calls List of Ajax calls.\n * @param {Object} evidenceData Evidence data from evidence node.\n * @return {Promise}\n */\n UserEvidenceActions.prototype._callAndRefresh = function(calls, evidenceData) {\n var self = this;\n calls.push({\n methodname: self._contextMethod,\n args: self._getContextArgs(evidenceData)\n });\n\n // Apply all the promises, and refresh when the last one is resolved.\n return $.when.apply($.when, ajax.call(calls))\n .then(function() {\n return self._renderView(arguments[arguments.length - 1]);\n })\n .fail(notification.exception);\n };\n\n /**\n * Delete a plan and reload the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype._doDelete = function(evidenceData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_delete_user_evidence',\n args: {id: evidenceData.id}\n }];\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Delete a plan.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.deleteEvidence = function(evidenceData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_user_evidence',\n args: {id: evidenceData.id}\n }]);\n\n requests[0].done(function(evidence) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deleteuserevidence', component: 'tool_lp', param: evidence.name},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete evidence X?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n self._doDelete(evidenceData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Delete evidence handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._deleteEvidenceHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.deleteEvidence(data);\n };\n\n /**\n * Link a competency and reload.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyIds The competency IDs.\n */\n UserEvidenceActions.prototype._doCreateUserEvidenceCompetency = function(evidenceData, competencyIds) {\n var self = this,\n calls = [];\n\n $.each(competencyIds, function(index, competencyId) {\n calls.push({\n methodname: 'core_competency_create_user_evidence_competency',\n args: {\n userevidenceid: evidenceData.id,\n competencyid: competencyId,\n }\n });\n });\n\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Create a user evidence competency.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.createUserEvidenceCompetency = function(evidenceData) {\n var self = this,\n picker = new PickerUserPlans(evidenceData.userid);\n\n picker.on('save', function(e, data) {\n var competencyIds = data.competencyIds;\n self._doCreateUserEvidenceCompetency(evidenceData, competencyIds, data.requestReview);\n });\n\n picker.display();\n };\n\n /**\n * Create user evidence competency handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._createUserEvidenceCompetencyHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.createUserEvidenceCompetency(data);\n };\n\n /**\n * Remove a linked competency and reload.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyId The competency ID.\n */\n UserEvidenceActions.prototype._doDeleteUserEvidenceCompetency = function(evidenceData, competencyId) {\n var self = this,\n calls = [];\n\n calls.push({\n methodname: 'core_competency_delete_user_evidence_competency',\n args: {\n userevidenceid: evidenceData.id,\n competencyid: competencyId,\n }\n });\n\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Delete a user evidence competency.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyId The competency ID.\n */\n UserEvidenceActions.prototype.deleteUserEvidenceCompetency = function(evidenceData, competencyId) {\n this._doDeleteUserEvidenceCompetency(evidenceData, competencyId);\n };\n\n /**\n * Delete user evidence competency handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._deleteUserEvidenceCompetencyHandler = function(e) {\n var data = this._findEvidenceData($(e.currentTarget)),\n competencyId = $(e.currentTarget).data('id');\n e.preventDefault();\n this.deleteUserEvidenceCompetency(data, competencyId);\n };\n\n /**\n * Send request review for user evidence competencies and reload the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype._doReviewUserEvidenceCompetencies = function(evidenceData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_request_review_of_user_evidence_linked_competencies',\n args: {id: evidenceData.id}\n }];\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Send request review for user evidence competencies.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.reviewUserEvidenceCompetencies = function(evidenceData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_user_evidence',\n args: {id: evidenceData.id}\n }]);\n\n requests[0].done(function(evidence) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'sendallcompetenciestoreview', component: 'tool_lp', param: evidence.name},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Send all competencies in review for X?\n strings[2], // Confirm.\n strings[3], // Cancel.\n function() {\n self._doReviewUserEvidenceCompetencies(evidenceData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Send request review for user evidence competencies handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._reviewUserEvidenceCompetenciesHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.reviewUserEvidenceCompetencies(data);\n };\n\n /**\n * Find the evidence data from the evidence node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} Evidence data.\n */\n UserEvidenceActions.prototype._findEvidenceData = function(node) {\n var parent = node.parentsUntil($(this._region).parent(), this._evidenceNode),\n data;\n\n if (parent.length != 1) {\n throw new Error('The evidence node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.id === 'undefined') {\n throw new Error('Evidence data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserEvidenceActions.prototype.enhanceMenubar = function(selector) {\n var self = this;\n Menubar.enhance(selector, {\n '[data-action=\"user-evidence-delete\"]': self._deleteEvidenceHandler.bind(self),\n '[data-action=\"link-competency\"]': self._createUserEvidenceCompetencyHandler.bind(self),\n '[data-action=\"send-competencies-review\"]': self._reviewUserEvidenceCompetenciesHandler.bind(self),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * At this stage this cannot be used with enhanceMenubar or multiple handlers\n * will be added to the same node.\n */\n UserEvidenceActions.prototype.registerEvents = function() {\n var wrapper = $(this._region),\n self = this;\n\n wrapper.find('[data-action=\"user-evidence-delete\"]').click(self._deleteEvidenceHandler.bind(self));\n wrapper.find('[data-action=\"link-competency\"]').click(self._createUserEvidenceCompetencyHandler.bind(self));\n wrapper.find('[data-action=\"delete-competency-link\"]').click(self._deleteUserEvidenceCompetencyHandler.bind(self));\n wrapper.find('[data-action=\"send-competencies-review\"]').click(self._reviewUserEvidenceCompetenciesHandler.bind(self));\n };\n\n return /** @alias module:tool_lp/user_evidence_actions */ UserEvidenceActions;\n});\n"],"names":["define","$","templates","ajax","notification","str","Menubar","PickerUserPlans","UserEvidenceActions","type","_type","_region","_evidenceNode","_template","_contextMethod","TypeError","prototype","_getContextArgs","evidenceData","args","this","id","userid","_renderView","context","self","render","then","newhtml","newjs","replaceNode","_callAndRefresh","calls","push","methodname","when","apply","call","arguments","length","fail","exception","_doDelete","deleteEvidence","done","evidence","get_strings","key","component","param","name","strings","confirm","_deleteEvidenceHandler","e","preventDefault","data","_findEvidenceData","target","_doCreateUserEvidenceCompetency","competencyIds","each","index","competencyId","userevidenceid","competencyid","createUserEvidenceCompetency","picker","on","requestReview","display","_createUserEvidenceCompetencyHandler","_doDeleteUserEvidenceCompetency","deleteUserEvidenceCompetency","_deleteUserEvidenceCompetencyHandler","currentTarget","_doReviewUserEvidenceCompetencies","reviewUserEvidenceCompetencies","_reviewUserEvidenceCompetenciesHandler","node","parent","parentsUntil","Error","enhanceMenubar","selector","enhance","bind","registerEvents","wrapper","find","click"],"mappings":";;;;;;;AAsBAA,uCAAO,CAAC,SACA,iBACA,YACA,oBACA,WACA,kBACA,wCACA,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,QAASC,qBASzDC,oBAAsB,SAASC,cAC1BC,MAAQD,KAEA,aAATA,UAEKE,QAAU,0CACVC,cAAgB,0CAChBC,UAAY,kCACZC,eAAiB,0CAEnB,CAAA,GAAa,SAATL,WAQD,IAAIM,UAAU,yBANfJ,QAAU,0CACVC,cAAgB,0CAChBC,UAAY,uCACZC,eAAiB,oDAQ9BN,oBAAoBQ,UAAUF,eAAiB,KAE/CN,oBAAoBQ,UAAUJ,cAAgB,KAE9CJ,oBAAoBQ,UAAUL,QAAU,KAExCH,oBAAoBQ,UAAUH,UAAY,KAE1CL,oBAAoBQ,UAAUN,MAAQ,KAQtCF,oBAAoBQ,UAAUC,gBAAkB,SAASC,kBAEjDC,KAAO,SAEQ,aAHRC,KAGFV,MACLS,KAAO,CACHE,GAAIH,aAAaG,IAGC,SARfD,KAQKV,QACZS,KAAO,CACHG,OAAQJ,aAAaI,SAItBH,MASXX,oBAAoBQ,UAAUO,YAAc,SAASC,aAC7CC,KAAOL,YACJlB,UAAUwB,OAAOD,KAAKZ,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,OAKXoE,QAAQC,KAAK,4CAA4CC,MAL9CtE,KAKyD0D,uCAAuCQ,KALhGlE,QAQ2CZ"} \ No newline at end of file +{"version":3,"file":"user_evidence_actions.min.js","sources":["../src/user_evidence_actions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * User evidence actions.\n *\n * @module tool_lp/user_evidence_actions\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'tool_lp/menubar',\n 'tool_lp/competencypicker_user_plans'],\n function($, templates, ajax, notification, str, Menubar, PickerUserPlans) {\n\n /**\n * UserEvidenceActions class.\n *\n * Note that presently this cannot be instantiated more than once per page.\n *\n * @param {String} type The type of page we're in.\n */\n var UserEvidenceActions = function(type) {\n this._type = type;\n\n if (type === 'evidence') {\n // This is the page to view one evidence.\n this._region = '[data-region=\"user-evidence-page\"]';\n this._evidenceNode = '[data-region=\"user-evidence-page\"]';\n this._template = 'tool_lp/user_evidence_page';\n this._contextMethod = 'tool_lp_data_for_user_evidence_page';\n\n } else if (type === 'list') {\n // This is the page to view a list of evidence.\n this._region = '[data-region=\"user-evidence-list\"]';\n this._evidenceNode = '[data-region=\"user-evidence-node\"]';\n this._template = 'tool_lp/user_evidence_list_page';\n this._contextMethod = 'tool_lp_data_for_user_evidence_list_page';\n\n } else {\n throw new TypeError('Unexpected type.');\n }\n };\n\n /** @property {String} Ajax method to fetch the page data from. */\n UserEvidenceActions.prototype._contextMethod = null;\n /** @property {String} Selector to find the node describing the evidence. */\n UserEvidenceActions.prototype._evidenceNode = null;\n /** @property {String} Selector mapping to the region to update. Usually similar to wrapper. */\n UserEvidenceActions.prototype._region = null;\n /** @property {String} Name of the template used to render the region. */\n UserEvidenceActions.prototype._template = null;\n /** @property {String} Type of page/region we're in. */\n UserEvidenceActions.prototype._type = null;\n\n /**\n * Resolve the arguments to refresh the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @return {Object} List of arguments.\n */\n UserEvidenceActions.prototype._getContextArgs = function(evidenceData) {\n var self = this,\n args = {};\n\n if (self._type === 'evidence') {\n args = {\n id: evidenceData.id\n };\n\n } else if (self._type === 'list') {\n args = {\n userid: evidenceData.userid\n };\n }\n\n return args;\n };\n\n /**\n * Callback to render the region template.\n *\n * @param {Object} context The context for the template.\n * @return {Promise}\n */\n UserEvidenceActions.prototype._renderView = function(context) {\n var self = this;\n return templates.render(self._template, context)\n .then(function(newhtml, newjs) {\n templates.replaceNode($(self._region), newhtml, newjs);\n return;\n });\n };\n\n /**\n * Call multiple ajax methods, and refresh.\n *\n * @param {Array} calls List of Ajax calls.\n * @param {Object} evidenceData Evidence data from evidence node.\n * @return {Promise}\n */\n UserEvidenceActions.prototype._callAndRefresh = function(calls, evidenceData) {\n var self = this;\n calls.push({\n methodname: self._contextMethod,\n args: self._getContextArgs(evidenceData)\n });\n\n // Apply all the promises, and refresh when the last one is resolved.\n return $.when.apply($.when, ajax.call(calls))\n .then(function() {\n return self._renderView(arguments[arguments.length - 1]);\n })\n .fail(notification.exception);\n };\n\n /**\n * Delete a plan and reload the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype._doDelete = function(evidenceData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_delete_user_evidence',\n args: {id: evidenceData.id}\n }];\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Delete a plan.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.deleteEvidence = function(evidenceData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_user_evidence',\n args: {id: evidenceData.id}\n }]);\n\n requests[0].done(function(evidence) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'deleteuserevidence', component: 'tool_lp', param: evidence.name},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete evidence X?\n strings[2], // Delete.\n strings[3], // Cancel.\n function() {\n self._doDelete(evidenceData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Delete evidence handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._deleteEvidenceHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.deleteEvidence(data);\n };\n\n /**\n * Link a competency and reload.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyIds The competency IDs.\n */\n UserEvidenceActions.prototype._doCreateUserEvidenceCompetency = function(evidenceData, competencyIds) {\n var self = this,\n calls = [];\n\n $.each(competencyIds, function(index, competencyId) {\n calls.push({\n methodname: 'core_competency_create_user_evidence_competency',\n args: {\n userevidenceid: evidenceData.id,\n competencyid: competencyId,\n }\n });\n });\n\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Create a user evidence competency.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.createUserEvidenceCompetency = function(evidenceData) {\n var self = this,\n picker = new PickerUserPlans(evidenceData.userid);\n\n picker.on('save', function(e, data) {\n var competencyIds = data.competencyIds;\n self._doCreateUserEvidenceCompetency(evidenceData, competencyIds, data.requestReview);\n });\n\n picker.display();\n };\n\n /**\n * Create user evidence competency handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._createUserEvidenceCompetencyHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.createUserEvidenceCompetency(data);\n };\n\n /**\n * Remove a linked competency and reload.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyId The competency ID.\n */\n UserEvidenceActions.prototype._doDeleteUserEvidenceCompetency = function(evidenceData, competencyId) {\n var self = this,\n calls = [];\n\n calls.push({\n methodname: 'core_competency_delete_user_evidence_competency',\n args: {\n userevidenceid: evidenceData.id,\n competencyid: competencyId,\n }\n });\n\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Delete a user evidence competency.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n * @param {Number} competencyId The competency ID.\n */\n UserEvidenceActions.prototype.deleteUserEvidenceCompetency = function(evidenceData, competencyId) {\n this._doDeleteUserEvidenceCompetency(evidenceData, competencyId);\n };\n\n /**\n * Delete user evidence competency handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._deleteUserEvidenceCompetencyHandler = function(e) {\n var data = this._findEvidenceData($(e.currentTarget)),\n competencyId = $(e.currentTarget).data('id');\n e.preventDefault();\n this.deleteUserEvidenceCompetency(data, competencyId);\n };\n\n /**\n * Send request review for user evidence competencies and reload the region.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype._doReviewUserEvidenceCompetencies = function(evidenceData) {\n var self = this,\n calls = [{\n methodname: 'core_competency_request_review_of_user_evidence_linked_competencies',\n args: {id: evidenceData.id}\n }];\n self._callAndRefresh(calls, evidenceData);\n };\n\n /**\n * Send request review for user evidence competencies.\n *\n * @param {Object} evidenceData Evidence data from evidence node.\n */\n UserEvidenceActions.prototype.reviewUserEvidenceCompetencies = function(evidenceData) {\n var self = this,\n requests;\n\n requests = ajax.call([{\n methodname: 'core_competency_read_user_evidence',\n args: {id: evidenceData.id}\n }]);\n\n requests[0].done(function(evidence) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'sendallcompetenciestoreview', component: 'tool_lp', param: evidence.name},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Send all competencies in review for X?\n strings[2], // Confirm.\n strings[3], // Cancel.\n function() {\n self._doReviewUserEvidenceCompetencies(evidenceData);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Send request review for user evidence competencies handler.\n *\n * @param {Event} e The event.\n */\n UserEvidenceActions.prototype._reviewUserEvidenceCompetenciesHandler = function(e) {\n e.preventDefault();\n var data = this._findEvidenceData($(e.target));\n this.reviewUserEvidenceCompetencies(data);\n };\n\n /**\n * Find the evidence data from the evidence node.\n *\n * @param {Node} node The node to search from.\n * @return {Object} Evidence data.\n */\n UserEvidenceActions.prototype._findEvidenceData = function(node) {\n var parent = node.parentsUntil($(this._region).parent(), this._evidenceNode),\n data;\n\n if (parent.length != 1) {\n throw new Error('The evidence node was not located.');\n }\n\n data = parent.data();\n if (typeof data === 'undefined' || typeof data.id === 'undefined') {\n throw new Error('Evidence data could not be found.');\n }\n\n return data;\n };\n\n /**\n * Enhance a menu bar.\n *\n * @param {String} selector Menubar selector.\n */\n UserEvidenceActions.prototype.enhanceMenubar = function(selector) {\n var self = this;\n Menubar.enhance(selector, {\n '[data-action=\"user-evidence-delete\"]': self._deleteEvidenceHandler.bind(self),\n '[data-action=\"link-competency\"]': self._createUserEvidenceCompetencyHandler.bind(self),\n '[data-action=\"send-competencies-review\"]': self._reviewUserEvidenceCompetenciesHandler.bind(self),\n });\n };\n\n /**\n * Register the events in the region.\n *\n * At this stage this cannot be used with enhanceMenubar or multiple handlers\n * will be added to the same node.\n */\n UserEvidenceActions.prototype.registerEvents = function() {\n var wrapper = $(this._region),\n self = this;\n\n wrapper.find('[data-action=\"user-evidence-delete\"]').click(self._deleteEvidenceHandler.bind(self));\n wrapper.find('[data-action=\"link-competency\"]').click(self._createUserEvidenceCompetencyHandler.bind(self));\n wrapper.find('[data-action=\"delete-competency-link\"]').click(self._deleteUserEvidenceCompetencyHandler.bind(self));\n wrapper.find('[data-action=\"send-competencies-review\"]').click(self._reviewUserEvidenceCompetenciesHandler.bind(self));\n };\n\n return /** @alias module:tool_lp/user_evidence_actions */ UserEvidenceActions;\n});\n"],"names":["define","$","templates","ajax","notification","str","Menubar","PickerUserPlans","UserEvidenceActions","type","this","_type","_region","_evidenceNode","_template","_contextMethod","TypeError","prototype","_getContextArgs","evidenceData","args","id","userid","_renderView","context","self","render","then","newhtml","newjs","replaceNode","_callAndRefresh","calls","push","methodname","when","apply","call","arguments","length","fail","exception","_doDelete","deleteEvidence","done","evidence","get_strings","key","component","param","name","strings","confirm","_deleteEvidenceHandler","e","preventDefault","data","_findEvidenceData","target","_doCreateUserEvidenceCompetency","competencyIds","each","index","competencyId","userevidenceid","competencyid","createUserEvidenceCompetency","picker","on","requestReview","display","_createUserEvidenceCompetencyHandler","_doDeleteUserEvidenceCompetency","deleteUserEvidenceCompetency","_deleteUserEvidenceCompetencyHandler","currentTarget","_doReviewUserEvidenceCompetencies","reviewUserEvidenceCompetencies","_reviewUserEvidenceCompetenciesHandler","node","parent","parentsUntil","Error","enhanceMenubar","selector","enhance","bind","registerEvents","wrapper","find","click"],"mappings":";;;;;;;AAsBAA,OAAO,gCAAA,CAAC,SACA,iBACA,YACA,oBACA,WACA,kBACA,wCACA,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,QAASC,iBAS7D,IAAIC,oBAAsB,SAASC,MAG/B,GAFAC,KAAKC,MAAQF,KAEA,aAATA,KAEAC,KAAKE,QAAU,qCACfF,KAAKG,cAAgB,qCACrBH,KAAKI,UAAY,6BACjBJ,KAAKK,eAAiB,0CAEnB,IAAa,SAATN,KAQP,MAAM,IAAIO,UAAU,oBANpBN,KAAKE,QAAU,qCACfF,KAAKG,cAAgB,qCACrBH,KAAKI,UAAY,kCACjBJ,KAAKK,eAAiB,0CAI1B,GAqVJ,OAjVAP,oBAAoBS,UAAUF,eA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AAM,IAAI2C,MAAM,sCAIpB,QAAoB,KADpB1B,KAAOwB,OAAOxB,cACwC,IAAZA,KAAKnC,GAC3C,MAAM,IAAI6D,MAAM,qCAGpB,OAAO1B,MAQXhD,oBAAoBS,UAAUkE,eAAiB,SAASC,UAEpD9E,QAAQ+E,QAAQD,SAAU,CACtB,uCAFO1E,KAEsC2C,uBAAuBiC,KAF7D5E,MAGP,kCAHOA,KAGiC6D,qCAAqCe,KAHtE5E,MAIP,2CAJOA,KAI0CoE,uCAAuCQ,KAJjF5E,SAcfF,oBAAoBS,UAAUsE,eAAiB,WAC3C,IAAIC,QAAUvF,EAAES,KAAKE,SAGrB4E,QAAQC,KAAK,wCAAwCC,MAF1ChF,KAEqD2C,uBAAuBiC,KAF5E5E,OAGX8E,QAAQC,KAAK,mCAAmCC,MAHrChF,KAGgD6D,qCAAqCe,KAHrF5E,OAIX8E,QAAQC,KAAK,0CAA0CC,MAJ5ChF,KAIuDgE,qCAAqCY,KAJ5F5E,OAKX8E,QAAQC,KAAK,4CAA4CC,MAL9ChF,KAKyDoE,uCAAuCQ,KALhG5E,QAQ2CF,mBAC9D"} \ No newline at end of file diff --git a/admin/tool/monitor/amd/build/dropdown.min.js.map b/admin/tool/monitor/amd/build/dropdown.min.js.map index 93bf5355381..7eff12d136c 100644 --- a/admin/tool/monitor/amd/build/dropdown.min.js.map +++ b/admin/tool/monitor/amd/build/dropdown.min.js.map @@ -1 +1 @@ -{"version":3,"file":"dropdown.min.js","sources":["../src/dropdown.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Dropdown handler for the Event monitor tool.\n *\n * @module tool_monitor/dropdown\n * @copyright 2023 Andrew Lyons \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport const init = () => {\n const componentSelector = document.querySelector('[data-field=\"component\"]');\n const eventSelector = document.querySelector('[data-field=\"eventname\"]');\n\n const matchesComponent = (component, event) => event.startsWith(`\\\\${component}\\\\`);\n\n // Helper to fetch events for a component.\n const getEventsForComponent = (component) => {\n const events = Object.entries(JSON.parse(eventSelector.dataset.eventlist));\n return events.filter(([eventName], index) => {\n // Always return the Choose... option.\n if (index === 0) {\n return true;\n }\n return matchesComponent(component, eventName);\n });\n };\n\n // Helper to fetch the
')),this.children.push(i),this.inner.one(".availability-children").appendChild(i.node)},M.core_availability.List.prototype.focusAfterAdd=function(){this.inner.one("button").focus()},M.core_availability.List.prototype.isIndividualShowIcons=function(){var i,t;if(this.root)return i="!"===this.node.one(".availability-neg").get("value"),t="|"===this.node.one(".availability-op").get("value"),!i&&!t||i&&t;throw"Can only call this on root list"},M.core_availability.List.prototype.renumber=function(i){var t,e={count:this.children.length},a=i===undefined?e.number="":(e.number=i+":",i+"."),i=M.util.get_string("setheading","availability",e);for(this.node.one("> h3").set("innerHTML",i),t=0;t .availability-children").removeAttribute("aria-hidden"),this.inner.one("> .availability-none").setAttribute("aria-hidden","true"),this.inner.one("> .availability-header").removeAttribute("aria-hidden"),1 .availability-children").setAttribute("aria-hidden","true"),this.inner.one("> .availability-none").removeAttribute("aria-hidden"),this.inner.one("> .availability-header").setAttribute("aria-hidden","true")),this.root){for(i=this.isIndividualShowIcons(),t=0;t .availability-children > .availability-connector span.label").each(function(i){i.set("innerHTML",a)})},M.core_availability.List.prototype.deleteDescendant=function(i){for(var t,e,a=0;a .availability-children").removeChild(e),M.core_availability.form.update(),this.updateHtml(),this.inner.one("> .availability-button").one("button").focus(),!0;if(t instanceof M.core_availability.List&&t.deleteDescendant(i))return!0}return!1},M.core_availability.List.prototype.clickAdd=function(){var i,t,e,a,l,n=d.Node.create('
    "),o=n.one("button"),s={dialog:null},r=n.one("ul");for(l in M.core_availability.form.plugins)M.core_availability.form.plugins[l].allowAdd&&(i=d.Node.create('
  • '),(e=d.Node.create('
    ")).on("click",this.getAddHandler(l,s),this),i.appendChild(e),a=d.Node.create('
    "),i.appendChild(a),r.appendChild(i));i=d.Node.create('
  • '),(e=d.Node.create('
    ")).on("click",this.getAddHandler(null,s),this),i.appendChild(e),a=d.Node.create('
    "),i.appendChild(a),r.appendChild(i),n={headerContent:M.util.get_string("addrestriction","availability"),bodyContent:n,additionalBaseClass:"availability-dialogue",draggable:!0,modal:!0,closeButton:!1,width:"450px"},s.dialog=new M.core.dialogue(n),s.dialog.show(),o.on("click",function(){s.dialog.destroy(),this.inner.one("> .availability-button").one("button").focus()},this)},M.core_availability.List.prototype.getAddHandler=function(t,e){return function(){var i=t?new M.core_availability.Item({type:t,creating:!0},this.root):new M.core_availability.List({c:[],showc:!0},!1,this.root);this.addChild(i),M.core_availability.form.update(),M.core_availability.form.rootList.renumber(),this.updateHtml(),e.dialog.destroy(),i.focusAfterAdd()}},M.core_availability.List.prototype.getValue=function(){var i,t={};for(t.op=this.node.one(".availability-neg").get("value")+this.node.one(".availability-op").get("value"),t.c=[],i=0;i'+M.util.get_string("missingplugin","availability")+"
    ")):(this.plugin=M.core_availability.form.plugins[i.type],this.pluginNode=this.plugin.getNode(i),this.pluginNode.addClass("availability_"+i.type)),this.node=d.Node.create('

    '),t&&(t=!0,i.showc!==undefined&&(t=i.showc),this.eyeIcon=new M.core_availability.EyeIcon(!0,t),this.node.appendChild(this.eyeIcon.span)),this.pluginNode.addClass("availability-plugincontrols"),this.node.appendChild(this.pluginNode),i=new M.core_availability.DeleteIcon(this),this.node.appendChild(i.span),this.node.appendChild(document.createTextNode(" ")),this.node.appendChild(d.Node.create(''))},M.core_availability.Item.prototype.getValue=function(){var i={type:this.pluginType};return this.plugin&&this.plugin.fillValue(i,this.pluginNode),i},M.core_availability.Item.prototype.fillErrors=function(i){var t,e,a,l=i.length;this.plugin?this.plugin.fillErrors(i,this.pluginNode):i.push("core_availability:item_unknowntype"),t=this.node.one("> .badge-warning"),i.length===l||t.get("firstChild")?i.length===l&&t.get("firstChild")&&t.get("firstChild").remove():(l="",e=(i=i[i.length-1].split(":"))[0],a="[["+(i=i[1])+","+e+"]]",(l=M.util.get_string(i,e))===a&&(l=M.util.get_string("invalid","availability")),t.appendChild(document.createTextNode(l)))},M.core_availability.Item.prototype.renumber=function(i){var t={number:i};this.plugin?t.type=M.util.get_string("title","availability_"+this.pluginType):t.type="["+this.pluginType+"]",t.number=i+":",i=M.util.get_string("itemheading","availability",t),this.node.one("> h3").set("innerHTML",i)},M.core_availability.Item.prototype.focusAfterAdd=function(){this.plugin.focusAfterAdd(this.pluginNode)},M.core_availability.Item.prototype.pluginType=null,M.core_availability.Item.prototype.plugin=null,M.core_availability.Item.prototype.eyeIcon=null,M.core_availability.Item.prototype.node=null,M.core_availability.Item.prototype.pluginNode=null,M.core_availability.EyeIcon=function(i,t){var e,a,l,n;this.individual=i,this.span=d.Node.create('
    '),e=d.Node.create(""),this.span.appendChild(e),a=i?"_individual":"_all",l=function(){var i=M.util.get_string("hidden"+a,"availability");e.set("src",M.util.image_url("i/show","core")),e.set("alt",i),this.span.set("title",i+" • "+M.util.get_string("show_verb","availability"))},n=function(){var i=M.util.get_string("shown"+a,"availability");e.set("src",M.util.image_url("i/hide","core")),e.set("alt",i),this.span.set("title",i+" • "+M.util.get_string("hide_verb","availability"))},(t?n:l).call(this),this.span.on("click",i=function(i){i.preventDefault(),(this.isHidden()?n:l).call(this),M.core_availability.form.update()},this),this.span.on("key",i,"up:32",this),this.span.on("key",function(i){i.preventDefault()},"down:32",this)},M.core_availability.EyeIcon.prototype.individual=!1,M.core_availability.EyeIcon.prototype.span=null,M.core_availability.EyeIcon.prototype.isHidden=function(){var i=this.individual?"_individual":"_all",i=M.util.get_string("hidden"+i,"availability");return this.span.one("img").get("alt")===i},M.core_availability.DeleteIcon=function(t){var i;this.span=d.Node.create(''),i=d.Node.create(''+M.util.get_string('),this.span.appendChild(i),this.span.on("click",i=function(i){i.preventDefault(),M.core_availability.form.rootList.deleteDescendant(t),M.core_availability.form.rootList.renumber()},this),this.span.on("key",i,"up:32",this),this.span.on("key",function(i){i.preventDefault()},"down:32",this)},M.core_availability.DeleteIcon.prototype.span=null},"@VERSION@",{requires:["base","node","event","event-delegate","panel","moodle-core-notification-dialogue","json"]}); \ No newline at end of file diff --git a/backup/util/ui/amd/build/async_backup.min.js b/backup/util/ui/amd/build/async_backup.min.js index 09a59771743..967948dd035 100644 --- a/backup/util/ui/amd/build/async_backup.min.js +++ b/backup/util/ui/amd/build/async_backup.min.js @@ -7,6 +7,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since 3.7 */ -define("core_backup/async_backup",["jquery","core/ajax","core/str","core/notification","core/templates"],(function($,ajax,Str,notification,Templates){var backupid,contextid,restoreurl,typeid,backupintervalid,allbackupintervalid,allcopyintervalid,Asyncbackup={},checkdelay=15e3;function updateElement(backupid,type,percentage){var percentagewidth=Math.round(percentage)+"%",elementbar=document.querySelectorAll("[data-"+type+"id="+CSS.escape(backupid)+"]")[0],percentagetext=percentage.toFixed(2)+"%";elementbar.setAttribute("aria-valuenow",percentagewidth),elementbar.style.width=percentagewidth,elementbar.innerHTML=percentagetext}function updateInterval(intervalid,callback,value){return clearInterval(intervalid),setInterval(callback,value)}function updateProgressAll(progress){progress.forEach((function(element){var percentage=100*element.progress,backupid=element.backupid,type=element.operation,elementbar=document.querySelectorAll("[data-"+type+"id="+CSS.escape(backupid)+"]")[0];800==element.status?(elementbar.classList.add("bg-success"),updateElement(backupid,type,percentage)):900==element.status?(elementbar.classList.add("bg-danger"),elementbar.classList.add("complete"),elementbar.classList.remove("bg-success"),updateElement(backupid,type,100)):1e3==element.status&&(elementbar.classList.add("bg-success"),elementbar.classList.add("complete"),updateElement(backupid,type,100),"backup"==type?function(backupid){var statuscell=$("#"+backupid+"_bar").parent().parent(),tablerow=statuscell.parent(),cellsiblings=statuscell.siblings(),timecell=cellsiblings[1],timevalue=$(timecell).text(),filenamecell=cellsiblings[0],filename=$(filenamecell).text();ajax.call([{methodname:"core_backup_get_async_backup_links_backup",args:{filename:filename,contextid:contextid}}])[0].done((function(response){var context={filename:filename,time:timevalue,size:response.filesize,fileurl:response.fileurl,restoreurl:response.restoreurl};Templates.render("core/async_backup_progress_row",context).then((function(html,js){Templates.replaceNodeContents(tablerow,html,js)})).fail((function(){notification.exception(new Error("Failed to load table row"))}))}))}(backupid):function(backupid){var statuscell=$("#"+backupid+"_bar").parent().parent(),tablerow=statuscell.parent(),cellsiblings=statuscell.siblings(),coursecell=cellsiblings[0],timecell=cellsiblings[1],timevalue=$(timecell).text();ajax.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:backupid,contextid:contextid}}])[0].done((function(response){var context={resourcename:$(coursecell).text(),restoreurl:response.restoreurl,time:timevalue};Templates.render("core/async_restore_progress_row",context).then((function(html,js){Templates.replaceNodeContents(tablerow,html,js)})).fail((function(){notification.exception(new Error("Failed to load table row"))}))}))}(backupid))}))}function updateProgressCopy(progress){progress.forEach((function(element){var percentage=100*element.progress,backupid=element.backupid,type=element.operation,elementbar=document.querySelectorAll("[data-"+type+"id="+CSS.escape(backupid)+"]")[0];if("restore"==type){let restorecell=elementbar.closest("tr").children[3];Str.get_string("restore").then((function(content){restorecell.innerHTML=content})).catch((function(){notification.exception(new Error("Failed to load string: restore"))}))}800==element.status?(elementbar.classList.add("bg-success"),updateElement(backupid,type,percentage)):900==element.status?(elementbar.classList.add("bg-danger"),elementbar.classList.add("complete"),elementbar.classList.remove("bg-success"),updateElement(backupid,type,100)):1e3==element.status&&"restore"==type&&(elementbar.classList.add("bg-success"),elementbar.classList.add("complete"),updateElement(backupid,type,100),function(backupid){var elementbar=document.querySelectorAll("[data-restoreid="+CSS.escape(backupid)+"]")[0],restorecourse=elementbar.closest("tr").children[1],coursename=restorecourse.innerHTML,courselink=document.createElement("a"),elementbarparent=elementbar.closest("td"),operation=elementbarparent.previousElementSibling;Str.get_string("complete").then((function(content){operation.innerHTML=content})).catch((function(){notification.exception(new Error("Failed to load string: complete"))})),Templates.render("core/async_copy_complete_cell",{}).then((function(html,js){Templates.replaceNodeContents(elementbarparent,html,js)})).fail((function(){notification.exception(new Error("Failed to load table cell"))})),ajax.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:backupid,contextid:0}}])[0].done((function(response){courselink.setAttribute("href",response.restoreurl),courselink.innerHTML=coursename,restorecourse.innerHTML=null,restorecourse.appendChild(courselink)})).fail((function(){notification.exception(new Error("Failed to update table row"))}))}(backupid))}))}function getBackupProgress(){ajax.call([{methodname:"core_backup_get_async_backup_progress",args:{backupids:[backupid],contextid:contextid}}],!0,!0,!1,2e3)[0].done((function(response){!function(progress){var stringRequests,percentage=100*progress.progress,type="backup",elementbar=document.querySelectorAll("[data-backupid="+CSS.escape(backupid)+"]")[0],elementstatus=$("#"+backupid+"_status"),elementdetail=$("#"+backupid+"_detail"),elementbutton=$("#"+backupid+"_button");if(800==progress.status){elementbar.classList.add("bg-success"),updateElement(backupid,type,percentage);var strProcessing="async"+typeid+"processing";Str.get_string(strProcessing,"backup").then((function(title){elementstatus.text(title)})).catch((function(){notification.exception(new Error("Failed to load string: backup "+strProcessing))}))}else if(900==progress.status)elementbar.classList.add("bg-danger"),elementbar.classList.remove("bg-success"),updateElement(backupid,type,100),stringRequests=[{key:"async"+typeid+"error",component:"backup"},{key:"async"+typeid+"errordetail",component:"backup"}],Str.get_strings(stringRequests).then((function(strings){elementstatus.text(strings[0]),elementdetail.text(strings[1])})).catch((function(){notification.exception(new Error("Failed to load string"))})),$(".backup_progress").children("span").removeClass("backup_stage_current"),$(".backup_progress").children("span").last().addClass("backup_stage_current"),clearInterval(backupintervalid);else if(1e3==progress.status){elementbar.classList.add("bg-success"),updateElement(backupid,type,100);var strComplete="async"+typeid+"complete";Str.get_string(strComplete,"backup").then((function(title){elementstatus.text(title)})).catch((function(){notification.exception(new Error("Failed to load string: backup "+strComplete))})),"restore"==typeid?ajax.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:backupid,contextid:contextid}}])[0].done((function(response){var strButton="async"+typeid+"completebutton",stringRequests=[{key:"async"+typeid+"completedetail",component:"backup",param:response.restoreurl},{key:strButton,component:"backup"}];Str.get_strings(stringRequests).then((function(strings){elementdetail.html(strings[0]),elementbutton.text(strings[1]),elementbutton.attr("href",response.restoreurl)})).catch((function(){notification.exception(new Error("Failed to load string"))}))})):(stringRequests=[{key:"async"+typeid+"completedetail",component:"backup",param:restoreurl},{key:"async"+typeid+"completebutton",component:"backup"}],Str.get_strings(stringRequests).then((function(strings){elementdetail.html(strings[0]),elementbutton.text(strings[1]),elementbutton.attr("href",restoreurl)})).catch((function(){notification.exception(new Error("Failed to load string"))}))),$(".backup_progress").children("span").removeClass("backup_stage_current"),$(".backup_progress").children("span").last().addClass("backup_stage_current"),clearInterval(backupintervalid)}}(response[0]),checkdelay=15e3,backupintervalid=updateInterval(backupintervalid,getBackupProgress,15e3)})).fail((function(){backupintervalid=updateInterval(backupintervalid,getBackupProgress,checkdelay*=1.5)}))}function getAllBackupProgress(){var backupids=[];$(".progress").find(".progress-bar").not(".complete").each((function(){backupids.push(this.id.substring(0,32))})),backupids.length>0?ajax.call([{methodname:"core_backup_get_async_backup_progress",args:{backupids:backupids,contextid:contextid}}],!0,!0,!1,2e3)[0].done((function(response){updateProgressAll(response),checkdelay=15e3,allbackupintervalid=updateInterval(allbackupintervalid,getAllBackupProgress,15e3)})).fail((function(){allbackupintervalid=updateInterval(allbackupintervalid,getAllBackupProgress,checkdelay*=1.5)})):clearInterval(allbackupintervalid)}function getAllCopyProgress(){var copyids=[];$(".progress").find(".progress-bar[data-operation][data-backupid][data-restoreid]").not(".complete").each((function(){let progressvars={backupid:this.dataset.backupid,restoreid:this.dataset.restoreid,operation:this.dataset.operation};copyids.push(progressvars)})),copyids.length>0?ajax.call([{methodname:"core_backup_get_copy_progress",args:{copies:copyids}}],!0,!0,!1,2e3)[0].done((function(response){updateProgressCopy(response),checkdelay=15e3,allcopyintervalid=updateInterval(allcopyintervalid,getAllCopyProgress,15e3)})).fail((function(){allcopyintervalid=updateInterval(allcopyintervalid,getAllCopyProgress,checkdelay*=1.5)})):clearInterval(allcopyintervalid)}return Asyncbackup.asyncBackupAllStatus=function(context){contextid=context,allbackupintervalid=setInterval(getAllBackupProgress,checkdelay)},Asyncbackup.asyncCopyAllStatus=function(){allcopyintervalid=setInterval(getAllCopyProgress,checkdelay)},Asyncbackup.asyncBackupStatus=function(backup,context,restore,type){backupid=backup,contextid=context,restoreurl=restore,typeid="backup"==type?"backup":"restore",$(".backup_progress").children("a").removeAttr("href"),backupintervalid=setInterval(getBackupProgress,checkdelay)},Asyncbackup})); +define("core_backup/async_backup",["jquery","core/ajax","core/str","core/notification","core/templates"],(function($,ajax,Str,notification,Templates){var backupid,contextid,restoreurl,typeid,backupintervalid,allbackupintervalid,allcopyintervalid,STATUS_EXECUTING=800,STATUS_FINISHED_ERR=900,STATUS_FINISHED_OK=1e3,Asyncbackup={},checkdelayoriginal=15e3,checkdelay=15e3,checkdelaymultipler=1.5,timeout=2e3;function updateElement(backupid,type,percentage){var percentagewidth=Math.round(percentage)+"%",elementbar=document.querySelectorAll("[data-"+type+"id="+CSS.escape(backupid)+"]")[0],percentagetext=percentage.toFixed(2)+"%";elementbar.setAttribute("aria-valuenow",percentagewidth),elementbar.style.width=percentagewidth,elementbar.innerHTML=percentagetext}function updateInterval(intervalid,callback,value){return clearInterval(intervalid),setInterval(callback,value)}function updateProgressAll(progress){progress.forEach((function(element){var percentage=100*element.progress,backupid=element.backupid,type=element.operation,elementbar=document.querySelectorAll("[data-"+type+"id="+CSS.escape(backupid)+"]")[0];element.status==STATUS_EXECUTING?(elementbar.classList.add("bg-success"),updateElement(backupid,type,percentage)):element.status==STATUS_FINISHED_ERR?(elementbar.classList.add("bg-danger"),elementbar.classList.add("complete"),elementbar.classList.remove("bg-success"),updateElement(backupid,type,100)):element.status==STATUS_FINISHED_OK&&(elementbar.classList.add("bg-success"),elementbar.classList.add("complete"),updateElement(backupid,type,100),"backup"==type?function(backupid){var statuscell=$("#"+backupid+"_bar").parent().parent(),tablerow=statuscell.parent(),cellsiblings=statuscell.siblings(),timecell=cellsiblings[1],timevalue=$(timecell).text(),filenamecell=cellsiblings[0],filename=$(filenamecell).text();ajax.call([{methodname:"core_backup_get_async_backup_links_backup",args:{filename:filename,contextid:contextid}}])[0].done((function(response){var context={filename:filename,time:timevalue,size:response.filesize,fileurl:response.fileurl,restoreurl:response.restoreurl};Templates.render("core/async_backup_progress_row",context).then((function(html,js){Templates.replaceNodeContents(tablerow,html,js)})).fail((function(){notification.exception(new Error("Failed to load table row"))}))}))}(backupid):function(backupid){var statuscell=$("#"+backupid+"_bar").parent().parent(),tablerow=statuscell.parent(),cellsiblings=statuscell.siblings(),coursecell=cellsiblings[0],timecell=cellsiblings[1],timevalue=$(timecell).text();ajax.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:backupid,contextid:contextid}}])[0].done((function(response){var context={resourcename:$(coursecell).text(),restoreurl:response.restoreurl,time:timevalue};Templates.render("core/async_restore_progress_row",context).then((function(html,js){Templates.replaceNodeContents(tablerow,html,js)})).fail((function(){notification.exception(new Error("Failed to load table row"))}))}))}(backupid))}))}function updateProgressCopy(progress){progress.forEach((function(element){var percentage=100*element.progress,backupid=element.backupid,type=element.operation,elementbar=document.querySelectorAll("[data-"+type+"id="+CSS.escape(backupid)+"]")[0];if("restore"==type){let restorecell=elementbar.closest("tr").children[3];Str.get_string("restore").then((function(content){restorecell.innerHTML=content})).catch((function(){notification.exception(new Error("Failed to load string: restore"))}))}element.status==STATUS_EXECUTING?(elementbar.classList.add("bg-success"),updateElement(backupid,type,percentage)):element.status==STATUS_FINISHED_ERR?(elementbar.classList.add("bg-danger"),elementbar.classList.add("complete"),elementbar.classList.remove("bg-success"),updateElement(backupid,type,100)):element.status==STATUS_FINISHED_OK&&"restore"==type&&(elementbar.classList.add("bg-success"),elementbar.classList.add("complete"),updateElement(backupid,type,100),function(backupid){var elementbar=document.querySelectorAll("[data-restoreid="+CSS.escape(backupid)+"]")[0],restorecourse=elementbar.closest("tr").children[1],coursename=restorecourse.innerHTML,courselink=document.createElement("a"),elementbarparent=elementbar.closest("td"),operation=elementbarparent.previousElementSibling;Str.get_string("complete").then((function(content){operation.innerHTML=content})).catch((function(){notification.exception(new Error("Failed to load string: complete"))})),Templates.render("core/async_copy_complete_cell",{}).then((function(html,js){Templates.replaceNodeContents(elementbarparent,html,js)})).fail((function(){notification.exception(new Error("Failed to load table cell"))})),ajax.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:backupid,contextid:0}}])[0].done((function(response){courselink.setAttribute("href",response.restoreurl),courselink.innerHTML=coursename,restorecourse.innerHTML=null,restorecourse.appendChild(courselink)})).fail((function(){notification.exception(new Error("Failed to update table row"))}))}(backupid))}))}function getBackupProgress(){ajax.call([{methodname:"core_backup_get_async_backup_progress",args:{backupids:[backupid],contextid:contextid}}],!0,!0,!1,timeout)[0].done((function(response){!function(progress){var stringRequests,percentage=100*progress.progress,type="backup",elementbar=document.querySelectorAll("[data-backupid="+CSS.escape(backupid)+"]")[0],elementstatus=$("#"+backupid+"_status"),elementdetail=$("#"+backupid+"_detail"),elementbutton=$("#"+backupid+"_button");if(progress.status==STATUS_EXECUTING){elementbar.classList.add("bg-success"),updateElement(backupid,type,percentage);var strProcessing="async"+typeid+"processing";Str.get_string(strProcessing,"backup").then((function(title){elementstatus.text(title)})).catch((function(){notification.exception(new Error("Failed to load string: backup "+strProcessing))}))}else if(progress.status==STATUS_FINISHED_ERR)elementbar.classList.add("bg-danger"),elementbar.classList.remove("bg-success"),updateElement(backupid,type,100),stringRequests=[{key:"async"+typeid+"error",component:"backup"},{key:"async"+typeid+"errordetail",component:"backup"}],Str.get_strings(stringRequests).then((function(strings){elementstatus.text(strings[0]),elementdetail.text(strings[1])})).catch((function(){notification.exception(new Error("Failed to load string"))})),$(".backup_progress").children("span").removeClass("backup_stage_current"),$(".backup_progress").children("span").last().addClass("backup_stage_current"),clearInterval(backupintervalid);else if(progress.status==STATUS_FINISHED_OK){elementbar.classList.add("bg-success"),updateElement(backupid,type,100);var strComplete="async"+typeid+"complete";Str.get_string(strComplete,"backup").then((function(title){elementstatus.text(title)})).catch((function(){notification.exception(new Error("Failed to load string: backup "+strComplete))})),"restore"==typeid?ajax.call([{methodname:"core_backup_get_async_backup_links_restore",args:{backupid:backupid,contextid:contextid}}])[0].done((function(response){var strButton="async"+typeid+"completebutton",stringRequests=[{key:"async"+typeid+"completedetail",component:"backup",param:response.restoreurl},{key:strButton,component:"backup"}];Str.get_strings(stringRequests).then((function(strings){elementdetail.html(strings[0]),elementbutton.text(strings[1]),elementbutton.attr("href",response.restoreurl)})).catch((function(){notification.exception(new Error("Failed to load string"))}))})):(stringRequests=[{key:"async"+typeid+"completedetail",component:"backup",param:restoreurl},{key:"async"+typeid+"completebutton",component:"backup"}],Str.get_strings(stringRequests).then((function(strings){elementdetail.html(strings[0]),elementbutton.text(strings[1]),elementbutton.attr("href",restoreurl)})).catch((function(){notification.exception(new Error("Failed to load string"))}))),$(".backup_progress").children("span").removeClass("backup_stage_current"),$(".backup_progress").children("span").last().addClass("backup_stage_current"),clearInterval(backupintervalid)}}(response[0]),checkdelay=checkdelayoriginal,backupintervalid=updateInterval(backupintervalid,getBackupProgress,checkdelayoriginal)})).fail((function(){backupintervalid=updateInterval(backupintervalid,getBackupProgress,checkdelay*=checkdelaymultipler)}))}function getAllBackupProgress(){var backupids=[];$(".progress").find(".progress-bar").not(".complete").each((function(){backupids.push(this.id.substring(0,32))})),backupids.length>0?ajax.call([{methodname:"core_backup_get_async_backup_progress",args:{backupids:backupids,contextid:contextid}}],!0,!0,!1,timeout)[0].done((function(response){updateProgressAll(response),checkdelay=checkdelayoriginal,allbackupintervalid=updateInterval(allbackupintervalid,getAllBackupProgress,checkdelayoriginal)})).fail((function(){allbackupintervalid=updateInterval(allbackupintervalid,getAllBackupProgress,checkdelay*=checkdelaymultipler)})):clearInterval(allbackupintervalid)}function getAllCopyProgress(){var copyids=[];$(".progress").find(".progress-bar[data-operation][data-backupid][data-restoreid]").not(".complete").each((function(){let progressvars={backupid:this.dataset.backupid,restoreid:this.dataset.restoreid,operation:this.dataset.operation};copyids.push(progressvars)})),copyids.length>0?ajax.call([{methodname:"core_backup_get_copy_progress",args:{copies:copyids}}],!0,!0,!1,timeout)[0].done((function(response){updateProgressCopy(response),checkdelay=checkdelayoriginal,allcopyintervalid=updateInterval(allcopyintervalid,getAllCopyProgress,checkdelayoriginal)})).fail((function(){allcopyintervalid=updateInterval(allcopyintervalid,getAllCopyProgress,checkdelay*=checkdelaymultipler)})):clearInterval(allcopyintervalid)}return Asyncbackup.asyncBackupAllStatus=function(context){contextid=context,allbackupintervalid=setInterval(getAllBackupProgress,checkdelay)},Asyncbackup.asyncCopyAllStatus=function(){allcopyintervalid=setInterval(getAllCopyProgress,checkdelay)},Asyncbackup.asyncBackupStatus=function(backup,context,restore,type){backupid=backup,contextid=context,restoreurl=restore,typeid="backup"==type?"backup":"restore",$(".backup_progress").children("a").removeAttr("href"),backupintervalid=setInterval(getBackupProgress,checkdelay)},Asyncbackup})); //# sourceMappingURL=async_backup.min.js.map \ No newline at end of file diff --git a/backup/util/ui/amd/build/async_backup.min.js.map b/backup/util/ui/amd/build/async_backup.min.js.map index 72f084eec81..5500ed70b40 100644 --- a/backup/util/ui/amd/build/async_backup.min.js.map +++ b/backup/util/ui/amd/build/async_backup.min.js.map @@ -1 +1 @@ -{"version":3,"file":"async_backup.min.js","sources":["../src/async_backup.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * This module updates the UI during an asynchronous\n * backup or restore process.\n *\n * @module core_backup/async_backup\n * @copyright 2018 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.7\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'core/notification', 'core/templates'],\n function($, ajax, Str, notification, Templates) {\n\n /**\n * Module level constants.\n *\n * Using var instead of const as ES6 isn't fully supported yet.\n */\n var STATUS_EXECUTING = 800;\n var STATUS_FINISHED_ERR = 900;\n var STATUS_FINISHED_OK = 1000;\n\n /**\n * Module level variables.\n */\n var Asyncbackup = {};\n var checkdelayoriginal = 15000; // This is the default time to use.\n var checkdelay = 15000; // How often we should check for progress updates.\n var checkdelaymultipler = 1.5; // If a request fails this multiplier will be used to increase the checkdelay value\n var backupid; // The backup id to get the progress for.\n var contextid; // The course this backup progress is for.\n var restoreurl; // The URL to view course restores.\n var typeid; // The type of operation backup or restore.\n var backupintervalid; // The id of the setInterval function.\n var allbackupintervalid; // The id of the setInterval function.\n var allcopyintervalid; // The id of the setInterval function.\n var timeout = 2000; // Timeout for ajax requests.\n\n /**\n * Helper function to update UI components.\n *\n * @param {string} backupid The id to match elements on.\n * @param {string} type The type of operation, backup or restore.\n * @param {number} percentage The completion percentage to apply.\n */\n function updateElement(backupid, type, percentage) {\n var percentagewidth = Math.round(percentage) + '%';\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n var percentagetext = percentage.toFixed(2) + '%';\n\n // Set progress bar percentage indicators\n elementbar.setAttribute('aria-valuenow', percentagewidth);\n elementbar.style.width = percentagewidth;\n elementbar.innerHTML = percentagetext;\n }\n\n /**\n * Updates the interval we use to check for backup progress.\n *\n * @param {Number} intervalid The id of the interval\n * @param {Function} callback The function to use in setInterval\n * @param {Number} value The specified interval (in milliseconds)\n * @returns {Number}\n */\n function updateInterval(intervalid, callback, value) {\n clearInterval(intervalid);\n return setInterval(callback, value);\n }\n\n /**\n * Update backup table row when an async backup completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateBackupTableRow(backupid) {\n var statuscell = $('#' + backupid + '_bar').parent().parent();\n var tablerow = statuscell.parent();\n var cellsiblings = statuscell.siblings();\n var timecell = cellsiblings[1];\n var timevalue = $(timecell).text();\n var filenamecell = cellsiblings[0];\n var filename = $(filenamecell).text();\n\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_backup',\n args: {\n 'filename': filename,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n // We have the data now update the UI.\n var context = {\n filename: filename,\n time: timevalue,\n size: response.filesize,\n fileurl: response.fileurl,\n restoreurl: response.restoreurl\n };\n\n Templates.render('core/async_backup_progress_row', context).then(function(html, js) {\n Templates.replaceNodeContents(tablerow, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table row'));\n return;\n });\n });\n }\n\n /**\n * Update restore table row when an async restore completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateRestoreTableRow(backupid) {\n var statuscell = $('#' + backupid + '_bar').parent().parent();\n var tablerow = statuscell.parent();\n var cellsiblings = statuscell.siblings();\n var coursecell = cellsiblings[0];\n var timecell = cellsiblings[1];\n var timevalue = $(timecell).text();\n\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n // We have the data now update the UI.\n var resourcename = $(coursecell).text();\n var context = {\n resourcename: resourcename,\n restoreurl: response.restoreurl,\n time: timevalue\n };\n\n Templates.render('core/async_restore_progress_row', context).then(function(html, js) {\n Templates.replaceNodeContents(tablerow, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table row'));\n return;\n });\n });\n }\n\n /**\n * Update copy table row when an course copy completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateCopyTableRow(backupid) {\n var elementbar = document.querySelectorAll(\"[data-restoreid=\" + CSS.escape(backupid) + \"]\")[0];\n var restorecourse = elementbar.closest('tr').children[1];\n var coursename = restorecourse.innerHTML;\n var courselink = document.createElement('a');\n var elementbarparent = elementbar.closest('td');\n var operation = elementbarparent.previousElementSibling;\n\n // Replace the prgress bar.\n Str.get_string('complete').then(function(content) {\n operation.innerHTML = content;\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: complete'));\n return;\n });\n\n Templates.render('core/async_copy_complete_cell', {}).then(function(html, js) {\n Templates.replaceNodeContents(elementbarparent, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table cell'));\n return;\n });\n\n // Update the destination course name to a link to that course.\n ajax.call([{\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': 0\n },\n }])[0].done(function(response) {\n courselink.setAttribute('href', response.restoreurl);\n courselink.innerHTML = coursename;\n restorecourse.innerHTML = null;\n restorecourse.appendChild(courselink);\n\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to update table row'));\n return;\n });\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * the backup process.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgress(progress) {\n var percentage = progress.progress * 100;\n var type = 'backup';\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n var elementstatus = $('#' + backupid + '_status');\n var elementdetail = $('#' + backupid + '_detail');\n var elementbutton = $('#' + backupid + '_button');\n var stringRequests;\n\n if (progress.status == STATUS_EXECUTING) {\n // Process is in progress.\n // Add in progress class color to bar.\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n // Change heading.\n var strProcessing = 'async' + typeid + 'processing';\n Str.get_string(strProcessing, 'backup').then(function(title) {\n elementstatus.text(title);\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: backup ' + strProcessing));\n });\n\n } else if (progress.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar.\n elementbar.classList.add('bg-danger');\n\n // Remove in progress class color to bar.\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n // Change heading and text.\n var strStatus = 'async' + typeid + 'error';\n var strStatusDetail = 'async' + typeid + 'errordetail';\n stringRequests = [\n {key: strStatus, component: 'backup'},\n {key: strStatusDetail, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementstatus.text(strings[0]);\n elementdetail.text(strings[1]);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n $('.backup_progress').children('span').removeClass('backup_stage_current');\n $('.backup_progress').children('span').last().addClass('backup_stage_current');\n\n // Stop checking when we either have an error or a completion.\n clearInterval(backupintervalid);\n\n } else if (progress.status == STATUS_FINISHED_OK) {\n // Process completed successfully.\n\n // Add in progress class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, 100);\n\n // Change heading and text\n var strComplete = 'async' + typeid + 'complete';\n Str.get_string(strComplete, 'backup').then(function(title) {\n elementstatus.text(title);\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: backup ' + strComplete));\n });\n\n if (typeid == 'restore') {\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n var strDetail = 'async' + typeid + 'completedetail';\n var strButton = 'async' + typeid + 'completebutton';\n var stringRequests = [\n {key: strDetail, component: 'backup', param: response.restoreurl},\n {key: strButton, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementdetail.html(strings[0]);\n elementbutton.text(strings[1]);\n elementbutton.attr('href', response.restoreurl);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n });\n } else {\n var strDetail = 'async' + typeid + 'completedetail';\n var strButton = 'async' + typeid + 'completebutton';\n stringRequests = [\n {key: strDetail, component: 'backup', param: restoreurl},\n {key: strButton, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementdetail.html(strings[0]);\n elementbutton.text(strings[1]);\n elementbutton.attr('href', restoreurl);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n }\n\n $('.backup_progress').children('span').removeClass('backup_stage_current');\n $('.backup_progress').children('span').last().addClass('backup_stage_current');\n\n // Stop checking when we either have an error or a completion.\n clearInterval(backupintervalid);\n }\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * all the pending processes for backup and restore operations.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgressAll(progress) {\n progress.forEach(function(element) {\n var percentage = element.progress * 100;\n var backupid = element.backupid;\n var type = element.operation;\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n\n if (element.status == STATUS_EXECUTING) {\n // Process is in element.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n } else if (element.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar\n elementbar.classList.add('bg-danger');\n elementbar.classList.add('complete');\n\n // Remove in element class color to bar\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n } else if (element.status == STATUS_FINISHED_OK) {\n // Process completed successfully.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n elementbar.classList.add('complete');\n\n updateElement(backupid, type, 100);\n\n // We have a successful backup. Update the UI with download and file details.\n if (type == 'backup') {\n updateBackupTableRow(backupid);\n } else {\n updateRestoreTableRow(backupid);\n }\n\n }\n\n });\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * all the pending processes for copy operations.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgressCopy(progress) {\n progress.forEach(function(element) {\n var percentage = element.progress * 100;\n var backupid = element.backupid;\n var type = element.operation;\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n\n if (type == 'restore') {\n let restorecell = elementbar.closest('tr').children[3];\n Str.get_string('restore').then(function(content) {\n restorecell.innerHTML = content;\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: restore'));\n });\n }\n\n if (element.status == STATUS_EXECUTING) {\n // Process is in element.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n } else if (element.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar\n elementbar.classList.add('bg-danger');\n elementbar.classList.add('complete');\n\n // Remove in element class color to bar\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n } else if ((element.status == STATUS_FINISHED_OK) && (type == 'restore')) {\n // Process completed successfully.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n elementbar.classList.add('complete');\n\n updateElement(backupid, type, 100);\n\n // We have a successful copy. Update the UI link to copied course.\n updateCopyTableRow(backupid);\n }\n\n });\n }\n\n /**\n * Get the progress of the backup process via ajax.\n */\n function getBackupProgress() {\n ajax.call([{\n // Get the backup progress via webservice.\n methodname: 'core_backup_get_async_backup_progress',\n args: {\n 'backupids': [backupid],\n 'contextid': contextid\n },\n }], true, true, false, timeout)[0].done(function(response) {\n // We have the progress now update the UI.\n updateProgress(response[0]);\n checkdelay = checkdelayoriginal;\n backupintervalid = updateInterval(backupintervalid, getBackupProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n backupintervalid = updateInterval(backupintervalid, getBackupProgress, checkdelay);\n });\n }\n\n /**\n * Get the progress of all backup processes via ajax.\n */\n function getAllBackupProgress() {\n var backupids = [];\n var progressbars = $('.progress').find('.progress-bar').not('.complete');\n\n progressbars.each(function() {\n backupids.push((this.id).substring(0, 32));\n });\n\n if (backupids.length > 0) {\n ajax.call([{\n // Get the backup progress via webservice.\n methodname: 'core_backup_get_async_backup_progress',\n args: {\n 'backupids': backupids,\n 'contextid': contextid\n },\n }], true, true, false, timeout)[0].done(function(response) {\n updateProgressAll(response);\n checkdelay = checkdelayoriginal;\n allbackupintervalid = updateInterval(allbackupintervalid, getAllBackupProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n allbackupintervalid = updateInterval(allbackupintervalid, getAllBackupProgress, checkdelay);\n });\n } else {\n clearInterval(allbackupintervalid); // No more progress bars to update, stop checking.\n }\n }\n\n /**\n * Get the progress of all copy processes via ajax.\n */\n function getAllCopyProgress() {\n var copyids = [];\n var progressbars = $('.progress').find('.progress-bar[data-operation][data-backupid][data-restoreid]').not('.complete');\n\n progressbars.each(function() {\n let progressvars = {\n 'backupid': this.dataset.backupid,\n 'restoreid': this.dataset.restoreid,\n 'operation': this.dataset.operation,\n };\n copyids.push(progressvars);\n });\n\n if (copyids.length > 0) {\n ajax.call([{\n // Get the copy progress via webservice.\n methodname: 'core_backup_get_copy_progress',\n args: {\n 'copies': copyids\n },\n }], true, true, false, timeout)[0].done(function(response) {\n updateProgressCopy(response);\n checkdelay = checkdelayoriginal;\n allcopyintervalid = updateInterval(allcopyintervalid, getAllCopyProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n allcopyintervalid = updateInterval(allcopyintervalid, getAllCopyProgress, checkdelay);\n });\n } else {\n clearInterval(allcopyintervalid); // No more progress bars to update, stop checking.\n }\n }\n\n /**\n * Get status updates for all backups.\n *\n * @public\n * @param {number} context The context id.\n */\n Asyncbackup.asyncBackupAllStatus = function(context) {\n contextid = context;\n allbackupintervalid = setInterval(getAllBackupProgress, checkdelay);\n };\n\n /**\n * Get status updates for all course copies.\n *\n * @public\n */\n Asyncbackup.asyncCopyAllStatus = function() {\n allcopyintervalid = setInterval(getAllCopyProgress, checkdelay);\n };\n\n /**\n * Get status updates for backup.\n *\n * @public\n * @param {string} backup The backup record id.\n * @param {number} context The context id.\n * @param {string} restore The restore link.\n * @param {string} type The operation type (backup or restore).\n */\n Asyncbackup.asyncBackupStatus = function(backup, context, restore, type) {\n backupid = backup;\n contextid = context;\n restoreurl = restore;\n\n if (type == 'backup') {\n typeid = 'backup';\n } else {\n typeid = 'restore';\n }\n\n // Remove the links from the progress bar, no going back now.\n $('.backup_progress').children('a').removeAttr('href');\n\n // Periodically check for progress updates and update the UI as required.\n backupintervalid = setInterval(getBackupProgress, checkdelay);\n\n };\n\n return Asyncbackup;\n});\n"],"names":["define","$","ajax","Str","notification","Templates","backupid","contextid","restoreurl","typeid","backupintervalid","allbackupintervalid","allcopyintervalid","Asyncbackup","checkdelay","updateElement","type","percentage","percentagewidth","Math","round","elementbar","document","querySelectorAll","CSS","escape","percentagetext","toFixed","setAttribute","style","width","innerHTML","updateInterval","intervalid","callback","value","clearInterval","setInterval","updateProgressAll","progress","forEach","element","operation","status","classList","add","remove","statuscell","parent","tablerow","cellsiblings","siblings","timecell","timevalue","text","filenamecell","filename","call","methodname","args","done","response","context","time","size","filesize","fileurl","render","then","html","js","replaceNodeContents","fail","exception","Error","updateBackupTableRow","coursecell","resourcename","updateRestoreTableRow","updateProgressCopy","restorecell","closest","children","get_string","content","catch","restorecourse","coursename","courselink","createElement","elementbarparent","previousElementSibling","appendChild","updateCopyTableRow","getBackupProgress","stringRequests","elementstatus","elementdetail","elementbutton","strProcessing","title","key","component","get_strings","strings","removeClass","last","addClass","strComplete","strButton","param","attr","updateProgress","getAllBackupProgress","backupids","find","not","each","push","this","id","substring","length","getAllCopyProgress","copyids","progressvars","dataset","restoreid","asyncBackupAllStatus","asyncCopyAllStatus","asyncBackupStatus","backup","restore","removeAttr"],"mappings":";;;;;;;;;AAwBAA,kCAAO,CAAC,SAAU,YAAa,WAAY,oBAAqB,mBACxD,SAASC,EAAGC,KAAMC,IAAKC,aAAcC,eAkBrCC,SACAC,UACAC,WACA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WAAW,QAG/C3H,iBAAmB2B,YAAYyD,kBAAmBhF,aAI7CD"} \ No newline at end of file +{"version":3,"file":"async_backup.min.js","sources":["../src/async_backup.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * This module updates the UI during an asynchronous\n * backup or restore process.\n *\n * @module core_backup/async_backup\n * @copyright 2018 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.7\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'core/notification', 'core/templates'],\n function($, ajax, Str, notification, Templates) {\n\n /**\n * Module level constants.\n *\n * Using var instead of const as ES6 isn't fully supported yet.\n */\n var STATUS_EXECUTING = 800;\n var STATUS_FINISHED_ERR = 900;\n var STATUS_FINISHED_OK = 1000;\n\n /**\n * Module level variables.\n */\n var Asyncbackup = {};\n var checkdelayoriginal = 15000; // This is the default time to use.\n var checkdelay = 15000; // How often we should check for progress updates.\n var checkdelaymultipler = 1.5; // If a request fails this multiplier will be used to increase the checkdelay value\n var backupid; // The backup id to get the progress for.\n var contextid; // The course this backup progress is for.\n var restoreurl; // The URL to view course restores.\n var typeid; // The type of operation backup or restore.\n var backupintervalid; // The id of the setInterval function.\n var allbackupintervalid; // The id of the setInterval function.\n var allcopyintervalid; // The id of the setInterval function.\n var timeout = 2000; // Timeout for ajax requests.\n\n /**\n * Helper function to update UI components.\n *\n * @param {string} backupid The id to match elements on.\n * @param {string} type The type of operation, backup or restore.\n * @param {number} percentage The completion percentage to apply.\n */\n function updateElement(backupid, type, percentage) {\n var percentagewidth = Math.round(percentage) + '%';\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n var percentagetext = percentage.toFixed(2) + '%';\n\n // Set progress bar percentage indicators\n elementbar.setAttribute('aria-valuenow', percentagewidth);\n elementbar.style.width = percentagewidth;\n elementbar.innerHTML = percentagetext;\n }\n\n /**\n * Updates the interval we use to check for backup progress.\n *\n * @param {Number} intervalid The id of the interval\n * @param {Function} callback The function to use in setInterval\n * @param {Number} value The specified interval (in milliseconds)\n * @returns {Number}\n */\n function updateInterval(intervalid, callback, value) {\n clearInterval(intervalid);\n return setInterval(callback, value);\n }\n\n /**\n * Update backup table row when an async backup completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateBackupTableRow(backupid) {\n var statuscell = $('#' + backupid + '_bar').parent().parent();\n var tablerow = statuscell.parent();\n var cellsiblings = statuscell.siblings();\n var timecell = cellsiblings[1];\n var timevalue = $(timecell).text();\n var filenamecell = cellsiblings[0];\n var filename = $(filenamecell).text();\n\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_backup',\n args: {\n 'filename': filename,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n // We have the data now update the UI.\n var context = {\n filename: filename,\n time: timevalue,\n size: response.filesize,\n fileurl: response.fileurl,\n restoreurl: response.restoreurl\n };\n\n Templates.render('core/async_backup_progress_row', context).then(function(html, js) {\n Templates.replaceNodeContents(tablerow, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table row'));\n return;\n });\n });\n }\n\n /**\n * Update restore table row when an async restore completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateRestoreTableRow(backupid) {\n var statuscell = $('#' + backupid + '_bar').parent().parent();\n var tablerow = statuscell.parent();\n var cellsiblings = statuscell.siblings();\n var coursecell = cellsiblings[0];\n var timecell = cellsiblings[1];\n var timevalue = $(timecell).text();\n\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n // We have the data now update the UI.\n var resourcename = $(coursecell).text();\n var context = {\n resourcename: resourcename,\n restoreurl: response.restoreurl,\n time: timevalue\n };\n\n Templates.render('core/async_restore_progress_row', context).then(function(html, js) {\n Templates.replaceNodeContents(tablerow, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table row'));\n return;\n });\n });\n }\n\n /**\n * Update copy table row when an course copy completes.\n *\n * @param {string} backupid The id to match elements on.\n */\n function updateCopyTableRow(backupid) {\n var elementbar = document.querySelectorAll(\"[data-restoreid=\" + CSS.escape(backupid) + \"]\")[0];\n var restorecourse = elementbar.closest('tr').children[1];\n var coursename = restorecourse.innerHTML;\n var courselink = document.createElement('a');\n var elementbarparent = elementbar.closest('td');\n var operation = elementbarparent.previousElementSibling;\n\n // Replace the prgress bar.\n Str.get_string('complete').then(function(content) {\n operation.innerHTML = content;\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: complete'));\n return;\n });\n\n Templates.render('core/async_copy_complete_cell', {}).then(function(html, js) {\n Templates.replaceNodeContents(elementbarparent, html, js);\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to load table cell'));\n return;\n });\n\n // Update the destination course name to a link to that course.\n ajax.call([{\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': 0\n },\n }])[0].done(function(response) {\n courselink.setAttribute('href', response.restoreurl);\n courselink.innerHTML = coursename;\n restorecourse.innerHTML = null;\n restorecourse.appendChild(courselink);\n\n return;\n }).fail(function() {\n notification.exception(new Error('Failed to update table row'));\n return;\n });\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * the backup process.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgress(progress) {\n var percentage = progress.progress * 100;\n var type = 'backup';\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n var elementstatus = $('#' + backupid + '_status');\n var elementdetail = $('#' + backupid + '_detail');\n var elementbutton = $('#' + backupid + '_button');\n var stringRequests;\n\n if (progress.status == STATUS_EXECUTING) {\n // Process is in progress.\n // Add in progress class color to bar.\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n // Change heading.\n var strProcessing = 'async' + typeid + 'processing';\n Str.get_string(strProcessing, 'backup').then(function(title) {\n elementstatus.text(title);\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: backup ' + strProcessing));\n });\n\n } else if (progress.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar.\n elementbar.classList.add('bg-danger');\n\n // Remove in progress class color to bar.\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n // Change heading and text.\n var strStatus = 'async' + typeid + 'error';\n var strStatusDetail = 'async' + typeid + 'errordetail';\n stringRequests = [\n {key: strStatus, component: 'backup'},\n {key: strStatusDetail, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementstatus.text(strings[0]);\n elementdetail.text(strings[1]);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n $('.backup_progress').children('span').removeClass('backup_stage_current');\n $('.backup_progress').children('span').last().addClass('backup_stage_current');\n\n // Stop checking when we either have an error or a completion.\n clearInterval(backupintervalid);\n\n } else if (progress.status == STATUS_FINISHED_OK) {\n // Process completed successfully.\n\n // Add in progress class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, 100);\n\n // Change heading and text\n var strComplete = 'async' + typeid + 'complete';\n Str.get_string(strComplete, 'backup').then(function(title) {\n elementstatus.text(title);\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: backup ' + strComplete));\n });\n\n if (typeid == 'restore') {\n ajax.call([{\n // Get the table data via webservice.\n methodname: 'core_backup_get_async_backup_links_restore',\n args: {\n 'backupid': backupid,\n 'contextid': contextid\n },\n }])[0].done(function(response) {\n var strDetail = 'async' + typeid + 'completedetail';\n var strButton = 'async' + typeid + 'completebutton';\n var stringRequests = [\n {key: strDetail, component: 'backup', param: response.restoreurl},\n {key: strButton, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementdetail.html(strings[0]);\n elementbutton.text(strings[1]);\n elementbutton.attr('href', response.restoreurl);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n });\n } else {\n var strDetail = 'async' + typeid + 'completedetail';\n var strButton = 'async' + typeid + 'completebutton';\n stringRequests = [\n {key: strDetail, component: 'backup', param: restoreurl},\n {key: strButton, component: 'backup'}\n ];\n Str.get_strings(stringRequests).then(function(strings) {\n elementdetail.html(strings[0]);\n elementbutton.text(strings[1]);\n elementbutton.attr('href', restoreurl);\n\n return;\n })\n .catch(function() {\n notification.exception(new Error('Failed to load string'));\n return;\n });\n\n }\n\n $('.backup_progress').children('span').removeClass('backup_stage_current');\n $('.backup_progress').children('span').last().addClass('backup_stage_current');\n\n // Stop checking when we either have an error or a completion.\n clearInterval(backupintervalid);\n }\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * all the pending processes for backup and restore operations.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgressAll(progress) {\n progress.forEach(function(element) {\n var percentage = element.progress * 100;\n var backupid = element.backupid;\n var type = element.operation;\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n\n if (element.status == STATUS_EXECUTING) {\n // Process is in element.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n } else if (element.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar\n elementbar.classList.add('bg-danger');\n elementbar.classList.add('complete');\n\n // Remove in element class color to bar\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n } else if (element.status == STATUS_FINISHED_OK) {\n // Process completed successfully.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n elementbar.classList.add('complete');\n\n updateElement(backupid, type, 100);\n\n // We have a successful backup. Update the UI with download and file details.\n if (type == 'backup') {\n updateBackupTableRow(backupid);\n } else {\n updateRestoreTableRow(backupid);\n }\n\n }\n\n });\n }\n\n /**\n * Update the Moodle user interface with the progress of\n * all the pending processes for copy operations.\n *\n * @param {object} progress The progress and status of the process.\n */\n function updateProgressCopy(progress) {\n progress.forEach(function(element) {\n var percentage = element.progress * 100;\n var backupid = element.backupid;\n var type = element.operation;\n var elementbar = document.querySelectorAll(\"[data-\" + type + \"id=\" + CSS.escape(backupid) + \"]\")[0];\n\n if (type == 'restore') {\n let restorecell = elementbar.closest('tr').children[3];\n Str.get_string('restore').then(function(content) {\n restorecell.innerHTML = content;\n return;\n }).catch(function() {\n notification.exception(new Error('Failed to load string: restore'));\n });\n }\n\n if (element.status == STATUS_EXECUTING) {\n // Process is in element.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n\n updateElement(backupid, type, percentage);\n\n } else if (element.status == STATUS_FINISHED_ERR) {\n // Process completed with error.\n\n // Add in fail class color to bar\n elementbar.classList.add('bg-danger');\n elementbar.classList.add('complete');\n\n // Remove in element class color to bar\n elementbar.classList.remove('bg-success');\n\n updateElement(backupid, type, 100);\n\n } else if ((element.status == STATUS_FINISHED_OK) && (type == 'restore')) {\n // Process completed successfully.\n\n // Add in element class color to bar\n elementbar.classList.add('bg-success');\n elementbar.classList.add('complete');\n\n updateElement(backupid, type, 100);\n\n // We have a successful copy. Update the UI link to copied course.\n updateCopyTableRow(backupid);\n }\n\n });\n }\n\n /**\n * Get the progress of the backup process via ajax.\n */\n function getBackupProgress() {\n ajax.call([{\n // Get the backup progress via webservice.\n methodname: 'core_backup_get_async_backup_progress',\n args: {\n 'backupids': [backupid],\n 'contextid': contextid\n },\n }], true, true, false, timeout)[0].done(function(response) {\n // We have the progress now update the UI.\n updateProgress(response[0]);\n checkdelay = checkdelayoriginal;\n backupintervalid = updateInterval(backupintervalid, getBackupProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n backupintervalid = updateInterval(backupintervalid, getBackupProgress, checkdelay);\n });\n }\n\n /**\n * Get the progress of all backup processes via ajax.\n */\n function getAllBackupProgress() {\n var backupids = [];\n var progressbars = $('.progress').find('.progress-bar').not('.complete');\n\n progressbars.each(function() {\n backupids.push((this.id).substring(0, 32));\n });\n\n if (backupids.length > 0) {\n ajax.call([{\n // Get the backup progress via webservice.\n methodname: 'core_backup_get_async_backup_progress',\n args: {\n 'backupids': backupids,\n 'contextid': contextid\n },\n }], true, true, false, timeout)[0].done(function(response) {\n updateProgressAll(response);\n checkdelay = checkdelayoriginal;\n allbackupintervalid = updateInterval(allbackupintervalid, getAllBackupProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n allbackupintervalid = updateInterval(allbackupintervalid, getAllBackupProgress, checkdelay);\n });\n } else {\n clearInterval(allbackupintervalid); // No more progress bars to update, stop checking.\n }\n }\n\n /**\n * Get the progress of all copy processes via ajax.\n */\n function getAllCopyProgress() {\n var copyids = [];\n var progressbars = $('.progress').find('.progress-bar[data-operation][data-backupid][data-restoreid]').not('.complete');\n\n progressbars.each(function() {\n let progressvars = {\n 'backupid': this.dataset.backupid,\n 'restoreid': this.dataset.restoreid,\n 'operation': this.dataset.operation,\n };\n copyids.push(progressvars);\n });\n\n if (copyids.length > 0) {\n ajax.call([{\n // Get the copy progress via webservice.\n methodname: 'core_backup_get_copy_progress',\n args: {\n 'copies': copyids\n },\n }], true, true, false, timeout)[0].done(function(response) {\n updateProgressCopy(response);\n checkdelay = checkdelayoriginal;\n allcopyintervalid = updateInterval(allcopyintervalid, getAllCopyProgress, checkdelayoriginal);\n }).fail(function() {\n checkdelay = checkdelay * checkdelaymultipler;\n allcopyintervalid = updateInterval(allcopyintervalid, getAllCopyProgress, checkdelay);\n });\n } else {\n clearInterval(allcopyintervalid); // No more progress bars to update, stop checking.\n }\n }\n\n /**\n * Get status updates for all backups.\n *\n * @public\n * @param {number} context The context id.\n */\n Asyncbackup.asyncBackupAllStatus = function(context) {\n contextid = context;\n allbackupintervalid = setInterval(getAllBackupProgress, checkdelay);\n };\n\n /**\n * Get status updates for all course copies.\n *\n * @public\n */\n Asyncbackup.asyncCopyAllStatus = function() {\n allcopyintervalid = setInterval(getAllCopyProgress, checkdelay);\n };\n\n /**\n * Get status updates for backup.\n *\n * @public\n * @param {string} backup The backup record id.\n * @param {number} context The context id.\n * @param {string} restore The restore link.\n * @param {string} type The operation type (backup or restore).\n */\n Asyncbackup.asyncBackupStatus = function(backup, context, restore, type) {\n backupid = backup;\n contextid = context;\n restoreurl = restore;\n\n if (type == 'backup') {\n typeid = 'backup';\n } else {\n typeid = 'restore';\n }\n\n // Remove the links from the progress bar, no going back now.\n $('.backup_progress').children('a').removeAttr('href');\n\n // Periodically check for progress updates and update the UI as required.\n backupintervalid = setInterval(getBackupProgress, checkdelay);\n\n };\n\n return Asyncbackup;\n});\n"],"names":["define","$","ajax","Str","notification","Templates","backupid","contextid","restoreurl","typeid","backupintervalid","allbackupintervalid","allcopyintervalid","STATUS_EXECUTING","STATUS_FINISHED_ERR","STATUS_FINISHED_OK","Asyncbackup","checkdelayoriginal","checkdelay","checkdelaymultipler","timeout","updateElement","type","percentage","percentagewidth","Math","round","elementbar","document","querySelectorAll","CSS","escape","percentagetext","toFixed","setAttribute","style","width","innerHTML","updateInterval","intervalid","callback","value","clearInterval","setInterval","updateProgressAll","progress","forEach","element","operation","status","classList","add","remove","statuscell","parent","tablerow","cellsiblings","siblings","timecell","timevalue","text","filenamecell","filename","call","methodname","args","done","response","context","time","size","filesize","fileurl","render","then","html","js","replaceNodeContents","fail","exception","Error","updateBackupTableRow","coursecell","resourcename","updateRestoreTableRow","updateProgressCopy","restorecell","closest","children","get_string","content","catch","restorecourse","coursename","courselink","createElement","elementbarparent","previousElementSibling","appendChild","updateCopyTableRow","getBackupProgress","backupids","stringRequests","elementstatus","elementdetail","elementbutton","strProcessing","title","key","component","get_strings","strings","removeClass","last","addClass","strComplete","strButton","param","attr","updateProgress","getAllBackupProgress","find","not","each","push","this","id","substring","length","getAllCopyProgress","copyids","progressvars","dataset","restoreid","copies","asyncBackupAllStatus","asyncCopyAllStatus","asyncBackupStatus","backup","restore","removeAttr"],"mappings":";;;;;;;;;AAwBAA,OAAM,2BAAC,CAAC,SAAU,YAAa,WAAY,oBAAqB,mBACxD,SAASC,EAAGC,KAAMC,IAAKC,aAAcC,WAOzC,IAWIC,SACAC,UACAC,WACAC,OACAC,iBACAC,oBACAC,kBAjBAC,iBAAmB,IACnBC,oBAAsB,IACtBC,mBAAqB,IAKrBC,YAAc,CAAA,EACdC,mBAAqB,KACrBC,WAAa,KACbC,oBAAsB,IAQtBC,QAAU,IASd,SAASC,cAAcf,SAAUgB,KAAMC,YACnC,IAAIC,gBAAkBC,KAAKC,MAAMH,YAAc,IAC3CI,WAAaC,SAASC,iBAAiB,SAAWP,KAAO,MAAQQ,IAAIC,OAAOzB,UAAY,KAAK,GAC7F0B,eAAiBT,WAAWU,QAAQ,GAAK,IAG7CN,WAAWO,aAAa,gBAAiBV,iBACzCG,WAAWQ,MAAMC,MAAQZ,gBACzBG,WAAWU,UAAYL,cAC3B,CAUA,SAASM,eAAeC,WAAYC,SAAUC,OAE1C,OADAC,cAAcH,YACPI,YAAYH,SAAUC,MACjC,CAsRA,SAASG,kBAAkBC,UACvBA,SAASC,SAAQ,SAASC,SACtB,IAAIxB,WAAgC,IAAnBwB,QAAQF,SACrBvC,SAAWyC,QAAQzC,SACnBgB,KAAOyB,QAAQC,UACfrB,WAAaC,SAASC,iBAAiB,SAAWP,KAAO,MAAQQ,IAAIC,OAAOzB,UAAY,KAAK,GAE7FyC,QAAQE,QAAUpC,kBAIlBc,WAAWuB,UAAUC,IAAI,cAEzB9B,cAAcf,SAAUgB,KAAMC,aAEvBwB,QAAQE,QAAUnC,qBAIzBa,WAAWuB,UAAUC,IAAI,aACzBxB,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mBACbN,oBAAsB2B,eAAe3B,oBAAqB6G,qBAAsBvG,mBACpF,IAAG6D,MAAK,WAEJnE,oBAAsB2B,eAAe3B,oBAAqB6G,qBAD1DtG,YAA0BC,oBAE9B,IAEAuB,cAAc/B,oBAEtB,CAKA,SAASsH,qBACL,IAAIC,QAAU,GACKjI,EAAE,aAAawH,KAAK,gEAAgEC,IAAI,aAE9FC,MAAK,WACd,IAAIQ,aAAe,CACX7H,SAAYuH,KAAKO,QAAQ9H,SACzB+H,UAAaR,KAAKO,QAAQC,UAC1BrF,UAAa6E,KAAKO,QAAQpF,WAElCkF,QAAQN,KAAKO,aACjB,IAEID,QAAQF,OAAS,EACjB9H,KAAK6D,KAAK,CAAC,CAEPC,WAAY,gCACZC,KAAM,CACFqE,OAAUJ,YAEd,GAAM,GAAM,EAAO9G,SAAS,GAAG8C,MAAK,SAASC,UAC7CkB,mBAAmBlB,UACnBjD,WAAaD,mBACbL,kBAAoB0B,eAAe1B,kBAAmBqH,mBAAoBhH,mBAC9E,IAAG6D,MAAK,WAEJlE,kBAAoB0B,eAAe1B,kBAAmBqH,mBADtD/G,YAA0BC,oBAE9B,IAEAuB,cAAc9B,kBAEtB,CAkDE,OA1CFI,YAAYuH,qBAAuB,SAASnE,SACxC7D,UAAY6D,QACZzD,oBAAsBgC,YAAY6E,qBAAsBtG,aAQ5DF,YAAYwH,mBAAqB,WAC7B5H,kBAAoB+B,YAAYsF,mBAAoB/G,aAYxDF,YAAYyH,kBAAoB,SAASC,OAAQtE,QAASuE,QAASrH,MAC/DhB,SAAWoI,OACXnI,UAAY6D,QACZ5D,WAAamI,QAGTlI,OADQ,UAARa,KACS,SAEA,UAIbrB,EAAE,oBAAoBuF,SAAS,KAAKoD,WAAW,QAG/ClI,iBAAmBiC,YAAYyD,kBAAmBlF,aAI7CF,WACb"} \ No newline at end of file diff --git a/backup/util/ui/yui/build/moodle-backup-backupselectall/moodle-backup-backupselectall-min.js b/backup/util/ui/yui/build/moodle-backup-backupselectall/moodle-backup-backupselectall-min.js index 6a6bc4fd6e4..a0253358c30 100644 --- a/backup/util/ui/yui/build/moodle-backup-backupselectall/moodle-backup-backupselectall-min.js +++ b/backup/util/ui/yui/build/moodle-backup-backupselectall/moodle-backup-backupselectall-min.js @@ -1 +1 @@ -YUI.add("moodle-backup-backupselectall",function(g,e){M.core_backup=M.core_backup||{},M.core_backup.backupselectall=function(e){var t,n,i,d,o,c,r,p,l=null,a=function(e,t,i,n){var o,c;e.preventDefault(),o=void 0!==n?"setting_activity_"+n+"_":"",c=i.length,g.all('input[type="checkbox"]').each(function(e){var n=e.get("name");o&&n.substring(0,o.length)!==o||n.substring(n.length-c)===i&&e.set("checked",t)}),l&&M.form&&M.form.updateFormState(l)},u=function(e,n,t,i){return void 0===i&&(i=""),'"},s=g.one("fieldset#id_coursesettings .fcontainer .grouped_settings.section_level");if(s&&s.one('input[type="checkbox"]')){for(c in l=s.ancestor("form").getAttribute("id"),t=!1,g.all('input[type="checkbox"]').each(function(e){e=e.get("name");"_userdata"===e.substring(e.length-9)?t="_userdata":"_userinfo"===e.substring(e.length-9)&&(t="_userinfo")}),n=u("include_setting section_level","included",M.util.get_string("select","moodle"),' ('+M.util.get_string("showtypes","backup")+")"),t&&(n+=u("normal_setting","userdata",M.util.get_string("select","moodle"))),i=g.Node.create('
    '+n+"
    "),s.insert(i,"before"),d=function(e,n){g.one("#backup-all-mod_"+n).on("click",function(e){a(e,!0,"_included",n)}),g.one("#backup-none-mod_"+n).on("click",function(e){a(e,!1,"_included",n)}),t&&(g.one("#backup-all-userdata-mod_"+n).on("click",function(e){a(e,!0,t,n)}),g.one("#backup-none-userdata-mod_"+n).on("click",function(e){a(e,!1,t,n)}))},(o=g.Node.create('