From 6764c9ab5404f1384dd2fac539e3d47740e124be Mon Sep 17 00:00:00 2001 From: andris-sevcenko Date: Wed, 6 Oct 2021 21:33:06 +0300 Subject: [PATCH] Saving an image as a new asset now automatically replaces the previous selected asset when editing assets in an assets field. Resolve #8974 --- CHANGELOG.md | 1 + src/controllers/AssetsController.php | 7 ++++++- src/web/assets/cp/dist/js/Craft.min.js | 2 +- src/web/assets/cp/dist/js/Craft.min.js.map | 2 +- src/web/assets/cp/src/js/AssetEditor.js | 14 ++++++++++++-- src/web/assets/cp/src/js/AssetImageEditor.js | 6 +++--- src/web/assets/cp/src/js/AssetSelectInput.js | 19 +++++++++++++++++++ 7 files changed, 43 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a4072e6e7d..ffb46f0bd0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -113,6 +113,7 @@ - All control panel templates end in `.twig` now. ([#9743](https://github.com/craftcms/cms/pull/9743)) - The `users/save-user` action no longer includes a `unverifiedEmail` key in failure responses. - When using GraphQL to mutate entries, the `enabled` status is now affected on a per-site basis when specifying both the `enabled` and `siteId` parameters. ([#9771](https://github.com/craftcms/cms/issues/9771)) +- Saving an image as a new asset now automatically replaces the previous selected asset when editing assets in an assets field. ([#8974](https://github.com/craftcms/cms/discussions/8974)) - Elements’ `searchScore` GraphQL fields are now returned as integers. - Plugins’ `$changelogUrl` properties must now have a `?string` type declaration. - Plugins’ `$description` properties must now have a `?string` type declaration. diff --git a/src/controllers/AssetsController.php b/src/controllers/AssetsController.php index 104fc438f0c..8c4aa8bdeca 100644 --- a/src/controllers/AssetsController.php +++ b/src/controllers/AssetsController.php @@ -1035,6 +1035,8 @@ public function actionSaveImage(): Response $image->saveAs($imageCopy); } + $output = []; + if ($replace) { $oldFocal = $asset->getHasFocalPoint() ? $asset->getFocalPoint() : null; $focalChanged = $focal !== $oldFocal; @@ -1065,12 +1067,15 @@ public function actionSaveImage(): Response // Don't validate required custom fields Craft::$app->getElements()->saveElement($newAsset); + + $output['elementId'] = $newAsset->id; } } catch (Throwable $exception) { return $this->asErrorJson($exception->getMessage()); } - return $this->asJson(['success' => true]); + $output['success'] = true; + return $this->asJson($output); } /** diff --git a/src/web/assets/cp/dist/js/Craft.min.js b/src/web/assets/cp/dist/js/Craft.min.js index 7d22508afc4..5323498ba85 100644 --- a/src/web/assets/cp/dist/js/Craft.min.js +++ b/src/web/assets/cp/dist/js/Craft.min.js @@ -1,2 +1,2 @@ -!function(t){var i=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi;jQuery.htmlPrefilter=function(t){return t.replace(i,"<$1>")},t.extend(Craft,{navHeight:48,index:function(e,i){if(!t.isArray(e))throw"The first argument passed to Craft.index() must be an array.";return e.reduce((t,e,s)=>(t["string"==typeof i?e[i]:i(e,s)]=e,t),{})},group:function(e,i){if(!t.isArray(e))throw"The first argument passed to Craft.group() must be an array.";let s={};return e.reduce((t,e,a)=>{const n="string"==typeof i?e[i]:i(e,a);return s.hasOwnProperty(n)||(s[n]=[[],n],t.push(s[n])),s[n][0].push(e),t},[])},t:function(t,e,i){return void 0!==Craft.translations[t]&&void 0!==Craft.translations[t][e]&&(e=Craft.translations[t][e]),i?this.formatMessage(e,i):e},formatMessage:function(t,e){let i;if(!1===(i=this._tokenizePattern(t)))throw"Message pattern is invalid.";for(let t=0;tt?(s++,i=t):(s--,i=r),0===s&&(n.push(a.slice(e+1,i).join("").split(",",3)),e=i+1,n.push(a.slice(e,t).join("")),e=t),0!==s&&(!1===t||!1===r))break}return 0===s&&n},_parseToken:function(t,e){const i=Craft.trim(t[0]);if(void 0===e[i])return`{${t.join(",")}}`;const s=e[i],a=void 0!==t[1]?Craft.trim(t[1]):"none";switch(a){case"number":return(()=>{let e=void 0!==t[2]?Craft.trim(t[2]):null;if(null!==e&&"integer"!==e)throw"Message format 'number' is only supported for integer values.";let i,a=Craft.formatNumber(s);return null===e&&-1!==(i=(""+s).indexOf("."))&&(a+="."+s.substr(i+1)),a})();case"none":return s;case"select":return(()=>{if(void 0===t[2])return!1;let i=this._tokenizePattern(t[2]),a=i.length,n=!1;for(let t=0;t+1{if(void 0===t[2])return!1;let i=this._tokenizePattern(t[2]);const a=i.length;let n=!1,r=0;for(let t=0;t+1t.replace("#",s-r)).join(","))}return!1!==n&&this.formatMessage(n,e)})();default:throw`Message format '${a}' is not supported.`}},formatDate:function(e){return"object"!=typeof e&&(e=new Date(e)),t.datepicker.formatDate(Craft.datepickerOptions.dateFormat,e)},formatNumber:function(t,e){return void 0===e&&(e=",.0f"),d3.formatLocale(d3FormatLocaleDefinition).format(e)(t)},shortcutText:function(t,e,i){return"Mac"===Craft.clientOs?(i?"⌥":"")+(e?"⇧":"")+"⌘"+t:"Ctrl+"+(i?"Alt+":"")+(e?"Shift+":"")+t},escapeHtml:function(e){return t("
").text(e).html()},escapeRegex:function(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},getText:function(e){return t("
").html(e).text()},encodeUriComponent:function(t){t=encodeURIComponent(t);var e={"!":"%21","*":"%2A","'":"%27","(":"%28",")":"%29"};for(var i in e){var s=new RegExp("\\"+i,"g");t=t.replace(s,e[i])}return t},selectFullValue:function(e){var i=t(e),s=i.val();if(void 0!==i[0].setSelectionRange){var a=2*s.length;i[0].setSelectionRange(0,a)}else i.val(s)},formatInputId:function(t){return this.rtrim(t.replace(/[^\w]+/g,"-"),"-")},getUrl:function(e,i,s){"string"!=typeof e&&(e="");var a="";if(t.isPlainObject(i)){var n=[];for(var r in i)if(i.hasOwnProperty(r)){var o=i[r];"#"===r?a=o:null!==o&&""!==o&&n.push(r+"="+o)}i=n}i=Garnish.isArray(i)?i.join("&"):Craft.trim(i,"&?");var l=e.indexOf("#");-1!==l&&(a||(a=e.substr(l+1)),e=e.substr(0,l));var h,d=e.indexOf("?");if(-1!==d&&(i=e.substr(d+1)+(i?"&"+i:""),e=e.substr(0,d)),-1!==e.search("://")||"/"===e[0])return e+(i?"?"+i:"")+(a?"#"+a:"");if(e=Craft.trim(e,"/"),s){if(h=s,e&&Craft.pathParam){var c=h.match(new RegExp("[&?]"+Craft.escapeRegex(Craft.pathParam)+"=[^&]+"));c&&(h=h.replace(c[0],Craft.rtrim(c[0],"/")+"/"+e),e="")}}else h=Craft.baseUrl;if(-1!==(d=h.indexOf("?"))&&(i=h.substr(d+1)+(i?"&"+i:""),h=h.substr(0,d)),!Craft.omitScriptNameInUrls&&e)if(Craft.usePathInfo||!Craft.pathParam)-1===h.search(Craft.scriptName)&&(h=Craft.rtrim(h,"/")+"/"+Craft.scriptName);else{if(i&&i.substr(0,Craft.pathParam.length+1)===Craft.pathParam+"="){var u,p=i.indexOf("&");-1!==p?(u=i.substring(2,p),i=i.substr(p+1)):(u=i.substr(2),i=null),e=(u=Craft.rtrim(u))+(e?"/"+e:"")}i=Craft.pathParam+"="+e+(i?"&"+i:""),e=null}return e&&(h=Craft.rtrim(h,"/")+"/"+e),i&&(h+="?"+i),a&&(h+="#"+a),h},getCpUrl:function(t,e){return this.getUrl(t,e,Craft.baseCpUrl)},getSiteUrl:function(t,e){return this.getUrl(t,e,Craft.baseSiteUrl)},getActionUrl:function(t,e){return Craft.getUrl(t,e,Craft.actionUrl)},redirectTo:function(t){document.location.href=this.getUrl(t)},getCsrfInput:function(){return Craft.csrfTokenName?'':""},postActionRequest:function(e,i,s,a){"function"==typeof i&&(a=s,s=i,i={}),(a=a||{}).contentType&&a.contentType.match(/\bjson\b/)&&("object"==typeof i&&(i=JSON.stringify(i)),a.contentType="application/json; charset=utf-8");var n=t.ajax(t.extend({url:Craft.getActionUrl(e),type:"POST",dataType:"json",headers:this._actionHeaders(),data:i,success:s,error:function(t,e,i){4===t.readyState&&(void 0!==Craft.cp?Craft.cp.displayError():alert(Craft.t("app","A server error occurred.")),s&&s(null,e,t))}},a));return"function"==typeof a.send&&a.send(n),n},_waitingOnAjax:!1,_ajaxQueue:[],queueActionRequest:function(t,e,i,s){"function"==typeof e&&(s=i,i=e,e=void 0),Craft._ajaxQueue.push([t,e,i,s]),Craft._waitingOnAjax||Craft._postNextActionRequestInQueue()},_postNextActionRequestInQueue:function(){Craft._waitingOnAjax=!0;var t=Craft._ajaxQueue.shift();Craft.postActionRequest(t[0],t[1],(function(e,i,s){t[2]&&"function"==typeof t[2]&&t[2](e,i,s),Craft._ajaxQueue.length?Craft._postNextActionRequestInQueue():Craft._waitingOnAjax=!1}),t[3])},_actionHeaders:function(){let t={"X-Registered-Asset-Bundles":Object.keys(Craft.registeredAssetBundles).join(","),"X-Registered-Js-Files":Object.keys(Craft.registeredJsFiles).join(",")};return Craft.csrfTokenValue&&(t["X-CSRF-Token"]=Craft.csrfTokenValue),t},sendActionRequest:function(e,i,s){return new Promise((a,n)=>{(s=s?t.extend({},s):{}).method=e,s.url=Craft.getActionUrl(i),s.headers=t.extend({"X-Requested-With":"XMLHttpRequest"},s.headers||{},this._actionHeaders()),s.params=t.extend({},s.params||{},{v:(new Date).getTime()}),axios.request(s).then(a).catch(n)})},sendApiRequest:function(e,i,s){return new Promise((a,n)=>{let r=(s=s?t.extend({},s):{}).cancelToken||null;this._getApiHeaders(r).then(o=>{s.method=e,s.baseURL=Craft.baseApiUrl,s.url=i,s.headers=t.extend(o,s.headers||{}),s.params=t.extend(Craft.apiParams||{},s.params||{},{v:(new Date).getTime()}),this._apiHeaders||(s.params.processCraftHeaders=1),Craft.httpProxy&&(s.proxy=Craft.httpProxy),axios.request(s).then(t=>{this._processApiHeaders(t.headers,r).then(()=>{a(t.data)}).catch(n)}).catch(n)}).catch(n)})},_loadingApiHeaders:!1,_apiHeaders:null,_apiHeaderWaitlist:[],_getApiHeaders:function(t){return new Promise((i,s)=>{this._loadingApiHeaders?this._apiHeaderWaitlist.push([i,s]):this._apiHeaders?i(this._apiHeaders):(this._loadingApiHeaders=!0,this.sendActionRequest("POST","app/api-headers",{cancelToken:t}).then(t=>{this._loadingApiHeaders?i(t.data):s(e)}).catch(t=>{this._rejectApiRequests(s,t)}))})},_processApiHeaders:function(t,i){return new Promise((s,a)=>{this._apiHeaders?s():this.sendActionRequest("POST","app/process-api-response-headers",{data:{headers:t},cancelToken:i}).then(t=>{if(this._loadingApiHeaders)for(this._apiHeaders=t.data,this._loadingApiHeaders=!1,s();this._apiHeaderWaitlist.length;)this._apiHeaderWaitlist.shift()[0](this._apiHeaders);else a(e)}).catch(t=>{this._rejectApiRequests(a,t)})})},_rejectApiRequests:function(t,e){for(this._loadingApiHeaders=!1,t(e);this._apiHeaderWaitlist.length;)this._apiHeaderWaitlist.shift()[1](e)},clearCachedApiHeaders:function(){for(this._apiHeaders=null,this._loadingApiHeaders=!1;this._apiHeaderWaitlist.length;)this._apiHeaderWaitlist.shift()[1]()},downloadFromUrl:function(t,e,i){return new Promise((s,a)=>{let n=new XMLHttpRequest;n.open(t,e,!0),"object"==typeof i?(n.setRequestHeader("Content-Type","application/json; charset=UTF-8"),i=JSON.stringify(i)):n.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),n.responseType="blob",n.onload=()=>{if(200===n.status){let t=n.getResponseHeader("content-disposition"),e=/"([^"]*)"/.exec(t),i=null!=e&&e[1]?e[1]:"Download",a=n.getResponseHeader("content-type"),r=new Blob([n.response],{type:a}),o=document.createElement("a");o.href=window.URL.createObjectURL(r),o.download=i,document.body.appendChild(o),o.click(),document.body.removeChild(o),s()}else a()},n.send(i)})},stringToArray:function(e){if("string"!=typeof e)return e;for(var i=e.split(","),s=0;se.length?1:-1})),void 0===a&&(a=Craft.initialDeltaValues);for(var n=this._groupParamsByDeltaNames(t.split("&"),i,!1,a),r=this._groupParamsByDeltaNames(e.split("&"),i,!0,!1),o=r.__root__,l=0;lencodeURIComponent(t).replace("%3D","=");e=e.map(t=>decodeURIComponent(t));t:for(let t=0;t=0;s--){const a=e[t].substr(0,i[s].length+1);if(a===i[s]+"="||a===i[s]+"["){void 0===n[i[s]]&&(n[i[s]]=[]),n[i[s]].push(r(e[t]));continue t}}s&&n.__root__.push(r(e[t]))}if(a)for(let e in a)a.hasOwnProperty(e)&&(n[e]=[encodeURIComponent(e)+"="+t.param(a[e])]);return n},expandPostArray:function(t){var e,i={};for(var s in t)if(t.hasOwnProperty(s)){var a,n=t[s],r=s.match(/^(\w+)(\[.*)?/);if(r[2])for(a=r[2].match(/\[[^\[\]]*\]/g),e=0;e",{attr:{method:"post",action:"","accept-charset":"UTF-8"}});if("string"==typeof e)for(var s,a=e.split("&"),n=0;n",{type:"hidden",name:decodeURIComponent(s[0]),value:decodeURIComponent(s[1]||"")}).appendTo(i);return i},compare:function(t,e,i){if(typeof t!=typeof e)return!1;if("object"==typeof t){if(t.length!==e.length)return!1;if(t instanceof Array!=e instanceof Array)return!1;if(!(t instanceof Array))if(void 0===i||!0===i){if(!Craft.compare(Craft.getObjectKeys(t).sort(),Craft.getObjectKeys(e).sort()))return!1}else if(!Craft.compare(Craft.getObjectKeys(t),Craft.getObjectKeys(e)))return!1;for(var s in t)if(t.hasOwnProperty(s)&&!Craft.compare(t[s],e[s]))return!1;return!0}return t===e},getObjectKeys:function(t){var e=[];for(var i in t)t.hasOwnProperty(i)&&e.push(i);return e},escapeChars:function(t){Garnish.isArray(t)||(t=t.split());for(var e="",i=0;i]*href="(?:'+a.join("|")+')".*?><\/script>',"g");e=e.replace(r,"")}t("head").append(e)}},appendFootHtml:function(e){if(e){var i=t("script[src]");if(i.length){for(var s,a=[],n=0;n]*src="(?:'+a.join("|")+')".*?><\/script>',"g");e=e.replace(r,"")}Garnish.$bod.append(e)}},initUiElements:function(e){t(".grid",e).grid(),t(".info",e).infoicon(),t(".checkbox-select",e).checkboxselect(),t(".fieldtoggle",e).fieldtoggle(),t(".lightswitch",e).lightswitch(),t(".nicetext",e).nicetext(),t(".formsubmit",e).formsubmit(),t(".menubtn",e).menubtn(),t(".datetimewrapper",e).datetime(),t("a",e).each((function(){this.hostname.length&&this.hostname!==location.hostname&&void 0===t(this).attr("target")&&t(this).attr("rel","noopener").attr("target","_blank")}))},_elementIndexClasses:{},_elementSelectorModalClasses:{},_elementEditorClasses:{},registerElementIndexClass:function(t,e){if(void 0!==this._elementIndexClasses[t])throw"An element index class has already been registered for the element type “"+t+"”.";this._elementIndexClasses[t]=e},registerElementSelectorModalClass:function(t,e){if(void 0!==this._elementSelectorModalClasses[t])throw"An element selector modal class has already been registered for the element type “"+t+"”.";this._elementSelectorModalClasses[t]=e},registerElementEditorClass:function(t,e){if(void 0!==this._elementEditorClasses[t])throw"An element editor class has already been registered for the element type “"+t+"”.";this._elementEditorClasses[t]=e},createElementIndex:function(t,e,i){return new(void 0!==this._elementIndexClasses[t]?this._elementIndexClasses[t]:Craft.BaseElementIndex)(t,e,i)},createElementSelectorModal:function(t,e){return new(void 0!==this._elementSelectorModalClasses[t]?this._elementSelectorModalClasses[t]:Craft.BaseElementSelectorModal)(t,e)},createElementEditor:function(e,i,s){return void 0===s&&t.isPlainObject(i)?(s=i,i=null):"object"!=typeof s&&(s={}),s.elementType||(s.elementType=e),new(void 0!==this._elementEditorClasses[e]?this._elementEditorClasses[e]:Craft.BaseElementEditor)(i,s)},getLocalStorage:function(t,e){return t="Craft-"+Craft.systemUid+"."+t,"undefined"!=typeof localStorage&&void 0!==localStorage[t]?JSON.parse(localStorage[t]):e},setLocalStorage:function(t,e){if("undefined"!=typeof localStorage){t="Craft-"+Craft.systemUid+"."+t;try{localStorage[t]=JSON.stringify(e)}catch(t){}}},removeLocalStorage:function(t){"undefined"!=typeof localStorage&&localStorage.removeItem(`Craft-${Craft.systemUid}.${t}`)},getCookie:function(t){return document.cookie.replace(new RegExp(`(?:(?:^|.*;\\s*)Craft-${Craft.systemUid}:${t}\\s*\\=\\s*([^;]*).*$)|^.*$`),"$1")},setCookie:function(e,i,s){s=t.extend({},this.defaultCookieOptions,s);let a=`Craft-${Craft.systemUid}:${e}=${encodeURIComponent(i)}`;s.path&&(a+=";path="+s.path),s.domain&&(a+=";domain="+s.domain),s.maxAge?a+=";max-age-in-seconds="+s.maxAge:s.expires&&(a+=";expires="+s.expires.toUTCString()),s.secure&&(a+=";secure"),document.cookie=a},removeCookie:function(t){this.setCookie(t,"",new Date("1970-01-01T00:00:00"))},getElementInfo:function(e){var i=t(e);return i.hasClass("element")||(i=i.find(".element:first")),{id:i.data("id"),siteId:i.data("site-id"),label:i.data("label"),status:i.data("status"),url:i.data("url"),hasThumb:i.hasClass("hasthumb"),$element:i}},setElementSize:function(e,i){var s=t(e);if("small"!==i&&"large"!==i&&(i="small"),!s.hasClass(i)){var a="small"===i?"large":"small";if(s.addClass(i).removeClass(a),s.hasClass("hasthumb")){var n=s.find("> .elementthumb > img"),r=t("",{sizes:("small"===i?"30":"100")+"px",srcset:n.attr("srcset")||n.attr("data-pfsrcset")});n.replaceWith(r),picturefill({elements:[r[0]]})}}},submitForm:function(e,i){if(void 0===i&&(i={}),!i.confirm||confirm(i.confirm)){if(i.action&&t("",{type:"hidden",name:"action",val:i.action}).appendTo(e),i.redirect&&t("",{type:"hidden",name:"redirect",val:i.redirect}).appendTo(e),i.params)for(let s in i.params){let a=i.params[s];t("",{type:"hidden",name:s,val:a}).appendTo(e)}i.retainScroll&&this.setLocalStorage("scrollY",window.scrollY),e.trigger(t.extend({type:"submit"},i.data))}},trapFocusWithin:function(e){const i=t(e);i.on("keydown.focus-trap",t=>{if(9===t.keyCode){const e=i.find(":focusable"),s=e.index(document.activeElement);-1!==s&&(0===s&&t.shiftKey?(t.preventDefault(),t.stopPropagation(),e.last().focus()):s!==e.length-1||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e.first().focus()))}})},setFocusWithin:function(e){t(e).find(":focusable:first").focus()}}),t.extend(t.fn,{animateLeft:function(t,e,i,s){return"ltr"===Craft.orientation?this.velocity({left:t},e,i,s):this.velocity({right:t},e,i,s)},animateRight:function(t,e,i,s){return"ltr"===Craft.orientation?this.velocity({right:t},e,i,s):this.velocity({left:t},e,i,s)},disable:function(){return this.each((function(){var e=t(this);e.addClass("disabled"),e.data("activatable")&&e.removeAttr("tabindex")}))},enable:function(){return this.each((function(){var e=t(this);e.removeClass("disabled"),e.data("activatable")&&e.attr("tabindex","0")}))},grid:function(){return this.each((function(){var e=t(this),i={};e.data("item-selector")&&(i.itemSelector=e.data("item-selector")),e.data("cols")&&(i.cols=parseInt(e.data("cols"))),e.data("max-cols")&&(i.maxCols=parseInt(e.data("max-cols"))),e.data("min-col-width")&&(i.minColWidth=parseInt(e.data("min-col-width"))),e.data("mode")&&(i.mode=e.data("mode")),e.data("fill-mode")&&(i.fillMode=e.data("fill-mode")),e.data("col-class")&&(i.colClass=e.data("col-class")),e.data("snap-to-grid")&&(i.snapToGrid=!!e.data("snap-to-grid")),new Craft.Grid(this,i)}))},infoicon:function(){return this.each((function(){new Craft.InfoIcon(this)}))},checkboxselect:function(){return this.each((function(){t.data(this,"checkboxselect")||new Garnish.CheckboxSelect(this)}))},fieldtoggle:function(){return this.each((function(){t.data(this,"fieldtoggle")||new Craft.FieldToggle(this)}))},lightswitch:function(e,i,s){return"settings"===e?("string"==typeof i?(e={})[i]=s:e=i,this.each((function(){var i=t.data(this,"lightswitch");i&&i.setSettings(e)}))):(t.isPlainObject(e)||(e={}),this.each((function(){var i=t.extend({},e);Garnish.hasAttr(this,"data-value")&&(i.value=t(this).attr("data-value")),Garnish.hasAttr(this,"data-indeterminate-value")&&(i.indeterminateValue=t(this).attr("data-indeterminate-value")),t.data(this,"lightswitch")||new Craft.LightSwitch(this,i)})))},nicetext:function(){return this.each((function(){t.data(this,"nicetext")||new Garnish.NiceText(this)}))},formsubmit:function(){return this.on("click",(function(e){let i=t(e.currentTarget),s=i.data("params")||{};i.data("param")&&(s[i.data("param")]=i.data("value"));let a=i.data("menu")?i.data("menu").$anchor:i,n=a.attr("data-form")?t("#"+a.attr("data-form")):a.closest("form");Craft.submitForm(n,{confirm:i.data("confirm"),action:i.data("action"),redirect:i.data("redirect"),params:s,data:t.extend({customTrigger:i},i.data("event-data"))})}))},menubtn:function(){return this.each((function(){var e=t(this);if(!e.data("menubtn")&&e.next().hasClass("menu")){var i={};e.data("menu-anchor")&&(i.menuAnchor=e.data("menu-anchor")),new Garnish.MenuBtn(e,i)}}))},datetime:function(){return this.each((function(){let e=t(this),i=e.find('input:not([name$="[timezone]"])'),s=()=>{let s=!1;for(let t=0;t",{type:"button",class:"clear-btn",title:Craft.t("app","Clear"),"aria-label":Craft.t("app","Clear")}).appendTo(e).on("click",()=>{for(let t=0;tCraft.t("app",'Characters left: {chars, number}',{chars:t}),Garnish.$doc.ready((function(){Craft.initUiElements()})),Craft.BaseElementEditor=Garnish.Base.extend({$element:null,elementId:null,siteId:null,deltaNames:null,initialData:null,$header:null,$toolbar:null,$tabContainer:null,$editLink:null,$sidebarBtn:null,$loadSpinner:null,$body:null,$fieldsContainer:null,$sidebar:null,$footer:null,$siteSelectContainer:null,$siteSelect:null,$siteSpinner:null,$cancelBtn:null,$saveBtn:null,$saveSpinner:null,slideout:null,tabManager:null,showingSidebar:!1,cancelToken:null,ignoreFailedRequest:!1,initialDeltaValues:null,init:function(e,i){void 0===i&&t.isPlainObject(e)&&(i=e,e=null),this.$element=t(e),this.setSettings(i,Craft.BaseElementEditor.defaults),this.$header=t("
",{class:"pane-header"}),this.$toolbar=t("
",{class:"ee-toolbar"}).appendTo(this.$header),this.$tabContainer=t("
",{class:"pane-tabs"}).appendTo(this.$toolbar),this.$loadSpinner=t("
",{class:"spinner",title:Craft.t("app","Loading"),"aria-label":Craft.t("app","Loading")}).appendTo(this.$toolbar),this.$editLink=t("",{target:"_blank",class:"btn hidden",title:Craft.t("app","Open the full edit page in a new tab"),"aria-label":Craft.t("app","Open the full edit page in a new tab"),"data-icon":"external"}).appendTo(this.$toolbar),this.$sidebarBtn=t("