Skip to content

Commit

Permalink
Merge branch 'MDL-47603' of git://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Oct 13, 2014
2 parents bb29fe9 + 84b45a2 commit ec72585
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 37 deletions.
12 changes: 6 additions & 6 deletions mod/quiz/classes/output/edit_renderer.php
Expand Up @@ -877,22 +877,22 @@ protected function initialise_editing_javascript($course, $quiz) {

// 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(
Expand Down
Expand Up @@ -24,11 +24,12 @@ YUI.add('moodle-mod_quiz-quizquestionbank', function (Y, NAME) {
* @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 = {
Expand All @@ -44,6 +45,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.
Expand All @@ -60,8 +62,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();
Expand Down Expand Up @@ -91,6 +92,7 @@ Y.extend(POPUP, Y.Base, {
hidden.set('value', this.addonpage);
}

this.initialiseSearchRegion();
this.dialogue.show();
},

Expand Down Expand Up @@ -135,9 +137,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');
Expand All @@ -157,18 +159,49 @@ 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'));
},

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;
}
});

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -24,11 +24,12 @@ YUI.add('moodle-mod_quiz-quizquestionbank', function (Y, NAME) {
* @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 = {
Expand All @@ -44,6 +45,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.
Expand All @@ -60,8 +62,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();
Expand Down Expand Up @@ -91,6 +92,7 @@ Y.extend(POPUP, Y.Base, {
hidden.set('value', this.addonpage);
}

this.initialiseSearchRegion();
this.dialogue.show();
},

Expand Down Expand Up @@ -132,9 +134,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');
Expand All @@ -153,18 +155,49 @@ 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'));
},

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;
}
});

Expand Down
53 changes: 43 additions & 10 deletions mod/quiz/yui/src/quizquestionbank/js/quizquestionbank.js
Expand Up @@ -22,11 +22,12 @@
* @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 = {
Expand All @@ -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.
Expand All @@ -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();
Expand Down Expand Up @@ -89,6 +90,7 @@ Y.extend(POPUP, Y.Base, {
hidden.set('value', this.addonpage);
}

this.initialiseSearchRegion();
this.dialogue.show();
},

Expand Down Expand Up @@ -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');
Expand All @@ -155,18 +157,49 @@ 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'));
},

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;
}
});

Expand Down

0 comments on commit ec72585

Please sign in to comment.