Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
/**
* Various actions on modules and sections in the editing mode - hiding, duplicating, deleting, etc.
*
* @module core_course/actions
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.3
*/
define(
[
'jquery',
'core/ajax',
'core/templates',
'core/notification',
'core/str',
'core/url',
'core/yui',
'core/modal_factory',
'core/modal_events',
'core/key_codes',
'core/log',
'core_courseformat/courseeditor',
'core/event_dispatcher',
'core_course/events'
],
function(
$,
ajax,
templates,
notification,
str,
url,
Y,
ModalFactory,
ModalEvents,
KeyCodes,
log,
editor,
EventDispatcher,
CourseEvents
) {
// Eventually, core_courseformat/local/content/actions will handle all actions for
// component compatible formats and the default actions.js won't be necessary anymore.
// Meanwhile, we filter the migrated actions.
const componentActions = [
'moveSection', 'moveCm', 'addSection', 'deleteSection', 'sectionHide', 'sectionShow',
'cmHide', 'cmShow', 'cmStealth',
];
// The course reactive instance.
const courseeditor = editor.getCurrentCourseEditor();
// The current course format name (loaded on init).
let formatname;
var CSS = {
EDITINPROGRESS: 'editinprogress',
SECTIONDRAGGABLE: 'sectiondraggable',
EDITINGMOVE: 'editing_move'
};
var SELECTOR = {
ACTIVITYLI: 'li.activity',
ACTIONAREA: '.actions',
ACTIVITYACTION: 'a.cm-edit-action',
MENU: '.moodle-actionmenu[data-enhance=moodle-core-actionmenu]',
TOGGLE: '.toggle-display,.dropdown-toggle',
SECTIONLI: 'li.section',
SECTIONACTIONMENU: '.section_action_menu',
ADDSECTIONS: '.changenumsections [data-add-sections]',
SECTIONBADGES: '[data-region="sectionbadges"]',
};
Y.use('moodle-course-coursebase', function() {
var courseformatselector = M.course.format.get_section_selector();
if (courseformatselector) {
SELECTOR.SECTIONLI = courseformatselector;
}
});
/**
* Dispatch event wrapper.
*
* Old jQuery events will be replaced by native events gradually.
*
* @method dispatchEvent
* @param {String} eventName The name of the event
* @param {Object} detail Any additional details to pass into the eveent
* @param {Node|HTMLElement} container The point at which to dispatch the event
* @param {Object} options
* @param {Boolean} options.bubbles Whether to bubble up the DOM
* @param {Boolean} options.cancelable Whether preventDefault() can be called
* @param {Boolean} options.composed Whether the event can bubble across the ShadowDOM boundary
* @returns {CustomEvent}
*/
const dispatchEvent = function(eventName, detail, container, options) {
// Most actions still uses jQuery node instead of regular HTMLElement.
if (!(container instanceof Element) && container.get !== undefined) {
container = container.get(0);
}
return EventDispatcher.dispatchEvent(eventName, detail, container, options);
};
/**
* Wrapper for Y.Moodle.core_course.util.cm.getId
*
* @param {JQuery} element
* @returns {Integer}
*/
var getModuleId = function(element) {
// Check if we have a data-id first.
const item = element.get(0);
if (item.dataset.id) {
return item.dataset.id;
}
// Use YUI way if data-id is not present.
let id;
Y.use('moodle-course-util', function(Y) {
id = Y.Moodle.core_course.util.cm.getId(Y.Node(item));
});
return id;
};
/**
* Wrapper for Y.Moodle.core_course.util.cm.getName
*
* @param {JQuery} element
* @returns {String}
*/
var getModuleName = function(element) {
var name;
Y.use('moodle-course-util', function(Y) {
name = Y.Moodle.core_course.util.cm.getName(Y.Node(element.get(0)));
});
// Check if we have the name in the course state.
const state = courseeditor.state;
const cmid = getModuleId(element);
if (!name && state && cmid) {
name = state.cm.get(cmid)?.name;
}
return name;
};
/**
* Wrapper for M.util.add_spinner for an activity
*
* @param {JQuery} activity
* @returns {Node}
*/
var addActivitySpinner = function(activity) {
activity.addClass(CSS.EDITINPROGRESS);
var actionarea = activity.find(SELECTOR.ACTIONAREA).get(0);
if (actionarea) {
var spinner = M.util.add_spinner(Y, Y.Node(actionarea));
spinner.show();
// Lock the activity state element.
if (activity.data('id') !== undefined) {
courseeditor.dispatch('cmLock', [activity.data('id')], true);
}
return spinner;
}
return null;
};
/**
* Wrapper for M.util.add_spinner for a section
*
* @param {JQuery} sectionelement
* @returns {Node}
*/
var addSectionSpinner = function(sectionelement) {
sectionelement.addClass(CSS.EDITINPROGRESS);
var actionarea = sectionelement.find(SELECTOR.SECTIONACTIONMENU).get(0);
if (actionarea) {
var spinner = M.util.add_spinner(Y, Y.Node(actionarea));
spinner.show();
// Lock the section state element.
if (sectionelement.data('id') !== undefined) {
courseeditor.dispatch('sectionLock', [sectionelement.data('id')], true);
}
return spinner;
}
return null;
};
/**
* Wrapper for M.util.add_lightbox
*
* @param {JQuery} sectionelement
* @returns {Node}
*/
var addSectionLightbox = function(sectionelement) {
const item = sectionelement.get(0);
var lightbox = M.util.add_lightbox(Y, Y.Node(item));
if (item.dataset.for == 'section' && item.dataset.id) {
courseeditor.dispatch('sectionLock', [item.dataset.id], true);
lightbox.setAttribute('data-state', 'section');
lightbox.setAttribute('data-state-id', item.dataset.id);
}
lightbox.show();
return lightbox;
};
/**
* Removes the spinner element
*
* @param {JQuery} element
* @param {Node} spinner
* @param {Number} delay
*/
var removeSpinner = function(element, spinner, delay) {
window.setTimeout(function() {
element.removeClass(CSS.EDITINPROGRESS);
if (spinner) {
spinner.hide();
}
// Unlock the state element.
if (element.data('id') !== undefined) {
const mutation = (element.data('for') === 'section') ? 'sectionLock' : 'cmLock';
courseeditor.dispatch(mutation, [element.data('id')], false);
}
}, delay);
};
/**
* Removes the lightbox element
*
* @param {Node} lightbox lighbox YUI element returned by addSectionLightbox
* @param {Number} delay
*/
var removeLightbox = function(lightbox, delay) {
if (lightbox) {
window.setTimeout(function() {
lightbox.hide();
// Unlock state if necessary.
if (lightbox.getAttribute('data-state')) {
courseeditor.dispatch(
`${lightbox.getAttribute('data-state')}Lock`,
[lightbox.getAttribute('data-state-id')],
false
);
}
}, delay);
}
};
/**
* Initialise action menu for the element (section or module)
*
* @param {String} elementid CSS id attribute of the element
*/
var initActionMenu = function(elementid) {
// Initialise action menu in the new activity.
Y.use('moodle-course-coursebase', function() {
M.course.coursebase.invoke_function('setup_for_resource', '#' + elementid);
});
if (M.core.actionmenu && M.core.actionmenu.newDOMNode) {
M.core.actionmenu.newDOMNode(Y.one('#' + elementid));
}
};
/**
* Returns focus to the element that was clicked or "Edit" link if element is no longer visible.
*
* @param {String} elementId CSS id attribute of the element
* @param {String} action data-action property of the element that was clicked
*/
var focusActionItem = function(elementId, action) {
var mainelement = $('#' + elementId);
var selector = '[data-action=' + action + ']';
if (action === 'groupsseparate' || action === 'groupsvisible' || action === 'groupsnone') {
// New element will have different data-action.
selector = '[data-action=groupsseparate],[data-action=groupsvisible],[data-action=groupsnone]';
}
if (mainelement.find(selector).is(':visible')) {
mainelement.find(selector).focus();
} else {
// Element not visible, focus the "Edit" link.
mainelement.find(SELECTOR.MENU).find(SELECTOR.TOGGLE).focus();
}
};
/**
* Find next after the element
*
* @param {JQuery} mainElement element that is about to be deleted
* @returns {JQuery}
*/
var findNextFocusable = function(mainElement) {
var tabables = $("a:visible");
var isInside = false;
var foundElement = null;
tabables.each(function() {
if ($.contains(mainElement[0], this)) {
isInside = true;
} else if (isInside) {
foundElement = this;
return false; // Returning false in .each() is equivalent to "break;" inside the loop in php.
}
return true;
});
return foundElement;
};
/**
* Performs an action on a module (moving, deleting, duplicating, hiding, etc.)
*
* @param {JQuery} moduleElement activity element we perform action on
* @param {Number} cmid
* @param {JQuery} target the element (menu item) that was clicked
*/
var editModule = function(moduleElement, cmid, target) {
var action = target.attr('data-action');
var spinner = addActivitySpinner(moduleElement);
var promises = ajax.call([{
methodname: 'core_course_edit_module',
args: {id: cmid,
action: action,
sectionreturn: target.attr('data-sectionreturn') ? target.attr('data-sectionreturn') : 0
}
}], true);
var lightbox;
if (action === 'duplicate') {
lightbox = addSectionLightbox(target.closest(SELECTOR.SECTIONLI));
}
$.when.apply($, promises)
.done(function(data) {
var elementToFocus = findNextFocusable(moduleElement);
moduleElement.replaceWith(data);
let affectedids = [];
// Initialise action menu for activity(ies) added as a result of this.
$('