From b181f297ced509eab77c0b078a254e52635ccb6e Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 27 Aug 2024 15:47:42 +0100 Subject: [PATCH] MDL-82909 javascript: replace custom loading icon with existing module. --- lib/amd/build/inplace_editable.min.js | 2 +- lib/amd/build/inplace_editable.min.js.map | 2 +- lib/amd/src/inplace_editable.js | 25 ++++++----------------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/lib/amd/build/inplace_editable.min.js b/lib/amd/build/inplace_editable.min.js index 88d7c9ac72e..0279b2422c3 100644 --- a/lib/amd/build/inplace_editable.min.js +++ b/lib/amd/build/inplace_editable.min.js @@ -12,6 +12,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since 3.1 */ -define("core/inplace_editable",["jquery","core/ajax","core/templates","core/notification","core/str","core/config","core/url","core/form-autocomplete","core/pending","core/local/inplace_editable/events"],(function($,ajax,templates,notification,str,cfg,url,autocomplete,Pending,Events){const updateValue=function(mainelement,value,silent){var pendingId=[mainelement.attr("data-itemid"),mainelement.attr("data-component"),mainelement.attr("data-itemtype")].join("-"),pendingPromise=new Pending(pendingId);addSpinner(mainelement),ajax.call([{methodname:"core_update_inplace_editable",args:{itemid:mainelement.attr("data-itemid"),component:mainelement.attr("data-component"),itemtype:mainelement.attr("data-itemtype"),value:value}}])[0].then((function(data){return templates.render("core/inplace_editable",data).then((function(html,js){var oldvalue=mainelement.attr("data-value"),newelement=$(html);templates.replaceNode(mainelement,newelement,js),silent||newelement.find("[data-inplaceeditablelink]").focus(),Events.notifyElementUpdated(newelement.get(0),data,oldvalue)}))})).then((function(){return pendingPromise.resolve()})).fail((function(ex){var element;(element=mainelement).removeClass("updating"),element.find("img.spinner").hide(),M.util.js_complete(pendingId),Events.notifyElementUpdateFailed(mainelement.get(0),ex,value).defaultPrevented||notification.exception(ex)}))},addSpinner=function(element){element.addClass("updating");var spinner=element.find("img.spinner");spinner.length?spinner.show():(spinner=$("").attr("src",url.imageUrl("i/loading_small")).addClass(["spinner","icon"]),element.append(spinner))};return $("body").on("click keypress","[data-inplaceeditable] [data-inplaceeditablelink]",(function(e){if("keypress"!==e.type||13===e.keyCode){var editingEnabledPromise=new Pending("autocomplete-start-editing");e.stopImmediatePropagation(),e.preventDefault();var mainelement=$(this).closest("[data-inplaceeditable]"),turnEditingOff=function(el){el.find("input").off(),el.find("select").off(),el.html(el.attr("data-oldcontent")),el.removeAttr("data-oldcontent"),el.removeClass("inplaceeditingon"),el.find("[data-inplaceeditablelink]").focus(),el.parents('[data-inplace-in-draggable="true"]').attr("draggable",!0).attr("data-inplace-in-draggable",!1)},uniqueId=function(prefix,idlength){var i,uniqid=prefix;for(i=0;i").attr("id",uniqueId("id_inplacevalue_",20)).addClass("custom-select"),lbl=$('").attr("for",inputelement.attr("id"));for(i in options)inputelement.append($("