~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to course/yui/build/moodle-course-util-section/moodle-course-util-section-debug.js

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
YUI.add('moodle-course-util-section', function (Y, NAME) {
 
2
 
 
3
/**
 
4
 * A collection of utility classes for use with course sections.
 
5
 *
 
6
 * @module moodle-course-util
 
7
 * @submodule moodle-course-util-section
 
8
 */
 
9
 
 
10
Y.namespace('Moodle.core_course.util.section');
 
11
 
 
12
/**
 
13
 * A collection of utility classes for use with course sections.
 
14
 *
 
15
 * @class Moodle.core_course.util.section
 
16
 * @static
 
17
 */
 
18
Y.Moodle.core_course.util.section = {
 
19
    CONSTANTS: {
 
20
        SECTIONIDPREFIX : 'section-'
 
21
    },
 
22
 
 
23
    /**
 
24
     * Determines the section ID for the provided section.
 
25
     *
 
26
     * @method getId
 
27
     * @param section {Node} The section to find an ID for.
 
28
     * @return {Number|false} The ID of the section in question or false if no ID was found.
 
29
     */
 
30
    getId: function(section) {
 
31
        // We perform a simple substitution operation to get the ID.
 
32
        var id = section.get('id').replace(
 
33
                this.CONSTANTS.SECTIONIDPREFIX, '');
 
34
 
 
35
        // Attempt to validate the ID.
 
36
        id = parseInt(id, 10);
 
37
        if (typeof id === 'number' && isFinite(id)) {
 
38
            return id;
 
39
        }
 
40
        return false;
 
41
    }
 
42
};
 
43
 
 
44
 
 
45
}, '@VERSION@', {"requires": ["node", "moodle-course-util-base"]});