[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/course/yui/build/moodle-course-util-section/ -> moodle-course-util-section.js (source)

   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"]});


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1