| Línea 143... | 
            Línea 143... | 
          
          
            | 143 | 
             
  | 
            143 | 
             
  | 
          
          
            | 144 | 
            /**
  | 
            144 | 
            /**
  | 
          
          
            | 145 | 
             * Register event listeners for the module.
  | 
            145 | 
             * Register event listeners for the module.
  | 
          
          
            | 146 | 
             *
  | 
            146 | 
             *
  | 
          
          
            | - | 
               | 
            147 | 
             * @param {object} root The root element.
  | 
          
          
            | 147 | 
             * @param {object} root The root element.
  | 
            148 | 
             * @param {boolean} isCalendarBlock - A flag indicating whether this is a calendar block.
  | 
          
          
            | 148 | 
             */
  | 
            149 | 
             */
  | 
          
          
            | 149 | 
            const registerEventListeners = (root) => {
  | 
            150 | 
            const registerEventListeners = (root, isCalendarBlock) => {
  | 
          
          
            | Línea 150... | 
            Línea 151... | 
          
          
            | 150 | 
                root = $(root);
  | 
            151 | 
                root = $(root);
  | 
          
          
            | 151 | 
             
  | 
            152 | 
             
  | 
          
          
            | 152 | 
                // Bind click events to event links.
  | 
            153 | 
                // Bind click events to event links.
  | 
          
          
            | Línea 190... | 
            Línea 191... | 
          
          
            | 190 | 
                    const courseId = wrapper.data('courseid');
  | 
            191 | 
                    const courseId = wrapper.data('courseid');
  | 
          
          
            | 191 | 
                    const categoryId = wrapper.data('categoryid');
  | 
            192 | 
                    const categoryId = wrapper.data('categoryid');
  | 
          
          
            | 192 | 
                    const link = e.currentTarget;
  | 
            193 | 
                    const link = e.currentTarget;
  | 
          
          
            | Línea 193... | 
            Línea 194... | 
          
          
            | 193 | 
             
  | 
            194 | 
             
  | 
          
          
            | 194 | 
                    if (view === 'month' || view === 'monthblock') {
  | 
            195 | 
                    if (view === 'month' || view === 'monthblock') {
  | 
          
          
            | - | 
               | 
            196 | 
                        changeMonth(root, link.href, link.dataset.year, link.dataset.month,
  | 
          
          
            | 195 | 
                        changeMonth(root, link.href, link.dataset.year, link.dataset.month, courseId, categoryId, link.dataset.day);
  | 
            197 | 
                            courseId, categoryId, link.dataset.day, isCalendarBlock);
  | 
          
          
            | 196 | 
                        e.preventDefault();
  | 
            198 | 
                        e.preventDefault();
  | 
          
          
            | 197 | 
                    } else if (view === 'day') {
  | 
            199 | 
                    } else if (view === 'day') {
  | 
          
          
            | - | 
               | 
            200 | 
                        changeDay(root, link.href, link.dataset.year, link.dataset.month, link.dataset.day,
  | 
          
          
            | 198 | 
                        changeDay(root, link.href, link.dataset.year, link.dataset.month, link.dataset.day, courseId, categoryId);
  | 
            201 | 
                            courseId, categoryId, isCalendarBlock);
  | 
          
          
            | 199 | 
                        e.preventDefault();
  | 
            202 | 
                        e.preventDefault();
  | 
          
          
            | 200 | 
                    }
  | 
            203 | 
                    }
  | 
          
          
            | Línea 201... | 
            Línea 204... | 
          
          
            | 201 | 
                });
  | 
            204 | 
                });
  | 
          
          
            | Línea 290... | 
            Línea 293... | 
          
          
            | 290 | 
             * @param {number} year Year
  | 
            293 | 
             * @param {number} year Year
  | 
          
          
            | 291 | 
             * @param {number} month Month
  | 
            294 | 
             * @param {number} month Month
  | 
          
          
            | 292 | 
             * @param {number} courseId The id of the course whose events are shown
  | 
            295 | 
             * @param {number} courseId The id of the course whose events are shown
  | 
          
          
            | 293 | 
             * @param {number} categoryId The id of the category whose events are shown
  | 
            296 | 
             * @param {number} categoryId The id of the category whose events are shown
  | 
          
          
            | 294 | 
             * @param {number} day Day (optional)
  | 
            297 | 
             * @param {number} day Day (optional)
  | 
          
          
            | - | 
               | 
            298 | 
             * @param {boolean} [isCalendarBlock=false] - A flag indicating whether this is a calendar block.
  | 
          
          
            | 295 | 
             * @return {promise}
  | 
            299 | 
             * @return {promise}
  | 
          
          
            | 296 | 
             */
  | 
            300 | 
             */
  | 
          
          
            | 297 | 
            export const changeMonth = (root, url, year, month, courseId, categoryId, day = 1) => {
  | 
            301 | 
            export const changeMonth = (root, url, year, month, courseId, categoryId, day = 1, isCalendarBlock = false) => {
  | 
          
          
            | 298 | 
                return refreshMonthContent(root, year, month, courseId, categoryId, null, '', day)
  | 
            302 | 
                return refreshMonthContent(root, year, month, courseId, categoryId, null, '', day)
  | 
          
          
            | 299 | 
                    .then((...args) => {
  | 
            303 | 
                    .then((...args) => {
  | 
          
          
            | 300 | 
                        if (url.length && url !== '#') {
  | 
            304 | 
                        if (url.length && url !== '#' && !isCalendarBlock) {
  | 
          
          
            | 301 | 
                            updateUrl(url);
  | 
            305 | 
                            updateUrl(url);
  | 
          
          
            | 302 | 
                        }
  | 
            306 | 
                        }
  | 
          
          
            | 303 | 
                        return args;
  | 
            307 | 
                        return args;
  | 
          
          
            | 304 | 
                    })
  | 
            308 | 
                    })
  | 
          
          
            | 305 | 
                    .then((...args) => {
  | 
            309 | 
                    .then((...args) => {
  | 
          
          
            | 306 | 
                        $('body').trigger(CalendarEvents.monthChanged, [year, month, courseId, categoryId]);
  | 
            310 | 
                        $('body').trigger(CalendarEvents.monthChanged, [year, month, courseId, categoryId, day, isCalendarBlock]);
  | 
          
          
            | 307 | 
                        return args;
  | 
            311 | 
                        return args;
  | 
          
          
            | 308 | 
                    });
  | 
            312 | 
                    });
  | 
          
          
            | 309 | 
            };
  | 
            313 | 
            };
  | 
          
          
            | Línea 310... | 
            Línea 314... | 
          
          
            | 310 | 
             
  | 
            314 | 
             
  | 
          
          
            | Línea 341... | 
            Línea 345... | 
          
          
            | 341 | 
             * @param {number} day Day
  | 
            345 | 
             * @param {number} day Day
  | 
          
          
            | 342 | 
             * @param {number} courseId The id of the course whose events are shown
  | 
            346 | 
             * @param {number} courseId The id of the course whose events are shown
  | 
          
          
            | 343 | 
             * @param {number} categoryId The id of the category whose events are shown
  | 
            347 | 
             * @param {number} categoryId The id of the category whose events are shown
  | 
          
          
            | 344 | 
             * @param {object} target The element being replaced. If not specified, the calendarwrapper is used.
  | 
            348 | 
             * @param {object} target The element being replaced. If not specified, the calendarwrapper is used.
  | 
          
          
            | 345 | 
             * @param {string} template The template to be rendered.
  | 
            349 | 
             * @param {string} template The template to be rendered.
  | 
          
          
            | - | 
               | 
            350 | 
             * @param {boolean} isCalendarBlock - A flag indicating whether this is a calendar block.
  | 
          
          
            | 346 | 
             *
  | 
            351 | 
             *
  | 
          
          
            | 347 | 
             * @return {promise}
  | 
            352 | 
             * @return {promise}
  | 
          
          
            | 348 | 
             */
  | 
            353 | 
             */
  | 
          
          
            | 349 | 
            export const refreshDayContent = (root, year, month, day, courseId, categoryId, target = null, template = '') => {
  | 
            354 | 
            export const refreshDayContent = (root, year, month, day, courseId, categoryId,
  | 
          
          
            | - | 
               | 
            355 | 
                target = null, template = '', isCalendarBlock = false) => {
  | 
          
          
            | 350 | 
                startLoading(root);
  | 
            356 | 
                startLoading(root);
  | 
          
          
            | Línea 351... | 
            Línea 357... | 
          
          
            | 351 | 
             
  | 
            357 | 
             
  | 
          
          
            | 352 | 
                if (!target || target.length == 0){
  | 
            358 | 
                if (!target || target.length == 0){
  | 
          
          
            | 353 | 
                    target = root.find(CalendarSelectors.wrapper);
  | 
            359 | 
                    target = root.find(CalendarSelectors.wrapper);
  | 
          
          
            | Línea 357... | 
            Línea 363... | 
          
          
            | 357 | 
                const includenavigation = root.data('includenavigation');
  | 
            363 | 
                const includenavigation = root.data('includenavigation');
  | 
          
          
            | 358 | 
                return CalendarRepository.getCalendarDayData(year, month, day, courseId, categoryId, includenavigation)
  | 
            364 | 
                return CalendarRepository.getCalendarDayData(year, month, day, courseId, categoryId, includenavigation)
  | 
          
          
            | 359 | 
                    .then((context) => {
  | 
            365 | 
                    .then((context) => {
  | 
          
          
            | 360 | 
                        context.viewingday = true;
  | 
            366 | 
                        context.viewingday = true;
  | 
          
          
            | 361 | 
                        context.showviewselector = true;
  | 
            367 | 
                        context.showviewselector = true;
  | 
          
          
            | - | 
               | 
            368 | 
                        context.iscalendarblock = isCalendarBlock;
  | 
          
          
            | 362 | 
                        return Templates.render(template, context);
  | 
            369 | 
                        return Templates.render(template, context);
  | 
          
          
            | 363 | 
                    })
  | 
            370 | 
                    })
  | 
          
          
            | 364 | 
                    .then((html, js) => {
  | 
            371 | 
                    .then((html, js) => {
  | 
          
          
            | 365 | 
                        return Templates.replaceNode(target, html, js);
  | 
            372 | 
                        return Templates.replaceNode(target, html, js);
  | 
          
          
            | 366 | 
                    })
  | 
            373 | 
                    })
  | 
          
          
            | Línea 403... | 
            Línea 410... | 
          
          
            | 403 | 
             * @param {Number} year Year
  | 
            410 | 
             * @param {Number} year Year
  | 
          
          
            | 404 | 
             * @param {Number} month Month
  | 
            411 | 
             * @param {Number} month Month
  | 
          
          
            | 405 | 
             * @param {Number} day Day
  | 
            412 | 
             * @param {Number} day Day
  | 
          
          
            | 406 | 
             * @param {Number} courseId The id of the course whose events are shown
  | 
            413 | 
             * @param {Number} courseId The id of the course whose events are shown
  | 
          
          
            | 407 | 
             * @param {Number} categoryId The id of the category whose events are shown
  | 
            414 | 
             * @param {Number} categoryId The id of the category whose events are shown
  | 
          
          
            | - | 
               | 
            415 | 
             * @param {boolean} [isCalendarBlock=false] - A flag indicating whether this is a calendar block.
  | 
          
          
            | 408 | 
             * @return {promise}
  | 
            416 | 
             * @return {promise}
  | 
          
          
            | 409 | 
             */
  | 
            417 | 
             */
  | 
          
          
            | 410 | 
            export const changeDay = (root, url, year, month, day, courseId, categoryId) => {
  | 
            418 | 
            export const changeDay = (root, url, year, month, day, courseId, categoryId, isCalendarBlock = false) => {
  | 
          
          
            | 411 | 
                return refreshDayContent(root, year, month, day, courseId, categoryId)
  | 
            419 | 
                return refreshDayContent(root, year, month, day, courseId, categoryId, null, '', isCalendarBlock)
  | 
          
          
            | 412 | 
                    .then((...args) => {
  | 
            420 | 
                    .then((...args) => {
  | 
          
          
            | 413 | 
                        if (url.length && url !== '#') {
  | 
            421 | 
                        if (url.length && url !== '#' && !isCalendarBlock) {
  | 
          
          
            | 414 | 
                            updateUrl(url);
  | 
            422 | 
                            updateUrl(url);
  | 
          
          
            | 415 | 
                        }
  | 
            423 | 
                        }
  | 
          
          
            | 416 | 
                        return args;
  | 
            424 | 
                        return args;
  | 
          
          
            | 417 | 
                    })
  | 
            425 | 
                    })
  | 
          
          
            | 418 | 
                    .then((...args) => {
  | 
            426 | 
                    .then((...args) => {
  | 
          
          
            | 419 | 
                        $('body').trigger(CalendarEvents.dayChanged, [year, month, courseId, categoryId]);
  | 
            427 | 
                        $('body').trigger(CalendarEvents.dayChanged, [year, month, courseId, categoryId, isCalendarBlock]);
  | 
          
          
            | 420 | 
                        return args;
  | 
            428 | 
                        return args;
  | 
          
          
            | 421 | 
                    });
  | 
            429 | 
                    });
  | 
          
          
            | 422 | 
            };
  | 
            430 | 
            };
  | 
          
          
            | Línea 423... | 
            Línea 431... | 
          
          
            | 423 | 
             
  | 
            431 | 
             
  | 
          
          
            | Línea 560... | 
            Línea 568... | 
          
          
            | 560 | 
                    return modal;
  | 
            568 | 
                    return modal;
  | 
          
          
            | 561 | 
                })
  | 
            569 | 
                })
  | 
          
          
            | 562 | 
                .catch(Notification.exception);
  | 
            570 | 
                .catch(Notification.exception);
  | 
          
          
            | 563 | 
            };
  | 
            571 | 
            };
  | 
          
          
            | Línea -... | 
            Línea 572... | 
          
          
            | - | 
               | 
            572 | 
             
  | 
          
          
            | - | 
               | 
            573 | 
            /**
  | 
          
          
            | - | 
               | 
            574 | 
             * Initializes the calendar component by prefetching strings, folding day events,
  | 
          
          
            | - | 
               | 
            575 | 
             * and registering event listeners.
  | 
          
          
            | - | 
               | 
            576 | 
             *
  | 
          
          
            | - | 
               | 
            577 | 
             * @param {HTMLElement} root - The root element where the calendar view manager and event listeners will be attached.
  | 
          
          
            | - | 
               | 
            578 | 
             * @param {string} view - A flag indicating whether this is a calendar block.
  | 
          
          
            | - | 
               | 
            579 | 
             * @param {boolean} isCalendarBlock - A flag indicating whether this is a calendar block.
  | 
          
          
            | 564 | 
             
  | 
            580 | 
             */
  | 
          
          
            | 565 | 
            export const init = (root, view) => {
  | 
            581 | 
            export const init = (root, view, isCalendarBlock) => {
  | 
          
          
            | 566 | 
                prefetchStrings('calendar', ['moreevents']);
  | 
            582 | 
                prefetchStrings('calendar', ['moreevents']);
  | 
          
          
            | 567 | 
                foldDayEvents();
  | 
            583 | 
                foldDayEvents();
  | 
          
          
            | 568 | 
                registerEventListeners(root, view);
  | 
            584 | 
                registerEventListeners(root, isCalendarBlock);
  | 
          
          
            | 569 | 
                const calendarTable = root.find(CalendarSelectors.elements.monthDetailed);
  | 
            585 | 
                const calendarTable = root.find(CalendarSelectors.elements.monthDetailed);
  | 
          
          
            | 570 | 
                if (calendarTable.length) {
  | 
            586 | 
                if (calendarTable.length) {
  | 
          
          
            | 571 | 
                    const pendingId = `month-detailed-${calendarTable.id}-filterChanged`;
  | 
            587 | 
                    const pendingId = `month-detailed-${calendarTable.id}-filterChanged`;
  | 
          
          
            | 572 | 
                    registerEventListenersForMonthDetailed(calendarTable, pendingId);
  | 
            588 | 
                    registerEventListenersForMonthDetailed(calendarTable, pendingId);
  |