[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/quiz/yui/src/randomquestion/js/ -> randomquestion.js (source)

   1  // This file is part of Moodle - http://moodle.org/
   2  //
   3  // Moodle is free software: you can redistribute it and/or modify
   4  // it under the terms of the GNU General Public License as published by
   5  // the Free Software Foundation, either version 3 of the License, or
   6  // (at your option) any later version.
   7  //
   8  // Moodle is distributed in the hope that it will be useful,
   9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11  // GNU General Public License for more details.
  12  //
  13  // You should have received a copy of the GNU General Public License
  14  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  15  
  16  
  17  /**
  18   * Add a random question functionality for a popup in quiz editing page.
  19   *
  20   * @package   mod_quiz
  21   * @copyright 2014 The Open University
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  var CSS = {
  26      RANDOMQUESTIONFORM: 'div.randomquestionformforpopup',
  27      PAGEHIDDENINPUT: 'input#rform_qpage',
  28      RANDOMQUESTIONLINKS: 'ul.menu a.addarandomquestion'
  29  };
  30  
  31  var PARAMS = {
  32      PAGE: 'addonpage',
  33      HEADER: 'header',
  34      FORM: 'form'
  35  };
  36  
  37  var POPUP = function() {
  38      POPUP.superclass.constructor.apply(this, arguments);
  39  };
  40  
  41  Y.extend(POPUP, Y.Base, {
  42  
  43      dialogue: function(header) {
  44          // Create a dialogue on the page and hide it.
  45          var config = {
  46              headerContent: header,
  47              bodyContent: Y.one(CSS.RANDOMQUESTIONFORM),
  48              draggable: true,
  49              modal: true,
  50              zIndex: 1000,
  51              centered: false,
  52              width: 'auto',
  53              visible: false,
  54              postmethod: 'form',
  55              footerContent: null
  56          };
  57          var popup = {dialog: null};
  58          popup.dialog = new M.core.dialogue(config);
  59          popup.dialog.show();
  60      },
  61  
  62      initializer: function() {
  63          Y.one('body').delegate('click', this.display_dialogue, CSS.RANDOMQUESTIONLINKS, this);
  64      },
  65  
  66      display_dialogue: function(e) {
  67          e.preventDefault();
  68  
  69          Y.one(CSS.RANDOMQUESTIONFORM + ' ' + CSS.PAGEHIDDENINPUT).set('value',
  70                  e.currentTarget.getData(PARAMS.PAGE));
  71  
  72          this.dialogue(e.currentTarget.getData(PARAMS.HEADER));
  73      }
  74  });
  75  
  76  M.mod_quiz = M.mod_quiz || {};
  77  M.mod_quiz.randomquestion = M.mod_quiz.randomquestion || {};
  78  M.mod_quiz.randomquestion.init = function() {
  79      return new POPUP();
  80  };


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