Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -8,8 +8,8 @@ var template='table.row.loading';if(this.scope.attr('data-dummyLoadingTemplate')
|
||||
var newRows=[];for(var i=0;i<=rows.length;i++){var rnd=parseInt(Math.random()*(10-1)+1);newRows.push(ips.templates.render(template,{extraClass:this.scope.attr('data-dummyLoadingClass')||'',rnd:rnd}));}
|
||||
this.scope.find('[data-role="tableRows"]').html(newRows.join(''));};this._basicLoading=function(loading){var rowElem=this.scope.find('[data-role="tableRows"]');if(!rowElem.length){return;}
|
||||
if(!this._tableOverlay){this._tableOverlay=$('<div/>').addClass('ipsLoading').hide();ips.getContainer().append(this._tableOverlay);}
|
||||
if(loading){var dims=ips.utils.position.getElemDims(rowElem);var position=ips.utils.position.getElemPosition(rowElem);this._tableOverlay.show().css({left:position.viewportOffset.left+'px',top:position.viewportOffset.top+$(document).scrollTop()+'px',width:dims.width+'px',height:dims.height+'px',position:'absolute',zIndex:ips.ui.zIndex()});rowElem.css({opacity:"0.5"});}else{rowElem.animate({opacity:"1"});this._tableOverlay.hide();}};this.changeSorting=function(e,data){data.originalEvent.preventDefault();if(_.isUndefined(data.selectedItemID)){return;}
|
||||
var current=this._getSortValue();var menuItem=data.menuElem.find('[data-ipsMenuValue="'+data.selectedItemID+'"]');var sortBy=data.selectedItemID;var sortDirection=current.order;if(menuItem.attr('data-sortDirection')){sortDirection=menuItem.attr('data-sortDirection');}
|
||||
if(loading){var dims=ips.utils.position.getElemDims(rowElem);var position=ips.utils.position.getElemPosition(rowElem);this._tableOverlay.show().css({left:position.viewportOffset.left+'px',top:position.viewportOffset.top+$(document).scrollTop()+'px',width:dims.width+'px',height:dims.height+'px',position:'absolute',zIndex:ips.ui.zIndex()});rowElem.css({opacity:"0.5"});}else{rowElem.animate({opacity:"1"});this._tableOverlay.hide();}};this.changeSorting=function(e,data=e.detail){data.originalEvent.preventDefault();if(_.isUndefined(data.selectedItemID)){return;}
|
||||
var current=this._getSortValue();var menuItem=$(data.menuElem).find('[data-ipsMenuValue="'+data.selectedItemID+'"]');var sortBy=data.selectedItemID;var sortDirection=current.order;if(menuItem.attr('data-sortDirection')){sortDirection=menuItem.attr('data-sortDirection');}
|
||||
this.updateURL({sortby:sortBy,sortdirection:sortDirection,page:1});};this._getSortValue=function(){var by=ips.utils.url.getParam('sortby');var order=ips.utils.url.getParam('sortdirection');return{by:by||'',order:order||''};};this._getFilterValue=function(){var filter=ips.utils.url.getParam('filter');return filter||'';};});}(jQuery,_));;
|
||||
;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.app',{initialize:function(){this.on('click','a[data-confirm],button[data-confirm]',this.confirmSomething);this.on(document,'contentChange',this._checkAndClearAutosave);this.on(document,'contentChange',this.checkOldEmbeds);this.on(document,'contentChange',this.updateExternalLinks);document.addEventListener("ips:colorScheme",this.colorScheme);window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change',this.updatePrefersColorScheme);if(ips.utils.broadcastChannel.enabled){ips.utils.broadcastChannel.channel.addEventListener("message",this.broadcastChannelEvent);}
|
||||
this.setup();},setup:function(){if(ips.utils.serviceWorker.supported){ips.utils.serviceWorker.registerServiceWorker('front',!_.isUndefined(ips.utils.cookie.get('loggedIn')));}
|
||||
@@ -27,12 +27,12 @@ ips.controller.register('core.front.core.autoSizeIframe',{_origin:ips.utils.url.
|
||||
this.on(window,'message',this.receiveMessage);this.on(document,'breakpointChange',this.breakpointChange);this.setup();},getEmbedSrc(){return this.elem.src;},setup(){this._lastDims={height:0,width:0};let cachedDims;if(PREINITIALIZED_DIMS_FLAG in this.elem){Object.assign(this._lastDims,this.elem[PREINITIALIZED_DIMS_FLAG]);}else if(this.getEmbedSrc()&&(cachedDims=ips.utils.db.get('embedDimsCache',this.getEmbedSrc()))&&cachedDims){if(typeof cachedDims?.height==='number'&&cachedDims.height>0){Debug.log(`(EMBED) - Using cached height and width while the embed initializes`);if(typeof cachedDims?.width==='number'&&cachedDims.width>0){this.dims(cachedDims);}else{this.height({height:cachedDims.height});}}}
|
||||
var iframe=this.scope.get(0);iframe.style.overflow='hidden';this._getBorderAdjustment();if(this.scope.height()>800){this.scope.css({height:'800px'});}
|
||||
this._iframe=iframe.contentWindow;this._embedId='embed'+parseInt(Math.random()*(10000000000-1)+1);this.scope.attr('data-embedId',this._embedId);if(!window.postMessage||!window.JSON.parse){this.scope.css({height:'400px'});Debug.error("Can't resize embed: "+this._embedId);return;}
|
||||
this._startReadyTimeout();},_startReadyTimeout(){this._readyTimeout=setInterval(_.bind(function(){this._postMessage('ready');},this),100);setTimeout(_.bind(function(){this._stopReadyTimeout();},this),10000);},_stopReadyTimeout(){if(this._readyTimeout!==null){Debug.log("Stopped posting to embed "+this._embedId);clearInterval(this._readyTimeout);this._readyTimeout=null;}},destruct(){Debug.log('Destruct autoSizeIframe '+this._embedId);this._stopReadyTimeout();this._postMessage('stop');},receiveMessage(e){if(e.originalEvent.origin!==this._origin){return;}
|
||||
this._intersectionObserver=new IntersectionObserver(entries=>{if(entries.some(entry=>entry.isIntersecting)){this._intersectionObserver.disconnect();this._startReadyTimeout();}},{threshold:0});this._intersectionObserver.observe(iframe);},_startReadyTimeout(){this._readyTimeout=setInterval(_.bind(function(){this._postMessage('ready');},this),100);setTimeout(_.bind(function(){this._stopReadyTimeout();},this),10000);},_stopReadyTimeout(){if(this._readyTimeout!==null){Debug.log("Stopped posting to embed "+this._embedId);clearInterval(this._readyTimeout);this._readyTimeout=null;}},destruct(){Debug.log('Destruct autoSizeIframe '+this._embedId);this._intersectionObserver?.disconnect();this._stopReadyTimeout();this._postMessage('stop');},receiveMessage(e){if(e.originalEvent.origin!==this._origin){return;}
|
||||
try{const pmData=typeof e.originalEvent.data==='string'?JSON.parse(e.originalEvent.data):e.originalEvent.data;const method=pmData.method;if(pmData.embedId===undefined||pmData.embedId!==this._embedId){return;}
|
||||
this._stopReadyTimeout();this[method]?.call(this,pmData);}catch(err){Debug.error(err.message);}},_postMessage(method,obj){Debug.log("Posting to iframe "+this._embedId);this._iframe.postMessage(JSON.stringify(_.extend(obj||{},{method:method,embedId:this._embedId})),this._origin);},_getBorderAdjustment(){this._border.vertical=parseInt(this.scope.css('border-top-width'))+parseInt(this.scope.css('border-bottom-width'));this._border.horizontal=parseInt(this.scope.css('border-left-width'))+parseInt(this.scope.css('border-right-width'));},breakpointChange(e,data){this._postMessage('responsiveState',{currentIs:data.curBreakName});},dialog(data){var options=ips.ui.getAcceptedOptions('dialog');var dialogOptions={};_.each(options,function(opt){if(!_.isUndefined(data.options['data-ipsdialog-'+opt.toLowerCase()])){dialogOptions[opt]=data.options['data-ipsdialog-'+opt.toLowerCase()];}});if(_.isUndefined(dialogOptions['url'])){dialogOptions['url']=data.url;}
|
||||
var dialogRef=ips.ui.dialog.create(dialogOptions);dialogRef.show();},height(data){if(this._lastDims.height!==data.height){this.scope.css({height:parseInt(data.height)+this._border.vertical+'px'});this._lastDims.height=data.height;if(this.getEmbedSrc()){ips.utils.db.set('embedDimsCache',this.getEmbedSrc(),this._lastDims);}}},dims(data){if(parseInt(this._lastDims.height)!==parseInt(data.height)||this._lastDims.width!==data.width){this.scope.css({height:parseInt(data.height)+this._border.vertical+'px',maxWidth:(data.width.toString().indexOf('%')==-1)?parseInt(data.width)+this._border.horizontal+'px':'100%'});this._lastDims.height=data.height;this._lastDims.width=data.width;if(this.getEmbedSrc()){ips.utils.db.set('embedDimsCache',this.getEmbedSrc(),this._lastDims);}}},ok(){this._stopReadyTimeout();this.scope.addClass('ipsEmbed_finishedLoading');this._postMessage('responsiveState',{currentIs:ips.utils.responsive.getCurrentKey()});}});}(jQuery,_));;
|
||||
;(function(){"use strict";ips.controller.register('core.front.core.colorScheme',{initialize(){this.menu=this.scope[0];this.on(this.menu,'click',this.changeColorScheme);if(!this.menu.querySelector("[aria-current")){this.schemePref=ips.utils.cookie.get('scheme_preference')||document.documentElement.dataset.ipsSchemeDefault;document.querySelectorAll('[data-ips-prefers-color-scheme='+this.schemePref+']').forEach(el=>el.setAttribute('aria-current','true'));}},changeColorScheme(ev){let el=ev.target.closest('[data-controller="core.front.core.colorScheme"] [data-ips-prefers-color-scheme]');if(!el)return;document.dispatchEvent(new CustomEvent("ips:colorScheme",{bubbles:true,detail:{scheme:el.dataset.ipsPrefersColorScheme}}));if(ips.utils.broadcastChannel.enabled){ips.utils.broadcastChannel.channel.postMessage({command:'colorScheme',value:el.dataset.ipsPrefersColorScheme});}}});}());;
|
||||
;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.comment',{_quoteData:null,_commentContents:'',_quotingDisabled:false,_quoteTimeout:null,_isEditing:false,_clickHandler:null,_observer:null,initialize:function(){for(const link of this.scope.find('[data-ipsMenu]')){const menuSelector=$(link).attr('href');for(const action of['editComment','deleteComment','approveComment']){this.on(document,'click',`${menuSelector} [data-action="${action}"]`,this[action]);}}
|
||||
;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.comment',{_quoteData:null,_commentContents:'',_quotingDisabled:false,_quoteTimeout:null,_isEditing:false,_clickHandler:null,_observer:null,initialize:function(){for(const link of this.scope.find('[popovertarget^="elcomment_"]')){const menuSelector=$(link).attr('popovertarget');for(const action of['editComment','deleteComment','approveComment']){this.on(document,'click',`#${menuSelector} [data-action="${action}"]`,this[action]);}}
|
||||
for(const action of['quoteComment','multiQuoteComment','rateReview','cancelEditComment']){this.on('click',`[data-action="${action}"]`,this[action]);}
|
||||
this.on('submit','form',this.submitEdit);this.on('change','input[type="checkbox"][data-role="moderation"]',this.commentCheckbox);this.elem.addEventListener('ipsCalcQuote',()=>this.inlineQuote())
|
||||
this.on('click','[data-action="quoteSelection"]',this.quoteSelection);this.on('submitDialog','[data-action="recommendComment"]',this.recommendComment);this.on('click','[data-action="unrecommendComment"]',this.unrecommendComment);this.on('tabChanged',this.tabChanged);this.on('setMultiQuoteEnabled.comment setMultiQuoteDisabled.comment',this.setMultiQuote);this.on('disableQuoting.comment',this.disableQuoting);this.on(document,'getEditFormLoading.comment saveEditCommentLoading.comment '+
|
||||
@@ -45,16 +45,16 @@ var commentHtml=$('<div>'+data.comment+'</div>').find('[data-controller="core.fr
|
||||
window.reload();},_checkQuoteStatus:function(){var selectedText=ips.utils.selection.getSelectedText('[data-role="commentContent"]',this.scope.find('[data-role="commentContent"]').parent());var ancestor=ips.utils.selection.getCommonAncestor();if(selectedText.trim()===''){this._hideQuoteTooltip();return;}
|
||||
if(ancestor&&ancestor.closest('.ipsCode').length){selectedText="<pre class='ipsCode prettyprint'>"+selectedText+"</pre>";}else if(!selectedText.startsWith('<')){selectedText='<p>'+selectedText+'</p>';}
|
||||
if(this._selectedText===selectedText){return;}
|
||||
this._selectedText=selectedText;this._showQuoteTooltip();},_showQuoteTooltip:function(){var selection=ips.utils.selection.getSelection();var range=ips.utils.selection.getRange(this.scope.find('[data-role="commentContent"]'));var tooltip=this.scope.find('[data-role="inlineQuoteTooltip"]');var scopeOffset=this.scope.offset();var position={left:0,top:0};if(range===false||!_.isObject(range)||_.isUndefined(range.type)){Debug.log("No selection found");return;}
|
||||
this._selectedText=selectedText;this._showQuoteTooltip();},_showQuoteTooltip:function(){var selection=ips.utils.selection.getSelection();var range=ips.utils.selection.getRange(this.scope.find('[data-role="commentContent"]'));var tooltip=this.scope.find('[data-role="inlineQuoteTooltip"]');var position={left:0,top:0};if(range===false||!_.isObject(range)||_.isUndefined(range.type)){Debug.log("No selection found");return;}
|
||||
if(!tooltip.length){this.scope.append(ips.templates.render('core.selection.quote',{direction:'bottom'}));tooltip=this.scope.find('[data-role="inlineQuoteTooltip"]');$(document).on('click dblclick',this._clickHandler);}
|
||||
if(range.type==='outside'){var boundingBox=range.range.getBoundingClientRect();var offset=this.scope.offset();position.left=boundingBox.left+(boundingBox.width/2)+$(window).scrollLeft()-offset.left;position.top=boundingBox.top+boundingBox.height+$(window).scrollTop()-offset.top;}else{var cloneRange=range.range.cloneRange();var invisibleElement=document.createElement('span');invisibleElement.appendChild(document.createTextNode('\ufeff'));cloneRange.collapse(false);cloneRange.insertNode(invisibleElement);var tmpPosition=ips.utils.position.getElemPosition($(invisibleElement));position.left=tmpPosition.absPos.left-scopeOffset.left;position.top=tmpPosition.absPos.top-scopeOffset.top+25;invisibleElement.parentNode.removeChild(invisibleElement);}
|
||||
var tooltipSize={width:tooltip.show().outerWidth(),height:tooltip.show().outerHeight()};var leftAdjustment=ips.utils.events.isTouchDevice()?tooltipSize.width:(tooltipSize.width/2);tooltip.css({position:'absolute',left:Math.round(position.left-leftAdjustment)+'px',top:Math.round(position.top)+'px',zIndex:ips.ui.zIndex()});if(!tooltip.is(':visible')){tooltip.hide().fadeIn('fast');}else{tooltip.show();}},_hideQuoteTooltip:function(){$(document).off('click dblclick',this._clickHandler);clearInterval(this._quoteTimeout);this.scope.find('[data-role="inlineQuoteTooltip"]').fadeOut('fast');this._selectedText='';},feedJQ(){if(this.elem.dataset.feedid){const closest=this.elem.closest(`[data-feedid=${this.elem.dataset.feedid}][data-controller*="core.front.core.commentFeed"]`);if(closest){return $(closest);}
|
||||
if(range.type==='outside'){var boundingBox=range.range.getBoundingClientRect();var offset=this.scope.offset();position.left=boundingBox.left+(boundingBox.width/2)+$(window).scrollLeft()-offset.left;position.top=boundingBox.top+boundingBox.height+$(window).scrollTop()-offset.top;}else{var cloneRange=range.range.cloneRange();var invisibleElement=document.createElement('span');invisibleElement.appendChild(document.createTextNode('\ufeff'));cloneRange.collapse(false);cloneRange.insertNode(invisibleElement);var tmpPosition=ips.utils.position.getElemPosition($(invisibleElement));position.left=tmpPosition.absPos.left;position.top=tmpPosition.absPos.top+25;invisibleElement.parentNode.removeChild(invisibleElement);}
|
||||
tooltip[0].showPopover();var tooltipSize={width:tooltip.outerWidth(),height:tooltip.outerHeight()};var leftAdjustment=ips.utils.events.isTouchDevice()?tooltipSize.width:(tooltipSize.width/2);tooltip.css({left:Math.round(position.left-leftAdjustment)+'px',top:Math.round(position.top)+'px'});tooltip[0].showPopover();},_hideQuoteTooltip:function(){$(document).off('click dblclick',this._clickHandler);clearInterval(this._quoteTimeout);this.scope.find('[data-role="inlineQuoteTooltip"]')[0]?.hidePopover();this._selectedText='';},feedJQ(){if(this.elem.dataset.feedid){const closest=this.elem.closest(`[data-feedid=${this.elem.dataset.feedid}][data-controller*="core.front.core.commentFeed"]`);if(closest){return $(closest);}
|
||||
const feed=document.querySelector(`[data-feedid=${this.elem.dataset.feedid}][data-controller*="core.front.core.commentFeed"]`);if(feed){return $(feed);}
|
||||
Debug.warn(`The comment feed for a comment could not be identified. This can be prevented by ensuring the comment and its feed have macthing data-feedid attributes (comment's feedid: ${this.elem.dataset.feedid})`);}else{Debug.warn(`A comment is missing its data-feedid attribute, so its comment feed could not be identified. This can be prevented by ensuring the comment and its feed have macthing data-feedid attributes`);}
|
||||
Debug.warn(this.elem);return $(this.elem.closest(`[data-controller*="core.front.core.commentFeed"]`)||this.elem);},quoteSelection:function(e){e.preventDefault();this._getQuoteData();if(this._selectedText){this.feedJQ().trigger('quoteComment.comment',{userid:this._quoteData.userid,username:this._quoteData.username,timestamp:this._quoteData.timestamp,contentapp:this._quoteData.contentapp,contenttype:this._quoteData.contenttype,contentclass:this._quoteData.contentclass,contentid:this._quoteData.contentid,contentcommentid:this._quoteData.contentcommentid,quoteHtml:this._selectedText,citeurl:$(this.elem).get(0).querySelector(".ipsEntry__date[href]")?.getAttribute('href')});}
|
||||
this._hideQuoteTooltip();},commentCheckbox:function(e){var checked=$(e.currentTarget).is(':checked');this.scope.closest('.js-ipsEntry').toggleClass('ipsEntry--selected',checked);this.scope.closest('.js-ipsEntry').find('label[for='+$(e.currentTarget).attr('id')+']').toggleClass('ipsInput--pseudoChecked',checked);this.feedJQ().trigger('checkedComment.comment',{commentID:this._commentID,actions:$(e.currentTarget).attr('data-actions'),checked:checked});},disableQuoting:function(){this._quotingDisabled=true;this.scope.find('[data-ipsQuote-editor]').remove();},rateReview:function(e){e.preventDefault();var self=this;ips.getAjax()($(e.currentTarget).attr('href')).done(function(response){var content=$("<div>"+response+"</div>");self.scope.html(content.find('[data-controller="core.front.core.comment"]').contents());$(document).trigger('contentChange',[self.scope]);}).fail(function(err){window.location=$(e.currentTarget).attr('href');});},_menu:undefined,getMenu(){if(!this._menu){let activeTabId=this.elem.closest(`[data-commentstype="reviews"]`)?'elReview':'elComment';let commentFeed=this.scope.get(0)?.closest('[data-controller]')
|
||||
while(commentFeed&&!commentFeed.dataset.controller?.includes('core.front.core.commentFeed')){commentFeed=commentFeed.parentElement?.closest('[data-controller]')}
|
||||
const menuLink=(commentFeed||document).querySelector('#'+activeTabId+`_${this.scope.get(0)?.dataset['commentid']} [href][data-ipsmenu]`);this._menu=menuLink?document.querySelector(menuLink.getAttribute('href')):null;}
|
||||
const menuLink=(commentFeed||document).querySelector('#'+activeTabId+`_${this.scope.get(0)?.dataset['commentid']} [popovertarget]`);this._menu=menuLink?document.querySelector('#'+menuLink.getAttribute('popovertarget')):null;}
|
||||
return this._menu;},_setupShareCommentDialog(){const shareButton=this.getMenu()?.querySelector('[data-role="shareComment"], [data-role="shareReview"]');const shareMenu=shareButton?.dataset.ipsdialogContent?document.querySelector(shareButton.dataset.ipsdialogContent):null;const copyToClipboard=shareMenu?.querySelector('[data-role="shareButton"]');let shared=false;if(window.isSecureContext&©ToClipboard){copyToClipboard.onclick=e=>e.preventDefault()
|
||||
copyToClipboard?.addEventListener('pointerdown',async e=>{e.preventDefault();const href=copyToClipboard.getAttribute('href');const cb=async e=>{copyToClipboard.removeEventListener('pointerup',cb)
|
||||
if(window.navigator?.clipboard?.writeText instanceof Function){e.preventDefault()
|
||||
@@ -98,7 +98,7 @@ var commentLoading=this.scope.find('[data-role="commentLoading"]');commentLoadin
|
||||
this.scope.find('[data-role="commentLoading"]').addClass('ipsHide');},getEditFormDone:function(e,data){if(data.commentID!=this._commentID){return;}
|
||||
const showForm=_.once(()=>{this._isEditing=true;this.scope.find('[data-action="expandTruncate"], [data-role="commentControls"]').hide();this.scope.find('[data-action="editComment"]').parent('li').hide();this.scope.find('[data-role="commentContent"]').html(data.response);this.scope.find('[data-role="commentContent"]').removeClass('ipsRichText');$(document).trigger('contentChange',[this.scope.find('[data-role="commentContent"]')]);});var elemPosition=ips.utils.position.getElemPosition(this.scope);var windowScroll=$(window).scrollTop();var viewHeight=$(window).height();if(elemPosition.absPos.top<windowScroll||elemPosition.absPos.top>(windowScroll+viewHeight)){$('html, body').animate({scrollTop:elemPosition.absPos.top+'px'},function(){showForm();});}else{showForm();}},getEditFormError:function(e,data){if(data.commentID!=this._commentID){return;}
|
||||
window.location=data.url;},saveEditCommentDone:function(e,data){if(data.commentID!=this._commentID){return;}
|
||||
ips.ui.editorv5.destruct(this.scope.find('[data-ipseditorv5]'));this._isEditing=false;this.scope.find('[data-role="commentContent"]').replaceWith($('<div>'+data.response+'</div>').find('[data-role="commentContent"]'));this.scope.trigger('refreshContent');this.scope.find('[data-action="expandTruncate"], [data-role="commentControls"]').show();this.scope.find('[data-action="editComment"]').parent('li').show();$(document).trigger('contentChange',[this.scope]);},saveEditCommentError:function(e,data){if(data.commentID!=this._commentID){return;}
|
||||
ips.ui.editorv5.destruct(this.scope.find('[data-ipseditorv5]'));this._isEditing=false;this.scope.find('[data-role="commentContent"]').replaceWith($('<div>'+data.response+'</div>').find('[data-role="commentContent"]'));this.scope.trigger('refreshContent');this.scope.find('[data-action="expandTruncate"], [data-role="commentControls"]').show();this.scope.find('[data-action="editComment"]').parent('li').show();$(document).trigger('contentChange',[this.scope]);setTimeout(()=>{document.body.dispatchEvent(new CustomEvent('ipsDataLayerSync',{bubbles:true}))},10);},saveEditCommentError:function(e,data){if(data.commentID!=this._commentID){return;}
|
||||
ips.ui.alert.show({type:'alert',icon:'warn',message:ips.getString('editCommentError'),});},approveComment:function(e){e.preventDefault();var url=$(e.currentTarget).attr('href');this.trigger('approveComment.comment',{url:url,commentID:this._commentID});},approveCommentLoading:function(e,data){if(data.commentID!=this._commentID){return;}
|
||||
this.scope.find('[data-role="commentControls"]').addClass('i-opacity_4').find('[data-action="approveComment"]').addClass('ipsButton--disabled').text(ips.getString('commentApproving'));},approveCommentDone:function(e,data){if(data.commentID!=this._commentID){return;}
|
||||
var commentHtml=$('<div>'+data.response+'</div>').find('[data-controller="core.front.core.comment"]').html();this.scope.html(commentHtml).removeClass('ipsModerated').closest('.ipsEntry').removeClass('ipsModerated');$(document).trigger('contentChange',[this.scope]);if(ips.utils.db.isEnabled()){this.scope.find('[data-action="multiQuoteComment"]').removeClass('ipsHide');}
|
||||
@@ -107,7 +107,7 @@ window.location=data.url;},deleteComment:function(e){e.preventDefault();var url=
|
||||
var deleteLink=this.scope.find('[data-action="deleteComment"]');var toHide=null;var toShow=null;if(deleteLink.attr('data-hideOnDelete')){toHide=this.scope.find(deleteLink.attr('data-hideOnDelete'));}else{toHide=this.scope.closest('article');}
|
||||
toHide.animationComplete(function(){toHide.remove();});ips.utils.anim.go('fadeOutDown',toHide);if(deleteLink.attr('data-updateOnDelete')){$(deleteLink.attr('data-updateOnDelete')).text(parseInt($(deleteLink.attr('data-updateOnDelete')).text())-1);}
|
||||
if(deleteLink.attr('data-showOnDelete')){toShow=this.scope.find(deleteLink.attr('data-showOnDelete'));ips.utils.anim.go('fadeIn',toShow);}
|
||||
this.feedJQ().trigger('deletedComment.comment',{commentID:this._commentID,response:data.response});},deleteCommentError:function(e,data){if(data.commentID!=this._commentID){return;}
|
||||
this.feedJQ().trigger('deletedComment.comment',{commentID:this._commentID,response:data.response});setTimeout(()=>document.body.dispatchEvent(new CustomEvent('ipsDataLayerSync',{bubbles:true})),10);},deleteCommentError:function(e,data){if(data.commentID!=this._commentID){return;}
|
||||
window.location=data.url;},_prepareQuote:function(html){html=$(html);html.find('[data-action="expandTruncate"]').remove();if(![...html.find('> :not(blockquote.ipsQuote)')].some(elem=>elem.matches('img,video,iframe,audio,object,embed')||elem.innerText.trim().length||elem.querySelector(':is(img,video,iframe,audio,object,embed):not(blockquote.ipsQuote *)'))&&html.find('> blockquote.ipsQuote')){const self=this;html.find('> blockquote.ipsQuote').each(function(){let child=this.querySelector(':scope > .ipsQuote_contents')||this;child.innerHTML=self._prepareQuote($(child.innerHTML)).html();});}else{if(html.find('blockquote.ipsQuote')?.parent()?.get(0)?.matches('div')&&html.find('blockquote.ipsQuote').siblings().length===0){var div=html.find('blockquote.ipsQuote').closest('div');div.next('p').find("br:first-child").remove();div.remove();}else{html.find('blockquote.ipsQuote').remove();}
|
||||
html.find('.ipsStyle_spoilerFancy,.ipsStyle_spoiler').replaceWith(ips.templates.render('core.posts.quotedSpoiler'));html.find("[data-excludequote]").remove();html.find('.ipsQuote_citation').remove();html.find('[data-quote-value]').each(function(){$(this).replaceWith('<p>'+$(this).attr('data-quote-value')+'</p>');});}
|
||||
return html;},_getQuoteData:function(){if(!this._quoteData){try{this._quoteData=$.parseJSON(this.scope.attr('data-quoteData'));return this._quoteData;}catch(err){Debug.log("Couldn't parse quote data");return{};}}
|
||||
@@ -116,20 +116,20 @@ function clearMouseUpResolvers(){mouseState='up'
|
||||
const resolves=[...mouseUpResolvers]
|
||||
mouseUpResolvers.clear()
|
||||
resolves.forEach(resolve=>resolve())}
|
||||
document.addEventListener('mousedown',()=>mouseState='down',{capture:true})
|
||||
document.addEventListener('touchstart',()=>mouseState='down',{capture:true})
|
||||
document.addEventListener('touchend',clearMouseUpResolvers,{capture:true})
|
||||
document.addEventListener('mouseup',clearMouseUpResolvers,{capture:true})
|
||||
document.addEventListener('selectionchange',_.debounce(()=>{const selection=document.getSelection();for(let i=0;i<selection.rangeCount;i++){const range=selection.getRangeAt(i);const quoteBox=range.commonAncestorContainer instanceof Text?range.commonAncestorContainer.parentElement.closest('[data-role="commentContent"]'):range.commonAncestorContainer.closest('[data-role="commentContent"]')
|
||||
document.addEventListener('pointerdown',()=>mouseState='down',{capture:true})
|
||||
document.addEventListener('pointerup',clearMouseUpResolvers,{capture:true})
|
||||
document.addEventListener('contextmenu',clearMouseUpResolvers,{capture:true})
|
||||
document.addEventListener('selectionchange',_.throttle(()=>{const selection=document.getSelection();for(let i=0;i<selection.rangeCount;i++){const range=selection.getRangeAt(i);const quoteBox=range.commonAncestorContainer instanceof Text?range.commonAncestorContainer.parentElement.closest('[data-role="commentContent"]'):range.commonAncestorContainer.closest('[data-role="commentContent"]')
|
||||
if(quoteBox instanceof Element){mouseUp().then(()=>quoteBox.dispatchEvent(new CustomEvent('ipsCalcQuote',{bubbles:true})))
|
||||
break;}}},400))}(jQuery,_));;
|
||||
break;}}},1000,{leading:true,trailing:true}))}(jQuery,_));;
|
||||
;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.commentFeed',{_overlay:null,_commentFeedID:0,_newRepliesFlash:null,_maximumMultiQuote:50,_pageParam:'page',_seoPagination:false,_urlParams:{},_baseURL:'',_doneInitialState:false,_initialURL:'',_pollingEnabled:true,_pollingActive:false,_pollingPaused:false,_initialPoll:10000,_currentPoll:10000,_decay:20000,_maxInterval:(30*60)*1000,_pollingTimeout:null,_pollAjax:null,_pollOnUnpaused:false,_notification:null,_lastSeenTotal:0,initialize(){this._containerID=this.scope.closest('[data-commentsContainer]').length?this.scope.closest('[data-commentsContainer]').attr('data-commentsContainer'):this.scope.identify().attr('id');this.on('submit','[data-role="replyArea"]',this.quickReply);this.on('quoteComment.comment',this.quoteComment);this.on('addMultiQuote.comment',this.addMultiQuote);this.on('removeMultiQuote.comment deleteComment.comment',this.removeMultiQuote);this.on('click','[data-action="filterClick"]',this.filterClick);this.on('menuItemSelected','[data-role="signatureOptions"]',this.signatureOptions);this.on('editorCompatibility',this.editorCompatibility);this.on('checkedComment.comment',this.checkedComment);if(this.elem?.dataset.pageParam){this._pageParam=this.elem.dataset.pageParam;}
|
||||
this._boundMQ=_.bind(this.doMultiQuote,this);this._boundCMQ=_.bind(this.clearMultiQuote,this);$(document).on('click','[data-role="multiQuote_'+this._containerID+'"]',this._boundMQ);$(document).on('click','[data-action="clearQuoted_'+this._containerID+'"]',this._boundCMQ);$(document).on('moderationSubmitted',this.clearLocalStorage);this.on('paginationClicked paginationJump',this.paginationClick);this.on(document,'addToCommentFeed',this.addToCommentFeed);this.on('deletedComment.comment',this.deletedComment);this.on(document,'click','[data-action="loadNewPosts"]',this.loadNewPosts);this.on(window,'historychange',this.stateChange);this.on(document,"socket.new_comment",this.handleSocketCommentTrigger);this.setup();},setup:function(){const replyForm=this.scope.find('[data-role="replyArea"] form');this._commentFeedID=this.scope.attr('data-feedID');this._urlParams=this._getUrlParams();this._baseURL=this.scope.attr('data-baseURL');this._initialURL=window.location.href;this._currentPage=ips.utils.url.getPageNumber(this._pageParam);this._urlParams[this._pageParam]=this._currentPage;if(this._baseURL.match(/\?[^?]+$/)){this._baseURL+='&';}else{this._baseURL+='?';}
|
||||
if(replyForm.attr('data-noAjax')){this._pollingEnabled=false;}
|
||||
if(!('commentFeed'in ips.utils.history.getState())){this._updateState({})
|
||||
ips.utils.history.replaceState(this.historyState,'commentFeed',window.location.href)}
|
||||
if(!_.isUndefined(this.scope.attr('data-lastPage'))&&this._pollingEnabled){this._startPolling();}
|
||||
$(document).ready(()=>{this._setUpMultiQuote();this._findCheckedComments();});this.on('updateTimestamps',this._updateTimestamps);for(const ev of['ips:editorUpdated','ips:editorAfterInit']){this.elem.addEventListener(ev,_.debounce(e=>{const{elem,instance}=e.detail;const submit=elem.closest(CSS.supports('selector(a:has(b))')?'form:has(input[type="submit"],button[type="submit"])':'form').querySelectorAll(':is(button, input)[type="submit"]');if(!submit.length){return;}
|
||||
$(document).ready(()=>{this._setUpMultiQuote();this._findCheckedComments();});if(ips.getSetting('relativeDates')){this.on('updateTimestamps',this._updateTimestamps);}
|
||||
for(const ev of['ips:editorUpdated','ips:editorAfterInit']){this.elem.addEventListener(ev,_.debounce(e=>{const{elem,instance}=e.detail;const submit=elem.closest(CSS.supports('selector(a:has(b))')?'form:has(input[type="submit"],button[type="submit"])':'form').querySelectorAll(':is(button, input)[type="submit"]');if(!submit.length){return;}
|
||||
function nodeHasContent(node){if(node.textContent?.trim()?.length){return true;}
|
||||
if(node.isAtom&&!node.isText){return true;}
|
||||
if(node.children&&Symbol.iterator in node.children){for(const child of node.children){if(nodeHasContent(child)){return true;}}}
|
||||
@@ -164,7 +164,10 @@ ips.utils.history.pushState(this.historyState,'commentFeed',newUrl);this._update
|
||||
Object.assign(this.historyState,{controller:this.controllerID,feedID:this._commentFeedID})},_getURL:function(){const urlObj=new URL(this._baseURL);const skipParams=new Set(['controller','feedID','bypassState']);const params={};for(const param in this._urlParams){if(this._urlParams[param]&&!skipParams.has(param)){params[param]=this._urlParams[param].toString();}}
|
||||
urlObj.updateSearchParams({params});return urlObj.toString();},editorCompatibility:function(e,data){if(!data.compatible){this.triggerOn('core.front.core.comment','disableQuoting.comment');}},checkedComment:function(e,data){var dataStore=ips.utils.db.get('moderation',this._commentFeedID)||{};if(data.checked){if(_.isUndefined(dataStore[data.commentID])){dataStore[data.commentID]=data.actions;}}else{delete dataStore[data.commentID];}
|
||||
if(_.size(dataStore)){ips.utils.db.set('moderation',this._commentFeedID,dataStore,undefined,(Date.now()/1000)+86400);}else{ips.utils.db.remove('moderation',this._commentFeedID);}},_findCheckedComments:function(){if(!this.scope.find('input[type="checkbox"]').length){return;}
|
||||
var dataStore=ips.utils.db.get('moderation',this._commentFeedID)||{};var self=this;var pageAction=this.scope.find('[data-ipsPageAction]');if(_.size(dataStore)){var sizeOtherPage=0;_.each(dataStore,function(val,key){if(self.scope.find('[data-commentID="'+key+'"]').length){self.scope.find('[data-commentID="'+key+'"] input[type="checkbox"][data-role="moderation"]').attr('checked',true).trigger('change');}else{sizeOtherPage++;pageAction.trigger('addManualItem.pageAction',{id:'multimod['+key+']',actions:val});}});if(this.scope.find('[data-ipsAutoCheck]')){this.scope.find('[data-ipsAutoCheck]').trigger('setInitialCount.autoCheck',{count:sizeOtherPage});}}},signatureOptions:function(e,data){data.originalEvent.preventDefault();if(data.selectedItemID=='oneSignature'){this._ignoreSingleSignature($(e.currentTarget).attr('data-memberID'));}else{this._ignoreAllSignatures();}},_ignoreAllSignatures:function(){var self=this;var url=ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=settings&do=toggleSigs';var signatures=this.scope.find('[data-role="memberSignature"]');signatures.slideUp();ips.getAjax()(url).done(function(response){ips.ui.flashMsg.show(ips.getString('signatures_hidden'));signatures.remove();}).fail(function(){signatures.show();ips.ui.alert.show({type:'alert',icon:'warn',message:ips.getString('signatures_error'),callbacks:{}});});},_ignoreSingleSignature:function(memberID){var url=ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=ignore&do=ignoreType&type=signatures';var signatures=this.scope.find('[data-role="memberSignature"]').find('[data-memberID="'+memberID+'"]').closest('[data-role="memberSignature"]');signatures.slideUp();ips.getAjax()(url,{data:{member_id:parseInt(memberID)}}).done(function(response){ips.ui.flashMsg.show(ips.getString('single_signature_hidden'));signatures.remove();}).fail(function(){signatures.show();ips.ui.alert.show({type:'alert',icon:'warn',message:ips.getString('single_signature_error'),callbacks:{}});});},filterClick:function(e){e.preventDefault();var urlObj=ips.utils.url.getURIObject($(e.target).attr('href'));var queryKey=urlObj.queryKey;this._updateURL(queryKey);},quoteComment:function(e,data){if(this.scope.find('[data-role="replyArea"] [data-ipsEditorv5]').length){ips.ui.editorv5.getObjWithInit(this.scope.find('[data-role="replyArea"] [data-ipsEditorv5]'),function(editor){editor.insertQuotes([data]);});}},windowBlur:function(e){if(this._pollingEnabled){Debug.log('Window blurred, pausing polling...');this._pollingPaused=true;}},windowFocus:function(e){if(this._pollingEnabled&&this._pollingPaused){Debug.log('Window focused...');this._pollingPaused=false;if(this._pollOnUnpaused){this._pollOnUnpaused=false;this.pollForNewReplies();}}},handleSocketCommentTrigger:function(){if(!_.isUndefined(this.scope.attr('data-lastPage'))&&this._pollingEnabled){this.pollForNewReplies();}},_startPolling:function(){if(ips.utils.sockets.enabled()&&ips.utils.sockets.connected()){return;}
|
||||
var dataStore=ips.utils.db.get('moderation',this._commentFeedID)||{};var self=this;var pageAction=this.scope.find('[data-ipsPageAction]');if(_.size(dataStore)){var sizeOtherPage=0;_.each(dataStore,function(val,key){if(self.scope.find('[data-commentID="'+key+'"]').length){self.scope.find('[data-commentID="'+key+'"] input[type="checkbox"][data-role="moderation"]').attr('checked',true).trigger('change');}else{sizeOtherPage++;pageAction.trigger('addManualItem.pageAction',{id:'multimod['+key+']',actions:val});}});if(this.scope.find('[data-ipsAutoCheck]')){this.scope.find('[data-ipsAutoCheck]').trigger('setInitialCount.autoCheck',{count:sizeOtherPage});}}},signatureOptions:function(e,data=e.detail){data.originalEvent.preventDefault();if(data.selectedItemID=='oneSignature'){this._ignoreSingleSignature($(e.currentTarget).attr('data-memberID'));}else{this._ignoreAllSignatures();}},_ignoreAllSignatures:function(){var self=this;var url=ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=settings&do=toggleSigs';var signatures=this.scope.find('[data-role="memberSignature"]');signatures.slideUp();ips.getAjax()(url).done(function(response){ips.ui.flashMsg.show(ips.getString('signatures_hidden'));signatures.remove();}).fail(function(){signatures.show();ips.ui.alert.show({type:'alert',icon:'warn',message:ips.getString('signatures_error'),callbacks:{}});});},_ignoreSingleSignature:function(memberID){var url=ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=ignore&do=ignoreType&type=signatures';var signatures=this.scope.find('[data-role="memberSignature"]').find('[data-memberID="'+memberID+'"]').closest('[data-role="memberSignature"]');signatures.slideUp();ips.getAjax()(url,{data:{member_id:parseInt(memberID)}}).done(function(response){ips.ui.flashMsg.show(ips.getString('single_signature_hidden'));signatures.remove();}).fail(function(){signatures.show();ips.ui.alert.show({type:'alert',icon:'warn',message:ips.getString('single_signature_error'),callbacks:{}});});},filterClick:function(e){e.preventDefault();var urlObj=ips.utils.url.getURIObject($(e.target).attr('href'));var queryKey=urlObj.queryKey;this._updateURL(queryKey);},quoteComment:function(e,data){if(this.scope.find('[data-role="replyArea"] [data-ipsEditorv5]').length){ips.ui.editorv5.getObjWithInit(this.scope.find('[data-role="replyArea"] [data-ipsEditorv5]'),function(editor){editor.insertQuotes([data]);});}},windowBlur:function(e){if(this._pollingEnabled){Debug.log('Window blurred, pausing polling...');this._pollingPaused=true;}},windowFocus:function(e){if(this._pollingEnabled&&this._pollingPaused){Debug.log('Window focused...');this._pollingPaused=false;if(this._pollOnUnpaused){this._pollOnUnpaused=false;this.pollForNewReplies();}}},handleSocketCommentTrigger:function(){if(!_.isUndefined(this.scope.attr('data-lastPage'))&&this._pollingEnabled){this.pollForNewReplies();}},_startPolling:function(){if(ips.utils.sockets.enabled()&&ips.utils.sockets.connected()){if(ips.getSetting('relativeDates')){if(this._timestampTimeout){clearTimeout(this._timestampTimeout);}
|
||||
Debug.log('Setting interval to poll for relative dates');this._timestampTimeout=setTimeout(()=>{this._updateTimestamps();if((this._currentPoll+this._decay)<this._maxInterval){this._currentPoll+=this._decay;}else{this._currentPoll=this._maxInterval;}
|
||||
this._startPolling();},this._currentPoll);}
|
||||
return;}
|
||||
this._pollingActive=true;Debug.log('Starting polling with interval '+(this._currentPoll/1000)+'s');this._pollingTimeout=setTimeout(()=>{this.pollForNewReplies();},this._currentPoll);},_stopPolling:function(){this._pollingActive=false;if(this._pollingTimeout){clearTimeout(this._pollingTimeout);}
|
||||
Debug.log("Stopped polling for new replies in comment feed.");},pollForNewReplies(){const replyForm=this.scope.find('[data-role="replyArea"] form');const commentsOnThisPage=document.querySelectorAll(`[data-feedid="${this.elem.dataset.feedid}"] [data-commentid]`);if(!commentsOnThisPage.length){return;}
|
||||
const lastSeenId=this._getLastSeenID($(commentsOnThisPage));const type=$(commentsOnThisPage[commentsOnThisPage.length-1]).attr('data-commentType');if(type.match(/-review$/)){Debug.log("Polling disabled for reviews");this._stopPolling();return;}
|
||||
@@ -172,7 +175,7 @@ if(this._pollingPaused){Debug.log('Window blurred, delaying poll until focused..
|
||||
if(this._pollAjax&&this._pollAjax.abort!==undefined){this._pollAjax.abort();}
|
||||
this._pollAjax=ips.getAjax();this._pollAjax(replyForm.attr('action'),{dataType:'json',data:'do=checkForNewReplies&type=count&lastSeenID='+lastSeenId+'&csrfKey='+ips.getSetting('csrfKey'),type:'post'}).done(response=>{if(response.error&&response.error==='auto_polling_disabled'){this._stopPolling();return;}
|
||||
if(parseInt(response.count)>0){this._currentPoll=this._initialPoll;if(this.getCurrentCommentPageCount()<parseInt(response.perPage)){this._importNewReplies(false);}else{this._buildFlashMsg(response);if(parseInt(response.totalCount)>parseInt(this._lastSeenTotal)){this._buildNotifications(response);this._lastSeenTotal=parseInt(response.totalCount);}}}else{if((this._currentPoll+this._decay)<this._maxInterval){this._currentPoll+=this._decay;}else{this._currentPoll=this._maxInterval;}}
|
||||
if(this.scope.attr('data-lastPage')!==undefined){this._startPolling();}});this._updateTimestamps();},getCurrentCommentPageCount(){if(this.scope){return $(this.scope).get(0).querySelectorAll(`[data-commentid]`).length}else{return 0}},_buildFlashMsg(response){const spaceForMore=parseInt(response.perPage)-this.getCurrentCommentPageCount();let html;if(parseInt(response.count)>spaceForMore){html=ips.templates.render('core.postNotify.multipleSpillOver',{text:ips.pluralize(ips.getString('newPostMultipleSpillOver'),[response.totalNewCount]),canLoadNew:(spaceForMore>0),showFirstX:ips.pluralize(ips.getString('showFirstX'),[spaceForMore]),spillOverUrl:response.spillOverUrl});}else if(parseInt(response.count)===1&&!_.isUndefined(response.photo)&&!_.isUndefined(response.name)){html=ips.templates.render('core.postNotify.single',{photo:response.photo,text:ips.getString('newPostSingle',{name:response.name})});}else{html=ips.templates.render('core.postNotify.multiple',{text:ips.pluralize(ips.getString('newPostMultiple'),[response.count])});}
|
||||
if(this.scope.attr('data-lastPage')!==undefined){this._startPolling();}});if(ips.getSetting('relativeDates')){this._updateTimestamps();}},getCurrentCommentPageCount(){if(this.scope){return $(this.scope).get(0).querySelectorAll(`[data-commentid]`).length}else{return 0}},_buildFlashMsg(response){const spaceForMore=parseInt(response.perPage)-this.getCurrentCommentPageCount();let html;if(parseInt(response.count)>spaceForMore){html=ips.templates.render('core.postNotify.multipleSpillOver',{text:ips.pluralize(ips.getString('newPostMultipleSpillOver'),[response.totalNewCount]),canLoadNew:(spaceForMore>0),showFirstX:ips.pluralize(ips.getString('showFirstX'),[spaceForMore]),spillOverUrl:response.spillOverUrl});}else if(parseInt(response.count)===1&&!_.isUndefined(response.photo)&&!_.isUndefined(response.name)){html=ips.templates.render('core.postNotify.single',{photo:response.photo,text:ips.getString('newPostSingle',{name:response.name})});}else{html=ips.templates.render('core.postNotify.multiple',{text:ips.pluralize(ips.getString('newPostMultiple'),[response.count])});}
|
||||
if($('#elFlashMessage').is(':visible')&&$('#elFlashMessage').find('[data-role="newPostNotification"]').length){$('#elFlashMessage').find('[data-role="newPostNotification"]').replaceWith(html);}else{ips.ui.flashMsg.show(html,{sticky:true,position:'bottom',extraClasses:'cPostFlash',dismissable:()=>this._stopPolling(),escape:false});}},_buildNotifications(response){const hiddenProp=ips.utils.events.getVisibilityProp();if(hiddenProp===undefined||!document[hiddenProp]||!ips.utils.notification.hasPermission()){return;}
|
||||
const notifyData={onClick:e=>{try{window.focus();}catch(err){}
|
||||
this.loadNewPosts(e);}};if(this._notification){this._notification.hide();}
|
||||
@@ -199,7 +202,8 @@ const id=parseInt(actualContent?.querySelector(`[data-commentid]`)?.dataset.comm
|
||||
if(data.scrollToItem&&(newItemTop<windowScroll||newItemTop>(windowScroll+viewHeight))){$('html, body').animate({scrollTop:newItemTop+'px'},'fast',function(){setTimeout(_showComment,100);});}else{_showComment();}
|
||||
if(ips.utils.db.isEnabled()){const buttons=comment.find('[data-action="multiQuoteComment"]');buttons.hide().removeClass('ipsHide');ips.utils.anim.go('fadeIn',buttons);}}}else{Debug.log(`core.front.core.commentFeed:addToCommentFeed() - Invalid content provided to addToCommentFeed. The data.content property is supposed to contain HTML with an element that has the \`js-ipsEntry\` class. This may be expected, as in the case of posts held for approval.`);if(Debug.isEnabled()){console.log(data);}}
|
||||
if(!('resetEditor'in data)||data.resetEditor!==false){this.scope.find('[data-role="replyArea"] [data-ipsEditorv5]').data('_editor').reset();}
|
||||
this._updateCount(data.totalItems);this._updateTimestamps();$(document).trigger('contentChange',[this.scope]);},deletedComment:function(e,data){data=$.parseJSON(data.response);var self=this;if(data.type=='redirect'){window.location=data.url;}
|
||||
this._updateCount(data.totalItems);if(ips.getSetting('relativeDates')){this._updateTimestamps();}
|
||||
$(document).trigger('contentChange',[this.scope]);},deletedComment:function(e,data){data=$.parseJSON(data.response);var self=this;if(data.type=='redirect'){window.location=data.url;}
|
||||
else{this._updateCount(data.total);}},_updateCount:function(newTotal){if(this.scope.find('[data-role="comment_count"]')){var langString='js_num_comments';if(this.scope.find('[data-role="comment_count"]').attr('data-commentCountString')){langString=this.scope.find('[data-role="comment_count"]').attr('data-commentCountString');}
|
||||
this.scope.find('[data-role="comment_count"]').text(ips.pluralize(ips.getString(langString),newTotal));}},doMultiQuote:function(e){var mqData=this._getMultiQuoteData();var replyArea=this.scope.find('[data-role="replyArea"]');var output=[];var self=this;if(!_.size(mqData)||!replyArea.is(':visible')){return;}
|
||||
_.each(mqData,function(value){output.push(value);});ips.ui.editorv5.getObjWithInit(this.scope.find('[data-role="replyArea"] [data-ipsEditorv5]'),function(editor){editor.insertQuotes(output);});this._removeAllMultiQuoted();},clearMultiQuote:function(e){e.preventDefault();this._removeAllMultiQuoted();},_removeAllMultiQuoted:function(){var mqData=this._getMultiQuoteData();var self=this;ips.utils.db.set('mq','data',{});this._buildMultiQuote(0);if(!_.size(mqData)){return;}
|
||||
@@ -208,7 +212,8 @@ mqData[key]=data;ips.utils.db.set('mq','data',mqData);this._buildMultiQuote(_.si
|
||||
return mqData;},_setUpMultiQuote:function(){if(!ips.utils.db.isEnabled()){return;}
|
||||
var buttons=this.scope.find('[data-action="multiQuoteComment"]');var self=this;var mqData=this._getMultiQuoteData();buttons.show();if(_.size(mqData)){this._buildMultiQuote(_.size(mqData));_.each(mqData,function(value){self.triggerOn('core.front.core.comment','setMultiQuoteEnabled.comment',{contentapp:value.contentapp,contenttype:value.contenttype,contentcommentid:value.contentcommentid});});}},_buildMultiQuote:function(count){var quoterElem=$('#ipsMultiQuoter');if(!quoterElem.length&&count){ips.getContainer().append(ips.templates.render('core.posts.multiQuoter',{count:ips.getString('multiquote_count',{count:ips.pluralize(ips.getString('multiquote_count_plural'),[count])}),commentFeedId:this._containerID}));ips.utils.anim.go('zoomIn fast',$('#ipsMultiQuoter'));}else{if(quoterElem.attr('data-commentsContainer')!==this._containerID){quoterElem.attr('data-commentsContainer',this._containerID).find('[data-role^="multiQuote_"]').attr('data-role','multiQuote_'+this._containerID).end().find('[data-action^="clearQuoted_"]').attr('data-action','clearQuoted_'+this._containerID);}
|
||||
quoterElem.find('[data-role="quotingTotal"]').text(ips.pluralize(ips.getString('multiquote_count_plural'),[count]));if(count&"erElem.is(':visible')){ips.utils.anim.go('pulseOnce fast',quoterElem);}else if(count&&!quoterElem.is(':visible')){ips.utils.anim.go('zoomIn fast',quoterElem);}else{ips.utils.anim.go('zoomOut fast',quoterElem);}}},_getLastSeenID:function(commentsOnThisPage){var commentFeed=this.scope.find('[data-role="commentFeed"]');var maxComment=_.max(commentsOnThisPage,function(comment){return parseInt($(comment).attr('data-commentid'));});var max=$(maxComment).attr('data-commentid');if(commentFeed.attr('data-topicAnswerID')&&parseInt(commentFeed.attr('data-topicAnswerID'))>max){max=parseInt(commentFeed.attr('data-topicAnswerID'));}
|
||||
Debug.log("Max comment ID is "+max);return max;},async _updateTimestamps(){Debug.log('Updating the comment feed timestamps')
|
||||
Debug.log("Max comment ID is "+max);return max;},async _updateTimestamps(){if(!ips.getSetting('relativeDates')){return;}
|
||||
Debug.log('Updating the comment feed timestamps')
|
||||
const timestampMap=new Map();const roots=new Set([this.elem]);if(this.elem.dataset.feedid){for(const el of document.querySelectorAll(`[data-feedid="${this.elem.dataset.feedid}"]`)){roots.add(el);}}
|
||||
roots.forEach(root=>{for(const el of root.querySelectorAll('time.ipsTime[datetime]:not(.ipsTime .ipsTime, time time)')){if(OLD_TIME_ELEMENTS.has(el)){continue;}
|
||||
if(el instanceof HTMLTimeElement){const unixts=Math.round((new Date(el.dateTime)).getTime()/1000);if(unixts<=Math.round(Date.now()/1000)-86400){OLD_TIME_ELEMENTS.add(el);continue;}
|
||||
@@ -222,7 +227,7 @@ parsedResults[ts]=timeEl;}}}}
|
||||
for(const[timeEl,timeStamp]of timestampMap.entries()){const key="time_"+timeStamp;if(key in parsedResults){timeEl.innerHTML=parsedResults[key].innerHTML;timeEl.dataset.short=parsedResults[key].dataset.short;}else{Debug.warn(`Didn't get a formatted time for the timestamp ${timeStamp}.`)}}}});const OLD_TIME_ELEMENTS=new WeakSet();}(jQuery,_));;
|
||||
;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.commentsWrapper',{initialize:function(){this.on(document,'addToCommentFeed',this.addToCommentFeed);this.on('deletedComment.comment',this.deletedComment);},addToCommentFeed:function(e,data){this._updateCount($(e.target).attr('data-commentsType'),data.totalItems);},deletedComment:function(e,data){try{var newTotal=$.parseJSON(data.response).total;}catch(err){var newTotal=0;}
|
||||
this._updateCount($(e.target).closest('[data-commentsType]').attr('data-commentsType'),newTotal);},_updateCount:function(type,number){var langString='js_num_'+type;var elem=$('#'+$(this.scope).attr('data-tabsId')+'_tab_'+type);elem.text(ips.pluralize(ips.getString(langString),number));}});}(jQuery,_));;
|
||||
;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.ignoredComments',{initialize:function(){this.on('menuItemSelected','[data-action="ignoreOptions"]',this.commentIgnore);},commentIgnore:function(e,data){switch(data.selectedItemID){case'showPost':data.originalEvent.preventDefault();this._showHiddenPost(e,data);break;case'stopIgnoring':data.originalEvent.preventDefault();this._stopIgnoringFromComment(e,data);break;}},_showHiddenPost:function(e,data){var ignoreRow=$(data.triggerElem).closest('.ipsEntry--ignored');var commentID=ignoreRow.attr('data-ignoreCommentID');var comment=this.scope.find('#'+commentID);ignoreRow.remove();comment.removeClass('ipsHide');},_stopIgnoringFromComment:function(e,data){var ignoreRow=$(data.triggerElem).closest('.ipsEntry--ignored');var userID=ignoreRow.attr('data-ignoreUserID');var self=this;var posts=this.scope.find('[data-ignoreUserID="'+userID+'"]');posts.each(function(){self.scope.find('#'+$(this).attr('data-ignoreCommentID')).removeClass('ipsHide');$(this).remove();});var url=ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=ignore&do=ignoreType&type=topics&off=1';ips.getAjax()(url,{data:{member_id:parseInt(userID)}}).done(function(){ips.ui.flashMsg.show(ips.getString('ignore_prefs_updated'));}).fail(function(){window.location=ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=ignore&do=ignoreType&off=1type=topics&member_id='+userID;});}});}(jQuery,_));;
|
||||
;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.ignoredComments',{initialize:function(){this.on('menuItemSelected','[data-action="ignoreOptions"]',this.commentIgnore);},commentIgnore:function(e,data=e.detail){switch(data.selectedItemID){case'showPost':data.originalEvent.preventDefault();this._showHiddenPost(e,data);break;case'stopIgnoring':data.originalEvent.preventDefault();this._stopIgnoringFromComment(e,data);break;}},_showHiddenPost:function(e,data){var ignoreRow=$(data.triggerElem).closest('.ipsEntry--ignored');var commentID=ignoreRow.attr('data-ignoreCommentID');var comment=this.scope.find('#'+commentID);ignoreRow.remove();comment.removeClass('ipsHide');},_stopIgnoringFromComment:function(e,data){var ignoreRow=$(data.triggerElem).closest('.ipsEntry--ignored');var userID=ignoreRow.attr('data-ignoreUserID');var self=this;var posts=this.scope.find('[data-ignoreUserID="'+userID+'"]');posts.each(function(){self.scope.find('#'+$(this).attr('data-ignoreCommentID')).removeClass('ipsHide');$(this).remove();});var url=ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=ignore&do=ignoreType&type=topics&off=1';ips.getAjax()(url,{data:{member_id:parseInt(userID)}}).done(function(){ips.ui.flashMsg.show(ips.getString('ignore_prefs_updated'));}).fail(function(){window.location=ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=ignore&do=ignoreType&off=1type=topics&member_id='+userID;});}});}(jQuery,_));;
|
||||
;(function($,_){"use strict";ips.controller.register('core.front.core.instantNotifications',{_pollTimeout:60,_windowInactivePoll:0,_pollMultiplier:1,_messagesEnabled:null,_ajaxObj:null,_debugPolling:true,_browserNotifications:{},_paused:false,_interval:null,_usingRealtime:false,initialize(){this.on(document,ips.utils.events.getVisibilityEvent(),this.windowVisibilityChange);this.on(window,'storage',this.storageChange);this.setup();},setup(){if(!ips.utils.db.isEnabled()||!(window.JSON?.parse instanceof Function)){Debug.warn("Sorry, your browser doesn't support localStorage or JSON so we can't load instant notifications for you.");return;}
|
||||
if(ips.utils.sockets.enabled()){if(ips.utils.sockets.connected()){this._useRealtime();}else{this.on(document,'socket.connected',this._useRealtime)}}
|
||||
this.on(document,`socket.notifications_available`,()=>{Debug.log('Notifications: fetching the latest notification counts');this._useRealtime();this._doAjaxRequest(this._getCurrentCounts());})
|
||||
@@ -252,20 +257,32 @@ if($('#elFlashMessage').is(':visible')&&$('#elFlashMessage').find('[data-role="n
|
||||
if(this._messagesEnabled){if(parseInt(newData.messages)!==oldData.messages){this._updateIcon('inbox',newData.messages);this.scope.trigger('clearUserbarCache',{type:'inbox'});}
|
||||
notifyData.messages=parseInt(newData.messages);}},_updateIcon(type,count){const icon=this._getIcon(type);icon.attr('data-currentCount',count).text(count);if(parseInt(count)){ips.utils.anim.go((!icon.is(':visible'))?'zoomIn':'pulseOnce',$(icon).each(function(){this.ipsShow()}));}else{icon.fadeOut();}},_getIcon(type){return $('body').find('[data-notificationType="'+type+'"]');},_getCurrentCounts(){const messages=this.scope.find('[data-notificationType="inbox"]');const notifications=this.scope.find('[data-notificationType="notify"]');return{notifications:parseInt(notifications.attr('data-currentCount')),messages:(messages.length)?parseInt(messages.attr('data-currentCount')):null};},_stopPolling(){Debug.info("Stopping instant notification polling");clearInterval(this._interval);this._paused=true;}});}(jQuery,_));;
|
||||
;(function($,_,undefined){"use strict";const IMAGE_EXTENSIONS=new Set(['gif','jpeg','jpe','jpg','png','svg','webp','avif'])
|
||||
ips.controller.register('core.front.core.lightboxedImages',{_random:null,initialize:function(){var self=this;this.on('initializeImages',this.refreshContent);this.on('refreshContent',this.refreshContent);this.on(document,'imageRotated',function(e,data){var attachment=$(self.scope).find('.ipsAttachLink_image img[data-fileId='+data.fileId+']');self._updateAttachmentImage(attachment,data);});this.setup();},setup:function(){this._random='g'+(Math.round(Math.random()*100000));this._initializeAttachments();this._initializeImages();},refreshContent:function(e){Debug.log("Refreshing content in lightboxedImages");this.scope.removeAttr('data-loaded');this._initializeAttachments();this._initializeImages();e.stopPropagation();},_initializeAttachments:function(){var fileIDsToFetch={};var self=this;var attachments=this.scope.find('[data-fileid]').not(function(idx,elem){var elem=$(elem);return elem.is('source, video')||elem.find('source, video').length;});if(!attachments.length){return;}
|
||||
attachments.each(function(){var attachment=$(this);if(!_.isUndefined(attachment.attr('data-loaded'))){return;}
|
||||
if(!(attachment.is('img, .ipsAttachLink_image'))){var parent=attachment.parent();var clone=parent.clone();clone.children().remove();clone.text(clone.text().replace(/\s/g,''));if(!clone.text().length&&attachment.parentsUntil(this.scope,'li').length===0){attachment.addClass('ipsAttachLink_block');if(attachment.children().length){return;}
|
||||
var title=attachment.text();attachment.html(ips.templates.render('core.attachments.attachmentPreview',{title:title}));}else{attachment.addClass('ipsAttachLink_inline');attachment.attr('title',ips.getString('attachmentPending'));attachment.attr('data-ipstooltip',true);}}
|
||||
fileIDsToFetch[attachment.attr('data-fileid')]=true;});if(!_.size(fileIDsToFetch)){return;}
|
||||
ips.getAjax()(ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=ajax&do=attachmentInfo',{dataType:'json',data:{attachIDs:fileIDsToFetch}}).done(function(response){attachments.each(function(){var attachment=$(this);var attachmentID=attachment.attr('data-fileid');if(_.isUndefined(response[attachmentID])){self._updateAttachmentMetaDataError(attachment);}else if(!_.isUndefined(response[attachmentID].rotate)){self._updateAttachmentImage(attachment,response[attachmentID]);}else{self._updateAttachmentMetaData(attachment,response[attachmentID]);}});}).fail(function(){attachments.each(function(){var attachment=$(this);self._updateAttachmentMetaDataError(attachment);});});},_updateAttachmentMetaData:function(attachment,response){var attachmentID=attachment.attr('data-fileid');if(attachment.hasClass('ipsAttachLink_block')){attachment.find('.ipsAttachLink_metaInfo').html(ips.templates.render('core.attachments.metaInfo',{size:response.size,downloads:ips.pluralize(ips.getString('attachmentDownloads'),response.downloads)}));}else{attachment.attr('title',response.size+' - '+ips.pluralize(ips.getString('attachmentDownloads'),response.downloads));}
|
||||
attachment.attr('data-loaded',true);},_updateAttachmentImage:function(attachment,response){return;if(!(attachment.is('img'))){return;}
|
||||
const DISABLE_LIGHTBOX_ROTATE=true;ips.controller.register('core.front.core.lightboxedImages',{_random:null,initialize(){this.on('initializeImages',this.refreshContent);this.on('refreshContent',this.refreshContent);this.on(document,'imageRotated',(e,data)=>{const attachment=this.elem.querySelector('.ipsAttachLink_image img[data-fileId='+data.fileId+']');this._updateAttachmentImage(attachment,data);});this.setup();},setup(){this._random='g'+(Math.round(Math.random()*100000));this._initializeAttachments();this._initializeImages();},async refreshContent(e){Debug.log("Refreshing content in lightboxedImages");delete this.elem.dataset.loaded;e.stopPropagation();await Promise.allSettled([this._initializeAttachments(),this._initializeImages()]);},async _initializeAttachments(){const fileIDsToFetch={};const attachments=this.elem.querySelectorAll('[data-fileid]:not([data-loaded], audio, source, video, :has(audio, source, video))')
|
||||
if(!attachments.length){return;}
|
||||
const isInlineCache=new WeakMap();const calcIsInline=attachment=>{const listAncestor=attachment.closest('li');if(listAncestor&&(this.elem.contains(listAncestor)||this.elem===listAncestor)){return true;}
|
||||
let parent=attachment;const ancestors=[attachment];while(parent&&this.elem.contains(parent)&&(parent===attachment||parent.matches('[data-fileid]:not([data-loaded], audio, source, video, :has(audio, source, video)), a, span, b, i, u, strong, strike'))){if(isInlineCache.has(parent)){return isInlineCache.get(parent);}
|
||||
ancestors.push(parent)
|
||||
parent=parent.parentElement;}
|
||||
if(!parent){ancestors.forEach(ancestor=>isInlineCache.set(ancestor,false));return false;}
|
||||
const clone=parent.cloneNode(true);clone.querySelectorAll('[data-fileid]').forEach(cloneAttachment=>cloneAttachment.remove());const hasText=!!clone.innerText.trim();ancestors.forEach(ancestor=>isInlineCache.set(ancestor,hasText));return hasText;}
|
||||
attachments.forEach((attachment)=>{if(attachment.matches(':not(img, .ipsAttachLink_image)')){if(!calcIsInline(attachment)){attachment.classList.add('ipsAttachLink_block');if(attachment.children.length){return;}
|
||||
attachment.innerHTML=ips.templates.render('core.attachments.attachmentPreview',{title:attachment.textContent});}else{attachment.classList.add('ipsAttachLink_inline');attachment.setAttribute('title',ips.getString('attachmentPending'));attachment.dataset.ipstooltip="true";}}
|
||||
fileIDsToFetch[attachment.dataset.fileid]=true;});if(![...Object.keys(fileIDsToFetch)].length){return;}
|
||||
try{const response=await ips.fetch(ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=ajax&do=attachmentInfo',{dataType:'json',data:{attachIDs:fileIDsToFetch}});if(typeof response!=='object'||response instanceof Array){throw new RangeError("Expected response to be an object mapping file ids to details");}
|
||||
attachments.forEach(attachment=>{const attachmentID=attachment.dataset.fileid;if(!(attachmentID in response)||typeof response[attachmentID]!=='object'||response[attachmentID]instanceof Array){this._updateAttachmentMetaDataError(attachment);}else if('rotate'in response[attachmentID]){this._updateAttachmentImage(attachment,response[attachmentID]);}else{this._updateAttachmentMetaData(attachment,response[attachmentID]);}});}catch(e){Debug.warn("Failed to get attachment info for one or more lightboxed attachments on the page");attachments.forEach(attachment=>this._updateAttachmentMetaDataError(attachment));}},_updateAttachmentMetaData(attachment,response){if(attachment.classList.contains('ipsAttachLink_block')){const infoEl=attachment.querySelector('.ipsAttachLink_metaInfo')
|
||||
if(infoEl){infoEl.innerHTML=ips.templates.render('core.attachments.metaInfo',{size:response.size,downloads:ips.pluralize(ips.getString('attachmentDownloads'),response.downloads)});}}else{attachment.setAttribute('title',response.size+' - '+ips.pluralize(ips.getString('attachmentDownloads'),response.downloads));}
|
||||
attachment.dataset.loaded='true';},_updateAttachmentImage(attachment,response){if(DISABLE_LIGHTBOX_ROTATE){return;}
|
||||
attachment=$(attachment);if(!(attachment.is('img'))){return;}
|
||||
if(!_.isUndefined(response.rotate)&&response.rotate!==null){attachment.attr('data-rotate',response.rotate).css('transform','');attachment.parents('a.ipsAttachLink_image').css({'transform':'rotate('+response.rotate+'deg)','position':'absolute','top':0});if(response.rotate==90||response.rotate==-270){if(attachment.width()>attachment.height()){attachment.parents('a.ipsAttachLink_image').css({'right':'40%','height':'100%'});}else{attachment.parents('a.ipsAttachLink_image').css({'left':'5%','transform-origin':'right'});}}else if(response.rotate==-90||response.rotate==270){if(attachment.width()>attachment.height()){attachment.parents('a.ipsAttachLink_image').css({'right':'40%','height':'100%'});}else{attachment.parents('a.ipsAttachLink_image').css({'left':'40%','transform-origin':'left'});}}
|
||||
var containerHeight=attachment.height();if(response.rotate!=0&&response.rotate!=180&&response.rotate!=-180){containerHeight=attachment.width();}
|
||||
var parent=attachment.parents('p:first');if($(parent).height()<containerHeight){$(parent).css({'height':parseInt(containerHeight+5).toString()+'px','position':'relative'});}}},_updateAttachmentMetaDataError:function(attachment){if(attachment.hasClass('ipsAttachLink_block')){attachment.find('.ipsAttachLink_metaInfo').html(ips.getString('attachmentUnavailable'));}else{attachment.attr('title',ips.getString('attachmentUnavailable'));}
|
||||
attachment.attr('data-loaded',true);},async _addOrUpdateWrappingLink(image){const closestLink=image.closest('a');const imageSrc=image.attr('src');const fileId=image.attr('data-fileid');if(closestLink.length&&closestLink.hasClass('ipsAttachLink')&&closestLink.hasClass('ipsAttachLink_image')){const href=closestLink.attr('href');const ext=href?.includes('.')?href.split('.').pop():'';if(IMAGE_EXTENSIONS.has(ext)||(await ips.ui.lightbox.getImageDimensions(imageSrc)).solid){closestLink.attr('data-fileId',fileId).attr('data-ipsLightbox','').attr('data-ipsLightbox-group',this._random);if(href){closestLink.attr('data-fullurl',href)}}}else if(!closestLink.length){let link=$('<a data-wrappedLink data-ipslightbox>').attr('href',imageSrc).attr('title',ips.getString('enlargeImage')).attr('data-fileid',fileId).attr('data-lightbox-group',this._random);image.wrap(link);}},_initializeImages:function(){var self=this;var images=this.scope.find('img:not(.ipsEmoji *, .tiptap *, [data-emoticon] *)');if(images.length){_.each(images,function(image,i){let rawImage
|
||||
if(image instanceof $){rawImage=image.get(0);}else{rawImage=image;image=$(image);}
|
||||
const embedAncestor=rawImage?.closest('.ipsEmbedded_og[data-og-url]')
|
||||
if(embedAncestor){if(!('linkified'in embedAncestor.dataset)){const toLink=embedAncestor.querySelector(`.ipsEmbedded_og__title`)||rawImage
|
||||
var parent=attachment.parents('p:first');if($(parent).height()<containerHeight){$(parent).css({'height':parseInt(containerHeight+5).toString()+'px','position':'relative'});}}},_updateAttachmentMetaDataError(attachment){if(attachment.classList.contains('ipsAttachLink_block')){attachment.querySelector('.ipsAttachLink_metaInfo').innerHTML=ips.getString('attachmentUnavailable');}else{attachment.setAttribute('title',ips.getString('attachmentUnavailable'));}
|
||||
attachment.dataset.loaded='true';},async _addOrUpdateWrappingLink(image){const closestLink=image.closest(':is(a, i-lightbox):is([data-wrapped-link], .ipsAttachLink.ipsAttachLink_image)');const imageSrc='fullImage'in image.dataset?image.dataset.fullImage:image.getAttribute('src');const fileId=image.dataset.fileid;if(closestLink){const href=closestLink.getAttribute('href');const ext=href?.includes('.')?href.split('.').pop():'';if(IMAGE_EXTENSIONS.has(ext)||(await ips.ui.lightbox.getImageDimensions(imageSrc)).solid){closestLink.dataset.fileid=fileId;closestLink.dataset.ipslightbox='';closestLink.dataset.ipslightboxGroup=this._random;if(href){closestLink.dataset.fullurl=href;}}}else{const link=document.createElement('i-lightbox');link.dataset.wrappedlink='';link.dataset.ipslightbox='';link.setAttribute('href',imageSrc)
|
||||
if(image.hasAttribute('title')){image.setAttribute('data-original-title',image.getAttribute('title'));}
|
||||
image.setAttribute('title',ips.getString('enlargeImage'))
|
||||
link.dataset.fileid=fileId
|
||||
link.dataset.ipslightboxGroup=this._random;image.parentElement.insertBefore(link,image)
|
||||
link.append(image);}},async _initializeImages(){const images=this.elem.querySelectorAll('img:not(.ipsEmoji *, .tiptap *, [data-emoticon] *, .ipsEmoji, [data-emoticon], [data-ipslightbox] *, a *)');const promises=[];if(images.length){images.forEach(image=>{const embedAncestor=image?.closest('.ipsEmbedded_og[data-og-url]')
|
||||
if(embedAncestor){if(!('linkified'in embedAncestor.dataset)){const toLink=embedAncestor.querySelector(`.ipsEmbedded_og__title`)||image
|
||||
const toWrap=document.createElement('a')
|
||||
toWrap.href=embedAncestor.dataset.ogUrl
|
||||
toWrap.target="_blank"
|
||||
@@ -274,8 +291,8 @@ toLink.parentElement.insertBefore(toWrap,toLink)
|
||||
toWrap.append(toLink)
|
||||
embedAncestor.dataset.linkified=''}
|
||||
return;}
|
||||
if((!image.is('img')||image.is('[data-emoticon], .ipsEmoji'))&&!image.hasClass('ipsImage_thumbnailed')){return;}
|
||||
image.addClass('ipsImage_thumbnailed');self._addOrUpdateWrappingLink(image).then(()=>Debug.log('Wrapped the image if it\'s an image'));});}}});}(jQuery,_));;
|
||||
promises.push(this._addOrUpdateWrappingLink(image));});}
|
||||
await Promise.allSettled(promises);}});}(jQuery,_));;
|
||||
;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.markRead',{initialize:function(){this.on('click',this.markSiteRead);},markSiteRead:function(e){e.preventDefault();ips.ui.alert.show({type:'confirm',icon:'question',message:ips.getString('markAsReadConfirm'),subText:'',callbacks:{ok:function(){var url=$(e.currentTarget).attr('href');ips.getAjax()(url,{showLoading:true}).done(function(){$(document).trigger('markAllRead');}).fail(function(jqXHR,textStatus,errorThrown){window.location=url;});}}});}});}(jQuery,_));;
|
||||
;(function(_){"use strict";ips.controller.register('core.front.core.navigationPanel',{initialize(){let collapsedPanels=[];try{collapsedPanels=JSON.parse(ips.utils.cookie.get('collapsedNavigationPanels')||'[]');if(!Array.isArray(collapsedPanels))throw new TypeError();}catch(e){collapsedPanels=[]
|
||||
ips.utils.cookie.set('collapsedNavigationPanels','[]');}
|
||||
@@ -314,7 +331,8 @@ $(document).trigger('contentChange',[newComment]);newComment.fadeIn().slideDown(
|
||||
;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.sharelink',{initialize:function(){this.on('click','[data-role="shareLink"]',this.launchWindow);},launchWindow:function(e){e.preventDefault();var url=$(e.currentTarget).attr('href');if(!ips.utils.url.getParam('url',url)){url+="&url="+encodeURIComponent(location.href);}
|
||||
if(!ips.utils.url.getParam('title',url)){url+="&title="+encodeURIComponent(document.title);}
|
||||
window.open(url,'delicious','toolbar=no,width=550,height=550');},});}(jQuery,_));;
|
||||
;(function($,_){"use strict";ips.controller.register('core.front.core.userbar',{loaded:{inbox:false,notify:false,reports:false},initialize(){this.on(document,'menuOpened',(...args)=>this.menuOpened(...args));this.on(document,'clearUserbarCache',(...args)=>this.clearUserbarCache(...args));},menuOpened(e,data){if(data.elemID==='elFullInbox'||data.elemID==='ipsOffCanvas--messenger'){this._loadMenu('inbox',ips.getSetting('baseURL')+'index.php?app=core&module=messaging&controller=messenger&overview=1&_fromMenu=1');}else if(data.elemID==='elFullNotifications'||data.elemID==='ipsOffCanvas--notifications'){this._loadMenu('notify',ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=notifications');}else if(data.elemID==='elFullReports'||data.elemID==='elMobReports'){this._loadMenu('reports',ips.getSetting('baseURL')+'index.php?app=core&module=modcp&controller=modcp&tab=reports&overview=1');}},clearUserbarCache(e,data){this.loaded[data.type]=false;},async _loadMenu(type,url){if(!this.loaded[type]){const list=$(`[data-role="${type}List"]`);list.html('').css({height:'100px'}).addClass('ipsLoading');try{const returnedData=await ips.fetch(url,{dataType:'json'});list.css({height:'auto'}).removeClass('ipsLoading').html(returnedData.data);this.loaded[type]=true;if(type!=='reports'){const thisBubble=$(`[data-notificationtype="${type}"]`);const thisTotal=Math.max(0,parseInt(thisBubble.html()))||0;const globalBubble=$(`[data-notificationtype="total"]`);const globalCount=Math.max(0,parseInt(globalBubble.html()))||0;ips.utils.anim.go('fadeOut',thisBubble);if(globalCount-thisTotal<=0){ips.utils.anim.go('fadeOut',globalBubble);}else{globalBubble.html(globalCount-thisTotal)}}
|
||||
;(function($,_){"use strict";ips.controller.register('core.front.core.userbar',{loaded:{inbox:false,notify:false,reports:false},initialize(){this.on(document,'menuOpened',(...args)=>this.menuOpened(...args));this.on(document,'clearUserbarCache',(...args)=>this.clearUserbarCache(...args));},menuOpened(e,data=e.detail){if(data.elemID==='elFullInbox'||data.elemID==='ipsOffCanvas--messenger'){this._loadMenu('inbox',ips.getSetting('baseURL')+'index.php?app=core&module=messaging&controller=messenger&overview=1&_fromMenu=1');}else if(data.elemID==='elFullNotifications'||data.elemID==='ipsOffCanvas--notifications'){this._loadMenu('notify',ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=notifications');}else if(data.elemID==='elFullReports'||data.elemID==='elMobReports'){this._loadMenu('reports',ips.getSetting('baseURL')+'index.php?app=core&module=modcp&controller=modcp&tab=reports&overview=1');}},clearUserbarCache(e,data){this.loaded[data.type]=false;},async _loadMenu(type,url){if(!this.loaded[type]){const list=$(`[data-role="${type}List"]`);list.html('').css({height:'100px'}).addClass('ipsLoading');try{const returnedData=await ips.fetch(url,{dataType:'json'});list.css({height:'auto'}).removeClass('ipsLoading').html(returnedData.data);this.loaded[type]=true;if(type!=='reports'){const thisBubble=$(`[data-notificationtype="${type}"]`);const thisTotal=Math.max(0,parseInt(thisBubble.html()))||0;const globalBubble=$(`[data-notificationtype="total"]`);const globalCount=Math.max(0,parseInt(globalBubble.html()))||0;ips.utils.anim.go('fadeOut',thisBubble);if(globalCount-thisTotal<=0){ips.utils.anim.go('fadeOut',globalBubble);}else{globalBubble.html(globalCount-thisTotal)}}
|
||||
if(type==='notify'){ips.utils.notification.clearBadgeCount();}
|
||||
$(document).trigger('contentChange',[list]);}catch(e){Debug.log("Failed to load a userbar menu")}}}});}(jQuery,_));;
|
||||
;(function($,_,undefined){"use strict";ips.controller.register('core.front.core.webshare',{initialize:function(){if(navigator.share){this._render();this.on('click',this.initShare);}},_render:function(){$('[data-role="webShare"]').removeClass('ipsHide');},initShare:function(e){try{navigator.share({title:this.scope.attr('data-webShareTitle'),text:this.scope.attr('data-webShareText'),url:this.scope.attr('data-webShareUrl')});}catch(err){Debug.log("Failed to use web share API: ",err);}}});}(jQuery,_));;
|
||||
;(function($,_,undefined){"use strict";ips.model.register('core.comment',{initialize:function(){this.on('getEditForm.comment',this.getEditForm);this.on('saveEditComment.comment',this.saveEditComment);this.on('deleteComment.comment',this.deleteComment);this.on('newComment.comment',this.newComment);this.on('approveComment.comment',this.approveComment);this.on('unrecommendComment.comment',this.unrecommendComment);},getEditForm:function(e,data){this.getData({url:data.url,dataType:'html',data:{},events:'getEditForm',namespace:'comment'},data);},saveEditComment:function(e,data){var url=data.url;this.getData({url:data.url,dataType:'html',type:'post',data:data.form||{},events:'saveEditComment',namespace:'comment'},data);},approveComment:function(e,data){this.getData({url:data.url,dataType:'html',data:data.form||{},events:'approveComment',namespace:'comment'},data);},unrecommendComment:function(e,data){this.getData({url:data.url,dataType:'json',data:data.form||{},events:'unrecommendComment',namespace:'comment'},data);},deleteComment:function(e,data){this.getData({url:data.url,dataType:'html',data:data.form||{},events:'deleteComment',namespace:'comment'},data);},newComment:function(e,data){this.getData({url:data.url,dataType:'json',data:data.form||{},events:'newComment',namespace:'comment'},data);}});}(jQuery,_));;
|
||||
Reference in new issue
Block a user