Merge branch 'MDL-47603' of git://github.com/timhunt/moodle
authorDan Poltawski <dan@moodle.com>
Mon, 13 Oct 2014 12:33:56 +0000 (13:33 +0100)
committerDan Poltawski <dan@moodle.com>
Mon, 13 Oct 2014 12:33:56 +0000 (13:33 +0100)
mod/quiz/classes/output/edit_renderer.php
mod/quiz/yui/build/moodle-mod_quiz-quizquestionbank/moodle-mod_quiz-quizquestionbank-debug.js
mod/quiz/yui/build/moodle-mod_quiz-quizquestionbank/moodle-mod_quiz-quizquestionbank-min.js
mod/quiz/yui/build/moodle-mod_quiz-quizquestionbank/moodle-mod_quiz-quizquestionbank.js
mod/quiz/yui/src/quizquestionbank/js/quizquestionbank.js

index a1c2606..33de44b 100644 (file)
@@ -877,22 +877,22 @@ class edit_renderer extends \plugin_renderer_base {
 
         // Require various strings for the command toolbox.
         $this->page->requires->strings_for_js(array(
-                'moveleft',
+                'clicktohideshow',
                 'deletechecktype',
                 'deletechecktypename',
                 'edittitle',
                 'edittitleinstructions',
-                'show',
+                'emptydragdropregion',
                 'hide',
-                'clicktochangeinbrackets',
-                'markthistopic',
                 'markedthistopic',
+                'markthistopic',
                 'move',
-                'movesection',
                 'movecontent',
+                'moveleft',
+                'movesection',
                 'selectall',
+                'show',
                 'tocontent',
-                'emptydragdropregion'
         ), 'moodle');
 
         $this->page->requires->strings_for_js(array(
index cf9daa2..132d92c 100644 (file)
Binary files a/mod/quiz/yui/build/moodle-mod_quiz-quizquestionbank/moodle-mod_quiz-quizquestionbank-debug.js and b/mod/quiz/yui/build/moodle-mod_quiz-quizquestionbank/moodle-mod_quiz-quizquestionbank-debug.js differ
index ad574e5..af57316 100644 (file)
Binary files a/mod/quiz/yui/build/moodle-mod_quiz-quizquestionbank/moodle-mod_quiz-quizquestionbank-min.js and b/mod/quiz/yui/build/moodle-mod_quiz-quizquestionbank/moodle-mod_quiz-quizquestionbank-min.js differ
index a176a6d..4d4e4eb 100644 (file)
Binary files a/mod/quiz/yui/build/moodle-mod_quiz-quizquestionbank/moodle-mod_quiz-quizquestionbank.js and b/mod/quiz/yui/build/moodle-mod_quiz-quizquestionbank/moodle-mod_quiz-quizquestionbank.js differ
index d21ee3c..4d3becc 100644 (file)
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-
 var CSS = {
-        QBANKLOADING: 'div.questionbankloading',
-        ADDQUESTIONLINKS: 'ul.menu a.questionbank',
-        ADDTOQUIZCONTAINER: 'td.addtoquizaction'
+        QBANKLOADING:       'div.questionbankloading',
+        ADDQUESTIONLINKS:   'ul.menu a.questionbank',
+        ADDTOQUIZCONTAINER: 'td.addtoquizaction',
+        PREVIEWCONTAINER:   'td.previewaction',
+        SEARCHOPTIONS:      '#advancedsearch'
 };
 
 var PARAMS = {
@@ -42,6 +43,7 @@ Y.extend(POPUP, Y.Base, {
     loadingDiv: '',
     dialogue: null,
     addonpage: 0,
+    searchRegionInitialised: false,
 
     create_dialogue: function() {
         // Create a dialogue on the page and hide it.
@@ -58,8 +60,7 @@ Y.extend(POPUP, Y.Base, {
             extraClasses: ['mod_quiz_qbank_dialogue']
         };
         this.dialogue = new M.core.dialogue(config);
-        this.dialogue.bodyNode.delegate('click', this.link_clicked,
-                '.paging a[href], thead tr a[href]', this);
+        this.dialogue.bodyNode.delegate('click', this.link_clicked, 'a[href]', this);
         this.dialogue.hide();
 
         this.loadingDiv = this.dialogue.bodyNode.getHTML();
@@ -89,6 +90,7 @@ Y.extend(POPUP, Y.Base, {
             hidden.set('value', this.addonpage);
         }
 
+        this.initialiseSearchRegion();
         this.dialogue.show();
     },
 
@@ -133,9 +135,9 @@ Y.extend(POPUP, Y.Base, {
         }
         M.question.qbankmanager.init();
 
-        if (Y.one('#advancedsearch')) {
-            M.util.init_collapsible_region(Y, "advancedsearch", "question_bank_advanced_search",
-                    M.util.get_string('clicktohideshow'));
+        this.searchRegionInitialised = false;
+        if (this.dialogue.get('visible')) {
+            this.initialiseSearchRegion();
         }
 
         this.dialogue.fire('widget:contentUpdate');
@@ -155,11 +157,29 @@ Y.extend(POPUP, Y.Base, {
     },
 
     link_clicked: function(e) {
+        // Add question to quiz. mofify the URL, then let it work as normal.
         if (e.currentTarget.ancestor(CSS.ADDTOQUIZCONTAINER)) {
-            // These links need to work like normal, after we modify the URL.
             e.currentTarget.set('href', e.currentTarget.get('href') + '&addonpage=' + this.addonpage);
             return;
         }
+
+        // Question preview. Needs to open in a pop-up.
+        if (e.currentTarget.ancestor(CSS.PREVIEWCONTAINER)) {
+            openpopup(e, {
+                url: e.currentTarget.get('href'),
+                name: 'questionpreview',
+                options: 'height=600,width=800,top=0,left=0,menubar=0,location=0,scrollbars,resizable,toolbar,status,directories=0,fullscreen=0,dependent'
+            });
+            return;
+        }
+
+        // Click on expand/collaspse search-options. Has its own handler.
+        // We should not interfere.
+        if (e.currentTarget.ancestor(CSS.SEARCHOPTIONS)) {
+            return;
+        }
+
+        // Anything else means reload the pop-up contents.
         e.preventDefault();
         this.load_content(e.currentTarget.get('search'));
     },
@@ -167,6 +187,19 @@ Y.extend(POPUP, Y.Base, {
     options_changed: function(e) {
         e.preventDefault();
         this.load_content('?' + Y.IO.stringify(e.currentTarget.get('form')));
+    },
+
+    initialiseSearchRegion: function() {
+        if (this.searchRegionInitialised === true) {
+            return;
+        }
+        if (!Y.one(CSS.SEARCHOPTIONS)) {
+            return;
+        }
+
+        M.util.init_collapsible_region(Y, "advancedsearch", "question_bank_advanced_search",
+                M.util.get_string('clicktohideshow', 'moodle'));
+        this.searchRegionInitialised = true;
     }
 });