Version 3.2.3

This commit is contained in:
Neo committed 2025-12-19 00:34:03 -08:00
1 parent ae5c01cc78
commit 78706903a2
2641 files changed
+228363 -201264

No files matched your search

+132 -269
View File
@@ -37,141 +37,82 @@ _comments.prototype.comments = {
hc: '',
up: '',
_id: 0,
/*timer: [],
blockSizes: [],*/
/*------------------------------*/
/* Constructor */
init: function()
{
Debug.write("Initializing ips.gallery.js");
Debug.write("Initializing ips.comments.js");
document.observe("dom:loaded", function(){
ipb.comments.preCheckComments();
ipb.delegate.register('a[rel="bookmark"]', ipb.comments.showLinkToComment );
ipb.delegate.register('.post_id a[rel="bookmark"]', ipb.comments.showLinkToComment );
/* Comments */
ipb.delegate.register('.edit_comment' , ipb.comments.editShow );
ipb.delegate.register('.delete_comment' , ipb.comments.deletePop );
ipb.delegate.register('.reply_comment' , ipb.comments.reply );
ipb.delegate.register('a[rel="bookmark"]', ipb.comments.showCommentLink );
ipb.delegate.register('input.ipsComment_mod', ipb.comments.moderate );
if ( $('commentPost') )
if ( $('commentPost') && !$('commentCaptcha') )
{
$('commentPost').observe( 'click', ipb.comments.add );
}
/* Set up hovercard */
ipb.hoverCardRegister.initialize( 'comment_mod', { 'callback': ipb.comments.hCard, 'w': '250px', 'delay': 500, 'position': 'bottomLeft' } );
if ( $('reputation_filter') )
{
$('reputation_filter').hide();
}
if( $('comment_name') )
{
$('comment_name').observe( 'focus', function() {
if( $('commentCaptcha') )
{
$('commentCaptcha').show();
}
});
}
});
},
uCard: function( e, id )
moderate: function(e, elem)
{
Event.stop(e);
var elem = Event.element(e);
var sourceid = elem.identify();
var user = $( elem ).className.match('__id([0-9]+)');
var fid = $( elem ).className.match('__fid([0-9]+)');
if( user == null || Object.isUndefined( user[1] ) ){ Debug.error("Error showing popup"); return; }
var popid = 'popup_' + user[1] + '_user';
var _url = ipb.vars['base_url'] + '&app=members&module=ajax&secure_key=' + ipb.vars['secure_hash'] + '&section=card&mid=' + user[1];
Debug.write( fid );
if ( fid != null && !Object.isUndefined( fid[1] ) && fid[1] )
{
_url += '&f=' + fid[1];
// Count checked boxes that are visible
var count = $$(".ipsComment_mod:checked").findAll( function(el){ return el.up('.ipsComment').visible(); } );
if( count.size() ){
if( !$('comment_moderate_box') ){
$$('body')[0].insert({'bottom': ipb.templates['comment_moderation'].evaluate({count: count.size()}) });
$('submitModAction').on('click', ipb.comments.doModerate);
} else {
$('comment_count').update( count.size() );
}
if( !$('comment_moderate_box').visible() ){
new Effect.Appear( $('comment_moderate_box'), { duration: 0.3 } );
}
}
Debug.write( _url );
ipb.namePops[ user ] = new ipb.Popup( popid, {
type: 'balloon',
ajaxURL: _url,
stem: true,
hideAtStart: false,
attach: { target: elem, position: 'auto' },
w: '400px'
});
},
/**
* Hover card callback
*/
hCard: function( e, id )
{
var count = 0;
/* Store comment id for push */
ipb.comments.cCard = id.replace( /mod_comment_id_/, '' );
count = ipb.comments.countChecked();
Debug.write( "here at the callback " + count);
/* Got a count? If not, skip it */
if ( ! count )
else
{
return false;
if( $('comment_moderate_box') ){
new Effect.Fade( $('comment_moderate_box'), { duration: 0.3 } );
}
}
/* Fetch template and return */
return new Template( $('modPopUp').innerHTML ).evaluate( { 'count': count, 'id': ipb.comments.cCard } );
},
/**
* Count checked boxes.
* @returns int
*/
countChecked: function()
doModerate: function(e)
{
count = 0;
var doMod = $('commentModAction').value;
var url = ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=moderate&parentId=' + ipb.comments.parentId + '&fromApp=' + ipb.comments.data['fromApp'] + '&modact=' + doMod + '&secure_key=' + ipb.vars['secure_hash'];
/* Fetch count of active checkboxes */
$$('.comment_mod').each( function(elem)
{
if ( elem.checked === true )
{
count++;
if ( elem.id )
{
var _id = elem.id.replace( /mod_comment_id_/, '' );
if ( $('comment_id_' + _id) )
{
if ( ! $('comment_id_' + _id).visible() )
{
count--;
}
}
}
}
} );
return count;
},
/**
* Someone pushed the button!
*/
goModerate: function(e)
{
Event.stop(e);
/* Fire ajax */
var act = $( 'modOptions_' + ipb.comments.cCard ).value;
var url = ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=moderate&parentId=' + ipb.comments.parentId + '&fromApp=' + ipb.comments.data['fromApp'] + '&modact=' + act + '&secure_key=' + ipb.vars['secure_hash'];
var ids = new Array();
$$('.comment_mod').each( function(elem)
{
if ( elem.checked === true )
{
ids[ ids.length ] = elem.id.replace( /mod_comment_id_/, '' );
}
} );
// Get checked comment IDs
var ids = $$('.ipsComment_mod:checked').collect( function(item){
return item.up('.ipsComment').readAttribute('data-commentid');
});
new Ajax.Request( url,
{
@@ -181,68 +122,66 @@ _comments.prototype.comments = {
parameters: {
md5check: ipb.vars['secure_hash'],
"commentIds[]": ids
},
},
onSuccess: function(t)
{
if ( t.responseJSON['error'] )
{
if ( t.responseJSON['error'] ){
alert( t.responseJSON['error'] );
return false;
}
else
{
/* Untick checkboxes */
$$('.comment_mod').each( function(elem)
{
if ( elem.checked === true )
{
elem.checked = false;
}
} );
$$('.ipsComment_mod:checked').each( function(i){
i.checked = false;
});
if ( act == 'delete')
{
/* Inc. deleted count */
ipb.comments.deleted += ids.length;
Debug.write( "Deleted - " + ipb.comments.deleted + ", on this page - " + ipb.comments.data['counts']['thisPageCount'] );
if ( ipb.comments.data['counts']['curStart'] )
{
/* How many posts are actually left? */
if ( ipb.comments.data['counts']['thisPageCount'] - ipb.comments.deleted < 1 )
{
/* redirect to the previous page */
window.location = ipb.vars['base_url'] + 'app=core&module=global&section=comments&do=findLastComment&parentId=' +ipb.comments.parentId + '&fromApp=' + ipb.comments.data['fromApp'];
return false;
if( $('comment_moderate_box') ){
new Effect.Fade( $('comment_moderate_box'), { duration: 0.3 } );
}
switch( doMod ){
case 'delete':
ipb.comments.deleted += ids.length;
Debug.write( "Deleted - " + ipb.comments.deleted + ", on this page - " + ipb.comments.data['counts']['thisPageCount'] );
if ( ipb.comments.data['counts']['curStart'] ){
if ( ipb.comments.data['counts']['thisPageCount'] - ipb.comments.deleted < 1 ){
window.location = ipb.vars['base_url'] + 'app=core&module=global&section=comments&do=findLastComment&parentId=' +ipb.comments.parentId + '&fromApp=' + ipb.comments.data['fromApp'];
return false;
}
}
}
/* Just go away if still here */
for( var i = 0 ; i <= ids.length ; i++ )
{
Effect.Fade( 'comment_id_' + ids[i], { 'duration': 0.8 } );
}
}
else if ( act == 'unapprove' )
{
for( var i = 0 ; i <= ids.length ; i++ )
{
ipb.comments.visibilityEffect( 'off', ids[i] );
}
}
else if ( act == 'approve' )
{
for( var i = 0 ; i <= ids.length ; i++ )
{
ipb.comments.visibilityEffect( 'on', ids[i] );
}
Effect.multiple( ids.collect( function(i){ return $('comment_id_' + i); } ),
Effect.Fade,
{ duration: 0.8 }
);
break;
case 'unapprove':
for( var i = 0 ; i <= ids.length ; i++ ){
ipb.comments.visibilityEffect( 'off', ids[i] );
}
break;
case 'approve':
for( var i = 0 ; i <= ids.length ; i++ ){
ipb.comments.visibilityEffect( 'on', ids[i] );
}
break;
}
}
}
}
);
});
},
/* ------------------------------ */
/**
* Shows a prompt allowing user to copy the URL
*
* @var {event} e The event
*/
showCommentLink: function(e, elem)
{
_t = prompt( ipb.lang['copy_topic_link'], $( elem ).readAttribute('href') );
Event.stop(e);
},
/**
@@ -314,22 +253,24 @@ _comments.prototype.comments = {
{
Event.stop(e);
var commentId = elem.id.replace( /delete_comment_/, '' );
var commentId = elem.up('.ipsComment').readAttribute('data-commentid');
if( !commentId ){ return; }
/* store for use later */
ipb.comments.commentId = commentId;
/* Create the pop-up */
var popid = 'pop__delete_popup_' + commentId;
var content = new Template( $('delPopUp').innerHTML ).evaluate( { 'commentId': commentId } );
var content = ipb.templates['comment_delete'].evaluate( { 'commentId': commentId } );
ipb.comments.deletePopUps = new ipb.Popup( popid, { type: 'balloon',
initial: content,
stem: true,
hideAtStart: false,
attach: { target: $('delete_comment_' + commentId ), position: 'auto', 'event': 'click' },
w: '200px' } );
w: '350px' } );
/* store for use later */
ipb.comments.commentId = commentId;
},
@@ -357,10 +298,8 @@ _comments.prototype.comments = {
},
onSuccess: function(t)
{
if ( t.responseJSON['error'] )
{
alert( t.responseJSON['error'] );
if ( t.responseJSON['error'] ){
alert( ipb.lang['no_permission'] );
return false;
}
else
@@ -449,9 +388,9 @@ _comments.prototype.comments = {
alert(ipb.lang['no_permission']);
return;
}
if( t.responseText == 'error' )
if( t.responseText == 'error' || t.responseText.match( /^Error / ) )
{
alert(ipb.lang['action_failed']);
alert(ipb.lang['no_permission']);
return;
}
@@ -461,13 +400,6 @@ _comments.prototype.comments = {
edit['post'].update( t.responseText );
edit['pid'] = 'e' + edit['pid'];
// Init the editor
ipb.editors[ edit['pid'] ] = new ipb.editor( edit['pid'], USE_RTE );
try {
ipb.editors[ edit['pid'] ].editor_window.focus();
} catch(err) { }
// Set up events
if( $('edit_save_' + edit['pid'] ) ){
@@ -493,24 +425,16 @@ _comments.prototype.comments = {
var elem = Event.element(e);
var postid = elem.id.replace('edit_save_e', '');
if( !postid ){ return; }
try {
// Need to update for submit manually in this case
ipb.editors[ 'e' + postid ].update_for_form_submit();
var Post = $F( 'e' + postid + '_textarea' );
} catch(err) {
Debug.error( err );
Debug.dir( ipb.editors );
return;
}
var Post = ipb.textEditor.getEditor('edit-' + postid).getText();
if( Post.blank() )
{
alert( ipb.lang['post_empty'] );
return;
}
var url = ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=saveEdit&parentId=' +ipb.comments.parentId + '&fromApp=' + ipb.comments.data['fromApp'] + '&secure_key=' + ipb.vars['secure_hash'] + '&comment_id=' + postid;
var url = ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=saveEdit&parentId=' + ipb.comments.parentId + '&fromApp=' + ipb.comments.data['fromApp'] + '&secure_key=' + ipb.vars['secure_hash'] + '&comment_id=' + postid;
Debug.write( url );
new Ajax.Request( url,
{
@@ -552,9 +476,9 @@ _comments.prototype.comments = {
{
new Effect.ScrollTo( $( 'comment_id_' + postid ).down('.comment_content'), { offset: -50 } );
}
ipb.global.findImgs( $( 'comment_id_' + postid ).down('.comment_content') );
ipb.textEditor.getEditor( 'edit-' + postid ).remove();
prettyPrint();
}
}
@@ -577,8 +501,9 @@ _comments.prototype.comments = {
if( ipb.comments.commentCache[ postid ] ){
$( 'comment_id_' + postid ).down('.comment_content').update( ipb.comments.commentCache[ postid ] );
ipb.editors[ postid ] = null;
$('edit_comment_' + postid).writeAttribute('_editing', '0');
ipb.textEditor.getEditor( 'edit-' + postid ).remove();
}
return;
@@ -590,27 +515,19 @@ _comments.prototype.comments = {
add: function(e)
{
Event.stop(e);
try {
// Need to update for submit manually in this case
ipb.editors[ 'fast-reply' ].update_for_form_submit();
var Post = $F( 'fast-reply_textarea' );
} catch(err) {
Debug.error( err );
Debug.dir( ipb.editors );
return;
}
if( Post.blank() )
var content = ipb.textEditor.getEditor().getText();
var isRte = ipb.textEditor.getEditor().isRte();
if( content.blank() )
{
alert( ipb.lang['post_empty'] );
return;
}
/* Close editor */
$('fast-reply_textarea').value = '';
ipb.editors['fast-reply'].editor_set_content(false);
ipb.editors['fast-reply'].resize_to( 70 );
ipb.textEditor.getEditor().minimizeOpenedEditor();
in_use = 0;
var url = ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=add&parentId=' + ipb.comments.parentId + '&fromApp=' + ipb.comments.data['fromApp'] + '&secure_key=' + ipb.vars['secure_hash'];
@@ -623,13 +540,21 @@ _comments.prototype.comments = {
encoding: ipb.vars['charset'],
parameters: {
md5check: ipb.vars['secure_hash'],
Post: Post.encodeParam()
Post: content.encodeParam(),
isRte: isRte
},
onSuccess: function(t)
{
if ( t.responseJSON && t.responseJSON['error'] )
{
ipb.global.errorDialogue( ipb.lang['no_permission'] );
if( t.responseJSON['error'] == 'comment_requires_approval' )
{
ipb.global.okDialogue( ipb.lang['comment_requires_approval'] );
}
else
{
ipb.global.errorDialogue( ipb.lang['no_permission'] );
}
}
else if ( t.responseText && t.responseText != 'no_permission' )
{
@@ -671,16 +596,14 @@ _comments.prototype.comments = {
var endBorderColor = $('comment_id_' + latestId ).getStyle( 'border-top-color' );
/* Remove light BG */
$('comment_id_' + latestId).removeClassName('row1').addClassName('row2').setStyle( { 'border-top-color': startColor, 'border-top-style': 'solid', 'border-top-width': '1px' } );
$('comment_id_' + latestId).removeClassName('row1').addClassName('row2');
$('comment_id_' + latestId ).hide();
new Effect.BlindDown( 'comment_id_' + latestId, { duration: 1.0, queue: 'front' } );
new Effect.Morph( 'comment_id_' + latestId, { 'style': 'border-top-color:' + endBorderColor, queue: 'end' } );
new Effect.Morph( 'comment_id_' + latestId, { 'style': 'background-color:' + endColor, queue: 'end', afterFinish: function() { $('comment_id_' + latestId ).removeClassName('row2').addClassName( 'row1' ); } } );
}
//ipb.global.findImgs( $( 'post_id_' + postid ).down('.post') );
prettyPrint();
}
}
@@ -707,6 +630,7 @@ _comments.prototype.comments = {
Event.stop(e);
var edit = [];
Debug.write("Here");
if ( ! elem ){ return; }
@@ -737,9 +661,7 @@ _comments.prototype.comments = {
return;
}
editorExpand( 'fast-reply' );
ipb.editors['fast-reply'].insert_text( t.responseText );
ipb.textEditor.getEditor().insert( t.responseText );
}
}
);
@@ -754,20 +676,6 @@ _comments.prototype.comments = {
Event.stop(e);
},
/**
* Confirm they want to delete stuff
*
* @var {event} e The event
*/
confirmSingleDelete: function(e, elem)
{
if( !confirm( ipb.lang['delete_post_confirm'] ) )
{
Event.stop(e);
}
},
/**
* Toggles the multimod buttons in posts
*
@@ -903,51 +811,6 @@ _comments.prototype.comments = {
ipb.comments.updateModButton();
},
/**
* Check the files we've selected
*/
preCheckImages: function()
{
var topics = [];
if( $('selectedimgids' ) ){
topics = $F('selectedimgids').split(',');
}
var checkboxesOnPage = 0;
var checkedOnPage = 0;
if( topics )
{
topics.each( function(check){
if( check != '' )
{
if( $('img_' + check ) )
{
checkedOnPage++;
$('img_' + check ).checked = true;
}
ipb.comments.totalChecked++;
}
});
}
$$('.image_mod').each( function(check){
checkboxesOnPage++;
} );
if( $('imgs_all') )
{
if( checkedOnPage == checkboxesOnPage )
{
$('imgs_all').checked = true;
}
}
ipb.comments.updateModButton();
},
/**
* Update the moderation button
*/