Commit 573afde5 authored by Myriam Delaruelle's avatar Myriam Delaruelle

Bugfix #05: gestion du conflit avec jquery sur certains Moodles. Crédit @Elise

parent e7a3927c
...@@ -306,6 +306,7 @@ class view_competency_iena_competencies ...@@ -306,6 +306,7 @@ class view_competency_iena_competencies
<script type=\"text/javascript\" charset=\"utf8\" src=\"https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js\"></script> <script type=\"text/javascript\" charset=\"utf8\" src=\"https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js\"></script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$.noConflict();
var table = $('#example').DataTable( { var table = $('#example').DataTable( {
\"language\": { \"language\": {
\"url\": \"https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json\", \"url\": \"https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json\",
......
...@@ -36,92 +36,93 @@ class view_competency_iena_competencies_mgmt ...@@ -36,92 +36,93 @@ class view_competency_iena_competencies_mgmt
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#tab_mgmt').DataTable({ $.noConflict();
responsive: true, $('#tab_mgmt').DataTable({
responsive: true,
\"language\": {
\"url\": \"https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json\" \"language\": {
}, \"url\": \"https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json\"
\"bSort\": false, },
scrollCollapse: true, \"bSort\": false,
fixedColumns: { scrollCollapse: true,
leftColumns: 1 fixedColumns: {
} leftColumns: 1
}); }
});
setTimeout(function() { setTimeout(function() {
$('#tab_mgmt_filter').hide(); $('#tab_mgmt_filter').hide();
$('#tab_mgmt_length').hide(); $('#tab_mgmt_length').hide();
$('#tab_mgmt_info').hide(); $('#tab_mgmt_info').hide();
}, 500); }, 500);
$('.fram-iena').hide(); $('.fram-iena').hide();
// $('#btn-comp-iena').hide(); // $('#btn-comp-iena').hide();
$( '#select-framework' ).on( 'change', function () { $( '#select-framework' ).on( 'change', function () {
$('.fram-iena').hide(); $('.fram-iena').hide();
$('#fram-'+$(this).val()).show(); $('#fram-'+$(this).val()).show();
}); });
$('#btn-comp-iena').click(function(){ $('#btn-comp-iena').click(function(){
var idcomp = $('#id-comp-iena').val(); var idcomp = $('#id-comp-iena').val();
var idcourse = $('#id-course-iena').val(); var idcourse = $('#id-course-iena').val();
var value = []; var value = [];
value[0] = idcomp; value[0] = idcomp;
value[1] = idcourse; value[1] = idcourse;
$.ajax({ $.ajax({
url: '$CFG->wwwroot/blocks/competency_iena/competency_iena_competencies_api.php?courseid='+idcourse, url: '$CFG->wwwroot/blocks/competency_iena/competency_iena_competencies_api.php?courseid='+idcourse,
type: 'POST', type: 'POST',
timeout: 10000, timeout: 10000,
contentType: 'application/x-www-form-urlencoded', contentType: 'application/x-www-form-urlencoded',
data: {addcomp:value}, data: {addcomp:value},
success: function(result) { success: function(result) {
if (result.trim() == \"true\"){ if (result.trim() == \"true\"){
location.reload(); location.reload();
} else { } else {
alert('Cette compétence est déja liée au cours.'); alert('Cette compétence est déja liée au cours.');
} }
} }
}); });
}); });
$('#filter-iena-competence').keyup(function(){ $('#filter-iena-competence').keyup(function(){
var searchText = $(this).val(); var searchText = $(this).val();
$('ul > li').each(function(){ $('ul > li').each(function(){
var reg = new RegExp(searchText, 'gi'); var reg = new RegExp(searchText, 'gi');
var currentLiText = $(this).text(); var currentLiText = $(this).text();
var showCurrentLi = reg.test(currentLiText); var showCurrentLi = reg.test(currentLiText);
if (searchText){ if (searchText){
$(this).toggle(showCurrentLi); $(this).toggle(showCurrentLi);
} else { } else {
$(this).hide(showCurrentLi); $(this).hide(showCurrentLi);
$('#fram-'+$( '#select-framework' ).val()).show(); $('#fram-'+$( '#select-framework' ).val()).show();
} }
}); });
}); });
}); });
function showFilter(obj) function showFilter(obj)
{ {
var p = obj.parentNode; var p = obj.parentNode;
var c = p.children; var c = p.children;
if (c[2].dataset.edit == 'editOn') { if (c[2].dataset.edit == 'editOn') {
c[0].setAttribute(\"style\", \"display:inline\"); c[0].setAttribute(\"style\", \"display:inline\");
c[1].setAttribute(\"style\", \"display:none\"); c[1].setAttribute(\"style\", \"display:none\");
c[2].dataset.edit = 'editOff'; c[2].dataset.edit = 'editOff';
} else { } else {
c[0].setAttribute(\"style\", \"display:none\"); c[0].setAttribute(\"style\", \"display:none\");
c[1].setAttribute(\"style\", \"display:inline\"); c[1].setAttribute(\"style\", \"display:inline\");
c[2].dataset.edit = 'editOn'; c[2].dataset.edit = 'editOn';
} }
// console.log(c) // console.log(c)
// c[2].setAttribute(\"style\", \"display:none\"); // c[2].setAttribute(\"style\", \"display:none\");
} }
......
...@@ -157,6 +157,7 @@ class view_competency_iena_competency_students ...@@ -157,6 +157,7 @@ class view_competency_iena_competency_students
<script type=\"text/javascript\" charset=\"utf8\" src=\"https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js\"></script> <script type=\"text/javascript\" charset=\"utf8\" src=\"https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js\"></script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$.noConflict();
var table = $('#example').DataTable( { var table = $('#example').DataTable( {
\"language\": { \"language\": {
\"url\": \"https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json\" \"url\": \"https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json\"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment