__getMap: function()

in static/js/com/toc.js [43:65]


  __getMap: function (selector, scope) {
    var that = this;
    var sections = [], sectionNode, section;
    var i, len;
    var selector = (typeof selector != 'undefined') ? selector : that.selector;
    var scope = (typeof scope != 'undefined') ? scope : that.scope;
    var sectionsNodes = ('querySelectorAll' in scope)
      ? scope.querySelectorAll(selector)
      : $(selector, scope);

    for (i = 0, len = sectionsNodes.length; i < len; i++) {
      sectionNode = sectionsNodes[i];
      section = {
        id: sectionNode.id,
        level: parseInt(sectionNode.tagName.substr(1, 1)),
        title: $(sectionNode).text(),
        node: sectionNode,
        content: []
      };
      sections.push(section);
    }
    return sections;
  },