2020-09-03 21:25:42 +02:00
|
|
|
<div class="searchresult">
|
|
|
|
<ul>
|
|
|
|
{{#searchresults}}
|
2020-09-13 21:07:32 +02:00
|
|
|
<li><a href="javascript:;" class="searchresults" data-type="{{type}}" data-name="{{name}}" data-add="0">{{description}}</a>
|
|
|
|
<a href="javascript:;" class="searchresults" data-type="{{type}}" data-name="{{name}}" data-add="1">{{# pix}} t/add, core, Hinzufügen {{/ pix}}</a></li>
|
2020-09-03 21:25:42 +02:00
|
|
|
{{/searchresults}}
|
|
|
|
</ul>
|
|
|
|
{{^searchresults}}Keine Treffer{{/searchresults}}
|
|
|
|
</div>
|
|
|
|
{{# js }}
|
|
|
|
require([
|
|
|
|
'jquery','core/ajax','core/templates', 'core/notification'
|
|
|
|
] , function($, ajax, templates, notification) {
|
|
|
|
|
|
|
|
|
|
|
|
function load_timetable(type, name, add) {
|
|
|
|
//alert(searchstring);
|
|
|
|
var promises = ajax.call([
|
|
|
|
{ methodname: 'mod_timetable_get', args: { type: type, name: name, week: 0 } },
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (add=='1') {
|
|
|
|
promises[0].done(function(response) {
|
|
|
|
templates.render('mod_timetable/timetable',response).done(function(html, js) {
|
2020-09-13 21:07:32 +02:00
|
|
|
$('.timetables').append(html);
|
2020-09-03 21:25:42 +02:00
|
|
|
templates.runTemplateJS(js);
|
|
|
|
}).fail(notification.exception);
|
|
|
|
}).fail(function(ex) {
|
|
|
|
// do something with the exception
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
promises[0].done(function(response) {
|
|
|
|
templates.render('mod_timetable/timetable',response).done(function(html, js) {
|
2020-09-13 21:07:32 +02:00
|
|
|
if (!($('.timetables .timetable').length)) {
|
|
|
|
$('.timetables').prepend("<div class='timetable'></div>");
|
|
|
|
}
|
|
|
|
$('.timetables .timetable').first().replaceWith(html);
|
2020-09-03 21:25:42 +02:00
|
|
|
templates.runTemplateJS(js);
|
|
|
|
}).fail(notification.exception);
|
|
|
|
}).fail(function(ex) {
|
|
|
|
// do something with the exception
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(".searchresults").click(function() {
|
2020-09-13 21:07:32 +02:00
|
|
|
console.log($(event.target));
|
|
|
|
element = $(event.target);
|
|
|
|
while (!(element.is('a'))) {
|
|
|
|
element = element.parent();
|
|
|
|
}
|
|
|
|
console.log(element);
|
|
|
|
load_timetable(element.data('type'),element.data('name'),element.data('add'));
|
2020-09-03 21:25:42 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
{{/ js }}
|