").text(e).html()},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 n=2*s.length;i[0].setSelectionRange(0,n)}else i.val(s)},formatInputId:function(t){return this.rtrim(t.replace(/[\[\]\\]+/g,"-"),"-")},getUrl:function(e,i,s){if("string"!=typeof e&&(e=""),-1!==e.search("://")||"//"===e.substr(0,2))return e;e=Craft.trim(e,"/");var n="";if(t.isPlainObject(i)){var a=[];for(var r in i)if(i.hasOwnProperty(r)){var o=i[r];"#"===r?n=o:null!==o&&""!==o&&a.push(r+"="+o)}i=a}i=Garnish.isArray(i)?i.join("&"):Craft.trim(i,"&?");var l,h=e.indexOf("?");if(-1!==h&&(i=e.substr(h+1)+(i?"&"+i:""),e=e.substr(0,h)),s){if(l=s,e){var d=l.match(/[&\?]p=[^&]+/);d&&(l=l.replace(d[0],d[0]+"/"+e),e="")}}else l=Craft.baseUrl;if(-1!==(h=l.indexOf("?"))&&(i=l.substr(h+1)+(i?"&"+i:""),l=l.substr(0,h)),!Craft.omitScriptNameInUrls&&e)if(Craft.usePathInfo)-1===l.search(Craft.scriptName)&&(l=Craft.rtrim(l,"/")+"/"+Craft.scriptName);else{if(i&&"p="===i.substr(0,2)){var c,u=i.indexOf("&");-1!==u?(c=i.substring(2,u),i=i.substr(u+1)):(c=i.substr(2),i=null),e=(c=Craft.rtrim(c))+(e?"/"+e:"")}i="p="+e+(i?"&"+i:""),e=null}return e&&(l=Craft.rtrim(l,"/")+"/"+e),i&&(l+="?"+i),n&&(l+="#"+n),l},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,n){"function"==typeof i&&(n=s,s=i,i={});var a={};Craft.csrfTokenValue&&Craft.csrfTokenName&&(a["X-CSRF-Token"]=Craft.csrfTokenValue);var r=t.ajax(t.extend({url:Craft.getActionUrl(e),type:"POST",dataType:"json",headers:a,data:i,success:s,error:function(t,e){s&&s(null,e,t)},complete:function(t,e){"success"!==e&&(void 0!==Craft.cp?Craft.cp.displayError():alert(Craft.t("app","An unknown error occurred.")))}},n));return n&&"function"==typeof n.send&&n.send(r),r},_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])},stringToArray:function(e){if("string"!=typeof e)return e;for(var i=e.split(","),s=0;s=32&&s<128)e+=n;else for(var a in Craft.asciiCharMap)if(Craft.asciiCharMap.hasOwnProperty(a))for(var r=0;r]*href="(?:'+s.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=[],n=0;n]*src="(?:'+s.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(".pill",e).pill(),t(".formsubmit",e).formsubmit(),t(".menubtn",e).menubtn()},_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(t,e,i){return new(void 0!==this._elementEditorClasses[t]?this._elementEditorClasses[t]:Craft.BaseElementEditor)(e,i)},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){}}},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 n="small"===i?"large":"small";if(s.addClass(i).removeClass(n),s.hasClass("hasthumb")){var a=s.find("> .elementthumb > img"),r=t("",{sizes:("small"===i?"30":"100")+"px",srcset:a.attr("srcset")||a.attr("data-pfsrcset")});a.replaceWith(r),picturefill({elements:[r[0]]})}}}}),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")),t.data(this,"lightswitch")||new Craft.LightSwitch(this,i)}))},nicetext:function(){return this.each(function(){t.data(this,"nicetext")||new Garnish.NiceText(this)})},pill:function(){return this.each(function(){t.data(this,"pill")||new Garnish.Pill(this)})},formsubmit:function(){this.on("click",function(e){var i=t(e.currentTarget);if(!i.attr("data-confirm")||confirm(i.attr("data-confirm"))){var s=i.data("menu")?i.data("menu").$anchor:i,n=s.attr("data-form")?t("#"+s.attr("data-form")):s.closest("form");i.attr("data-action")&&t('').val(i.attr("data-action")).appendTo(n),i.attr("data-redirect")&&t('').val(i.attr("data-redirect")).appendTo(n),i.attr("data-param")&&t('').attr({name:i.attr("data-param"),value:i.attr("data-value")}).appendTo(n),n.trigger("submit")}})},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)}})}}),Garnish.$doc.ready(function(){Craft.initUiElements()}),Craft.BaseElementEditor=Garnish.Base.extend({$element:null,elementId:null,siteId:null,$form:null,$fieldsContainer:null,$cancelBtn:null,$saveBtn:null,$spinner:null,$siteSelect:null,$siteSpinner:null,hud: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.loadHud()},setElementAttribute:function(t,e){this.settings.attributes||(this.settings.attributes={}),null===e?delete this.settings.attributes[t]:this.settings.attributes[t]=e},getBaseData:function(){var e=t.extend({},this.settings.params);return this.settings.siteId?e.siteId=this.settings.siteId:this.$element&&this.$element.data("site-id")&&(e.siteId=this.$element.data("site-id")),this.settings.elementId?e.elementId=this.settings.elementId:this.$element&&this.$element.data("id")&&(e.elementId=this.$element.data("id")),this.settings.elementType&&(e.elementType=this.settings.elementType),this.settings.attributes&&(e.attributes=this.settings.attributes),e},loadHud:function(){this.onBeginLoading();var e=this.getBaseData();e.includeSites=this.settings.showSiteSwitcher,Craft.postActionRequest("elements/get-editor-html",e,t.proxy(this,"showHud"))},showHud:function(e,i){if(this.onEndLoading(),"success"===i){var s=t();if(e.sites){var n=t(''),a=t('').appendTo(n);this.$siteSelect=t("").appendTo(a),this.$siteSpinner=t('').appendTo(n);for(var r=0;r"+o.name+"").appendTo(this.$siteSelect)}this.addListener(this.$siteSelect,"change","switchSite"),s=s.add(n)}this.$form=t(""),this.$fieldsContainer=t('').appendTo(this.$form),this.updateForm(e),this.onCreateForm(this.$form);var l=t('').appendTo(this.$form),h=t('').appendTo(l);if(this.$cancelBtn=t('
").appendTo(this.$primaryButtons),this.$body=n,this.addListener(this.$cancelBtn,"activate","cancel"),this.addListener(this.$selectBtn,"activate","selectElements")},onFadeIn:function(){this.elementIndex?Garnish.isMobileBrowser(!0)||this.elementIndex.$search.trigger("focus"):this._createElementIndex(),this.base()},onSelectionChange:function(){this.updateSelectBtnState()},updateSelectBtnState:function(){this.$selectBtn&&(this.elementIndex.getSelectedElements().length?this.enableSelectBtn():this.disableSelectBtn())},enableSelectBtn:function(){this.$selectBtn.removeClass("disabled")},disableSelectBtn:function(){this.$selectBtn.addClass("disabled")},enableCancelBtn:function(){this.$cancelBtn.removeClass("disabled")},disableCancelBtn:function(){this.$cancelBtn.addClass("disabled")},showFooterSpinner:function(){this.$footerSpinner.removeClass("hidden")},hideFooterSpinner:function(){this.$footerSpinner.addClass("hidden")},cancel:function(){this.$cancelBtn.hasClass("disabled")||this.hide()},selectElements:function(){if(this.elementIndex&&this.elementIndex.getSelectedElements().length){this.elementIndex.view.elementSelect.clearMouseUpTimeout();var t=this.elementIndex.getSelectedElements(),e=this.getElementInfo(t);this.onSelect(e),this.settings.disableElementsOnSelect&&this.elementIndex.disableElements(this.elementIndex.getSelectedElements()),this.settings.hideOnSelect&&this.hide()}},getElementInfo:function(e){for(var i=[],s=0;s=this.settings.maxItems)){var i=t(e).appendTo(this.$tbody),s=i.find(".delete");this.settings.sortable&&this.sorter.addItems(i),this.$deleteBtns=this.$deleteBtns.add(s),this.addListener(s,"click","handleDeleteBtnClick"),this.totalItems++,this.updateUI()}},reorderItems:function(){if(this.settings.sortable){for(var e=[],i=0;i=this.settings.maxItems?t(this.settings.newItemBtnSelector).addClass("hidden"):t(this.settings.newItemBtnSelector).removeClass("hidden"))}},{defaults:{tableSelector:null,noItemsSelector:null,newItemBtnSelector:null,idAttribute:"data-id",nameAttribute:"data-name",sortable:!1,allowDeleteAll:!0,minItems:0,maxItems:null,reorderAction:null,deleteAction:null,reorderSuccessMessage:Craft.t("app","New order saved."),reorderFailMessage:Craft.t("app","Couldn’t save new order."),confirmDeleteMessage:Craft.t("app","Are you sure you want to delete “{name}”?"),deleteSuccessMessage:Craft.t("app","“{name}” deleted."),deleteFailMessage:Craft.t("app","Couldn’t delete “{name}”."),onReorderItems:t.noop,onDeleteItem:t.noop}}),Craft.AssetEditor=Craft.BaseElementEditor.extend({updateForm:function(t){if(this.base(t),this.$element.data("id")){var e=this.$fieldsContainer.find("> .meta > .image-preview-container.editable");e.length&&this.addListener(e,"click","showImageEditor")}},showImageEditor:function(){new Craft.AssetImageEditor(this.$element.data("id"),{onSave:t.proxy(this,"reloadForm"),allowDegreeFractions:Craft.isImagick})}}),Craft.registerElementEditorClass("craft\\elements\\Asset",Craft.AssetEditor),Craft.AssetImageEditor=Garnish.Modal.extend({$body:null,$footer:null,$imageTools:null,$buttons:null,$cancelBtn:null,$replaceBtn:null,$saveBtn:null,$editorContainer:null,$straighten:null,$croppingCanvas:null,$spinnerCanvas:null,canvas:null,image:null,viewport:null,focalPoint:null,grid:null,croppingCanvas:null,clipper:null,croppingRectangle:null,cropperHandles:null,cropperGrid:null,croppingShade:null,imageStraightenAngle:0,viewportRotation:0,originalWidth:0,originalHeight:0,imageVerticeCoords:null,zoomRatio:1,animationInProgress:!1,currentView:"",assetId:null,cacheBust:null,draggingCropper:!1,scalingCropper:!1,draggingFocal:!1,previousMouseX:0,previousMouseY:0,shiftKeyHeld:!1,editorHeight:0,editorWidth:0,cropperState:!1,scaleFactor:1,flipData:{},focalPointState:!1,croppingConstraint:!1,spinnerInterval:null,maxImageSize:null,lastLoadedDimensions:null,imageIsLoading:!1,renderImage:null,renderCropper:null,init:function(e,i){this.cacheBust=Date.now(),this.setSettings(i,Craft.AssetImageEditor.defaults),this.assetId=e,this.flipData={x:0,y:0},this.$container=t('').appendTo(Garnish.$bod),this.$body=t('').appendTo(this.$container),this.$footer=t('').appendTo(this.$container),this.base(this.$container,this.settings),this.$buttons=t('').appendTo(this.$footer),this.$cancelBtn=t('
'),this.initSourceToggle(t))},_appendSubfolder:function(e,i){for(var s=e.siblings("ul").children("li"),n=t.trim(i.children("a:first").text()),a=!1,r=0;rn){o.before(i),a=!0;break}}a||e.siblings("ul").append(i)},_cleanUpTree:function(t){null!==t&&0===t.siblings("ul").children("li").length&&(this.deinitSourceToggle(t),t.siblings("ul").remove(),t.siblings(".toggle").remove(),t.parent().removeClass("expanded"))},_positionProgressBar:function(){var e=t(),i=0,s=0;"index"===this.settings.context?(e=this.progressBar.$progressBar.closest("#content"),i=Garnish.$win.scrollTop()):(e=this.progressBar.$progressBar.closest(".main"),i=this.$main.scrollTop());var n=i-e.offset().top,a=Garnish.$win.height();s=e.height()>a?a/2-6+n:e.height()/2-6,"index"!==this.settings.context&&(s=i+(e.height()/2-6)),this.progressBar.$progressBar.css({top:s})},_performBatchRequests:function(t,e){for(var i=[],s=function(s){Craft.postActionRequest(s.action,s.params,function(s,n){this.progressBar.incrementProcessedItemCount(1),this.progressBar.updateProgressBar(),"success"===n&&(i.push(s),Craft.cp.runQueue()),i.length>=t.length&&e(i)}.bind(this))}.bind(this),n=0;n0&&"object"==typeof arguments[0]&&(arguments[0].editorSettings={onShowHud:t.proxy(this.resetOriginalFilename,this),onCreateForm:t.proxy(this._renameHelper,this),validators:[t.proxy(this.validateElementForm,this)]}),this.base.apply(this,arguments),this._attachUploader()},createElementEditor:function(t){return Craft.createElementEditor(this.settings.elementType,t,{params:{defaultFieldLayoutId:this.settings.defaultFieldLayoutId}})},_attachUploader:function(){this.progressBar=new Craft.ProgressBar(t('').appendTo(this.$container));var e={url:Craft.getActionUrl("assets/save-asset"),dropZone:this.$container,formData:{fieldId:this.settings.fieldId,elementId:this.settings.sourceElementId}};void 0!==Craft.csrfTokenName&&void 0!==Craft.csrfTokenValue&&(e.formData[Craft.csrfTokenName]=Craft.csrfTokenValue),void 0!==this.settings.criteria.kind&&(e.allowedKinds=this.settings.criteria.kind),e.canAddMoreFiles=t.proxy(this,"canAddMoreFiles"),e.events={},e.events.fileuploadstart=t.proxy(this,"_onUploadStart"),e.events.fileuploadprogressall=t.proxy(this,"_onUploadProgress"),e.events.fileuploaddone=t.proxy(this,"_onUploadComplete"),this.uploader=new Craft.Uploader(this.$container,e)},selectUploadedFile:function(t){if(this.canAddMoreElements()){var e=t.$element;e.addClass("removable"),e.prepend(''),e.appendTo(this.$elementsContainer);var i=-(e.outerWidth()+10);this.$addElementBtn.css("margin-"+Craft.left,i+"px");var s={};s["margin-"+Craft.left]=0,this.$addElementBtn.velocity(s,"fast"),this.addElements(e),delete this.modal}},_onUploadStart:function(){this.progressBar.$progressBar.css({top:Math.round(this.$container.outerHeight()/2)-6}),this.$container.addClass("uploading"),this.progressBar.resetProgressBar(),this.progressBar.showProgressBar()},_onUploadProgress:function(t,e){var i=parseInt(e.loaded/e.total*100,10);this.progressBar.setProgressPercentage(i)},_onUploadComplete:function(e,i){if(i.result.error)alert(i.result.error);else{var s=i.result.assetId;Craft.postActionRequest("elements/get-element-html",{elementId:s,siteId:this.settings.criteria.siteId},function(e){if(e.error)alert(e.error);else{var i=t(e.html);Craft.appendHeadHtml(e.headHtml),this.selectUploadedFile(Craft.getElementInfo(i))}this.uploader.isLastUpload()&&(this.progressBar.hideProgressBar(),this.$container.removeClass("uploading"))}.bind(this)),Craft.cp.runQueue()}},canAddMoreFiles:function(t){return!this.settings.limit||this.$elements.length+t1&&(i=e.pop()),{extension:i,baseFileName:e.join(".")}},_renameHelper:function(e){t(".renameHelper",e).on("focus",t.proxy(function(t){var e=t.currentTarget,i=this._parseFilename(e.value);""===this.originalFilename&&""===this.originalExtension&&(this.originalFilename=i.baseFileName,this.originalExtension=i.extension);var s=i.baseFileName.length;if(void 0!==e.selectionStart)e.selectionStart=0,e.selectionEnd=s;else if(document.selection&&document.selection.createRange){e.select();var n=document.selection.createRange();n.collapse(!0),n.moveEnd("character",s),n.moveStart("character",0),n.select()}},this))},resetOriginalFilename:function(){this.originalFilename="",this.originalExtension=""},validateElementForm:function(){var e=t(".renameHelper",this.elementEditor.hud.$hud.data("elementEditor").$form),i=this._parseFilename(e.val());return i.extension===this.originalExtension||(""===i.extension?this.originalFilename!==i.baseFileName?(e.val(i.baseFileName+"."+this.originalExtension),!0):confirm(Craft.t("app","Are you sure you want to remove the extension “.{ext}”?",{ext:this.originalExtension})):confirm(Craft.t("app","Are you sure you want to change the extension from “.{oldExt}” to “.{newExt}”?",{oldExt:this.originalExtension,newExt:i.extension})))}}),Craft.AssetSelectorModal=Craft.BaseElementSelectorModal.extend({$selectTransformBtn:null,_selectedTransform:null,init:function(e,i){i=t.extend({},Craft.AssetSelectorModal.defaults,i),this.base(e,i),i.transforms.length&&this.createSelectTransformButton(i.transforms)},createSelectTransformButton:function(e){if(e&&e.length){var i=t('').appendTo(this.$primaryButtons);this.$selectBtn.appendTo(i),this.$selectTransformBtn=t('
").appendTo(n),r=t('').appendTo(n);this.$logoutWarningPara=t("").prependTo(s),this.logoutWarningModal=new Garnish.Modal(i,{autoShow:!1,closeOtherModals:!1,hideOnEsc:!1,hideOnShadeClick:!1,shadeClass:"modal-shade dark",onFadeIn:function(){Garnish.isMobileBrowser(!0)||setTimeout(function(){r.trigger("focus")},100)}}),this.addListener(a,"activate","logout"),this.addListener(i,"submit","renewSession")}e?this.logoutWarningModal.quickShow():this.logoutWarningModal.show(),this.updateLogoutWarningMessage(),this.decrementLogoutWarningInterval=setInterval(t.proxy(this,"decrementLogoutWarning"),1e3)},updateLogoutWarningMessage:function(){this.$logoutWarningPara.text(Craft.t("app","Your session will expire in {time}.",{time:Craft.secondsToHumanTimeDuration(this.remainingSessionTime)})),this.logoutWarningModal.updateSizeAndPosition()},decrementLogoutWarning:function(){this.remainingSessionTime>0&&(this.remainingSessionTime--,this.updateLogoutWarningMessage()),0===this.remainingSessionTime&&clearInterval(this.decrementLogoutWarningInterval)},hideLogoutWarningModal:function(t){this.showingLogoutWarningModal=!1,this.logoutWarningModal&&(t?this.logoutWarningModal.quickHide():this.logoutWarningModal.hide(),this.decrementLogoutWarningInterval&&clearInterval(this.decrementLogoutWarningInterval))},showLoginModal:function(){var e;if(this.showingLogoutWarningModal?(this.hideLogoutWarningModal(!0),e=!0):e=!1,this.showingLoginModal=!0,!this.loginModal){var i=t(''),s=t('
'+Craft.t("app","Your session has ended.")+"
"+Craft.t("app","Enter your password to log back in.")+"
').appendTo(s),this.$footer=t('').appendTo(s),this.$footerBtnContainer=t('').appendTo(this.$footer),this.$cancelBtn=t('').text(Craft.t("app","Cancel")).appendTo(this.$footerBtnContainer),this.$saveBtn=t('').text(Craft.t("app","Save")).appendTo(this.$footerBtnContainer),this.$saveSpinner=t('').appendTo(this.$footerBtnContainer),this.$newHeadingBtn=t('').text(Craft.t("app","New heading")).appendTo(t('').appendTo(this.$footer)),this.$loadingSpinner=t('').appendTo(s),this.setContainer(s),this.show();var n={elementType:this.elementIndex.elementType};Craft.postActionRequest("element-index-settings/get-customize-sources-modal-data",n,t.proxy(function(t,e){this.$loadingSpinner.remove(),"success"===e&&(this.$saveBtn.removeClass("disabled"),this.buildModal(t))},this)),this.addListener(this.$newHeadingBtn,"click","handleNewHeadingBtnClick"),this.addListener(this.$cancelBtn,"click","hide"),this.addListener(this.$saveBtn,"click","save"),this.addListener(this.$container,"submit","save")},buildModal:function(e){this.availableTableAttributes=e.availableTableAttributes,this.sourceSort=new Garnish.DragSort({handle:".move",axis:"y",onSortChange:t.proxy(function(){this.updateSourcesOnSave=!0},this)}),this.sources=[];for(var i=0;i').appendTo(this.$sourcesContainer),n=t('').appendTo(s),a=t('').appendTo(s);return t('').appendTo(s),void 0!==e.heading?(s.addClass("heading"),a.attr("name","sourceOrder[][heading]"),(i=new Craft.CustomizeSourcesModal.Heading(this,s,n,a,e)).updateItemLabel(e.heading)):(a.attr("name","sourceOrder[][key]").val(e.key),(i=new Craft.CustomizeSourcesModal.Source(this,s,n,a,e)).updateItemLabel(e.label),(this.elementIndex.sourceKey+"/").substr(0,e.key.length+1)===e.key+"/"&&i.select()),this.sourceSort.addItems(s),i},handleNewHeadingBtnClick:function(){var t=this.addSource({heading:""});Garnish.scrollContainerToElement(this.$sidebar,t.$item),t.select(),this.updateSourcesOnSave=!0},save:function(e){if(e&&e.preventDefault(),!this.$saveBtn.hasClass("disabled")&&this.$saveSpinner.hasClass("hidden")){this.$saveSpinner.removeClass("hidden");var i=this.$container.serialize()+"&elementType="+this.elementIndex.elementType;Craft.postActionRequest("element-index-settings/save-customize-sources-modal-settings",i,t.proxy(function(t,e){if(this.$saveSpinner.addClass("hidden"),"success"===e&&t.success){if(this.updateSourcesOnSave&&this.$elementIndexSourcesContainer.length){for(var i,s=null,n=0;n").append(this.createSettings()).appendTo(this.modal.$sourceSettingsContainer),this.modal.$sourceSettingsContainer.scrollTop(0))},createSettings:function(){},getIndexSource:function(){},deselect:function(){this.$item.removeClass("sel"),this.modal.selectedSource=null,this.$settingsContainer.addClass("hidden")},updateItemLabel:function(t){this.$itemLabel.text(t)},destroy:function(){this.$item.data("source",null),this.base()}}),Craft.CustomizeSourcesModal.Source=Craft.CustomizeSourcesModal.BaseSource.extend({createSettings:function(){if(this.sourceData.tableAttributes.length){var e,i,s,n,a=this.sourceData.tableAttributes[0],r=a[0],o=a[1],l=this.createTableColumnOption(r,o,!0,!0),h=t(""),d=[r];for(t('').appendTo(h),e=1;e').append('').append(Craft.ui.createCheckbox({label:i,name:"sources["+this.sourceData.key+"][tableAttributes][]",value:e,checked:n,disabled:s}));return s&&a.children(".move").addClass("disabled"),a},getIndexSource:function(){var t=this.modal.elementIndex.getSourceByKey(this.sourceData.key);if(t)return t.closest("li")}}),Craft.CustomizeSourcesModal.Heading=Craft.CustomizeSourcesModal.BaseSource.extend({$labelField:null,$labelInput:null,$deleteBtn:null,isHeading:function(){return!0},select:function(){this.base(),this.$labelInput.trigger("focus")},createSettings:function(){return this.$labelField=Craft.ui.createTextField({label:Craft.t("app","Heading"),instructions:Craft.t("app","This can be left blank if you just want an unlabeled separator."),value:this.sourceData.heading}),this.$labelInput=this.$labelField.find(".text"),this.$deleteBtn=t('').text(Craft.t("app","Delete heading")),this.addListener(this.$labelInput,"textchange","handleLabelInputChange"),this.addListener(this.$deleteBtn,"click","deleteHeading"),t([this.$labelField[0],t("")[0],this.$deleteBtn[0]])},handleLabelInputChange:function(){this.updateItemLabel(this.$labelInput.val()),this.modal.updateSourcesOnSave=!0},updateItemLabel:function(t){this.$itemLabel.html((t?Craft.escapeHtml(t):''+Craft.t("app","(blank)")+"")+" "),this.$itemInput.val(t)},deleteHeading:function(){this.modal.sourceSort.removeItems(this.$item),this.modal.sources.splice(t.inArray(this,this.modal.sources),1),this.modal.updateSourcesOnSave=!0,this.isSelected()&&(this.deselect(),this.modal.sources.length&&this.modal.sources[0].select()),this.$item.remove(),this.$settingsContainer.remove(),this.destroy()},getIndexSource:function(){var e=this.$labelInput?this.$labelInput.val():this.sourceData.heading;return t('').append(t("").text(e))}}),Craft.DataTableSorter=Garnish.DragSort.extend({$table:null,init:function(e,i){this.$table=t(e);var s=this.$table.children("tbody").children(":not(.filler)");(i=t.extend({},Craft.DataTableSorter.defaults,i)).container=this.$table.children("tbody"),i.helper=t.proxy(this,"getHelper"),i.caboose="
'+Craft.t("app","What do you want to do with their content?")+'
'+Craft.t("app","Choose a user")+'
").appendTo(n),r=t('').appendTo(a),o=t('
'+Craft.t("app","Cancel")+"
").appendTo(r);if(this.$deleteActionRadios=a.find("input[type=radio]"),this.$deleteSubmitBtn=t('').appendTo(r),this.$deleteSpinner=t('').appendTo(r),Garnish.isArray(this.userId)){s=["and"];for(var l=0;l0},initialize:function(){if(!this.initialized){this.initialized=!0,this.removeListener(Garnish.$win,"resize");for(var t=this.$tbody.children(),e=0;e",{"data-id":e});for(var r in i)if(i.hasOwnProperty(r)){var o,l=i[r],h=void 0!==n[r]?n[r]:"";if("heading"===l.type)o=t("
").appendTo(this.$promptChoices).find("input");this.addListener(l,"click",function(){r.removeClass("disabled")})}this.addListener(r,"activate",function(e){var i=t(e.currentTarget).parents(".modal").find("input[name=promptAction]:checked").val(),s=this.$promptApplyToRemainingCheckbox.prop("checked");this._selectPromptChoice(i,s)}),this.addListener(a,"activate",function(){var t=this.$promptApplyToRemainingCheckbox.prop("checked");this._selectPromptChoice("cancel",t)}),n&&(this.$promptApplyToRemainingContainer.show(),this.$promptApplyToRemainingLabel.html(" "+Craft.t("app","Apply this to the {number} remaining conflicts?",{number:n}))),this.modal.show(),this.modal.removeListener(Garnish.Modal.$shade,"click"),this.addListener(Garnish.Modal.$shade,"click","_cancelPrompt")},_selectPromptChoice:function(e,i){this.$prompt.fadeOut("fast",t.proxy(function(){this.modal.hide(),this._promptCallback(e,i)},this))},_cancelPrompt:function(){this._selectPromptChoice("cancel",!0)}}),Craft.SlideRuleInput=Garnish.Base.extend({$container:null,$options:null,$selectedOption:null,$input:null,value:null,startPositionX:null,init:function(e,i){this.setSettings(i,Craft.SlideRuleInput.defaultSettings),this.value=0,this.graduationsMin=-70,this.graduationsMax=70,this.slideMin=-45,this.slideMax=45,this.$container=t("#"+e),this.$overlay=t('').appendTo(this.$container),this.$cursor=t('').appendTo(this.$container),this.$graduations=t('').appendTo(this.$container),this.$graduationsUl=t("