[ Index ] |
PHP Cross Reference of Unnamed Project |
[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 * @module moodle-core-event 18 */ 19 20 var LOGNAME = 'moodle-core-event'; 21 22 /** 23 * List of published global JS events in Moodle. This is a collection 24 * of global events that can be subscribed to, or fired from any plugin. 25 * 26 * @namespace M.core 27 * @class event 28 */ 29 M.core = M.core || {}; 30 31 M.core.event = M.core.event || { 32 /** 33 * This event is triggered when a page has added dynamic nodes to a page 34 * that should be processed by the filter system. An example is loading 35 * user text that could have equations in it. MathJax can typeset the equations 36 * but only if it is notified that there are new nodes in the page that need processing. 37 * To trigger this event use M.core.Event.fire(M.core.Event.FILTER_CONTENT_UPDATED, {nodes: list}); 38 * 39 * @event "filter-content-updated" 40 * @param nodes {Y.NodeList} List of nodes added to the DOM. 41 */ 42 FILTER_CONTENT_UPDATED: "filter-content-updated", 43 /** 44 * This event is triggered when an editor has recovered some draft text. 45 * It can be used to determine let other sections know that they should reset their 46 * form comparison for changes. 47 * 48 * @event "editor-content-restored" 49 */ 50 EDITOR_CONTENT_RESTORED: "editor-content-restored" 51 }; 52 53 M.core.globalEvents = M.core.globalEvents || { 54 /** 55 * This event is triggered when form has an error 56 * 57 * @event "form_error" 58 * @param formid {string} Id of form with error. 59 * @param elementid {string} Id of element with error. 60 */ 61 FORM_ERROR: "form_error", 62 63 /** 64 * This event is triggered when the content of a block has changed 65 * 66 * @event "block_content_updated" 67 * @param instanceid ID of the block instance that was updated 68 */ 69 BLOCK_CONTENT_UPDATED: "block_content_updated" 70 }; 71 72 73 var eventDefaultConfig = { 74 emitFacade: true, 75 defaultFn: function(e) { 76 Y.log('Event fired: ' + e.type, 'debug', LOGNAME); 77 }, 78 preventedFn: function(e) { 79 Y.log('Event prevented: ' + e.type, 'debug', LOGNAME); 80 }, 81 stoppedFn: function(e) { 82 Y.log('Event stopped: ' + e.type, 'debug', LOGNAME); 83 } 84 }; 85 86 // Publish events with a custom config here. 87 88 // Publish all the events with a standard config. 89 var key; 90 for (key in M.core.event) { 91 if (M.core.event.hasOwnProperty(key) && Y.getEvent(M.core.event[key]) === null) { 92 Y.publish(M.core.event[key], eventDefaultConfig); 93 } 94 } 95 96 // Publish global events. 97 for (key in M.core.globalEvents) { 98 // Make sure the key exists and that the event has not yet been published. Otherwise, skip publishing. 99 if (M.core.globalEvents.hasOwnProperty(key) && Y.Global.getEvent(M.core.globalEvents[key]) === null) { 100 Y.Global.publish(M.core.globalEvents[key], Y.merge(eventDefaultConfig, {broadcast: true})); 101 Y.log('Global event published: ' + key, 'debug', LOGNAME); 102 } 103 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |