Version 5.0.0 beta 5
This commit is contained in:
1 parent
2f24f9de48
commit
57d9db6ce2
218 files changed
+5331
-7416
No files matched your search
@@ -47,8 +47,7 @@ var tooltipSize={width:tooltip.show().outerWidth(),height:tooltip.show().outerHe
|
||||
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){const tablist=document.querySelector('[role="tablist"]');let activeTab=tablist?.querySelector('.ipsTabs__tab--active');let activeTabId='elComment';if(activeTab){const parts=activeTab.getAttribute('id').split('_');if(parts.length>=2){activeTabId=parts[parts.length-1]==='comments'?'elComment':'elReview';Debug.log(activeTabId);}else{Debug.log("Invalid object ID format");}}
|
||||
let commentFeed=this.scope.get(0)?.closest('[data-controller]')
|
||||
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';Debug.log(activeTabId);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;}
|
||||
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()
|
||||
@@ -174,17 +173,18 @@ if($('#elFlashMessage').find('[data-role="newPostNotification"]').length){$('#el
|
||||
e.preventDefault();e.stopPropagation();var self=this;var replyArea=this.scope.find('[data-role="replyArea"]');var submit=form.find('[type="submit"]');var autoFollow=this.scope.find('input[name$="auto_follow_checkbox"]');var commentsOnThisPage=this.scope.find('[data-commentid]');var _lastSeenID=this._getLastSeenID(commentsOnThisPage);var initialText=submit.text();submit.prop('disabled',true).text(ips.getString('saving'));var page=ips.utils.url.getPageNumber(this._pageParam);if(!page){page=1;}
|
||||
this._clearNotifications();ips.getAjax()(form.attr('action'),{data:form.serialize()+'¤tPage='+page+'&_lastSeenID='+_lastSeenID,type:'post'}).done(function(response){if(response.type=='error'){if(response.form){if(replyArea.find('[data-ipseditorv5]')){ips.ui.editorv5.getObj(replyArea.find('[data-ipseditorv5]')).destruct();}
|
||||
form.replaceWith($(response.form));$(document).trigger('contentChange',[self.scope]);}else{ips.ui.alert.show({type:'alert',icon:'warn',message:response.message,callbacks:{}});}}
|
||||
else if(response.type=='redirect'){self.paginationClick(e,{href:response.url,originalEvent:e});}else if(response.type=='merge'){var comment=self.scope.find('[data-commentid="'+response.id+'"]');comment.find('[data-role="commentContent"]').html(response.content);if(comment.find('pre.prettyprint').length){comment.find('pre.prettyprint').each(function(){$(this).html(window.PR.prettyPrintOne(_.escape($(this).text())));});}
|
||||
else if(response.type=='redirect'){self.paginationClick(e,{href:response.url,originalEvent:e});}else if(response.type=='merge'){var comment=$(self.findCommentInFeed(response.id));comment.find('[data-role="commentContent"]').html(response.content);if(comment.find('pre.prettyprint').length){comment.find('pre.prettyprint').each(function(){$(this).html(window.PR.prettyPrintOne(_.escape($(this).text())));});}
|
||||
self.scope.find('[data-role="replyArea"] [data-ipsEditorv5]').data('_editor').reset();if(self.scope.find('[data-role="replyArea"] input[name="guest_name"]').length){self.scope.find('[data-role="replyArea"] input[name="guest_name"]').val('');}
|
||||
form.find("[data-role='commentFormError']").each(function(){$(this).remove();});const container=comment.closest('.js-ipsEntry');if(container.length){ips.utils.anim.go('pulseOnce',container);}else{ips.utils.anim.go('pulseOnce',comment);}
|
||||
ips.ui.flashMsg.show(ips.getString('mergedConncurrentPosts'));$(document).trigger('contentChange',[self.scope]);}else{if(response.postedByLoggedInMember){self.trigger('ipsDataLayer',{_key:'content_comment',_properties:response.dataLayer});}
|
||||
self.trigger('addToCommentFeed',{content:response.content,totalItems:response.total,feedID:self._commentFeedID,scrollToItem:true});if(response.message){ips.ui.flashMsg.show(response.message);}
|
||||
if(self.scope.find('[data-role="replyArea"] input[name="guest_name"]').length){self.scope.find('[data-role="replyArea"] input[name="guest_name"]').val('');self.scope.find('[data-role="replyArea"] [data-ipsEditorv5]').find('.ipsComposeArea_dummy').hide().end().find('[data-role="mainEditorArea"]').show().end().closest('.ipsComposeArea').removeClass('ipsComposeArea_minimized').find('[data-ipsEditor-toolList]').show();}
|
||||
form.find("[data-role='commentFormError']").each(function(){$(this).remove();});if(autoFollow.length){self.trigger('followingItem',{feedID:self.scope.attr('data-feedID'),following:autoFollow.is(':checked')});}}
|
||||
self._clearNotifications();}).fail(function(jqXHR,textStatus,errorThrown){if(Debug.isEnabled()){Debug.error("Posting new reply failed: "+textStatus);Debug.log(jqXHR);Debug.log(errorThrown);}else{form.attr('data-noAjax','true');form.attr('action',form.attr('action')+((!form.attr('action').match(/\?/))?'?failedReply=1':'&failedReply=1'));form.submit();}}).always(function(){submit.prop('disabled',false).text(initialText?initialText:ips.getString('submit_reply'));});},loadNewPosts:function(e){e?.preventDefault?.();this._importNewReplies();},addToCommentFeed(e,data){if(typeof data?.content!=="string"||data.feedID!==this._commentFeedID){return;}
|
||||
self._clearNotifications();}).fail(function(jqXHR,textStatus,errorThrown){if(Debug.isEnabled()){Debug.error("Posting new reply failed: "+textStatus);Debug.log(jqXHR);Debug.log(errorThrown);}else{form.attr('data-noAjax','true');form.attr('action',form.attr('action')+((!form.attr('action').match(/\?/))?'?failedReply=1':'&failedReply=1'));form.submit();}}).always(function(){submit.prop('disabled',false).text(initialText?initialText:ips.getString('submit_reply'));});},loadNewPosts:function(e){e?.preventDefault?.();this._importNewReplies();},findCommentInFeed(commentId){const commentSelector=`[data-commentid="${commentId}"]`;const comment=this.elem.querySelector(`[data-role="commentFeed"] ${commentSelector}`);if(comment){return comment;}else if(this.elem.dataset.feedid){const feedSelector=`[data-feedid="${this.elem.dataset.feedid}"]`;return document.querySelector(`${feedSelector}${commentSelector}, ${feedSelector} ${commentSelector}`)||null;}
|
||||
return null;},addToCommentFeed(e,data){if(typeof data?.content!=="string"||data.feedID!==this._commentFeedID){return;}
|
||||
const content=$('<div/>').append(data.content);const div=content.get(0);const comment=content.find('.js-ipsEntry');let commentFeed=this.scope.find('[data-role="commentFeed"]');if(commentFeed.find('[data-role="moderationTools"]').length){commentFeed=commentFeed.find('[data-role="moderationTools"]');}
|
||||
this.scope.find('[data-role="noComments"]').remove();const actualContent=div.querySelector(`[data-ips-hook="postWrapper"]`)
|
||||
const id=parseInt(actualContent?.querySelector(`[data-commentid]`)?.dataset.commentid);const existing=Number.isInteger(id)&&(this.elem.querySelector(`[data-role="commentFeed"] [data-commentid="${id}"]`)?.closest(`[data-ips-hook="postWrapper"]`)||null);if(existing&&existing.parentElement){existing.parentElement.replaceChild(existing,actualContent);}else{commentFeed.append(comment.css({opacity:"0.001"}));const newItemTop=comment.offset().top;const windowScroll=$(window).scrollTop();const viewHeight=$(window).height();function _showComment(){comment.css({opacity:"1"});ips.utils.anim.go('fadeInDown',comment.filter(':not(.ipsHide)'));}
|
||||
const id=parseInt(actualContent?.querySelector(`[data-commentid]`)?.dataset.commentid);const existing=Number.isInteger(id)&&this.findCommentInFeed(id);if(existing&&existing.parentElement){existing.parentElement.replaceChild(existing,actualContent);}else{commentFeed.append(comment.css({opacity:"0.001"}));const newItemTop=comment.offset().top;const windowScroll=$(window).scrollTop();const viewHeight=$(window).height();function _showComment(){comment.css({opacity:"1"});ips.utils.anim.go('fadeInDown',comment.filter(':not(.ipsHide)'));}
|
||||
if(data.scrollToItem&&(newItemTop<windowScroll||newItemTop>(windowScroll+viewHeight))){$('html, body').animate({scrollTop:newItemTop+'px'},'fast',function(){setTimeout(_showComment,100);});}else{_showComment();}
|
||||
if(!('resetEditor'in data)||data.resetEditor!==false){this.scope.find('[data-role="replyArea"] [data-ipsEditorv5]').data('_editor').reset();}
|
||||
if(ips.utils.db.isEnabled()){const buttons=comment.find('[data-action="multiQuoteComment"]');buttons.hide().removeClass('ipsHide');ips.utils.anim.go('fadeIn',buttons);}}
|
||||
@@ -250,7 +250,7 @@ attachment.attr('data-loaded',true);},_updateAttachmentImage:function(attachment
|
||||
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){image.wrap($('<a href="'+imageSrc+'"'+" title='"+ips.getString('enlargeImage')+"' data-fileId='"+fileId+"'data-wrappedLink data-ipsLightbox data-ipsLightbox-group='"+this._random+"'></a>"));}},_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
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user