From ecbc2a2f2509a0350242d73daa762ab04aea5e33 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 29 Oct 2015 13:49:56 +0800 Subject: [PATCH] MDL-51966 forms: case-insensitive search in autocomplete --- lib/amd/build/form-autocomplete.min.js | 2 +- lib/amd/src/form-autocomplete.js | 73 +++++++++++++++++++++----- lib/form/autocomplete.php | 11 +++- 3 files changed, 71 insertions(+), 15 deletions(-) diff --git a/lib/amd/build/form-autocomplete.min.js b/lib/amd/build/form-autocomplete.min.js index bced4845ea0..4fbc871e001 100644 --- a/lib/amd/build/form-autocomplete.min.js +++ b/lib/amd/build/form-autocomplete.min.js @@ -1 +1 @@ -define(["jquery","core/log","core/str","core/templates","core/notification"],function(a,b,c,d,e){var f={DOWN:40,ENTER:13,SPACE:32,ESCAPE:27,COMMA:188,UP:38},g=null,h=function(b,c){var d=a(document.getElementById(c)),e=d.children("[aria-selected=true]").length;for(b%=e;0>b;)b+=e;var f=a(d.children("[aria-selected=true]").get(b)),g=c+"-"+b;d.children().attr("data-active-selection",!1).attr("id",""),f.attr("data-active-selection",!0).attr("id",g),d.attr("aria-activedescendant",g)},i=function(b,c,d,e,f){var g=a(d).attr("data-value");f&&e.children("option").each(function(b,c){a(c).attr("value")==g&&(a(c).prop("selected",!1),a(c).attr("data-iscustom")&&a(c).remove())}),r(c,b,e,f)},j=function(b,c,d){var e=a(document.getElementById(c)),f=a(document.getElementById(d)),g=f.children("[aria-hidden=false]").length;for(b%=g;0>b;)b+=g;var h=a(f.children("[aria-hidden=false]").get(b)),i=a(f.children("[role=option]")).index(h),j=d+"-"+i;f.children().attr("aria-selected",!1).attr("id",""),h.attr("aria-selected",!0).attr("id",j),e.attr("aria-activedescendant",j)},k=function(b,c){var d=a(document.getElementById(c)),e=d.children("[aria-selected=true]"),f=d.children("[aria-hidden=false]").index(e);j(f+1,b,c)},l=function(b){var c=a(document.getElementById(b)),d=c.children("[data-active-selection=true]");if(!d)return void h(0,b);var e=c.children("[aria-selected=true]").index(d);h(e-1,b)},m=function(b){var c=a(document.getElementById(b)),d=c.children("[data-active-selection=true]");if(!d)return void h(0,b);var e=c.children("[aria-selected=true]").index(d);h(e+1,b)},n=function(b,c){var d=a(document.getElementById(c)),e=d.children("[aria-selected=true]"),f=d.children("[aria-hidden=false]").index(e);j(f-1,b,c)},o=function(b,c,d){var e=a(document.getElementById(b)),f=a(document.getElementById(c));e.attr("aria-expanded",!1).attr("aria-activedescendant",d),f.hide().attr("aria-hidden",!0)},p=function(b,f,g,h,i,k){var l=a(document.getElementById(f)),m=a(document.getElementById(g)),n=!1,o=[];h.children("option").each(function(b,c){a(c).prop("selected")!==!0&&(o[o.length]={label:c.innerHTML,value:a(c).attr("value")})}),d.render("core/form_autocomplete_suggestions",{inputId:f,suggestionsId:g,options:o,multiple:i}).done(function(d){m.replaceWith(d),m=a(document.getElementById(g)),m.show().attr("aria-hidden",!1),m.children().each(function(c,d){d=a(d),d.text().indexOf(b)>-1?(d.show().attr("aria-hidden",!1),n=!0):d.hide().attr("aria-hidden",!0)}),l.attr("aria-expanded",!0),n?k||j(0,f,g):c.get_string("nosuggestions","form").done(function(a){m.html(a)})}).fail(e.exception)},q=function(b,c,d,e,f){var g=a(document.getElementById(b)),h=g.val(),i=h.split(","),j=!1;a.each(i,function(b,c){if(c=c.trim(),""!==c&&(e||f.children("option").prop("selected",!1),f.children("option").each(function(b,d){a(d).attr("value")==c&&(j=!0,a(d).prop("selected",!0))}),!j)){var d=a("