98 lines
25 KiB
JavaScript
98 lines
25 KiB
JavaScript
;(function($,_,undefined){"use strict";ips.controller.register('core.front.widgets.area',{_managing:false,reactContainer:null,reactRoot:null,initialize(){if(this.elem.closest('.pageBuilderRoot')){return;}
|
|
this.on('managingStarted.widgets',this.managingStarted);this.on('managingFinished.widgets',this.managingFinished);},isRoot(){if(!this.elem?.parentElement){return false}
|
|
return!this.elem.parentElement.closest('[data-controller="core.front.widgets.area"]')},async managingStarted(){if(!this.reactContainer&&this.elem.dataset.widgetarea&&this.isRoot()){this._managing=true;const container=this.reactContainer=document.createElement('div')
|
|
container.className='pageBuilderRoot'
|
|
this.elem.parentElement.insertBefore(container,this.elem)
|
|
this.reactContainer.ipsHide()
|
|
this.elem.classList.add('cWidgetContainer_managing')
|
|
this.elem.querySelectorAll('.cWidgetContainer').forEach(el=>el.classList.add('cWidgetContainer_managing'))
|
|
this.reactRoot=await ips.utils.pagebuilder.initializePageBuilderTree(container,this.elem).root
|
|
await new Promise(resolve=>setTimeout(resolve,10))
|
|
this.elem.ipsHide()
|
|
this.reactContainer.ipsShow()}},managingFinished(){if(this.isRoot()){this._managing=false;const rootClone=this.reactContainer?.cloneNode(true)
|
|
rootClone?.querySelectorAll('details > summary > input').forEach(titleInput=>{const titleNode=document.createTextNode(titleInput.value)
|
|
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){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(',')}})
|
|
try{$(document).trigger('contentChange',[$(this.elem)])}catch(e){Debug.error(e)}}}},cleanContents(){this.elem.querySelectorAll('.cWidgetContainer .ipsWidget__content--wrap > :is(.ipsWidgetBlank, .cSidebarBlock_managing), .cWidgetContainer__menu_region').forEach(el=>el.remove())
|
|
const classesToRemove=['cWidgetContainer_managing','cWidgetContainer--menu_open','cWidgetContainer--dragLeft','cWidgetContainer--dragRight','cWidgetContainer--dragAbove','cWidgetContainer--dragBelow','cWidgetContainer--dragInside','cWidgetContainer--editable']
|
|
const query=`:is(${classesToRemove.map(token => `.${token}`).join(', ')})`;[this.elem,...this.elem.querySelectorAll(query)].forEach(el=>{for(const token of classesToRemove){el.classList.remove(token)}})},});}(jQuery,_));;
|
|
;(function($,_,undefined){"use strict";ips.controller.register('core.front.widgets.block',{_orientation:'',_blockID:'',initialize(){this._blockID=this.scope.attr('data-blockID');this._orientation=this.scope.closest('[data-role="widgetReceiver"]').attr('data-orientation');this.on('reloadContents.sidebar',this.reloadContent);$(document).on('markAllRead',_.bind(this.markAllRead,this));},async reloadContent(){this._setLoading(true);try{const pageID=ips.getSetting('pageID')
|
|
const data={app:pageID?'cms':'core',module:pageID?'pages':'system',controller:pageID?'builder':'widgets',do:'getBlock',blockID:this._blockID,orientation:this._orientation}
|
|
Object.assign(data,pageID?{pageID}:{pageArea:this.elem.closest('[data-widgetArea]').dataset.widgetarea,pageApp:document.body.dataset.pageapp,pageModule:document.body.dataset.pagemodule,pageController:document.body.dataset.pagecontroller,})
|
|
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',{_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){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;}}}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++;}
|
|
return basePages;},setupObserver(){if(this._observer){this._observer.disconnect();}
|
|
if(this.getCarousel()instanceof HTMLElement){this._observer=new ResizeObserver(_.debounce(()=>this.updateCarouselIndicator()));this._observer.observe(this.getCarousel());}}});}(jQuery,_));;
|
|
;(function($,_){"use strict";let pageLoadTime;setTimeout(()=>pageLoadTime=Date.now());let state='unloaded';const whenLoadedCallbacks=[];function whenLoaded(){return new Promise(resolve=>{if(state==='loaded'){resolve();return;}
|
|
whenLoadedCallbacks.push(resolve);if(state==='unloaded'){ips.loader.get(['core/front/controllers/widgets/ips.widgets.block.js']).then(async()=>{if(!window.ips.utils.pagebuilder){const url=ips.getSetting('baseURL')+`/applications/core/interface/static/pagebuilder/manifest.json?v=${ips.getSetting('pagebuilderKey')}&antiCache=${encodeURIComponent(ips.getSetting('jsAntiCache'))}`
|
|
const data=await ips.fetch(url)
|
|
const toLoad=[];for(const key in data){if(data[key].file?.match(/\.css$/i)){const href=ips.getSetting('baseURL')+'/applications/core/interface/static/pagebuilder/'+data[key].file+`?antiCache=${encodeURIComponent(ips.getSetting('jsAntiCache'))}`
|
|
if(!document.querySelector(`[href="${encodeURI(href)}"]`)){const style=document.createElement('link')
|
|
style.rel='stylesheet'
|
|
style.href=href
|
|
document.head.appendChild(style)}}else if(data[key].isEntry){toLoad.push('/applications/core/interface/static/pagebuilder/'+data[key].file)}}
|
|
if(toLoad.length){await ips.loader.getStatic(toLoad)}}
|
|
state='loaded';while(whenLoadedCallbacks.length){whenLoadedCallbacks.shift()();}})
|
|
state='loading';}})}
|
|
ips.controller.register('core.front.widgets.manager',{_loadedManager:false,_loadingManager:false,_inManagingState:false,_wasUnused:false,initialize(){this.on('click','[data-action="openSidebar"]',this.openSidebarManager);this.on('click','[data-action="closeSidebar"]',this.closeSidebarManager);this._wasUnused=!!document.querySelector('.ipsLayout__secondary-column.ipsLayout__secondary-column--hide')||this._wasUnused;whenLoaded().then(()=>{if(ips.utils.url.getParam('_blockManager')){this.openSidebarManager();}});window.addEventListener('historychange',_.debounce((e)=>{if(ips.utils.history.getLastChangeType()!=='pagebuilder'&&e.detail?.type!=='pop'){return;}
|
|
if(this._inManagingState&&!ips.utils.url.getParam('_blockManager')){this.closeSidebarManager()}else if(!this._inManagingState&&ips.utils.url.getParam('_blockManager')){this.openSidebarManager()}},50))},getSidebar(){return this.elem.querySelector('#elSidebarManager');},setupSearch(){for(const group of this.getSidebar()?.querySelectorAll("[data-role='block_group']")||[]){let widgetsFound=group.querySelectorAll('[data-blockid][data-blocktitle]');if(widgetsFound&&widgetsFound.length){for(const block of widgetsFound){ips.utils.search.addTerm('widgets',block.dataset.blocktitle,[block.dataset.blockid]);if(block.dataset.searchterms){block.dataset.searchterms.split(',').forEach(term=>{ips.utils.search.addTerm('widgets',term,[block.dataset.blockid]);});}}}}
|
|
this.getSearchBar().addEventListener('input',e=>{const value=e.target.value;const widgetIds=ips.utils.search.search('widgets',value);if(!widgetIds.size){this.getSidebar().querySelector('[data-role="emptyMessage"]').removeAttribute('hidden');this.getSidebar().querySelector('[data-role="availableBlocks"]').setAttribute('hidden','');}else{this.getSidebar().querySelector('[data-role="emptyMessage"]').setAttribute('hidden','');this.getSidebar().querySelector('[data-role="availableBlocks"]').removeAttribute('hidden');this.getSidebar()?.querySelectorAll('[data-role=block_group]').forEach(group=>{if('favorites'in group.dataset){if(value.trim()||!group.querySelector('[data-blockid][data-blocktitle]')){group.setAttribute('hidden','');}else{group.removeAttribute('hidden');}
|
|
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.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();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',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:{}});}
|
|
this.scope.find('[data-role="availableBlocks"]').removeClass('ipsLoading ipsLoading_dark');this._loadingManager=false;}else{this._setUpDragging();this.setupSearch();this.setupFavorites();}
|
|
this._inManagingState=true;},_hideManager(){this._unfadeUnmanagedRoots();this.scope.find('#elSidebarManager').attr('hidden',true);this._inManagingState=false;},_buildSidebar(){this.elem.innerHTML+=ips.templates.render('core.sidebar.managerWrapper');try{$(document).trigger('contentChange',[this.scope]);}catch(e){Debug.error(e);}},_getUnmanagedRoots(){const unmanagedRoots=new Set();const visitedNodes=new Set();const root=document.querySelector('[data-ips-hook="main"]');function bubbleUp(el){if(el===root){return;}
|
|
if(visitedNodes.has(el)){return;}
|
|
[...el.children].forEach(child=>{if(!child.matches('.pageBuilderRoot, .cWidgetContainer, :is(.pageBuilderRoot, .cWidgetContainer) *')&&!child.querySelector('.pageBuilderRoot, .cWidgetContainer')){unmanagedRoots.add(child);}});if(el.parentElement){bubbleUp(el.parentElement);}
|
|
visitedNodes.add(el);}
|
|
root.querySelectorAll('.cWidgetContainer--main, .cWidgetContainer:not(.cWidgetContainer *)').forEach(el=>{bubbleUp(el.parentElement);})
|
|
return unmanagedRoots;},_fadeUnmanagedRoots(){this._getUnmanagedRoots().forEach(root=>{setTimeout(()=>{if(Date.now()-pageLoadTime>3000){root.classList.add('cWidgetsManaging__faded-root--animating');}
|
|
root.classList.add('cWidgetsManaging__faded-root');Promise.all(root.getAnimations().map(animation=>animation.finished)).then(()=>root.classList.remove('cWidgetsManaging__faded-root--animating'));})})},_unfadeUnmanagedRoots(){document.querySelectorAll('.cWidgetsManaging__faded-root').forEach(root=>{root.classList.add('cWidgetsManaging__faded-root--animating');root.classList.remove('cWidgetsManaging__faded-root');Promise.all(root.getAnimations().map(animation=>animation.finished)).then(()=>root.classList.remove('cWidgetsManaging__faded-root--animating'));});}});}(jQuery,_));;
|
|
;(function($,_){"use strict";ips.controller.register('core.front.widgets.sidebar',{initialize(){this.on('managingStarted.widgets',this.managingStarted);this.on('managingFinished.widgets',this.managingFinished);this.setup();},setup(){if(!CSS.supports("selector(a:has(b))")||ips.getSetting('sidebar_use_js_fallback')){Debug.log('using the js sidebar hide fallback')
|
|
this._addConditionalClasses();this.on(window,'resize',this._addConditionalClasses);this.on('addConditionalClasses',this._addConditionalClasses)}},managingStarted(){this.scope.addClass('ipsLayout__secondary-column--managing');},managingFinished(){this.scope.trigger('addConditionalClasses');this.scope.removeClass('ipsLayout__secondary-column--managing');},_addConditionalClasses(){const isVisible=[...this.elem.querySelectorAll('.cWidgetContainer--isWidget [data-blockID]:not([hidden]), #elContextualTools, [data-role="sidebarAd"]')].find(el=>{const rect=el.getBoundingClientRect();return!!(rect.width*rect.height);});if(!isVisible){this.scope.addClass('ipsLayout__secondary-column--hide');}else{this.scope.removeClass('ipsLayout__secondary-column--hide');}}});}(jQuery,_));; |