[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/assign/yui/build/moodle-mod_assign-history/ -> moodle-mod_assign-history.js (source)

   1  YUI.add('moodle-mod_assign-history', function (Y, NAME) {
   2  
   3  // Define a function that will run in the context of a
   4  // Node instance:
   5  var CSS = {
   6          LINK: 'mod-assign-history-link',
   7          OPEN: 'mod-assign-history-link-open',
   8          CLOSED: 'mod-assign-history-link-closed',
   9          PANEL: 'mod-assign-history-panel'
  10      },
  11      COUNT = 0,
  12      TOGGLE = function() {
  13          var id = this.get('for'),
  14              panel = Y.one('#' + id);
  15          if (this.hasClass(CSS.OPEN)) {
  16              this.removeClass(CSS.OPEN);
  17              this.addClass(CSS.CLOSED);
  18              this.setStyle('overflow', 'hidden');
  19              panel.hide();
  20          } else {
  21              this.removeClass(CSS.CLOSED);
  22              this.addClass(CSS.OPEN);
  23              panel.show();
  24          }
  25      },
  26      HISTORY = function() {
  27          var link = null,
  28              panel = null,
  29              wrapper = null,
  30              container = this;
  31  
  32          // Loop through all the children of this container and turn
  33          // every odd node to a link to open/close the following panel.
  34          this.get('children').each(function () {
  35              if (link) {
  36                  COUNT++;
  37                  // First convert the link to an anchor.
  38                  wrapper = Y.Node.create('<a/>');
  39                  panel = this;
  40                  container.insertBefore(wrapper, link);
  41                  link.remove(false);
  42                  wrapper.appendChild(link);
  43  
  44                  // Add a for attribute to the link to link to the id of the panel.
  45                  if (!panel.get('id')) {
  46                      panel.set('id', CSS.PANEL + COUNT);
  47                  }
  48                  wrapper.set('for', panel.get('id'));
  49                  // Add an aria attribute for the live region.
  50                  panel.set('aria-live', 'polite');
  51  
  52                  wrapper.addClass(CSS.LINK);
  53                  wrapper.addClass(CSS.CLOSED);
  54                  panel.addClass(CSS.PANEL);
  55                  panel.hide();
  56                  link = null;
  57              } else {
  58                  link = this;
  59              }
  60          });
  61  
  62          // Setup event listeners.
  63          this.delegate('click', TOGGLE, '.' + CSS.LINK);
  64      };
  65  
  66  // Use addMethod to add history to the Node prototype:
  67  Y.Node.addMethod("history", HISTORY);
  68  
  69  // Extend this functionality to NodeLists.
  70  Y.NodeList.importMethod(Y.Node.prototype, "history");
  71  
  72  
  73  }, '@VERSION@', {"requires": ["node", "transition"]});


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1