mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-62859 block_timeline: Rewrite view navigation as ESM
This commit is contained in:
parent
c5d1f72dca
commit
82d7635d52
12
blocks/timeline/amd/build/view_nav.min.js
vendored
12
blocks/timeline/amd/build/view_nav.min.js
vendored
@ -1,9 +1,9 @@
|
||||
define("block_timeline/view_nav",["exports","jquery","core/custom_interaction_events","block_timeline/view","core/notification","core/utils","core_user/repository"],(function(_exports,_jquery,CustomEvents,View,Notification,Utils,UserRepository){var obj;
|
||||
/**
|
||||
* Manage the timeline view navigation for the timeline block.
|
||||
*
|
||||
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define("block_timeline/view_nav",["jquery","core/custom_interaction_events","block_timeline/view","core/notification","core/utils","core_user/repository"],(function($,CustomEvents,View,Notification,Utils,UserRepository){var SELECTORS_TIMELINE_DAY_FILTER='[data-region="day-filter"]',SELECTORS_TIMELINE_DAY_FILTER_OPTION="[data-from]",SELECTORS_TIMELINE_VIEW_SELECTOR='[data-region="view-selector"]',SELECTORS_DATA_DAYS_OFFSET="[data-days-offset]",SELECTORS_TIMELINE_SEARCH_INPUT='[data-action="search"]',SELECTORS_TIMELINE_SEARCH_CLEAR_ICON='[data-action="clearsearch"]',SELECTORS_NO_COURSES_EMPTY_MESSAGE='[data-region="no-courses-empty-message"]';const activeSearchState=(clearSearchIcon,timelineViewRoot)=>{clearSearchIcon.removeClass("d-none"),View.reset(timelineViewRoot)},clearSearchState=(clearSearchIcon,timelineViewRoot)=>{clearSearchIcon.addClass("d-none"),View.reset(timelineViewRoot)};return{init:function(root,timelineViewRoot){(function(root,timelineViewRoot){var viewSelector=root.find(SELECTORS_TIMELINE_VIEW_SELECTOR);viewSelector.on("shown shown.bs.tab",(function(e){View.shown(timelineViewRoot),$(e.target).removeClass("active")})),CustomEvents.define(viewSelector,[CustomEvents.events.activate]),viewSelector.on(CustomEvents.events.activate,"[data-toggle='tab']",(function(e){var filtername=$(e.currentTarget).data("filtername");UserRepository.setUserPreference("block_timeline_user_sort_preference",filtername).catch(Notification.exception)}))})(root=$(root),timelineViewRoot),root.find(SELECTORS_NO_COURSES_EMPTY_MESSAGE).length||(function(root,timelineViewRoot){var timelineDaySelectorContainer=root.find(SELECTORS_TIMELINE_DAY_FILTER);CustomEvents.define(timelineDaySelectorContainer,[CustomEvents.events.activate]),timelineDaySelectorContainer.on(CustomEvents.events.activate,SELECTORS_TIMELINE_DAY_FILTER_OPTION,(function(e,data){var filtername=$(e.currentTarget).data("filtername");UserRepository.setUserPreference("block_timeline_user_filter_preference",filtername).catch(Notification.exception);var option=$(e.target).closest(SELECTORS_TIMELINE_DAY_FILTER_OPTION);if("true"!=option.attr("aria-current")){var daysOffset=option.attr("data-from"),daysLimit=option.attr("data-to"),elementsWithDaysOffset=root.find(SELECTORS_DATA_DAYS_OFFSET);elementsWithDaysOffset.attr("data-days-offset",daysOffset),null!=daysLimit?elementsWithDaysOffset.attr("data-days-limit",daysLimit):elementsWithDaysOffset.removeAttr("data-days-limit"),"overdue"===option.attr("data-filtername")?elementsWithDaysOffset.attr("data-filter-overdue",!0):elementsWithDaysOffset.removeAttr("data-filter-overdue"),View.reset(timelineViewRoot),data.originalEvent.preventDefault()}}))}(root,timelineViewRoot),((root,timelineViewRoot)=>{const searchInput=root.find(SELECTORS_TIMELINE_SEARCH_INPUT),clearSearchIcon=root.find(SELECTORS_TIMELINE_SEARCH_CLEAR_ICON);searchInput.on("input",Utils.debounce((()=>{""!==searchInput.val()?activeSearchState(clearSearchIcon,timelineViewRoot):clearSearchState(clearSearchIcon,timelineViewRoot)}),1e3)),clearSearchIcon.on("click",(()=>{searchInput.val(""),clearSearchState(clearSearchIcon,timelineViewRoot),searchInput.focus()}))})(root,timelineViewRoot))}}}));
|
||||
* Manage the timeline view navigation for the timeline block.
|
||||
*
|
||||
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj},CustomEvents=_interopRequireWildcard(CustomEvents),View=_interopRequireWildcard(View),Notification=_interopRequireWildcard(Notification),Utils=_interopRequireWildcard(Utils),UserRepository=_interopRequireWildcard(UserRepository);const SELECTORS_TIMELINE_DAY_FILTER='[data-region="day-filter"]',SELECTORS_TIMELINE_DAY_FILTER_OPTION="[data-from]",SELECTORS_TIMELINE_VIEW_SELECTOR='[data-region="view-selector"]',SELECTORS_DATA_DAYS_OFFSET="[data-days-offset]",SELECTORS_TIMELINE_SEARCH_INPUT='[data-action="search"]',SELECTORS_TIMELINE_SEARCH_CLEAR_ICON='[data-action="clearsearch"]',SELECTORS_NO_COURSES_EMPTY_MESSAGE='[data-region="no-courses-empty-message"]',activeSearchState=(clearSearchIcon,timelineViewRoot)=>{clearSearchIcon.removeClass("d-none"),View.reset(timelineViewRoot)},clearSearchState=(clearSearchIcon,timelineViewRoot)=>{clearSearchIcon.addClass("d-none"),View.reset(timelineViewRoot)};_exports.init=function(root,timelineViewRoot){(function(root,timelineViewRoot){const viewSelector=root.find(SELECTORS_TIMELINE_VIEW_SELECTOR);viewSelector.on("shown shown.bs.tab",(function(e){View.shown(timelineViewRoot),(0,_jquery.default)(e.target).removeClass("active")})),CustomEvents.define(viewSelector,[CustomEvents.events.activate]),viewSelector.on(CustomEvents.events.activate,"[data-toggle='tab']",(function(e){var filtername=(0,_jquery.default)(e.currentTarget).data("filtername");UserRepository.setUserPreference("block_timeline_user_sort_preference",filtername).catch(Notification.exception)}))})(root=(0,_jquery.default)(root),timelineViewRoot),root.find(SELECTORS_NO_COURSES_EMPTY_MESSAGE).length||(function(root,timelineViewRoot){const timelineDaySelectorContainer=root.find(SELECTORS_TIMELINE_DAY_FILTER);CustomEvents.define(timelineDaySelectorContainer,[CustomEvents.events.activate]),timelineDaySelectorContainer.on(CustomEvents.events.activate,SELECTORS_TIMELINE_DAY_FILTER_OPTION,(function(e,data){var filtername=(0,_jquery.default)(e.currentTarget).data("filtername");UserRepository.setUserPreference("block_timeline_user_filter_preference",filtername).catch(Notification.exception);var option=(0,_jquery.default)(e.target).closest(SELECTORS_TIMELINE_DAY_FILTER_OPTION);if("true"!=option.attr("aria-current")){var daysOffset=option.attr("data-from"),daysLimit=option.attr("data-to"),elementsWithDaysOffset=root.find(SELECTORS_DATA_DAYS_OFFSET);elementsWithDaysOffset.attr("data-days-offset",daysOffset),null!=daysLimit?elementsWithDaysOffset.attr("data-days-limit",daysLimit):elementsWithDaysOffset.removeAttr("data-days-limit"),"overdue"===option.attr("data-filtername")?elementsWithDaysOffset.attr("data-filter-overdue",!0):elementsWithDaysOffset.removeAttr("data-filter-overdue"),View.reset(timelineViewRoot),data.originalEvent.preventDefault()}}))}(root,timelineViewRoot),((root,timelineViewRoot)=>{const searchInput=root.find(SELECTORS_TIMELINE_SEARCH_INPUT),clearSearchIcon=root.find(SELECTORS_TIMELINE_SEARCH_CLEAR_ICON);searchInput.on("input",Utils.debounce((()=>{""!==searchInput.val()?activeSearchState(clearSearchIcon,timelineViewRoot):clearSearchState(clearSearchIcon,timelineViewRoot)}),1e3)),clearSearchIcon.on("click",(()=>{searchInput.val(""),clearSearchState(clearSearchIcon,timelineViewRoot),searchInput.focus()}))})(root,timelineViewRoot))}}));
|
||||
|
||||
//# sourceMappingURL=view_nav.min.js.map
|
File diff suppressed because one or more lines are too long
@ -20,186 +20,170 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'core/custom_interaction_events',
|
||||
'block_timeline/view',
|
||||
'core/notification',
|
||||
'core/utils',
|
||||
'core_user/repository'
|
||||
],
|
||||
function(
|
||||
$,
|
||||
CustomEvents,
|
||||
View,
|
||||
Notification,
|
||||
Utils,
|
||||
UserRepository,
|
||||
) {
|
||||
import $ from 'jquery';
|
||||
import * as CustomEvents from 'core/custom_interaction_events';
|
||||
import * as View from 'block_timeline/view';
|
||||
import * as Notification from 'core/notification';
|
||||
import * as Utils from 'core/utils';
|
||||
import * as UserRepository from 'core_user/repository';
|
||||
|
||||
var SELECTORS = {
|
||||
TIMELINE_DAY_FILTER: '[data-region="day-filter"]',
|
||||
TIMELINE_DAY_FILTER_OPTION: '[data-from]',
|
||||
TIMELINE_VIEW_SELECTOR: '[data-region="view-selector"]',
|
||||
DATA_DAYS_OFFSET: '[data-days-offset]',
|
||||
DATA_DAYS_LIMIT: '[data-days-limit]',
|
||||
TIMELINE_SEARCH_INPUT: '[data-action="search"]',
|
||||
TIMELINE_SEARCH_CLEAR_ICON: '[data-action="clearsearch"]',
|
||||
NO_COURSES_EMPTY_MESSAGE: '[data-region="no-courses-empty-message"]',
|
||||
};
|
||||
const SELECTORS = {
|
||||
TIMELINE_DAY_FILTER: '[data-region="day-filter"]',
|
||||
TIMELINE_DAY_FILTER_OPTION: '[data-from]',
|
||||
TIMELINE_VIEW_SELECTOR: '[data-region="view-selector"]',
|
||||
DATA_DAYS_OFFSET: '[data-days-offset]',
|
||||
DATA_DAYS_LIMIT: '[data-days-limit]',
|
||||
TIMELINE_SEARCH_INPUT: '[data-action="search"]',
|
||||
TIMELINE_SEARCH_CLEAR_ICON: '[data-action="clearsearch"]',
|
||||
NO_COURSES_EMPTY_MESSAGE: '[data-region="no-courses-empty-message"]',
|
||||
};
|
||||
|
||||
/**
|
||||
* Event listener for the day selector ("Next 7 days", "Next 30 days", etc).
|
||||
*
|
||||
* @param {object} root The root element for the timeline block
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
var registerTimelineDaySelector = function(root, timelineViewRoot) {
|
||||
var timelineDaySelectorContainer = root.find(SELECTORS.TIMELINE_DAY_FILTER);
|
||||
/**
|
||||
* Event listener for the day selector ("Next 7 days", "Next 30 days", etc).
|
||||
*
|
||||
* @param {object} root The root element for the timeline block
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
const registerTimelineDaySelector = function(root, timelineViewRoot) {
|
||||
const timelineDaySelectorContainer = root.find(SELECTORS.TIMELINE_DAY_FILTER);
|
||||
|
||||
CustomEvents.define(timelineDaySelectorContainer, [CustomEvents.events.activate]);
|
||||
timelineDaySelectorContainer.on(
|
||||
CustomEvents.events.activate,
|
||||
SELECTORS.TIMELINE_DAY_FILTER_OPTION,
|
||||
function(e, data) {
|
||||
// Update the user preference
|
||||
var filtername = $(e.currentTarget).data('filtername');
|
||||
var type = 'block_timeline_user_filter_preference';
|
||||
UserRepository.setUserPreference(type, filtername)
|
||||
.catch(Notification.exception);
|
||||
|
||||
var option = $(e.target).closest(SELECTORS.TIMELINE_DAY_FILTER_OPTION);
|
||||
|
||||
if (option.attr('aria-current') == 'true') {
|
||||
// If it's already active then we don't need to do anything.
|
||||
return;
|
||||
}
|
||||
|
||||
var daysOffset = option.attr('data-from');
|
||||
var daysLimit = option.attr('data-to');
|
||||
var elementsWithDaysOffset = root.find(SELECTORS.DATA_DAYS_OFFSET);
|
||||
|
||||
elementsWithDaysOffset.attr('data-days-offset', daysOffset);
|
||||
|
||||
if (daysLimit != undefined) {
|
||||
elementsWithDaysOffset.attr('data-days-limit', daysLimit);
|
||||
} else {
|
||||
elementsWithDaysOffset.removeAttr('data-days-limit');
|
||||
}
|
||||
|
||||
if (option.attr('data-filtername') === 'overdue') {
|
||||
elementsWithDaysOffset.attr('data-filter-overdue', true);
|
||||
} else {
|
||||
elementsWithDaysOffset.removeAttr('data-filter-overdue');
|
||||
}
|
||||
|
||||
// Reset the views to reinitialise the event lists now that we've
|
||||
// updated the day limits.
|
||||
View.reset(timelineViewRoot);
|
||||
|
||||
data.originalEvent.preventDefault();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Event listener for the "sort" button in the timeline navigation that allows for
|
||||
* changing between the timeline dates and courses views.
|
||||
*
|
||||
* On a view change we tell the timeline view module that the view has been shown
|
||||
* so that it can handle how to display the appropriate view.
|
||||
*
|
||||
* @param {object} root The root element for the timeline block
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
var registerViewSelector = function(root, timelineViewRoot) {
|
||||
var viewSelector = root.find(SELECTORS.TIMELINE_VIEW_SELECTOR);
|
||||
|
||||
// Listen for when the user changes tab so that we can show the first set of courses
|
||||
// and load their events when they request the sort by courses view for the first time.
|
||||
viewSelector.on('shown shown.bs.tab', function(e) {
|
||||
View.shown(timelineViewRoot);
|
||||
$(e.target).removeClass('active');
|
||||
});
|
||||
|
||||
|
||||
// Event selector for user_sort
|
||||
CustomEvents.define(viewSelector, [CustomEvents.events.activate]);
|
||||
viewSelector.on(CustomEvents.events.activate, "[data-toggle='tab']", function(e) {
|
||||
CustomEvents.define(timelineDaySelectorContainer, [CustomEvents.events.activate]);
|
||||
timelineDaySelectorContainer.on(
|
||||
CustomEvents.events.activate,
|
||||
SELECTORS.TIMELINE_DAY_FILTER_OPTION,
|
||||
function(e, data) {
|
||||
// Update the user preference
|
||||
var filtername = $(e.currentTarget).data('filtername');
|
||||
var type = 'block_timeline_user_sort_preference';
|
||||
var type = 'block_timeline_user_filter_preference';
|
||||
UserRepository.setUserPreference(type, filtername)
|
||||
.catch(Notification.exception);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Event listener for the "search" input field in the timeline navigation that allows for
|
||||
* searching the activity name, course name and activity type.
|
||||
*
|
||||
* @param {object} root The root element for the timeline block
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
const registerSearch = (root, timelineViewRoot) => {
|
||||
const searchInput = root.find(SELECTORS.TIMELINE_SEARCH_INPUT);
|
||||
const clearSearchIcon = root.find(SELECTORS.TIMELINE_SEARCH_CLEAR_ICON);
|
||||
searchInput.on('input', Utils.debounce(() => {
|
||||
if (searchInput.val() !== '') {
|
||||
activeSearchState(clearSearchIcon, timelineViewRoot);
|
||||
} else {
|
||||
clearSearchState(clearSearchIcon, timelineViewRoot);
|
||||
var option = $(e.target).closest(SELECTORS.TIMELINE_DAY_FILTER_OPTION);
|
||||
|
||||
if (option.attr('aria-current') == 'true') {
|
||||
// If it's already active then we don't need to do anything.
|
||||
return;
|
||||
}
|
||||
}, 1000));
|
||||
clearSearchIcon.on('click', () => {
|
||||
searchInput.val('');
|
||||
clearSearchState(clearSearchIcon, timelineViewRoot);
|
||||
searchInput.focus();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Show the clear search icon.
|
||||
*
|
||||
* @param {object} clearSearchIcon Clear search icon element.
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
const activeSearchState = (clearSearchIcon, timelineViewRoot) => {
|
||||
clearSearchIcon.removeClass('d-none');
|
||||
View.reset(timelineViewRoot);
|
||||
};
|
||||
var daysOffset = option.attr('data-from');
|
||||
var daysLimit = option.attr('data-to');
|
||||
var elementsWithDaysOffset = root.find(SELECTORS.DATA_DAYS_OFFSET);
|
||||
|
||||
/**
|
||||
* Hide the clear search icon.
|
||||
*
|
||||
* @param {object} clearSearchIcon Clear search icon element.
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
const clearSearchState = (clearSearchIcon, timelineViewRoot) => {
|
||||
clearSearchIcon.addClass('d-none');
|
||||
View.reset(timelineViewRoot);
|
||||
};
|
||||
elementsWithDaysOffset.attr('data-days-offset', daysOffset);
|
||||
|
||||
/**
|
||||
* Initialise the timeline view navigation by adding event listeners to
|
||||
* the navigation elements.
|
||||
*
|
||||
* @param {object} root The root element for the timeline block
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
var init = function(root, timelineViewRoot) {
|
||||
root = $(root);
|
||||
if (daysLimit != undefined) {
|
||||
elementsWithDaysOffset.attr('data-days-limit', daysLimit);
|
||||
} else {
|
||||
elementsWithDaysOffset.removeAttr('data-days-limit');
|
||||
}
|
||||
|
||||
registerViewSelector(root, timelineViewRoot);
|
||||
if (option.attr('data-filtername') === 'overdue') {
|
||||
elementsWithDaysOffset.attr('data-filter-overdue', true);
|
||||
} else {
|
||||
elementsWithDaysOffset.removeAttr('data-filter-overdue');
|
||||
}
|
||||
|
||||
// Only need to handle filtering if the user is actively enrolled in a course.
|
||||
if (!root.find(SELECTORS.NO_COURSES_EMPTY_MESSAGE).length) {
|
||||
registerTimelineDaySelector(root, timelineViewRoot);
|
||||
registerSearch(root, timelineViewRoot);
|
||||
// Reset the views to reinitialise the event lists now that we've
|
||||
// updated the day limits.
|
||||
View.reset(timelineViewRoot);
|
||||
|
||||
data.originalEvent.preventDefault();
|
||||
}
|
||||
};
|
||||
);
|
||||
};
|
||||
|
||||
return {
|
||||
init: init
|
||||
};
|
||||
});
|
||||
/**
|
||||
* Event listener for the "sort" button in the timeline navigation that allows for
|
||||
* changing between the timeline dates and courses views.
|
||||
*
|
||||
* On a view change we tell the timeline view module that the view has been shown
|
||||
* so that it can handle how to display the appropriate view.
|
||||
*
|
||||
* @param {object} root The root element for the timeline block
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
const registerViewSelector = function(root, timelineViewRoot) {
|
||||
const viewSelector = root.find(SELECTORS.TIMELINE_VIEW_SELECTOR);
|
||||
|
||||
// Listen for when the user changes tab so that we can show the first set of courses
|
||||
// and load their events when they request the sort by courses view for the first time.
|
||||
viewSelector.on('shown shown.bs.tab', function(e) {
|
||||
View.shown(timelineViewRoot);
|
||||
$(e.target).removeClass('active');
|
||||
});
|
||||
|
||||
|
||||
// Event selector for user_sort
|
||||
CustomEvents.define(viewSelector, [CustomEvents.events.activate]);
|
||||
viewSelector.on(CustomEvents.events.activate, "[data-toggle='tab']", function(e) {
|
||||
var filtername = $(e.currentTarget).data('filtername');
|
||||
var type = 'block_timeline_user_sort_preference';
|
||||
UserRepository.setUserPreference(type, filtername)
|
||||
.catch(Notification.exception);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Event listener for the "search" input field in the timeline navigation that allows for
|
||||
* searching the activity name, course name and activity type.
|
||||
*
|
||||
* @param {object} root The root element for the timeline block
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
const registerSearch = (root, timelineViewRoot) => {
|
||||
const searchInput = root.find(SELECTORS.TIMELINE_SEARCH_INPUT);
|
||||
const clearSearchIcon = root.find(SELECTORS.TIMELINE_SEARCH_CLEAR_ICON);
|
||||
searchInput.on('input', Utils.debounce(() => {
|
||||
if (searchInput.val() !== '') {
|
||||
activeSearchState(clearSearchIcon, timelineViewRoot);
|
||||
} else {
|
||||
clearSearchState(clearSearchIcon, timelineViewRoot);
|
||||
}
|
||||
}, 1000));
|
||||
clearSearchIcon.on('click', () => {
|
||||
searchInput.val('');
|
||||
clearSearchState(clearSearchIcon, timelineViewRoot);
|
||||
searchInput.focus();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Show the clear search icon.
|
||||
*
|
||||
* @param {object} clearSearchIcon Clear search icon element.
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
const activeSearchState = (clearSearchIcon, timelineViewRoot) => {
|
||||
clearSearchIcon.removeClass('d-none');
|
||||
View.reset(timelineViewRoot);
|
||||
};
|
||||
|
||||
/**
|
||||
* Hide the clear search icon.
|
||||
*
|
||||
* @param {object} clearSearchIcon Clear search icon element.
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
const clearSearchState = (clearSearchIcon, timelineViewRoot) => {
|
||||
clearSearchIcon.addClass('d-none');
|
||||
View.reset(timelineViewRoot);
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialise the timeline view navigation by adding event listeners to
|
||||
* the navigation elements.
|
||||
*
|
||||
* @param {jQuery|HTMLElement} root The root element for the timeline block
|
||||
* @param {object} timelineViewRoot The root element for the timeline view
|
||||
*/
|
||||
export const init = function(root, timelineViewRoot) {
|
||||
root = $(root);
|
||||
|
||||
registerViewSelector(root, timelineViewRoot);
|
||||
|
||||
// Only need to handle filtering if the user is actively enrolled in a course.
|
||||
if (!root.find(SELECTORS.NO_COURSES_EMPTY_MESSAGE).length) {
|
||||
registerTimelineDaySelector(root, timelineViewRoot);
|
||||
registerSearch(root, timelineViewRoot);
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user