51 lines
No EOL
1.8 KiB
JavaScript
51 lines
No EOL
1.8 KiB
JavaScript
/*eslint no-var: "error" */
|
|
/*eslint no-unused-vars: "off" */
|
|
/*eslint linebreak-style: "off" */
|
|
/*eslint-env es6*/
|
|
// Put this file in path/to/plugin/amd/src
|
|
// You can call it anything you like
|
|
|
|
define(['jquery', 'core/str', 'core/ajax', 'core/modal_factory', 'core/modal_events',
|
|
'local_treestudyplan/handlers', 'local_treestudyplan/debugger'],
|
|
function ($, str, ajax, ModalFactory, ModalEvents,
|
|
handlers, Debugger) {
|
|
let debug = new Debugger("treestudyplan");
|
|
debug.enable();
|
|
let self = {
|
|
init: function init() {
|
|
$('.path-local-treestudyplan a.m-action-confirm').on('click', function (e) {
|
|
e.preventDefault();
|
|
let $link = $(e.currentTarget);
|
|
let href = $link.attr('data-actionhref');
|
|
let text = $link.attr('data-confirmtext');
|
|
let oktext = $link.attr('data-confirmbtn');
|
|
debug.info("Ok", oktext);
|
|
if (undefined == oktext) { oktext = str.get_string('ok'); }
|
|
let title = $link.attr('data-confirmtitle');
|
|
debug.info("Title", title);
|
|
if (undefined == title) { title = str.get_string('confirm'); }
|
|
|
|
debug.info("Link, href, text", $link, href, text);
|
|
|
|
ModalFactory.create({
|
|
type: ModalFactory.types.SAVE_CANCEL,
|
|
title: title,
|
|
body: text,
|
|
}).then(function (modal) {
|
|
modal.setSaveButtonText(oktext);
|
|
|
|
let root = modal.getRoot();
|
|
root.on(ModalEvents.save, function () {
|
|
window.location = href;
|
|
});
|
|
|
|
$(modal.modal).css("max-width", "345px");
|
|
modal.show();
|
|
});
|
|
});
|
|
},
|
|
|
|
|
|
};
|
|
return self;
|
|
}); |