diff --git a/admin/tool/lp/templates/form-user-selector-suggestion.mustache b/admin/tool/lp/templates/form-user-selector-suggestion.mustache index 0946f788069..61557f9ab1f 100644 --- a/admin/tool/lp/templates/form-user-selector-suggestion.mustache +++ b/admin/tool/lp/templates/form-user-selector-suggestion.mustache @@ -49,7 +49,7 @@ } }} <span> - <img height="18" src="{{profileimageurlsmall}}" alt="" role="presentation"> + <img height="12" src="{{profileimageurlsmall}}" alt="" role="presentation"> <span>{{fullname}}</span> {{#hasidentity}} <span><small>{{identity}}</small></span> diff --git a/enrol/manual/templates/form-user-selector-suggestion.mustache b/enrol/manual/templates/form-user-selector-suggestion.mustache index a55b86746e6..ab9b862b0ad 100644 --- a/enrol/manual/templates/form-user-selector-suggestion.mustache +++ b/enrol/manual/templates/form-user-selector-suggestion.mustache @@ -49,7 +49,7 @@ } }} <span> - <img height="18" src="{{profileimageurlsmall}}" alt="" role="presentation"> + <img height="12" src="{{profileimageurlsmall}}" alt="" role="presentation"> <span>{{fullname}}</span> {{#hasidentity}} <span><small>{{identity}}</small></span> diff --git a/lib/amd/build/form-autocomplete.min.js b/lib/amd/build/form-autocomplete.min.js index 233e46e18dc..21643189379 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:44,UP:38},g=function(b,c){var d=a(document.getElementById(c.selectionId)),e=d.children("[aria-selected=true]").length;for(b%=e;b<0;)b+=e;var f=a(d.children("[aria-selected=true]").get(b)),g=c.selectionId+"-"+b;d.children().attr("data-active-selection",!1).attr("id",""),f.attr("data-active-selection",!0).attr("id",g),d.attr("aria-activedescendant",g)},h=function(b,c,f){var h=[],i=a(document.getElementById(c.selectionId)),j=i.attr("aria-activedescendant"),k=!1;j&&(k=a(document.getElementById(j)).attr("data-value")),f.children("option").each(function(b,c){a(c).prop("selected")&&h.push({label:a(c).html(),value:a(c).attr("value")})});var l=a.extend({items:h},b,c);d.render("core/form_autocomplete_selection",l).done(function(b){i.empty().append(a(b).html()),k!==!1&&i.children("[aria-selected=true]").each(function(b,d){a(d).attr("data-value")===k&&g(b,c)})}).fail(e.exception)},i=function(a){"undefined"!=typeof M.core_formchangechecker&&M.core_formchangechecker.set_form_changed(),a.change()},j=function(b,c,d,e){var f=a(d).attr("data-value");b.multiple&&e.children("option").each(function(b,c){a(c).attr("value")==f&&(a(c).prop("selected",!1),a(c).attr("data-iscustom")&&a(c).remove())}),h(b,c,e),i(e)},k=function(b,c){var d=a(document.getElementById(c.inputId)),e=a(document.getElementById(c.suggestionsId)),f=e.children("[aria-hidden=false]").length;for(b%=f;b<0;)b+=f;var g=a(e.children("[aria-hidden=false]").get(b)),h=a(e.children("[role=option]")).index(g),i=c.suggestionsId+"-"+h;e.children().attr("aria-selected",!1).attr("id",""),g.attr("aria-selected",!0).attr("id",i),d.attr("aria-activedescendant",i);var j=g.offset().top-e.offset().top+e.scrollTop()-e.height()/2;e.animate({scrollTop:j},100)},l=function(b){var c=a(document.getElementById(b.suggestionsId)),d=c.children("[aria-selected=true]"),e=c.children("[aria-hidden=false]").index(d);k(e+1,b)},m=function(b){var c=a(document.getElementById(b.selectionId)),d=c.children("[data-active-selection=true]");if(!d)return void g(0,b);var e=c.children("[aria-selected=true]").index(d);g(e-1,b)},n=function(b){var c=a(document.getElementById(b.selectionId)),d=c.children("[data-active-selection=true]");if(!d)return void g(0,b);var e=c.children("[aria-selected=true]").index(d);g(e+1,b)},o=function(b){var c=a(document.getElementById(b.suggestionsId)),d=c.children("[aria-selected=true]"),e=c.children("[aria-hidden=false]").index(d);k(e-1,b)},p=function(b){var c=a(document.getElementById(b.inputId)),d=a(document.getElementById(b.suggestionsId));c.attr("aria-expanded",!1).attr("aria-activedescendant",b.selectionId),d.hide().attr("aria-hidden",!0)},q=function(b,f,g,h){var i=a(document.getElementById(f.inputId)),j=a(document.getElementById(f.suggestionsId)),l=!1,m=[];h.children("option").each(function(b,c){a(c).prop("selected")!==!0&&(m[m.length]={label:c.innerHTML,value:a(c).attr("value")})});var n=f.caseSensitive?g:g.toLocaleLowerCase(),o=a.extend({options:m},b,f);d.render("core/form_autocomplete_suggestions",o).done(function(d){j.replaceWith(d),j=a(document.getElementById(f.suggestionsId)),j.show().attr("aria-hidden",!1),j.children().each(function(c,d){d=a(d),b.caseSensitive&&d.text().indexOf(n)>-1||!b.caseSensitive&&d.text().toLocaleLowerCase().indexOf(n)>-1?(d.show().attr("aria-hidden",!1),l=!0):d.hide().attr("aria-hidden",!0)}),i.attr("aria-expanded",!0),l?b.tags||k(0,f):c.get_string("nosuggestions","form").done(function(a){j.html(a)})}).fail(e.exception)},r=function(b,c,d){var e=a(document.getElementById(c.inputId)),f=e.val(),g=f.split(","),j=!1;a.each(g,function(c,e){if(e=e.trim(),""!==e&&(b.multiple||d.children("option").prop("selected",!1),d.children("option").each(function(b,c){a(c).attr("value")==e&&(j=!0,a(c).prop("selected",!0))}),!j)){var f=a("<option>");f.append(e),f.attr("value",e),d.append(f),f.prop("selected",!0),f.attr("data-iscustom",!0)}}),h(b,c,d),i(d),e.val(""),p(c)},s=function(b,c,d){var e=a(document.getElementById(c.inputId)),f=a(document.getElementById(c.suggestionsId)),g=f.children("[aria-selected=true]").attr("data-value");b.multiple||d.children("option").prop("selected",!1),d.children("option").each(function(b,c){a(c).attr("value")==g&&a(c).prop("selected",!0)}),h(b,c,d),i(d),b.closeSuggestionsOnSelect?(e.val(""),p(c)):(e.focus(),q(b,c,e.val(),d))},t=function(b,c,d,f,g){var h=a(b.currentTarget).val();g.transport(c.selector,h,function(b){var e=g.processResults(c.selector,b),h=[];if(f.children("option").each(function(b,c){c=a(c),c.prop("selected")?h.push(String(c.attr("value"))):c.remove()}),!c.multiple&&0===f.children("option").length){var i=a("<option>");f.append(i)}a.each(e,function(b,c){if(h.indexOf(String(c.value))===-1){var d=a("<option>");d.append(c.label),d.attr("value",c.value),f.append(d)}}),q(c,d,"",f)},e.exception)},u=function(b,c,d){var e=a(document.getElementById(c.inputId));if(e.on("keydown",function(g){switch(g.keyCode){case f.DOWN:return!b.showSuggestions||("true"===e.attr("aria-expanded")?l(c):!e.val()&&b.ajax?require([b.ajax],function(a){t(g,b,c,d,a)}):q(b,c,e.val(),d),g.preventDefault(),!1);case f.UP:return o(c),g.preventDefault(),!1;case f.ENTER:var h=a(document.getElementById(c.suggestionsId));return"true"===e.attr("aria-expanded")&&h.children("[aria-selected=true]").length>0?s(b,c,d):b.tags&&r(b,c,d),g.preventDefault(),!1;case f.ESCAPE:return"true"===e.attr("aria-expanded")&&p(c),g.preventDefault(),!1}return!0}),e.on("keypress",function(a){return a.keyCode!==f.COMMA||(b.tags&&r(b,c,d),a.preventDefault(),!1)}),e.on("behat:set-value",function(){var f=a(document.getElementById(c.suggestionsId));"true"===e.attr("aria-expanded")&&f.children("[aria-selected=true]").length>0?s(b,c,d):b.tags&&r(b,c,d)}),e.on("blur",function(){window.setTimeout(function(){var f=a(document.activeElement);f.attr("id")!=e.attr("id")&&(b.tags&&r(b,c,d),p(c))},500)}),b.showSuggestions){var g=a(document.getElementById(c.downArrowId));g.on("click",function(a){e.focus(),!e.val()&&b.ajax?require([b.ajax],function(e){t(a,b,c,d,e)}):q(b,c,e.val(),d)})}var h=a(document.getElementById(c.suggestionsId));h.parent().on("click","[role=option]",function(e){var f=a(e.currentTarget).closest("[role=option]"),g=a(document.getElementById(c.suggestionsId)),h=g.children("[aria-hidden=false]").index(f);k(h,c),s(b,c,d)});var i=a(document.getElementById(c.selectionId));i.on("click","[role=listitem]",function(e){var f=a(e.currentTarget);j(b,c,f,d)}),i.on("keydown",function(e){switch(e.keyCode){case f.DOWN:return n(c),e.preventDefault(),!1;case f.UP:return m(c),e.preventDefault(),!1;case f.SPACE:case f.ENTER:var g=a(document.getElementById(c.selectionId)).children("[data-active-selection=true]");return g&&(j(b,c,g,d),e.preventDefault()),!1}return!0}),b.showSuggestions&&e.on("input",function(e){var f=a(e.currentTarget).val(),g=a(e.currentTarget).data("last-value");g!==f&&q(b,c,f,d),a(e.currentTarget).data("last-value",f)})};return{enhance:function(f,g,i,j,k,l,m,n){var o={selector:f,tags:!1,ajax:!1,placeholder:j,caseSensitive:!1,showSuggestions:!0,noSelectionString:m};"undefined"!=typeof g&&(o.tags=g),"undefined"!=typeof i&&(o.ajax=i),"undefined"!=typeof k&&(o.caseSensitive=k),"undefined"!=typeof l&&(o.showSuggestions=l),"undefined"==typeof m&&c.get_string("noselection","form").done(function(a){o.noSelectionString=a}).fail(e.exception);var p=a(f);if(!p)return b.debug("Selector not found: "+f),!1;p.hide().attr("aria-hidden",!0);var q={selectId:p.attr("id"),inputId:"form_autocomplete_input-"+a.now(),suggestionsId:"form_autocomplete_suggestions-"+a.now(),selectionId:"form_autocomplete_selection-"+a.now(),downArrowId:"form_autocomplete_downarrow-"+a.now()};o.multiple=p.attr("multiple"),"undefined"!=typeof n?o.closeSuggestionsOnSelect=n:o.closeSuggestionsOnSelect=!o.multiple;var r=a("[for="+q.selectId+"]"),s=[];p.children("option").each(function(b,c){s[b]={label:c.innerHTML,value:a(c).attr("value")}});var v=a.extend({},o,q);v.options=s,v.items=[];var w=d.render("core/form_autocomplete_input",v),x=d.render("core/form_autocomplete_suggestions",v),y=d.render("core/form_autocomplete_selection",v);return a.when(w,x,y).then(function(b,c,d){p.after(c),p.after(b),p.after(d),r.attr("for",q.inputId),u(o,q,p);var e=a(document.getElementById(q.inputId)),f=a(document.getElementById(q.suggestionsId));return f.hide().attr("aria-hidden",!0),o.ajax&&require([o.ajax],function(a){var b=null,c=function(b){t(b,o,q,p,a)},d=function(a){null!==b&&(window.clearTimeout(b),b=null),b=window.setTimeout(c.bind(this,a),300)};e.on("input",d)}),h(o,q,p),!0})}}}); \ No newline at end of file +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:44,UP:38},g=function(b,c){var d=a(document.getElementById(c.selectionId)),e=d.children("[aria-selected=true]").length;for(b%=e;b<0;)b+=e;var f=a(d.children("[aria-selected=true]").get(b)),g=c.selectionId+"-"+b;d.children().attr("data-active-selection",!1).attr("id",""),f.attr("data-active-selection",!0).attr("id",g),d.attr("aria-activedescendant",g)},h=function(b,c,f){var h=[],i=a(document.getElementById(c.selectionId)),j=i.attr("aria-activedescendant"),k=!1;j&&(k=a(document.getElementById(j)).attr("data-value")),f.children("option").each(function(b,c){a(c).prop("selected")&&h.push({label:a(c).html(),value:a(c).attr("value")})});var l=a.extend({items:h},b,c);d.render("core/form_autocomplete_selection",l).done(function(b){i.empty().append(a(b).html()),k!==!1&&i.children("[aria-selected=true]").each(function(b,d){a(d).attr("data-value")===k&&g(b,c)})}).fail(e.exception)},i=function(a){"undefined"!=typeof M.core_formchangechecker&&M.core_formchangechecker.set_form_changed(),a.change()},j=function(b,c,d,e){var f=a(d).attr("data-value");b.multiple&&e.children("option").each(function(b,c){a(c).attr("value")==f&&(a(c).prop("selected",!1),a(c).attr("data-iscustom")&&a(c).remove())}),h(b,c,e),i(e)},k=function(b,c){var d=a(document.getElementById(c.inputId)),e=a(document.getElementById(c.suggestionsId)),f=e.children("[aria-hidden=false]").length;for(b%=f;b<0;)b+=f;var g=a(e.children("[aria-hidden=false]").get(b)),h=a(e.children("[role=option]")).index(g),i=c.suggestionsId+"-"+h;e.children().attr("aria-selected",!1).attr("id",""),g.attr("aria-selected",!0).attr("id",i),d.attr("aria-activedescendant",i);var j=g.offset().top-e.offset().top+e.scrollTop()-e.height()/2;e.animate({scrollTop:j},100)},l=function(b){var c=a(document.getElementById(b.suggestionsId)),d=c.children("[aria-selected=true]"),e=c.children("[aria-hidden=false]").index(d);k(e+1,b)},m=function(b){var c=a(document.getElementById(b.selectionId)),d=c.children("[data-active-selection=true]");if(!d)return void g(0,b);var e=c.children("[aria-selected=true]").index(d);g(e-1,b)},n=function(b){var c=a(document.getElementById(b.selectionId)),d=c.children("[data-active-selection=true]");if(!d)return void g(0,b);var e=c.children("[aria-selected=true]").index(d);g(e+1,b)},o=function(b){var c=a(document.getElementById(b.suggestionsId)),d=c.children("[aria-selected=true]"),e=c.children("[aria-hidden=false]").index(d);k(e-1,b)},p=function(b){var c=a(document.getElementById(b.inputId)),d=a(document.getElementById(b.suggestionsId));c.attr("aria-expanded",!1).attr("aria-activedescendant",b.selectionId),d.hide().attr("aria-hidden",!0)},q=function(b,f,g,h){var i=a(document.getElementById(f.inputId)),j=a(document.getElementById(f.suggestionsId)),l=!1,m=[];h.children("option").each(function(b,c){a(c).prop("selected")!==!0&&(m[m.length]={label:c.innerHTML,value:a(c).attr("value")})});var n=f.caseSensitive?g:g.toLocaleLowerCase(),o=a.extend({options:m},b,f);d.render("core/form_autocomplete_suggestions",o).done(function(d){j.replaceWith(d),j=a(document.getElementById(f.suggestionsId)),j.show().attr("aria-hidden",!1),j.children().each(function(c,d){d=a(d),b.caseSensitive&&d.text().indexOf(n)>-1||!b.caseSensitive&&d.text().toLocaleLowerCase().indexOf(n)>-1?(d.show().attr("aria-hidden",!1),l=!0):d.hide().attr("aria-hidden",!0)}),i.attr("aria-expanded",!0),l?b.tags||k(0,f):c.get_string("nosuggestions","form").done(function(a){j.html(a)})}).fail(e.exception)},r=function(b,c,d){var e=a(document.getElementById(c.inputId)),f=e.val(),g=f.split(","),j=!1;a.each(g,function(c,e){if(e=e.trim(),""!==e&&(b.multiple||d.children("option").prop("selected",!1),d.children("option").each(function(b,c){a(c).attr("value")==e&&(j=!0,a(c).prop("selected",!0))}),!j)){var f=a("<option>");f.append(e),f.attr("value",e),d.append(f),f.prop("selected",!0),f.attr("data-iscustom",!0)}}),h(b,c,d),i(d),e.val(""),p(c)},s=function(b,c,d){var e=a(document.getElementById(c.inputId)),f=a(document.getElementById(c.suggestionsId)),g=f.children("[aria-selected=true]").attr("data-value");b.multiple||d.children("option").prop("selected",!1),d.children("option").each(function(b,c){a(c).attr("value")==g&&a(c).prop("selected",!0)}),h(b,c,d),i(d),b.closeSuggestionsOnSelect?(e.val(""),p(c)):(e.focus(),q(b,c,e.val(),d))},t=function(b,c,d,f,g){var h=a(b.currentTarget).val();g.transport(c.selector,h,function(b){var e=g.processResults(c.selector,b),h=[];if(f.children("option").each(function(b,c){c=a(c),c.prop("selected")?h.push(String(c.attr("value"))):c.remove()}),!c.multiple&&0===f.children("option").length){var i=a("<option>");f.append(i)}a.each(e,function(b,c){if(h.indexOf(String(c.value))===-1){var d=a("<option>");d.append(c.label),d.attr("value",c.value),f.append(d)}}),q(c,d,"",f)},e.exception)},u=function(b,c,d){var e=a(document.getElementById(c.inputId));if(e.on("keydown",function(g){switch(g.keyCode){case f.DOWN:return!b.showSuggestions||("true"===e.attr("aria-expanded")?l(c):!e.val()&&b.ajax?require([b.ajax],function(a){t(g,b,c,d,a)}):q(b,c,e.val(),d),g.preventDefault(),!1);case f.UP:return o(c),g.preventDefault(),!1;case f.ENTER:var h=a(document.getElementById(c.suggestionsId));return"true"===e.attr("aria-expanded")&&h.children("[aria-selected=true]").length>0?s(b,c,d):b.tags&&r(b,c,d),g.preventDefault(),!1;case f.ESCAPE:return"true"===e.attr("aria-expanded")&&p(c),g.preventDefault(),!1}return!0}),e.on("keypress",function(a){return a.keyCode!==f.COMMA||(b.tags&&r(b,c,d),a.preventDefault(),!1)}),e.on("behat:set-value",function(){var f=a(document.getElementById(c.suggestionsId));"true"===e.attr("aria-expanded")&&f.children("[aria-selected=true]").length>0?s(b,c,d):b.tags&&r(b,c,d)}),e.on("blur",function(){window.setTimeout(function(){var f=a(document.activeElement);f.attr("id")!=e.attr("id")&&(b.tags&&r(b,c,d),p(c))},500)}),b.showSuggestions){var g=a(document.getElementById(c.downArrowId));g.on("click",function(a){e.focus(),!e.val()&&b.ajax?require([b.ajax],function(e){t(a,b,c,d,e)}):q(b,c,e.val(),d)})}var h=a(document.getElementById(c.suggestionsId));h.parent().on("click","[role=option]",function(e){var f=a(e.currentTarget).closest("[role=option]"),g=a(document.getElementById(c.suggestionsId)),h=g.children("[aria-hidden=false]").index(f);k(h,c),s(b,c,d)});var i=a(document.getElementById(c.selectionId));i.on("click","[role=listitem]",function(e){var f=a(e.currentTarget);j(b,c,f,d)}),i.on("keydown",function(e){switch(e.keyCode){case f.DOWN:return n(c),e.preventDefault(),!1;case f.UP:return m(c),e.preventDefault(),!1;case f.SPACE:case f.ENTER:var g=a(document.getElementById(c.selectionId)).children("[data-active-selection=true]");return g&&(j(b,c,g,d),e.preventDefault()),!1}return!0}),b.showSuggestions&&e.on("input",function(e){var f=a(e.currentTarget).val(),g=a(e.currentTarget).data("last-value");g!==f&&q(b,c,f,d),a(e.currentTarget).data("last-value",f)})};return{enhance:function(f,g,i,j,k,l,m,n){var o={selector:f,tags:!1,ajax:!1,placeholder:j,caseSensitive:!1,showSuggestions:!0,noSelectionString:m};"undefined"!=typeof g&&(o.tags=g),"undefined"!=typeof i&&(o.ajax=i),"undefined"!=typeof k&&(o.caseSensitive=k),"undefined"!=typeof l&&(o.showSuggestions=l),"undefined"==typeof m&&c.get_string("noselection","form").done(function(a){o.noSelectionString=a}).fail(e.exception);var p=a(f);if(!p)return b.debug("Selector not found: "+f),!1;p.css("visibility","hidden").attr("aria-hidden",!0);var q={selectId:p.attr("id"),inputId:"form_autocomplete_input-"+a.now(),suggestionsId:"form_autocomplete_suggestions-"+a.now(),selectionId:"form_autocomplete_selection-"+a.now(),downArrowId:"form_autocomplete_downarrow-"+a.now()};o.multiple=p.attr("multiple"),"undefined"!=typeof n?o.closeSuggestionsOnSelect=n:o.closeSuggestionsOnSelect=!o.multiple;var r=a("[for="+q.selectId+"]"),s=[];p.children("option").each(function(b,c){s[b]={label:c.innerHTML,value:a(c).attr("value")}});var v=a.extend({},o,q);v.options=s,v.items=[];var w=d.render("core/form_autocomplete_input",v),x=d.render("core/form_autocomplete_suggestions",v),y=d.render("core/form_autocomplete_selection",v);return a.when(w,x,y).then(function(b,c,d){p.hide(),p.after(c),p.after(b),p.after(d),r.attr("for",q.inputId),u(o,q,p);var e=a(document.getElementById(q.inputId)),f=a(document.getElementById(q.suggestionsId));return f.hide().attr("aria-hidden",!0),o.ajax&&require([o.ajax],function(a){var b=null,c=function(b){t(b,o,q,p,a)},d=function(a){null!==b&&(window.clearTimeout(b),b=null),b=window.setTimeout(c.bind(this,a),300)};e.on("input",d)}),h(o,q,p),!0})}}}); \ No newline at end of file diff --git a/lib/amd/build/inplace_editable.min.js b/lib/amd/build/inplace_editable.min.js index 73071d8da83..64b5446ec90 100644 --- a/lib/amd/build/inplace_editable.min.js +++ b/lib/amd/build/inplace_editable.min.js @@ -1 +1 @@ -define(["jquery","core/ajax","core/templates","core/notification","core/str","core/config","core/url","core/form-autocomplete"],function(a,b,c,d,e,f,g,h){return a("body").on("click keypress","[data-inplaceeditable] [data-inplaceeditablelink]",function(i){if("keypress"!==i.type||13===i.keyCode){i.stopImmediatePropagation(),i.preventDefault();var j=a(this),k=j.closest("[data-inplaceeditable]"),l=function(b){b.addClass("updating");var c=b.find("img.spinner");c.length?c.show():(c=a("<img/>").attr("src",g.imageUrl("i/loading_small")).addClass("spinner").addClass("smallicon"),b.append(c))},m=function(a){a.removeClass("updating"),a.find("img.spinner").hide()},n=function(e,f){l(e),b.call([{methodname:"core_update_inplace_editable",args:{itemid:e.attr("data-itemid"),component:e.attr("data-component"),itemtype:e.attr("data-itemtype"),value:f},done:function(b){var d=e.attr("data-value");c.render("core/inplace_editable",b).done(function(f,g){var h=a(f);c.replaceNode(e,h,g),h.find("[data-inplaceeditablelink]").focus(),h.trigger({type:"updated",ajaxreturn:b,oldvalue:d})})},fail:function(b){var c=a.Event("updatefailed",{exception:b,newvalue:f});m(e),e.trigger(c),c.isDefaultPrevented()||d.exception(b)}}],!0)},o=function(a){a.find("input").off(),a.find("select").off(),a.html(a.attr("data-oldcontent")),a.removeAttr("data-oldcontent"),a.removeClass("inplaceeditingon"),a.find("[data-inplaceeditablelink]").focus()},p=function(){a("span.inplaceeditable.inplaceeditingon").each(function(){o(a(this))})},q=function(b,c){var d,e=b;for(d=0;d<c;d++)e+=String(Math.floor(10*Math.random()));return 0===a("#"+e).length?e:q(b,c)},r=function(b){e.get_string("edittitleinstructions").done(function(c){var d=a('<span class="editinstructions">'+c+"</span>").attr("id",q("id_editinstructions_",20)),e=a('<input type="text"/>').attr("id",q("id_inplacevalue_",20)).attr("value",b.attr("data-value")).attr("aria-describedby",d.attr("id")).addClass("ignoredirty").addClass("form-control"),g=a('<label class="accesshide">'+k.attr("data-editlabel")+"</label>").attr("for",e.attr("id"));b.html("").append(d).append(g).append(e),e.focus(),e.select(),e.on("keyup keypress focusout",function(a){if(!f.behatsiterunning||"focusout"!==a.type){if("keypress"===a.type&&13===a.keyCode){var c=e.val();o(b),n(b,c)}("keyup"===a.type&&27===a.keyCode||"focusout"===a.type)&&o(b)}})})},s=function(a,b){o(a),n(a,b)},t=function(b,c){var d,e=a("<select></select>").attr("id",q("id_inplacevalue_",20)).addClass("custom-select"),g=a('<label class="accesshide">'+k.attr("data-editlabel")+"</label>").attr("for",e.attr("id"));for(d in c)e.append(a("<option>").attr("value",c[d].key).html(c[d].value));e.val(b.attr("data-value")),b.html("").append(g).append(e),e.focus(),e.select(),e.on("keyup change focusout",function(a){if(!f.behatsiterunning||"focusout"!==a.type){if("change"===a.type){var c=e.val();o(b),n(b,c)}("keyup"===a.type&&27===a.keyCode||"focusout"===a.type)&&o(b)}})},u=function(b,f){var g,i=a("<select></select>").attr("id",q("id_inplacevalue_",20)).addClass("custom-select"),j=a('<label class="accesshide">'+k.attr("data-editlabel")+"</label>").attr("for",i.attr("id")),l=f.options,m=f.attributes,p=a('<a href="#"></a>'),r=a('<a href="#"></a>');for(g in l)i.append(a("<option>").attr("value",l[g].key).html(l[g].value));m.multiple&&i.attr("multiple","true"),i.val(JSON.parse(b.attr("data-value"))),e.get_string("savechanges","core").then(function(a){return c.renderPix("e/save","core",a)}).then(function(a){p.append(a)}).fail(d.exception),e.get_string("cancel","core").then(function(a){return c.renderPix("e/cancel","core",a)}).then(function(a){r.append(a)}).fail(d.exception),b.html("").append(j).append(i).append(p).append(r),i.focus(),i.select(),h.enhance(i,m.tags,m.ajax,m.placeholder,m.caseSensitive,m.showSuggestions,m.noSelectionString).then(function(){b.find("[role=combobox]").focus()}).fail(d.exception),i.on("keyup",function(a){("keyup"===a.type&&27===a.keyCode||"focusout"===a.type)&&o(b)}),p.on("click",function(a){var c=JSON.stringify(i.val());o(b),n(b,c),a.preventDefault()}),r.on("click",function(a){o(b),a.preventDefault()})},v=function(b){b.addClass("inplaceeditingon"),b.attr("data-oldcontent",b.html());var c=b.attr("data-type"),d=b.attr("data-options");"toggle"===c?s(b,d):"select"===c?t(b,a.parseJSON(d)):"autocomplete"===c?u(b,a.parseJSON(d)):r(b)};p(),v(k)}}),{}}); \ No newline at end of file +define(["jquery","core/ajax","core/templates","core/notification","core/str","core/config","core/url","core/form-autocomplete"],function(a,b,c,d,e,f,g,h){return a("body").on("click keypress","[data-inplaceeditable] [data-inplaceeditablelink]",function(i){if("keypress"!==i.type||13===i.keyCode){i.stopImmediatePropagation(),i.preventDefault();var j=a(this),k=j.closest("[data-inplaceeditable]"),l=function(b){b.addClass("updating");var c=b.find("img.spinner");c.length?c.show():(c=a("<img/>").attr("src",g.imageUrl("i/loading_small")).addClass("spinner").addClass("smallicon"),b.append(c))},m=function(a){a.removeClass("updating"),a.find("img.spinner").hide()},n=function(e,f){l(e),b.call([{methodname:"core_update_inplace_editable",args:{itemid:e.attr("data-itemid"),component:e.attr("data-component"),itemtype:e.attr("data-itemtype"),value:f},done:function(b){var d=e.attr("data-value");c.render("core/inplace_editable",b).done(function(f,g){var h=a(f);c.replaceNode(e,h,g),h.find("[data-inplaceeditablelink]").focus(),h.trigger({type:"updated",ajaxreturn:b,oldvalue:d})})},fail:function(b){var c=a.Event("updatefailed",{exception:b,newvalue:f});m(e),e.trigger(c),c.isDefaultPrevented()||d.exception(b)}}],!0)},o=function(a){a.find("input").off(),a.find("select").off(),a.html(a.attr("data-oldcontent")),a.removeAttr("data-oldcontent"),a.removeClass("inplaceeditingon"),a.find("[data-inplaceeditablelink]").focus()},p=function(){a("span.inplaceeditable.inplaceeditingon").each(function(){o(a(this))})},q=function(b,c){var d,e=b;for(d=0;d<c;d++)e+=String(Math.floor(10*Math.random()));return 0===a("#"+e).length?e:q(b,c)},r=function(b){e.get_string("edittitleinstructions").done(function(c){var d=a('<span class="editinstructions">'+c+"</span>").attr("id",q("id_editinstructions_",20)),e=a('<input type="text"/>').attr("id",q("id_inplacevalue_",20)).attr("value",b.attr("data-value")).attr("aria-describedby",d.attr("id")).addClass("ignoredirty").addClass("form-control"),g=a('<label class="accesshide">'+k.attr("data-editlabel")+"</label>").attr("for",e.attr("id"));b.html("").append(d).append(g).append(e),e.focus(),e.select(),e.on("keyup keypress focusout",function(a){if(!f.behatsiterunning||"focusout"!==a.type){if("keypress"===a.type&&13===a.keyCode){var c=e.val();o(b),n(b,c)}("keyup"===a.type&&27===a.keyCode||"focusout"===a.type)&&o(b)}})})},s=function(a,b){o(a),n(a,b)},t=function(b,c){var d,e=a('<select class="form-autocomplete-original-select"></select>').attr("id",q("id_inplacevalue_",20)).addClass("custom-select"),g=a('<label class="accesshide">'+k.attr("data-editlabel")+"</label>").attr("for",e.attr("id"));for(d in c)e.append(a("<option>").attr("value",c[d].key).html(c[d].value));e.val(b.attr("data-value")),b.html("").append(g).append(e),e.focus(),e.select(),e.on("keyup change focusout",function(a){if(!f.behatsiterunning||"focusout"!==a.type){if("change"===a.type){var c=e.val();o(b),n(b,c)}("keyup"===a.type&&27===a.keyCode||"focusout"===a.type)&&o(b)}})},u=function(b,f){var g,i=a("<select></select>").attr("id",q("id_inplacevalue_",20)).addClass("custom-select"),j=a('<label class="accesshide">'+k.attr("data-editlabel")+"</label>").attr("for",i.attr("id")),l=f.options,m=f.attributes,p=a('<a href="#"></a>'),r=a('<a href="#"></a>');for(g in l)i.append(a("<option>").attr("value",l[g].key).html(l[g].value));m.multiple&&i.attr("multiple","true"),i.val(JSON.parse(b.attr("data-value"))),e.get_string("savechanges","core").then(function(a){return c.renderPix("e/save","core",a)}).then(function(a){p.append(a)}).fail(d.exception),e.get_string("cancel","core").then(function(a){return c.renderPix("e/cancel","core",a)}).then(function(a){r.append(a)}).fail(d.exception),b.html("").append(j).append(i).append(p).append(r),i.focus(),i.select(),h.enhance(i,m.tags,m.ajax,m.placeholder,m.caseSensitive,m.showSuggestions,m.noSelectionString).then(function(){b.find("[role=combobox]").focus()}).fail(d.exception),i.on("keyup",function(a){("keyup"===a.type&&27===a.keyCode||"focusout"===a.type)&&o(b)}),p.on("click",function(a){var c=JSON.stringify(i.val());o(b),n(b,c),a.preventDefault()}),r.on("click",function(a){o(b),a.preventDefault()})},v=function(b){b.addClass("inplaceeditingon"),b.attr("data-oldcontent",b.html());var c=b.attr("data-type"),d=b.attr("data-options");"toggle"===c?s(b,d):"select"===c?t(b,a.parseJSON(d)):"autocomplete"===c?u(b,a.parseJSON(d)):r(b)};p(),v(k)}}),{}}); \ No newline at end of file diff --git a/lib/amd/src/form-autocomplete.js b/lib/amd/src/form-autocomplete.js index 17e7adf23ea..3c01b188771 100644 --- a/lib/amd/src/form-autocomplete.js +++ b/lib/amd/src/form-autocomplete.js @@ -758,8 +758,9 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification'] return false; } + originalSelect.css('visibility', 'hidden').attr('aria-hidden', true); + // Hide the original select. - originalSelect.hide().attr('aria-hidden', true); // Find or generate some ids. var state = { @@ -795,10 +796,11 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification'] var renderSelection = templates.render('core/form_autocomplete_selection', context); return $.when(renderInput, renderDatalist, renderSelection).then(function(input, suggestions, selection) { - // Add our new UI elements to the page. + originalSelect.hide(); originalSelect.after(suggestions); originalSelect.after(input); originalSelect.after(selection); + // Update the form label to point to the text input. originalLabel.attr('for', state.inputId); // Add the event handlers. diff --git a/lib/amd/src/inplace_editable.js b/lib/amd/src/inplace_editable.js index 20ca0fbdeb8..f0086f83994 100644 --- a/lib/amd/src/inplace_editable.js +++ b/lib/amd/src/inplace_editable.js @@ -171,7 +171,7 @@ define(['jquery', var turnEditingOnSelect = function(el, options) { var i, - inputelement = $('<select></select>'). + inputelement = $('<select class="form-autocomplete-original-select"></select>'). attr('id', uniqueId('id_inplacevalue_', 20)). addClass('custom-select'), lbl = $('<label class="accesshide">' + mainelement.attr('data-editlabel') + '</label>') diff --git a/theme/boost/scss/moodle/forms.scss b/theme/boost/scss/moodle/forms.scss index 967a54c03bb..d7f3701a9b9 100644 --- a/theme/boost/scss/moodle/forms.scss +++ b/theme/boost/scss/moodle/forms.scss @@ -241,9 +241,24 @@ fieldset.coursesearchbox label { } /* Custom styles for autocomplete form element */ +/* These styles reserve a standard amount of space in the DOM to avoid flicker when the original select element is replaced */ +[data-fieldtype=autocomplete] select, +[data-fieldtype=tags] select, +.form-autocomplete-original-select { + visibility: hidden; + overflow: hidden; + width: 15rem; + height: 44px; + margin: 0; + padding: 0; + border: 0; + margin-top: $font-size-base * $line-height-base + $tag-padding-y; + vertical-align: bottom; +} .form-autocomplete-selection { - margin: 0.2em; - min-height: 21px; + margin: $tag-padding-y; + // Padding top and bottom, plus m-b-1 and the 100% lineheight. + min-height: 2 * $tag-padding-y + 2 * $font-size-base; } .form-autocomplete-multiple [role=listitem] { diff --git a/theme/boost/templates/core/form_autocomplete_selection.mustache b/theme/boost/templates/core/form_autocomplete_selection.mustache index 9231ccf676f..9169fb210e0 100644 --- a/theme/boost/templates/core/form_autocomplete_selection.mustache +++ b/theme/boost/templates/core/form_autocomplete_selection.mustache @@ -40,11 +40,11 @@ <div class="form-autocomplete-selection {{#multiple}}form-autocomplete-multiple{{/multiple}}" id="{{selectionId}}" role="list" aria-atomic="true" {{#multiple}}tabindex="0" aria-multiselectable="true"{{/multiple}}> <span class="accesshide">{{#str}}selecteditems, form{{/str}}</span> {{#items}} - <span role="listitem" data-value="{{value}}" aria-selected="true" class="tag tag-info m-b-1 m-r-1" style="font-size: larger"> + <span role="listitem" data-value="{{value}}" aria-selected="true" class="tag tag-info m-b-1 m-r-1" style="font-size: 100%"> {{#multiple}}<span aria-hidden="true">× </span>{{/multiple}}{{{label}}} </span> {{/items}} {{^items}} - <span>{{noSelectionString}}</span> + <span class="m-b-1 m-r-1">{{noSelectionString}}</span> {{/items}} </div> diff --git a/theme/bootstrapbase/less/moodle/forms.less b/theme/bootstrapbase/less/moodle/forms.less index 008de8d8569..dcaad6d6a5c 100644 --- a/theme/bootstrapbase/less/moodle/forms.less +++ b/theme/bootstrapbase/less/moodle/forms.less @@ -445,9 +445,27 @@ input[size] { } /* Custom styles for autocomplete form element */ + +[data-fieldtype=autocomplete] select, +[data-fieldtype=tags] select, +select.form-autocomplete-original-select { + visibility: hidden; + overflow: hidden; + width: 15rem; + height: 3 * @baseLineHeight + @baseFontSize / 2; + margin: 0; + margin-bottom: 0.2em; + padding: 0; + border: 0; + vertical-align: top; +} +.form-autocomplete-container { + display: inline-block; + min-height: 4.2rem; +} .form-autocomplete-selection { margin: 0.2em; - min-height: 21px; + min-height: @baseLineHeight + @baseFontSize / 2; } .form-autocomplete-multiple [role=listitem] { cursor: pointer; diff --git a/theme/bootstrapbase/style/moodle.css b/theme/bootstrapbase/style/moodle.css index 066dc473b30..3aae7d49cf4 100644 --- a/theme/bootstrapbase/style/moodle.css +++ b/theme/bootstrapbase/style/moodle.css @@ -16902,9 +16902,26 @@ input[size] { width: auto; } /* Custom styles for autocomplete form element */ +[data-fieldtype=autocomplete] select, +[data-fieldtype=tags] select, +select.form-autocomplete-original-select { + visibility: hidden; + overflow: hidden; + width: 15rem; + height: 67px; + margin: 0; + margin-bottom: 0.2em; + padding: 0; + border: 0; + vertical-align: top; +} +.form-autocomplete-container { + display: inline-block; + min-height: 4.2rem; +} .form-autocomplete-selection { margin: 0.2em; - min-height: 21px; + min-height: 27px; } .form-autocomplete-multiple [role=listitem] { cursor: pointer; diff --git a/user/templates/unified_filter.mustache b/user/templates/unified_filter.mustache index 81663ae26c6..a6562479151 100644 --- a/user/templates/unified_filter.mustache +++ b/user/templates/unified_filter.mustache @@ -51,9 +51,9 @@ ] } }} -<form method="post" action="{{action}}" class="form-inline m-b-2" role="search"> +<form method="post" action="{{action}}" class="m-b-1" role="search"> <label for="unified-filters" class="sr-only">{{#str}}filters{{/str}}</label> - <select name="unified-filters[]" id="unified-filters" multiple="multiple" data-originaloptionsjson="{{originaloptionsjson}}"> + <select name="unified-filters[]" id="unified-filters" multiple="multiple" data-originaloptionsjson="{{originaloptionsjson}}" class="form-autocomplete-original-select"> {{#filteroptions}} <option value="{{value}}" {{#selected}}selected="selected"{{/selected}}>{{{label}}}</option> {{/filteroptions}}