Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+19 -13
View File
@@ -14,7 +14,7 @@ rootClone?.querySelectorAll('details > summary > input').forEach(titleInput=>{co
titleInput.parentElement.replaceChild(titleNode,titleInput)})
rootClone?.querySelectorAll('[draggable]').forEach(el=>el.removeAttribute('draggable'))
const newState=rootClone?.querySelector(`[data-depth="0"]`)?.innerHTML;this.reactRoot?.unmount();this.reactContainer?.remove();document.querySelectorAll('[data-role="widgetAreaConfigForm"]').forEach(el=>el.remove())
this.reactContainer=null;this.reactRoot=null;if(newState!==undefined){this.elem.innerHTML=newState;const widgets=[...this.elem.querySelectorAll('.cWidgetContainer > .ipsWidget__content--wrap > .ipsWidget')];if(newState&&widgets.some(widget=>!!widget.innerHTML.match(/\S/))){widgets.forEach(widget=>{if(!widget.innerHTML.match(/\S/)){widget.closest('.cWidgetContainer').setAttribute('hidden','');}})
this.reactContainer=null;this.reactRoot=null;if(newState!==undefined){ips.cleanContentsOf(this.elem);this.elem.innerHTML=newState;const widgets=[...this.elem.querySelectorAll('.cWidgetContainer > .ipsWidget__content--wrap > .ipsWidget')];if(newState&&widgets.some(widget=>!!widget.innerHTML.match(/\S/))){widgets.forEach(widget=>{if(!widget.innerHTML.match(/\S/)){widget.closest('.cWidgetContainer').setAttribute('hidden','');}})
this.elem.ipsShow();}
this.cleanContents()
this.elem.querySelectorAll('section.cWidgetContainer').forEach(element=>{if(!element.dataset.controller?.split(',').includes('core.front.widgets.area')){element.dataset.controller=[(element.dataset.controller||''),'core.front.widgets.area'].filter(i=>!!i).join(',')}})
@@ -27,22 +27,29 @@ Object.assign(data,pageID?{pageID}:{pageArea:this.elem.closest('[data-widgetArea
const response=await ips.fetch(ips.getSetting('baseURL'),{method:'GET',data});this.scope.hide().html(response.html);if('devices'in response&&Array.isArray(response.devices)){this.resetResponsiveClasses(response.devices);}
ips.utils.anim.go('fadeIn',this.scope);this.trigger('loadedWidget.widgets',{blockID:this._blockID});}catch(e){this.scope.html('Error');}
this._setLoading(false);},resetResponsiveClasses(deviceList){this.scope.removeClass('ipsResponsive_hidePhone').removeClass('ipsResponsive_hideDesktop').removeClass('ipsResponsive_hideTablet');for(const value of["Phone","Tablet","Desktop"].filter(i=>!deviceList.includes(i))){this.scope.addClass('ipsResponsive_hide'+value);}},markAllRead(){this.scope.find('[data-ips-unread]').removeAttr('data-ips-unread');},_setLoading(status){if(status){this.scope.html('').addClass('ipsLoading cSidebarBlock_loading');}else{this.scope.removeClass('ipsLoading cSidebarBlock_loading');}}});}(jQuery,_));;
;(function($,_,undefined){"use strict";ips.controller.register('core.front.widgets.carouselControls',{initialize(){if(this.elem.closest('.pageBuilderRoot')||!this.getCarousel()){return;}
this._area=undefined;this.setupCarousel();},_area:undefined,getCarousel(){if(this._area===undefined){const container=this.elem.closest('.cWidgetContainer');if(!container?.classList.contains('cWidgetContainer--carousel')){this._area=null;}else{this._area=container.querySelector(":scope > .cWidgetContainer__carousel-wrap")||container;}}
return this._area;},_carouselIndicator:undefined,_isScrolling:false,_actualCarouselIndex:0,getCarouselOffset(){let children=[...this.getCarousel().querySelectorAll(':scope > .cWidgetContainer:not([hidden])')];if(this._isScrolling){return[this._actualCarouselIndex,children.length,children];}
;(function($,_,undefined){"use strict";ips.controller.register('core.front.widgets.carouselControls',{_area:undefined,_carouselInterval:undefined,_carouselIndicator:undefined,_isScrolling:false,_actualCarouselIndex:0,_container:undefined,initialize(){if(this.elem.closest('.pageBuilderRoot')||!this.getCarousel()){return;}
this._area=undefined;this.setupCarousel();},destroy(){if(this._carouselInterval){clearInterval(this._carouselInterval);}},getCarousel(){if(this._area===undefined){const container=this.getContainer();if(!container?.classList.contains('cWidgetContainer--carousel')){this._area=null;}else{this._area=container.querySelector(":scope > .cWidgetContainer__carousel-wrap")||container;}}
return this._area;},getContainer(){if(this._container===undefined){const container=this.elem.closest('.cWidgetContainer');if(!container?.classList.contains('cWidgetContainer--carousel')){this._container=null;}else{this._container=container;}}
return this._container;},getCarouselOffset(){let children=[...this.getCarousel().querySelectorAll(':scope > .cWidgetContainer:not([hidden])')];if(this._isScrolling){return[this._actualCarouselIndex,children.length,children];}
const box=this.getScrollerBox();let index;for(index=0;index<children.length-1;index++){if(!this.isRTL()&&Math.ceil(children[index].getBoundingClientRect().left)>=Math.floor(box.left)){return[index,children.length,children];}else if(this.isRTL()&&Math.floor(children[index].getBoundingClientRect().right)<=Math.ceil(box.right)){return[index,children.length,children];}}
return[children.length-1,children.length,children];},isRTL(){return ips.ui.carousel.isRTL(this.getCarousel());},getCarouselIndicator(){if(this._carouselIndicator===undefined){this._carouselIndicator=this.elem.querySelector(`.cWidgetContainer__carousel-indicator`);}
return this._carouselIndicator;},updateCarouselIndicator(){const indicator=this.getCarouselIndicator();if(!indicator){Debug.warn(`Couldn't find a carousel indicator for a carousel`);return;}
let[index,total]=this.getCarouselOffset();index=Math.min(index,this.getPageCount());total=Math.min(total,this.getPageCount());indicator.innerHTML=this.shouldUseCarouselLinks()?`<a href="#${this.getCarouselHref(index)}">${index + 1}/${total}</a>`:`${index + 1}/${total}`;this.elem.querySelectorAll('button').forEach(el=>total<=1?el.setAttribute('disabled',''):el.removeAttribute('disabled'));},carouselScroll(e){const button=e.target?.closest?.(`[data-carousel-arrow]`);if(!button){return;}
const[index,total,children]=this.getCarouselOffset();const dir=button.dataset.carouselArrow||'next';const box=this.getScrollerBox();let atEnd=false;if(dir==='next'){if(index===total-1){atEnd=true;}else if(!this.isRTL()){atEnd=Math.floor(children[total-1].getBoundingClientRect().right)<=Math.ceil(box.right);}else{atEnd=Math.ceil(children[total-1].getBoundingClientRect().left)>=Math.floor(box.left);}}else{if(index===0){atEnd=true;}else if(this.isRTL()){atEnd=Math.floor(children[0].getBoundingClientRect().right)<=Math.ceil(box.right);}else{atEnd=Math.ceil(children[0].getBoundingClientRect().left)>=Math.floor(box.left);}}
let[index,total]=this.getCarouselOffset();index=Math.min(index,this.getPageCount());total=Math.min(total,this.getPageCount());indicator.innerHTML=this.shouldUseCarouselLinks()?`<a href="#${this.getCarouselHref(index)}">${index + 1}/${total}</a>`:`${index + 1}/${total}`;this.elem.querySelectorAll('button').forEach(el=>total<=1?el.setAttribute('disabled',''):el.removeAttribute('disabled'));},carouselScroll(e){let dir;if(e instanceof PointerEvent){const button=e.target?.closest?.(`[data-carousel-arrow]`);if(!button){return;}
dir=button.dataset.carouselArrow||'next';}else if(e.detail.dir){dir=e.detail.dir}
if(!dir||!['prev','next'].includes(dir)){Debug.warn("Not scrolling because the direction could not be determined")
return;}
if(this._carouselInterval&&e instanceof PointerEvent){clearInterval(this._carouselInterval);this._carouselInterval=null;}
const[index,total,children]=this.getCarouselOffset();const box=this.getScrollerBox();let atEnd=false;if(dir==='next'){if(index===total-1){atEnd=true;}else if(!this.isRTL()){atEnd=Math.floor(children[total-1].getBoundingClientRect().right)<=Math.ceil(box.right);}else{atEnd=Math.ceil(children[total-1].getBoundingClientRect().left)>=Math.floor(box.left);}}else{if(index===0){atEnd=true;}else if(this.isRTL()){atEnd=Math.floor(children[0].getBoundingClientRect().right)<=Math.ceil(box.right);}else{atEnd=Math.ceil(children[0].getBoundingClientRect().left)>=Math.floor(box.left);}}
const toIndex=((dir==='prev'&&atEnd)?(total-1):(atEnd?0:index+(dir==='prev'?-1:1)))%total;const childBox=children[toIndex].getBoundingClientRect();const paddedBox=this.getPaddedScrollBox();let scrollAmount;if(this.isRTL()){scrollAmount=(toIndex===total-1?childBox.left:childBox.right)-paddedBox.right;}else{scrollAmount=(toIndex===total-1?childBox.right:childBox.left)-paddedBox.left;}
this._isScrolling=true;this._actualCarouselIndex=toIndex;children.forEach(child=>child.style.scrollSnapStop="normal")
this.getCarousel().scrollTo({left:this.getCarousel().scrollLeft+scrollAmount,behavior:"smooth"});this.updateCarouselIndicator();},getScrollerBox(){return this.getCarousel().getBoundingClientRect();},getPaddedScrollBox(){const box=this.getScrollerBox();const padding=this.getScrollPadding();return new DOMRect(box.x+padding.left,box.y,box.width-(padding.left+padding.right),box.height);},getScrollPadding(){return ips.ui.carousel.getScrollPadding(this.getCarousel());},carouselScrollEnd(){this._isScrolling=false;const children=this.getCarousel().querySelectorAll(":scope > .cWidgetContainer:not([hidden])");children.forEach(child=>child.style.scrollSnapStop="")
this.updateCarouselIndicator();},getCarouselHref(idx){if(this.shouldUseCarouselLinks()){return`carouselwidget_${this.getCarousel().dataset.widgetarea}_${this.getCarousel().dataset.widgetAreaId}_${idx + 1}`;}
return'';},shouldUseCarouselLinks(){return!!(this.getCarousel().dataset.widgetAreaId&&this.getCarousel().dataset.widgetarea);},setupCarousel(){if(!(this.getCarousel()instanceof Element)||this.getCarousel().closest('body')!==document.body||!this.getCarousel().querySelector(`:scope > .cWidgetContainer`)||(this.getCarousel().querySelectorAll(`:scope > .cWidgetContainer`).length===1&&this.getCarousel().querySelector(`:scope > .cWidgetContainer`).getBoundingClientRect().width>=this.elem.getBoundingClientRect().width)){this.elem.ipsHide();return;}
this.elem.ipsShow();const buttonContainer=this.elem;buttonContainer.querySelectorAll('[data-carousel-arrow]').forEach(button=>button.addEventListener('click',e=>this.carouselScroll(e)));if('onscrollend'in this.getCarousel()){this.getCarousel().addEventListener('scrollend',()=>this.carouselScrollEnd(),{capture:true});}else{this.getCarousel().addEventListener('scroll',_.debounce(()=>this.carouselScrollEnd(),200),{capture:true});}
this.updateCarouselIndicator();if(this.shouldUseCarouselLinks()&&window.location.hash){const[_,total,children]=this.getCarouselOffset();for(let i=0;i<total;i++){const hash=this.getCarouselHref(i);if(hash&&window.location.hash===`#${hash}`){this._actualCarouselIndex=i;this._isScrolling=true;children[i].scrollIntoView({behavior:"instant",block:"start",inline:"start"});break;}}}
this.setupObserver();},getPageCount(){const box=this.getCarousel()?.getBoundingClientRect();if(!box){return 1;}
this.updateCarouselIndicator();if(this.shouldUseCarouselLinks()&&window.location.hash){const[_,total,children]=this.getCarouselOffset();for(let i=0;i<total;i++){const hash=this.getCarouselHref(i);if(hash&&window.location.hash===`#${hash}`){this._actualCarouselIndex=i;this._isScrolling=true;children[i].scrollIntoView({behavior:"instant",block:"start",inline:"start"});break;}}}else{this.setupLoop();}
this.getContainer()?.addEventListener('ips:scrollCarousel',e=>this.carouselScroll(e));this.setupObserver();},setupLoop(){if(this._carouselInterval){return;}
const container=this.getContainer();if(container&&container.dataset.widgetInterval){const interval=parseInt(container.dataset.widgetInterval);if(interval>0){this._carouselInterval=setInterval(()=>{if(this.elem?.ownerDocument!==document){Debug.log('not scrolling because the carousel is no longer in the document');clearInterval(this._carouselInterval);return;}
this.elem.dispatchEvent(new CustomEvent('ips:scrollCarousel',{bubbles:true,detail:{dir:"next"}}))},interval*1000);}}},getPageCount(){const box=this.getCarousel()?.getBoundingClientRect();if(!box){return 1;}
let children=[...this.getCarousel().querySelectorAll(`:scope > .cWidgetContainer:not([hidden])`)];if(children.length<2){return 1;}
if(this.isRTL()){children=children.reverse();}
let basePages=Math.ceil(Math.abs(children[children.length-1].getBoundingClientRect().right-children[0].getBoundingClientRect().left)/box.width);if(children.length>2&&(children[children.length-1].getBoundingClientRect().right-children[children.length-2].getBoundingClientRect().left)>box.width){basePages++;}
@@ -65,18 +72,17 @@ this.getSearchBar().addEventListener('input',e=>{const value=e.target.value;cons
return;}
const blocks=group.querySelectorAll('[data-blockid][data-blocktitle]');let groupHasVisibleBlocks=(!value.trim()&&"showWhenEmpty"in group.dataset);blocks.forEach(block=>{if(!value.trim()||widgetIds.has(block.dataset.blockid)){groupHasVisibleBlocks=true;block.removeAttribute('hidden');}else{block.setAttribute('hidden','');}});if(!groupHasVisibleBlocks){group.setAttribute('hidden','');}else{group.removeAttribute('hidden');}})}})},sidebarSetup:false,setupFavorites(){if(!this.sidebarSetup){this.getSidebar().addEventListener('click',e=>{const indicator=e.target.closest('[data-blockid] [data-role="favorite-indicator"]');if(indicator){this.toggleFavorite(indicator);}});}
this.getSidebar().querySelectorAll(`[data-role="favorite-indicator"]`).forEach(indicator=>{if('isFavorite'in indicator.dataset){indicator.title=ips.getString('cSidebarBlock_unset-favorite')}else{indicator.title=ips.getString('cSidebarBlock_set-favorite')}});this.sidebarSetup=true;},async toggleFavorite(indicator){const block=indicator.closest('[data-blockid]');const blockID=block.dataset.blockid;const isFavorite="isFavorite"in indicator.dataset;const favoriteGroup=this.getSidebar().querySelector('[data-favorites]');const favoriteList=favoriteGroup.querySelector('ul');if(!isFavorite){if(!favoriteList.querySelector(`[data-blockid="${blockID}"]`)){const clone=block.cloneNode(true);clone.querySelector(`[data-role="favorite-indicator"]`).dataset.isFavorite='';clone.querySelector(`[data-role="favorite-indicator"]`).title=ips.getString('cSidebarBlock_unset-favorite');this._setupDraggingOnItem(clone);favoriteList.appendChild(clone);favoriteGroup.removeAttribute('hidden');}}else{favoriteList.querySelectorAll(`[data-blockid="${blockID}"]`).forEach(itemInFavorites=>{itemInFavorites.remove();});if(!favoriteGroup.querySelectorAll(`[data-blockid]`).length){favoriteGroup.setAttribute('hidden','');}}
this.getSidebar().querySelectorAll(`[data-blockid="${blockID}"] [data-role="favorite-indicator"]`).forEach(indicator=>{if(isFavorite){delete indicator.dataset.isFavorite;indicator.title=ips.getString('cSidebarBlock_set-favorite');}else{indicator.dataset.isFavorite="";indicator.title=ips.getString('cSidebarBlock_unset-favorite');}});try{await ips.fetch(ips.getSetting('baseURL'),{method:"get",data:{app:'core',module:'system',controller:'widgets',do:isFavorite?"removeFavorite":"addFavorite",blockID:blockID.split('_',3).pop()}});}catch(e){ips.ui.alert.show({"message":"Something went wrong, the favorites may not have been saved"});}},getSearchBar(){return this.elem.querySelector('input[data-role="widgetSearch"]');},async openSidebarManager(e){const userMenu=document.querySelector('#ipsMenu_elUserLink_menu');$(userMenu).trigger("closeMenu",true);e?.preventDefault();await whenLoaded();if(this._inManagingState){return}
this.getSidebar().querySelectorAll(`[data-blockid="${blockID}"] [data-role="favorite-indicator"]`).forEach(indicator=>{if(isFavorite){delete indicator.dataset.isFavorite;indicator.title=ips.getString('cSidebarBlock_set-favorite');}else{indicator.dataset.isFavorite="";indicator.title=ips.getString('cSidebarBlock_unset-favorite');}});try{await ips.fetch(ips.getSetting('baseURL'),{method:"get",data:{app:'core',module:'system',controller:'widgets',do:isFavorite?"removeFavorite":"addFavorite",blockID:blockID.split('_',3).pop()}});}catch(e){ips.ui.alert.show({"message":"Something went wrong, the favorites may not have been saved"});}},getSearchBar(){return this.elem.querySelector('input[data-role="widgetSearch"]');},async openSidebarManager(e){const userMenu=document.getElementById('elUserLink_menu');userMenu.hidePopover();e?.preventDefault();await whenLoaded();if(this._inManagingState){return}
document.querySelectorAll('.ipsTableOfContents__linkOptions').forEach(el=>el.dispatchEvent(new CustomEvent('remove')));if(!this.elem.querySelector('[data-role="manager"]')){this._buildSidebar();}else{this.elem.querySelectorAll('#elSidebarManager .ipsToolbox__tools').forEach(elem=>Object.assign(elem.style,{overflow:'',position:'',top:''}));}
this.triggerOn('core.front.widgets.area','managingStarted.widgets');this._showManager();if(!window.location.search.includes('_blockManager')){let anchor=window.location.href.match(/(#.*)$/)?.[1]||''
let url=window.location.href.replaceAll(/#.*$|\b_blockManager=1?\b/g,'')
url+=url.includes('?')?'&_blockManager=1':'?_blockManager=1'
url+=anchor
ips.utils.history.pushState({artificial:true},'pagebuilder',url)}
this.scope.addClass('cWidgetsManaging');},closeSidebarManager(e){e?.preventDefault();if(this._inManagingState){document.querySelectorAll('.ipsMenu[data-page-editor-menu]').forEach(element=>{element.dispatchEvent(new CustomEvent('closeMenu'));element.remove();})
this.scope.removeClass('cWidgetsManaging');this._hideManager();try{this.triggerOn('core.front.widgets.area','managingFinished.widgets');}catch(e){Debug.error(e);}
this.scope.addClass('cWidgetsManaging');},closeSidebarManager(e){e?.preventDefault();let self=this;let pageUrl=window.location.href.replace(/\?(.*?)&?_blockManager=[^&]*/,'?$1').replace(/[?&]+$/,'');if(this._inManagingState){document.querySelectorAll('.ipsMenu[data-page-editor-menu]').forEach(element=>{element.dispatchEvent(new CustomEvent('closeMenu'));element.remove();});ips.getAjax()(pageUrl,{showLoading:true,data:{do:'storeRevision'}}).done(function(response){self.scope.removeClass('cWidgetsManaging');self._hideManager();try{self.triggerOn('core.front.widgets.area','managingFinished.widgets');}catch(e){Debug.error(e);}
if(ips.utils.url.getParam('_blockManager')){if(ips.utils.history.getState('pagebuilder').artificial){window.history.back()}
setTimeout(()=>ips.utils.history.replaceState({},'pagebuilder',window.location.href.replace(/\?(.*?)&?_blockManager=[^&]*/,'?$1').replace(/[?&]+$/,'')))}}},_setUpDragging(){this.elem.querySelectorAll('[data-role="availableBlocks"] ul').forEach(list=>{list.style.zIndex=ips.ui.zIndex();list.querySelectorAll(':scope > .cSidebarManager_block').forEach(item=>this._setupDraggingOnItem(item));})},_setupDraggingOnItem(item){item.setAttribute('draggable','true');const wrapBehavior=item.dataset.widgetLayouts?.split(',')?.[0]?.trim()||'table'
item.addEventListener('dragstart',function(e){e.stopPropagation();e.dataTransfer.clearData();const data={blockID:e.target.dataset.blockid,blockTitle:e.target.dataset.blocktitle,allowReuse:e.target.dataset.allowreuse,config:!!e.target.dataset.blockconfig,blank:e.target.dataset.blockerrormessage,menustyle:e.target.dataset.menustyle,ipsWrapBehavior:wrapBehavior,};e.dataTransfer.setData('application/x.ipsblock',JSON.stringify(data));ipsSettings.__pageeditor_last_dragged_widget_data__=data;item.addEventListener('dragend',e=>{delete ipsSettings.__pageeditor_last_dragged_widget_data__;},{once:true});})},async _showManager(){this.scope.find('#elSidebarManager').removeAttr('hidden');this._fadeUnmanagedRoots();if(!this._loadedManager&&!this._loadingManager){try{const response=await ips.fetch(ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=widgets&do=getBlockList',{data:{pageApp:$('body').attr('data-pageApp')}})
setTimeout(()=>ips.utils.history.replaceState({},'pagebuilder',pageUrl));}}).fail(function(){window.location=pageUrl;});}},_setUpDragging(){this.elem.querySelectorAll('[data-role="availableBlocks"] ul').forEach(list=>{list.style.zIndex=ips.ui.zIndex();list.querySelectorAll(':scope > .cSidebarManager_block').forEach(item=>this._setupDraggingOnItem(item));})},_setupDraggingOnItem(item){item.setAttribute('draggable','true');const wrapBehavior=item.dataset.widgetLayouts?.split(',')?.[0]?.trim()||'table'
item.addEventListener('dragstart',function(e){e.stopPropagation();e.dataTransfer.clearData();const data={blockID:e.target.dataset.blockid,blockTitle:e.target.dataset.blocktitle,allowReuse:e.target.dataset.allowreuse,config:!!e.target.dataset.blockconfig,blank:e.target.dataset.blockerrormessage,menustyle:e.target.dataset.menustyle,ipsWrapBehavior:wrapBehavior,};e.dataTransfer.setData('application/x.ipsblock',JSON.stringify(data));ipsSettings.__pageeditor_last_dragged_widget_data__=data;item.addEventListener('dragend',e=>{delete ipsSettings.__pageeditor_last_dragged_widget_data__;},{once:true});})},async _showManager(){this.scope.find('#elSidebarManager').removeAttr('hidden');this._fadeUnmanagedRoots();if(!this._loadedManager&&!this._loadingManager){try{const response=await ips.fetch(ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=widgets&do=getBlockList',{data:{pageApp:$('body').attr('data-pageApp'),pageModule:$('body').attr('data-pageModule'),pageController:$('body').attr('data-pageController')}})
this._loadedManager=true;this.scope.find('[data-role="availableBlocks"]').html(response);this.scope.find('[data-role="availableBlocks"]').attr("data-unloaded",null);this._setUpDragging();this.setupSearch();this.setupFavorites();try{$(document).trigger('contentChange',[$('#elSidebarManager')]);}catch(e){Debug.error(e);}
document.dispatchEvent(new CustomEvent('ipsWidgetManagerLoaded',{bubbles:true,cancelable:true}))}catch(e){Debug.error(e)
ips.ui.alert.show({type:'alert',icon:'warn',message:ips.getString('sidebar_fetch_blocks_error'),callbacks:{}});}