Skip to content

Instantly share code, notes, and snippets.

@timhunt
Created June 22, 2017 09:48
Show Gist options
  • Save timhunt/a7c7109dcbebe2b50fcad1cdfbcac5b1 to your computer and use it in GitHub Desktop.
Save timhunt/a7c7109dcbebe2b50fcad1cdfbcac5b1 to your computer and use it in GitHub Desktop.
// 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/>.
/**
* Display the info icon explaining why the student is in a subject site.
*
* @package block_subjectlist
* @copyright 2017 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* @module block_subjectlist/infoicon
*/
define(['jquery', 'core/modal_events', 'core/modal_factory'], function ($, ModalEvents, ModalFactory) {
/**
* @alias block_subjectlist/infoicon
*/
var t = {
/**
* Initialise the event handler.
*/
init: function () {
$('body').on('click', '.block_subjectlist-infoicon', t.showInfo);
},
/**
* When the icon is clicked, show the dialogue.
*
* @private
*/
showInfo: function (e) {
e.preventDefault();
ModalFactory.create({
title: M.util.get_string('qualifications', 'block_subjectlist'),
body: $(e.currentTarget).data('whyamihere')
}).done(function (modal) {
modal.show();
modal.getRoot().on(ModalEvents.hidden, function() { modal.destroy(); });
});
}
};
return t;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment