MDL-43687, convert question/preview.js to the new yui format
authorM Kassaei <m.kassaei@open.ac.uk>
Tue, 14 Jan 2014 11:40:57 +0000 (11:40 +0000)
committerM Kassaei <m.kassaei@open.ac.uk>
Wed, 29 Jan 2014 11:37:57 +0000 (11:37 +0000)
question/preview.php
question/yui/build/moodle-question-preview/moodle-question-preview-debug.js [new file with mode: 0644]
question/yui/build/moodle-question-preview/moodle-question-preview-min.js [new file with mode: 0644]
question/yui/build/moodle-question-preview/moodle-question-preview.js [new file with mode: 0644]
question/yui/src/preview/build.json [new file with mode: 0644]
question/yui/src/preview/js/preview.js [moved from question/preview.js with 70% similarity]
question/yui/src/preview/meta/preview.json [new file with mode: 0644]

index f8de4ee..5212b5e 100644 (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();
 
diff --git a/question/yui/build/moodle-question-preview/moodle-question-preview-debug.js b/question/yui/build/moodle-question-preview/moodle-question-preview-debug.js
new file mode 100644 (file)
index 0000000..7922286
Binary files /dev/null and b/question/yui/build/moodle-question-preview/moodle-question-preview-debug.js differ
diff --git a/question/yui/build/moodle-question-preview/moodle-question-preview-min.js b/question/yui/build/moodle-question-preview/moodle-question-preview-min.js
new file mode 100644 (file)
index 0000000..4f8598d
Binary files /dev/null and b/question/yui/build/moodle-question-preview/moodle-question-preview-min.js differ
diff --git a/question/yui/build/moodle-question-preview/moodle-question-preview.js b/question/yui/build/moodle-question-preview/moodle-question-preview.js
new file mode 100644 (file)
index 0000000..7922286
Binary files /dev/null and b/question/yui/build/moodle-question-preview/moodle-question-preview.js differ
diff --git a/question/yui/src/preview/build.json b/question/yui/src/preview/build.json
new file mode 100644 (file)
index 0000000..ace3683
--- /dev/null
@@ -0,0 +1,10 @@
+{
+    "name": "moodle-question-preview",
+    "builds": {
+        "moodle-question-preview": {
+            "jsfiles": [
+                "preview.js"
+            ]
+        }
+    }
+}
similarity index 70%
rename from question/preview.js
rename to question/yui/src/preview/js/preview.js
index 9cd4e59..744253a 100644 (file)
 /**
  * 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);
+};
diff --git a/question/yui/src/preview/meta/preview.json b/question/yui/src/preview/meta/preview.json
new file mode 100644 (file)
index 0000000..9291a13
--- /dev/null
@@ -0,0 +1,11 @@
+{
+  "moodle-question-preview": {
+    "requires": [
+        "base",
+        "dom",
+        "event-delegate",
+        "event-key",
+        "core_question_engine"
+    ]
+  }
+}