MDL-43687, convert question/preview.js to the new yui format

This commit is contained in:
M Kassaei 2014-01-14 11:40:57 +00:00
parent 9788e26805
commit 7258470276
7 changed files with 122 additions and 20 deletions

View File

@ -275,12 +275,6 @@ print_collapsible_region_end();
// Display the settings form.
$optionsform->display();
$PAGE->requires->js_init_call('M.core_question_preview.init', null, false, array(
'name' => 'core_question_preview',
'fullpath' => '/question/preview.js',
'requires' => array('base', 'dom', 'event-delegate', 'event-key', 'core_question_engine'),
'strings' => array(
array('closepreview', 'question'),
)));
$PAGE->requires->yui_module('moodle-question-preview', 'M.question.preview.init');
echo $OUTPUT->footer();

View File

@ -0,0 +1,45 @@
YUI.add('moodle-question-preview', function (Y, NAME) {
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* JavaScript required by the question preview pop-up.
*
* @module moodle-question-preview
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
M.question = M.question || {};
/**
* Initialise JavaScript-specific parts of the question preview popup.
*/
M.question.preview.init = function(Y) {
M.core_question_engine.init_form(Y, '#responseform');
// Add a close button to the window.
var closebutton = Y.Node.create('<input type="button" />');
closebutton.set('value', M.str.question.closepreview);
Y.one('#previewcontrols').append(closebutton);
Y.on('click', function() { window.close(); }, closebutton);
// Stop a question form being submitted more than once.
Y.on('submit', M.core_question_engine.prevent_repeat_submission, '#mform1', null, Y);
};
}, '@VERSION@', {"requires": ["base", "dom", "event-delegate", "event-key", "core_question_engine"]});

View File

@ -0,0 +1 @@
YUI.add("moodle-question-preview",function(e,t){M.question=M.question||{},M.question.preview.init=function(e){M.core_question_engine.init_form(e,"#responseform");var t=e.Node.create('<input type="button" />');t.set("value",M.str.question.closepreview),e.one("#previewcontrols").append(t),e.on("click",function(){window.close()},t),e.on("submit",M.core_question_engine.prevent_repeat_submission,"#mform1",null,e)}},"@VERSION@",{requires:["base","dom","event-delegate","event-key","core_question_engine"]});

View File

@ -0,0 +1,45 @@
YUI.add('moodle-question-preview', function (Y, NAME) {
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* JavaScript required by the question preview pop-up.
*
* @module moodle-question-preview
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
M.question = M.question || {};
/**
* Initialise JavaScript-specific parts of the question preview popup.
*/
M.question.preview.init = function(Y) {
M.core_question_engine.init_form(Y, '#responseform');
// Add a close button to the window.
var closebutton = Y.Node.create('<input type="button" />');
closebutton.set('value', M.str.question.closepreview);
Y.one('#previewcontrols').append(closebutton);
Y.on('click', function() { window.close(); }, closebutton);
// Stop a question form being submitted more than once.
Y.on('submit', M.core_question_engine.prevent_repeat_submission, '#mform1', null, Y);
};
}, '@VERSION@', {"requires": ["base", "dom", "event-delegate", "event-key", "core_question_engine"]});

View File

@ -0,0 +1,10 @@
{
"name": "moodle-question-preview",
"builds": {
"moodle-question-preview": {
"jsfiles": [
"preview.js"
]
}
}
}

View File

@ -16,29 +16,25 @@
/**
* JavaScript required by the question preview pop-up.
*
* @package moodlecore
* @subpackage questionengine
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @module moodle-question-preview
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
M.core_question_preview = M.core_question_preview || {};
M.question = M.question || {};
/**
* Initialise JavaScript-specific parts of the question preview popup.
*/
M.core_question_preview.init = function(Y) {
M.question.preview.init = function(Y) {
M.core_question_engine.init_form(Y, '#responseform');
// Add a close button to the window.
var closebutton = Y.Node.create('<input type="button" />');
closebutton.set('value', M.str.question.closepreview);
Y.one('#previewcontrols').append(closebutton);
Y.on('click', function() { window.close() }, closebutton);
Y.on('click', function() { window.close(); }, closebutton);
// Make changing the settings disable all submit buttons, like clicking one
// of the question buttons does.
Y.on('submit', M.core_question_engine.prevent_repeat_submission, '#mform1', null, Y)
}
// Stop a question form being submitted more than once.
Y.on('submit', M.core_question_engine.prevent_repeat_submission, '#mform1', null, Y);
};

View File

@ -0,0 +1,11 @@
{
"moodle-question-preview": {
"requires": [
"base",
"dom",
"event-delegate",
"event-key",
"core_question_engine"
]
}
}