Skip to content
Snippets Groups Projects
Commit 9f054cfc authored by Tobias Baden's avatar Tobias Baden
Browse files

- Search starts after 3 chars

- idSearching still without char limitation
- Updated version number
parent 5bb861b2
No related branches found
No related tags found
No related merge requests found
/*! hshcourselist 2018-08-29 */ /*! hshcourselist 2018-08-29 */
define(["jquery"],function(a){function b(b,c,d,e,f,g,h,i,j){c&&(a("#hshcourseprogress").show(),a.ajax({type:"GET",url:j+"/blocks/hshcourselist/hshcourselist.php",data:"course="+b+"&instanceid="+e+"&sesskey="+f+"&contextid="+g+"&idSearching="+h+"&orderbysemester="+i,dataType:"json",success:function(b){var c=JSON.stringify(b),e=JSON.parse(c),f=a("<ul class='list-group' id='hshcourselistul'></ul>");e.length>0&&a.each(e,function(b,c){switch(d){case"0":displaystr=c.shortname;break;case"1":displaystr=c.fullname;break;case"2":displaystr=c.shortname+": "+c.fullname;break;default:displaystr=c.fullname}a('<li class="list-group-item hshcoursesearchlistitem " value="'+c.id+'"><a href="'+j+"/course/view.php?id="+c.id+'">'+displaystr+"</a> </li>").appendTo(f)}),a("#hshcourselistul").replaceWith(f),a("#hshcourseprogress").hide()},error:function(){console.error("error"),"abort"!==o.statusText&&(a("#hshcourseprogress").hide(),void 0!==o.statusText&&console.error("ABORT + STATUS : "+o.statusText))}}))}return{init:function(c,d){var e,c=c,f=c.instanceid,g=c.sesskey,h=c.displaymode,i=c.contextid,j=!1,k=!1,l=c.orderbysemester;a("#hshcourseprogress").hide(),a(".idSarchingLabel").hide(),a("#orderbysemestercheckbox_id").on("change",function(){l=document.getElementById("orderbysemestercheckbox_id").checked,j=!0,e=document.getElementById("hshcourselistsearch").value,"#"===e.slice(0,1)?(a(".idSarchingLabel").show(),k=!0,e=e.slice(1)):(a(".idSarchingLabel").hide(),k=!1),b(e,j,h,f,g,i,k,l,d)}),a("#hshcourselistsearch").on("keyup",function(c){var m=c.keyCode;l=document.getElementById("orderbysemestercheckbox_id").checked,40!==m&&38!==m&&13!==m&&(j=!0,e=document.getElementById("hshcourselistsearch").value,"#"===e.slice(0,1)?(a(".idSarchingLabel").show(),k=!0,e=e.slice(1)):(a(".idSarchingLabel").hide(),k=!1),b(e,j,h,f,g,i,k,l,d))}),a("#hshcourseform").on("submit",function(a){a.preventDefault,j=!0,k=!1,l=document.getElementById("orderbysemestercheckbox_id").checked,e=document.getElementById("hshcourselistsearch").value,"#"===e.slice(0,1)?(k=!0,e=e.slice(1)):k=!1,b(e,j,h,f,g,i,k,l,d)})}}}); define(["jquery"],function(a){function b(b,c,d,e,f,g,h,i,j){c&&(a("#hshcourseprogress").show(),a.ajax({type:"GET",url:j+"/blocks/hshcourselist/hshcourselist.php",data:"course="+b+"&instanceid="+e+"&sesskey="+f+"&contextid="+g+"&idSearching="+h+"&orderbysemester="+i,dataType:"json",success:function(b){var c=JSON.stringify(b),e=JSON.parse(c),f=a("<ul class='list-group' id='hshcourselistul'></ul>");e.length>0&&a.each(e,function(b,c){switch(d){case"0":displaystr=c.shortname;break;case"1":displaystr=c.fullname;break;case"2":displaystr=c.shortname+": "+c.fullname;break;default:displaystr=c.fullname}a('<li class="list-group-item hshcoursesearchlistitem " value="'+c.id+'"><a href="'+j+"/course/view.php?id="+c.id+'">'+displaystr+"</a> </li>").appendTo(f)}),a("#hshcourselistul").replaceWith(f),a("#hshcourseprogress").hide()},error:function(){console.error("error"),"abort"!==o.statusText&&(a("#hshcourseprogress").hide(),void 0!==o.statusText&&console.error("ABORT + STATUS : "+o.statusText))}}))}return{init:function(c,d){var e,c=c,f=c.instanceid,g=c.sesskey,h=c.displaymode,i=c.contextid,j=!1,k=!1,l=c.orderbysemester;a("#hshcourseprogress").hide(),a(".idSarchingLabel").hide(),a("#orderbysemestercheckbox_id").on("change",function(){l=document.getElementById("orderbysemestercheckbox_id").checked,j=!0,e=document.getElementById("hshcourselistsearch").value,"#"===e.slice(0,1)?(a(".idSarchingLabel").show(),k=!0,e=e.slice(1)):(a(".idSarchingLabel").hide(),k=!1),(1==k||e.length>=3)&&b(e,j,h,f,g,i,k,l,d)}),a("#hshcourselistsearch").on("keyup",function(c){var m=c.keyCode;l=document.getElementById("orderbysemestercheckbox_id").checked,40!==m&&38!==m&&13!==m&&(j=!0,e=document.getElementById("hshcourselistsearch").value,"#"===e.slice(0,1)?(a(".idSarchingLabel").show(),k=!0,e=e.slice(1)):(a(".idSarchingLabel").hide(),k=!1),(1==k||e.length>=3)&&b(e,j,h,f,g,i,k,l,d))}),a("#hshcourseform").on("submit",function(a){a.preventDefault,j=!0,k=!1,l=document.getElementById("orderbysemestercheckbox_id").checked,e=document.getElementById("hshcourselistsearch").value,"#"===e.slice(0,1)?(k=!0,e=e.slice(1)):k=!1,(1==k||e.length>=3)&&b(e,j,h,f,g,i,k,l,d)})}}});
\ No newline at end of file \ No newline at end of file
...@@ -82,7 +82,11 @@ define(['jquery'], function ($) { ...@@ -82,7 +82,11 @@ define(['jquery'], function ($) {
$(".idSarchingLabel").hide(); $(".idSarchingLabel").hide();
idSearching = false; idSearching = false;
} }
if (idSearching == true || searchstring.length >= 3) {
search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester, wwwroot); search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester, wwwroot);
} else {
// Search start after 3 chars or searching by id
}
}); });
$('#hshcourselistsearch').on('keyup', function (e) { $('#hshcourselistsearch').on('keyup', function (e) {
...@@ -99,7 +103,11 @@ define(['jquery'], function ($) { ...@@ -99,7 +103,11 @@ define(['jquery'], function ($) {
$(".idSarchingLabel").hide(); $(".idSarchingLabel").hide();
idSearching = false; idSearching = false;
} }
if (idSearching == true || searchstring.length >= 3) {
search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester, wwwroot); search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester, wwwroot);
} else {
// Search start after 3 chars or searching by id
}
} }
}); });
$('#hshcourseform').on('submit', function (e) { $('#hshcourseform').on('submit', function (e) {
...@@ -114,7 +122,11 @@ define(['jquery'], function ($) { ...@@ -114,7 +122,11 @@ define(['jquery'], function ($) {
} else { } else {
idSearching = false; idSearching = false;
} }
if (idSearching == true || searchstring.length >= 3) {
search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester, wwwroot); search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester, wwwroot);
} else {
// Search start after 3 chars or searching by id
}
}); });
}, },
} }
......
<?php <?php
$plugin->component = 'block_hshcourselist'; $plugin->component = 'block_hshcourselist';
$plugin->version = 2018082802; // YYYYMMDDHH $plugin->version = 2018082803; // YYYYMMDDHH
$plugin->requires = 2016112900; // YYYYMMDDHH $plugin->requires = 2016112900; // YYYYMMDDHH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment