[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 YUI.add('moodle-course-util-cm', function (Y, NAME) { 2 3 /** 4 * A collection of utility classes for use with course modules. 5 * 6 * @module moodle-course-util 7 * @submodule moodle-course-util-cm 8 */ 9 10 Y.namespace('Moodle.core_course.util.cm'); 11 12 /** 13 * A collection of utility classes for use with course modules. 14 * 15 * @class Moodle.core_course.util.cm 16 * @static 17 */ 18 Y.Moodle.core_course.util.cm = { 19 CONSTANTS: { 20 MODULEIDPREFIX: 'module-' 21 }, 22 SELECTORS: { 23 COURSEMODULE: '.activity', 24 INSTANCENAME: '.instancename' 25 }, 26 27 /** 28 * Retrieve the course module item from one of it's child Nodes. 29 * 30 * @method getCourseModuleNodeFromComponent 31 * @param coursemodulecomponent {Node} The component Node. 32 * @return {Node|null} The Course Module Node. 33 */ 34 getCourseModuleFromComponent: function(coursemodulecomponent) { 35 return Y.one(coursemodulecomponent).ancestor(this.SELECTORS.COURSEMODULE, true); 36 }, 37 38 /** 39 * Determines the section ID for the provided section. 40 * 41 * @method getId 42 * @param coursemodule {Node} The course module to find an ID for. 43 * @return {Number|false} The ID of the course module in question or false if no ID was found. 44 */ 45 getId: function(coursemodule) { 46 // We perform a simple substitution operation to get the ID. 47 var id = coursemodule.get('id').replace( 48 this.CONSTANTS.MODULEIDPREFIX, ''); 49 50 // Attempt to validate the ID. 51 id = parseInt(id, 10); 52 if (typeof id === 'number' && isFinite(id)) { 53 return id; 54 } 55 return false; 56 }, 57 58 /** 59 * Determines the section ID for the provided section. 60 * 61 * @method getName 62 * @param coursemodule {Node} The course module to find an ID for. 63 * @return {Number|false} The ID of the course module in question or false if no ID was found. 64 */ 65 getName: function(coursemodule) { 66 var instance = coursemodule.one(this.SELECTORS.INSTANCENAME); 67 if (instance) { 68 return instance.get('firstChild').get('data'); 69 } 70 return null; 71 } 72 }; 73 74 75 }, '@VERSION@', {"requires": ["node", "moodle-course-util-base"]});
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 |