[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/question/yui/build/moodle-question-chooser/ -> moodle-question-chooser.js (source)

   1  YUI.add('moodle-question-chooser', function (Y, NAME) {
   2  
   3  var SELECTORS = {
   4      CREATENEWQUESTION: 'div.createnewquestion',
   5      CREATENEWQUESTIONFORM: 'div.createnewquestion form',
   6      CHOOSERDIALOGUE: 'div.chooserdialogue',
   7      CHOOSERHEADER: 'div.choosertitle'
   8  };
   9  
  10  function Chooser() {
  11      Chooser.superclass.constructor.apply(this, arguments);
  12  }
  13  
  14  Y.extend(Chooser, M.core.chooserdialogue, {
  15      initializer: function() {
  16          Y.all('form').each(function(node) {
  17              if (/question\/addquestion\.php/.test(node.getAttribute('action'))) {
  18                  node.on('submit', this.displayQuestionChooser, this);
  19              }
  20          }, this);
  21      },
  22      displayQuestionChooser: function(e) {
  23          var dialogue = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERDIALOGUE),
  24              header = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERHEADER);
  25  
  26          if (this.container === null) {
  27              // Setup the dialogue, and then prepare the chooser if it's not already been set up.
  28              this.setup_chooser_dialogue(dialogue, header, {});
  29              this.prepare_chooser();
  30          }
  31  
  32          // Update all of the hidden fields within the questionbank form.
  33          var originForm = e.target.ancestor('form', true),
  34              targetForm = this.container.one('form'),
  35              hiddenElements = originForm.all('input[type="hidden"]');
  36  
  37          targetForm.all('input.customfield').remove();
  38          hiddenElements.each(function(field) {
  39              targetForm.appendChild(field.cloneNode())
  40                  .removeAttribute('id')
  41                  .addClass('customfield');
  42          });
  43  
  44          // Display the chooser dialogue.
  45          this.display_chooser(e);
  46      }
  47  }, {
  48      NAME: 'questionChooser'
  49  });
  50  
  51  M.question = M.question || {};
  52  M.question.init_chooser = function(config) {
  53      return new Chooser(config);
  54  };
  55  
  56  
  57  }, '@VERSION@', {"requires": ["moodle-core-chooserdialogue"]});


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