| [ Index ] |
PHP Cross Reference of Moodle 310 |
[Summary view] [Print] [Text view]
1 // This file is part of Moodle - http://moodle.org/ 2 // 3 // Moodle is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // (at your option) any later version. 7 // 8 // Moodle is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 15 16 /** 17 * Global registry of core events that can be triggered/listened for. 18 * 19 * @module core/event 20 * @class event 21 * @copyright 2015 Damyon Wiese <damyon@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 * @since 3.0 24 */ 25 define(['jquery', 'core/yui'], 26 function($, Y) { 27 28 return /** @alias module:core/event */ { 29 30 31 // Public variables and functions. 32 // These are AMD only events - no backwards compatibility for new things. 33 Events: { 34 FORM_FIELD_VALIDATION: "core_form-field-validation" 35 }, 36 37 /** 38 * Load the legacy YUI module which defines events in M.core.event and return it. 39 * 40 * @method getLegacyEvents 41 * @return {Promise} 42 */ 43 getLegacyEvents: function() { 44 var result = $.Deferred(); 45 Y.use('event', 'moodle-core-event', function() { 46 result.resolve(window.M.core.event); 47 }); 48 return result.promise(); 49 }, 50 51 /** 52 * Trigger an event using both JQuery and YUI 53 * 54 * @method notifyFilterContentUpdated 55 * @param {string|JQuery} nodes - Selector or list of elements that were inserted. 56 */ 57 notifyFilterContentUpdated: function(nodes) { 58 nodes = $(nodes); 59 Y.use('event', 'moodle-core-event', function(Y) { 60 // Trigger it the JQuery way. 61 $(document).trigger(M.core.event.FILTER_CONTENT_UPDATED, [nodes]); 62 63 // Create a YUI NodeList from our JQuery Object. 64 var yuiNodes = new Y.NodeList(nodes.get()); 65 66 // And again for YUI. 67 Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: yuiNodes}); 68 }); 69 }, 70 71 /** 72 * Trigger an event using both JQuery and YUI 73 * 74 * @method notifyFormSubmittedAjax 75 * @param {DOMElement} form 76 * @param {boolean} skipValidation Submit the form without validation. E.g. "Cancel". 77 */ 78 notifyFormSubmitAjax: function(form, skipValidation) { 79 80 // Argument is optional. 81 skipValidation = skipValidation || false; 82 83 Y.use('event', 'moodle-core-event', function(Y) { 84 if (skipValidation) { 85 window.skipClientValidation = true; 86 } 87 // Trigger it the JQuery way. 88 $(form).trigger(M.core.event.FORM_SUBMIT_AJAX); 89 90 // And again for YUI. 91 Y.one(form).fire(M.core.event.FORM_SUBMIT_AJAX, {currentTarget: Y.one(form)}); 92 93 if (skipValidation) { 94 window.skipClientValidation = false; 95 } 96 }); 97 }, 98 99 /** 100 * Trigger an event using both JQuery and YUI 101 * This event alerts the world that the editor has restored some content. 102 * 103 * @method notifyEditorContentRestored 104 */ 105 notifyEditorContentRestored: function() { 106 Y.use('event', 'moodle-core-event', function(Y) { 107 // Trigger it the JQuery way. 108 $(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED); 109 110 // And again for YUI. 111 Y.fire(M.core.event.EDITOR_CONTENT_RESTORED); 112 }); 113 }, 114 }; 115 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 22 11:59:49 2025 | Cross-referenced by PHPXref 0.7.1 |