Вход Регистрация
Файл: public/js/ips.comments.js
Строк: 871
<?php
/************************************************/
/* IPB3 Javascript                                */
/* -------------------------------------------- */
/* ips.gallery.js - Gallery javascript            */
/* (c) IPS, Inc 2008                            */
/* -------------------------------------------- */
/* Author: Rikki Tissier & Brandon Farber        */
/************************************************/

var _comments     window.IPBoard;
var 
_comments_id  0;
/**
 * 
 */
_comments.prototype.comments = {
    
    
totalChecked:    0,
    
inSection'',
    
    
cur_left:    0,
    
cur_right:    0,
    
cur_image:    0,
    
    
catPopups: [],
    
popupnull,
    
sApnull,
    
sApLn0,
    
templates: {},
    
commentCache: {},
    
data: {},
    
parentId0,
    
commentId0,
    
deletePopUps: {},
    
hidePopUps: {},
    
deleted0,
    
modPopfalse,
    
cCard0,
    
hc'',
    
up'',
    
_id0,
    
modOptionsUnapproved0,
    
modOptionsHidden0,
    
modOptionsUnhidden0,
    
    
/*------------------------------*/
    /* Constructor                     */
    
init: function()
    {
        
Debug.write("Initializing ips.comments.js");
        
        
document.observe("dom:loaded", function(){
            
            
ipb.comments.preCheckComments();
            
            
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('.hide_comment' ipb.comments.hidePop );
            
ipb.delegate.register('.reply_comment'  ipb.comments.reply );
            
ipb.delegate.register('input.ipsComment_mod'ipb.comments.checkComment );
            
            if ( $(
'commentPost') && !$('commentCaptcha') )
            {
                $(
'commentPost').observe'click'ipb.comments.add );
            }
            
            if ( $(
'reputation_filter') )
            {
                $(
'reputation_filter').hide();
            }
            
            if( $(
'comment_name') )
            {
                $(
'comment_name').observe'focus', function() { 
                    if( $(
'commentCaptcha') )
                    {
                        $(
'commentCaptcha').show();
                    }
                });
            }
        });
    },
    
    
moderate: function(eelem)
    {
        
// 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({countcount.size()}) });
                $(
'submitModAction').on('click'ipb.comments.doModerate);
            } else {
                $(
'comment_count').updatecount.size() );
            }
            
            if( !$(
'comment_moderate_box').visible() ){
                new 
Effect.Appear( $('comment_moderate_box'), { duration0.3 } );
            }
            
            
/* Update the available options */
            
$('commentModAction').select('option').invoke('remove');
            
            if ( 
ipb.comments.modOptionsUnapproved )
            {
                $(
'commentModAction').insert( new Element('option', { value'approve' } ).updateipb.lang['cpt_approve'] ) );
            }
            if ( 
ipb.comments.modOptionsUnhidden )
            {
                $(
'commentModAction').insert( new Element('option', { value'hide' } ).updateipb.lang['cpt_hide'] ) );
            }
            if ( 
ipb.comments.modOptionsHidden )
            {
                $(
'commentModAction').insert( new Element('option', { value'unhide' } ).updateipb.lang['cpt_undelete'] ) );
            }
            
            $(
'commentModAction').insert( new Element('option', { value'delete' } ).updateipb.lang['cpt_delete'] ) );
        }
        else
        {
            if( $(
'comment_moderate_box') ){
                new 
Effect.Fade( $('comment_moderate_box'), { duration0.3 } );
            }
        }
    },
    
    
doModerate: function(e)
    {
        var 
doMod    = $('commentModAction').value;
        var 
url        ipb.comments.data['ajaxModerateUrl'] ? ipb.comments.data['ajaxModerateUrl'] : ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=moderate&parentId=' ipb.comments.parentId '&fromApp=' ipb.comments.data['fromApp'];
        
        
// Get checked comment IDs
        
var ids = $$('.ipsComment_mod:checked').collect( function(item){
            return 
item.up('.ipsComment').readAttribute('data-commentid');
        });
        
        new 
Ajax.Request(    url,
                            {
                                
method'post',
                                
evalJSON'force',
                                
encodingipb.vars['charset'],
                                
parameters: {
                                    
md5check:             ipb.vars['secure_hash'],
                                    
modact:                doMod,
                                    
"commentIds[]":        ids
                                
},
                                
onSuccess: function(t)
                                {
                                    if ( 
t.responseJSON['error'] ){
                                        
alertt.responseJSON['error'] );
                                        return 
false;
                                    }
                                    else
                                    {
                                        $$(
'.ipsComment_mod:checked').each( function(i){
                                            
i.checked false;
                                        });
                                        
                                        if( $(
'comment_moderate_box') ){
                                            new 
Effect.Fade( $('comment_moderate_box'), { duration0.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 ){
                                                        
window.location ipb.comments.data['findLastComment'] ? ipb.comments.data['findLastComment'] : ipb.vars['base_url'] + 'app=core&module=global&section=comments&do=findLastComment&parentId=' +ipb.comments.parentId '&fromApp=' ipb.comments.data['fromApp'];
                                                        return 
false;
                                                    }
                                                }
                                                
                                                
Effect.multiple(     ids.collect( function(i){ return $('comment_id_' i); } ),
                                                                    
Effect.Fade,
                                                                    { 
duration0.8 }
                                                                );
                                            break;
                                            case 
'hide':
                                            case 
'unapprove':
                                                for( var 
<= ids.length i++ ){
                                                    
ipb.comments.visibilityEffect'off'ids[i] );
                                                }
                                            break;
                                            case 
'unhide':
                                            case 
'approve':
                                                for( var 
<= ids.length i++ ){
                                                    
ipb.comments.visibilityEffect'on'ids[i] );
                                                }
                                            break;
                                        }
                                    }
                                }
                            });
    },
    
    
/**
     * Do the color switch for approved/unapproved
     * 
     */
    
visibilityEffect: function( modeid )
    {
        if ( ! $(
'comment_id_' id ) )
        {
            return;
        }
        
        var 
moderated 'moderated';
        var 
row          'row1';
        
        if ( 
mode == 'off' )
        {
            
toClass   moderated;
            
fromClass row;
        }
        else
        {
            
toClass   row;
            
fromClass moderated;
        }
        
Debug.writemode );
        
/* Ensure the Morph BG has been removed */
        
$('comment_id_' id ).setStyle( { 'backgroundColor''' } );
        
        if ( 
mode == 'off' )
        {
            
/* Add  BG and fetch RGB value */
            
$('comment_id_' id ).addClassNametoClass );
            var 
endColor = $('comment_id_' id ).getStyle'background-color' );

            
/* Add BG and fetch RGB value */
            
$('comment_id_' id ).removeClassNametoClass );
            var 
startColor = $('comment_id_' id ).getStyle'background-color' );

            new 
Effect.Morph'comment_id_' id, { 'style''background-color:' endColorduration0.6afterFinish: function() { $('comment_id_' id ).addClassNametoClass ); } } );
            
            $( 
'mod_comment_id_' id ).writeAttribute'data-status''-1' );
            
ipb.comments.modOptionsHidden++;
            
ipb.comments.modOptionsUnhidden--;
        }
        else
        {            
            var 
startColor = $('comment_id_' id ).getStyle'background-color' );
            
            $(
'comment_id_' id ).removeClassNamefromClass );
            var 
endColor = $('comment_id_' id ).getStyle'background-color' );
            
            $(
'comment_id_' id ).addClassNamefromClass );
            
            new 
Effect.Morph'comment_id_' id, { 'style''background-color:' endColorduration0.6afterFinish: function() { $('comment_id_' id ).removeClassNamefromClass ); } } );
            
            $( 
'mod_comment_id_' id ).writeAttribute'data-status''1' );
            
ipb.comments.modOptionsHidden--;
            
ipb.comments.modOptionsUnhidden++;
        }
    },
    
    
/**
     * Set Data
     */
    
setData: function( json )
    {
        
ipb.comments.data json;
        
Debug.diripb.comments.data );
    },
    
    
/**
     * Show a pop-up for delete
     */
    
deletePop: function(eelem)
    {
        
Event.stop(e);
        
        var 
commentId elem.up('.ipsComment').readAttribute('data-commentid');
        if( !
commentId ){ return; }
        
        
/* Create the pop-up */
        
var popid   'pop__delete_popup_' commentId;
        var 
content ipb.templates['comment_delete'].evaluate( { 'commentId'commentId } );
        
        
ipb.comments.deletePopUps = new ipb.Popuppopid, {  type'balloon',
                                                             
initialcontent,
                                                             
stemtrue,
                                                             
hideAtStartfalse,
                                                             
attach: { target: $('delete_comment_' commentId ), position'auto''event''click' },
                                                             
w'350px' } );
        
        
/* store for use later */
        
ipb.comments.commentId commentId;
    },
    
    
/**
     * Fire delete
     */
    
deleteIt: function( )
    {
        
Event.stop(e);
        
        
ipb.comments.deletePopUps.hide();
        
        
/* Fire ajax */
        
var url ipb.comments.data['ajaxDeleteUrl'] ? ipb.comments.data['ajaxDeleteUrl'] : ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=delete&parentId=' ipb.comments.parentId '&fromApp=' ipb.comments.data['fromApp'];
        
        
Debug.writeurl );
        
        new 
Ajax.Request(    url,
                            {
                                
method'post',
                                
evalJSON'force',
                                
encodingipb.vars['charset'],
                                
parameters: {
                                    
md5check:             ipb.vars['secure_hash'],
                                    
comment_id:            ipb.comments.commentId
                                    
},
                                
onSuccess: function(t)
                                {
                                    if ( 
t.responseJSON['error'] ){
                                        
alertipb.lang['no_permission'] );
                                        return 
false;
                                    }
                                    else
                                    {
                                        
/* Inc. deleted count */
                                        
ipb.comments.deleted++;
                                        
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 )
                                            {
                                                
/* redirect to the previous page */
                                                
window.location ipb.comments.data['findLastComment'] ? ipb.comments.data['findLastComment'] : 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 */
                                        
Effect.Fade'comment_id_' ipb.comments.commentId, { 'duration'0.6 } );
                                    }
                                }
                            }
                        );
    },
    
    
/**
     * Show a pop-up for hide
     */
    
hidePop: function(eelem)
    {
        
Event.stop(e);
        
        var 
commentId elem.up('.ipsComment').readAttribute('data-commentid');
        if( !
commentId ){ return; }
        
        
/* Create the pop-up */
        
var popid   'pop__hide_popup_' commentId;
        var 
content ipb.templates['comment_hide'].evaluate( { 'commentId'commentIdurlelem.href } );
        
        
ipb.comments.deletePopUps = new ipb.Popuppopid, {  type'balloon',
                                                             
initialcontent,
                                                             
stemtrue,
                                                             
hideAtStartfalse,
                                                             
attach: { target: $('hide_comment_' commentId ), position'auto''event''click' },
                                                             
w'550px' } );
        
        $(
'hidePop_reason').defaultizeipb.lang['post_hide_reason_default'] );
        
        
/* store for use later */
        
ipb.comments.commentId commentId;
    },
    
    
/**
     * Show quick edit
    */
    
editShow: function(eelem)
    {
        if( 
DISABLE_AJAX )
        {
            return 
false;
        }
        
        
// If user is holding ctrl or command, just submit since they
        // want to open a new tab (requested by Luke)
        
if( e.ctrlKey == true || e.metaKey == true || e.keyCode == 91 )
        {
            return 
false;
        }
        
        
Event.stop(e);
        var 
edit = [];
        
        
edit['button'] = elem;
        if( !
edit['button'] ){ return; }
        
        
// Prevents loading the editor twice
        
if( edit['button'].readAttribute('_editing') == '1' )
        {
            return 
false;
        }        
        
        
edit['pid'] = edit['button'].id.replace('edit_comment_''');
        
edit['post'] = $( 'comment_id_' edit['pid'] ).down('.comment_content');
        
        
// Find post content
        
ipb.comments.commentCacheedit['pid'] ] = edit['post'].innerHTML;

        
url ipb.comments.data['ajaxShowEditUrl'] ? ipb.comments.data['ajaxShowEditUrl'] : ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=showEdit&parentId=' +ipb.comments.parentId '&fromApp=' ipb.comments.data['fromApp'];
        
        if ( 
Prototype.Browser.IE7 )
        {
            
window.location '#entry' edit['pid'];
        }
        else
        {
            new 
Effect.ScrollToedit['post'], { offset: -100 } );
        }
        
Debug.writeurl );
        
// DO TEH AJAX LOL
        
new Ajax.Request(     url
                            {
                                
method'post',
                                
parameters: {
                                    
md5check:     ipb.vars['secure_hash'],
                                    
comment_id:    edit['pid']
                                },
                                
onSuccess: function(t)
                                {
                                    if( 
t.responseText == 'nopermission' )
                                    {
                                        
alert(ipb.lang['no_permission']);
                                        return;
                                    }
                                    if( 
t.responseText == 'error' || t.responseText.match( /^Error / ) )
                                    {
                                        
alert(ipb.lang['no_permission']);
                                        return;
                                    }
                                    
                                    
// Put it in
                                    
edit['button'].writeAttribute('_editing''1');
                                    
                                    
edit['post'].updatet.responseText );
                                    
                                    
edit['pid'] = 'e' edit['pid'];

                                    
// Set up events
                                    
if( $('edit_save_' edit['pid'] ) ){
                                        $(
'edit_save_' edit['pid'] ).observe('click'ipb.comments.editSave );
                                    }
                        
                                    if( $(
'edit_cancel_' edit['pid'] ) ){
                                        $(
'edit_cancel_' edit['pid'] ).observe('click'ipb.comments.editCancel );
                                    }
                                }
                            }
                        );
        
        
Debug.writeurl );
    },
    
    
/**
     * Saves the contents of quick edit
     */
    
editSave: function(e)
    {
        
Event.stop(e);
        var 
elem Event.element(e);
        var 
postid elem.id.replace('edit_save_e''');
        if( !
postid ){ return; }

        var 
Post ipb.textEditor.getEditor('edit-' postid).getText();
        
        if( 
Post.blank() )
        {
            
alertipb.lang['post_empty'] );
            return;
        }
        
        var 
url ipb.comments.data['ajaxSaveEditUrl'] ? ipb.comments.data['ajaxSaveEditUrl'] : ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=saveEdit&parentId=' ipb.comments.parentId '&fromApp=' ipb.comments.data['fromApp'];
        
        new 
Ajax.Request(    url,
                            {
                                
method'post',
                                
evalJSON'force',
                                
encodingipb.vars['charset'],
                                
parameters: {
                                    
md5check:             ipb.vars['secure_hash'],
                                    
Post:                 Post.encodeParam(),
                                    
comment_id:            postid
                                
},
                                
onSuccess: function(t)
                                {
                                    if( 
t.responseJSON['error'] )
                                    {
                                        if( $(
'error_msg_e' postid) )
                                        {
                                            $(
'error_msg_e' postid).updatet.responseJSON['error'] );
                                            new 
Effect.BlindDown( $('error_msg_e' postid), { duration0.4 } );
                                        }
                                        else
                                        {
                                            
alertt.responseJSON['error'] );
                                        }
                                        
                                        return 
false;
                                    }
                                    else
                                    {
                                        
                                        $(
'edit_comment_' postid).writeAttribute('_editing''0');
                                        
                                        $( 
'comment_id_' postid ).down('.comment_content').updatet.responseJSON['successString'] );
                                        
                                        if ( 
Prototype.Browser.IE7 )
                                        {
                                            
window.location '#entry' edit['pid'];
                                        }
                                        else
                                        {
                                            new 
Effect.ScrollTo( $( 'comment_id_' postid ).down('.comment_content'), { offset: -50 } );
                                        }
                                        
                                        
ipb.textEditor.getEditor'edit-' postid ).remove();

                                        
prettyPrint();
                                    }
                                }
                            }
                        );
    },
    
    
/**
     * Cancel the quick edit
     * 
     * @var        {event}        e        The event
     */
    
editCancel: function(e)
    {
        
Event.stop(e);
        var 
elem Event.element(e);
        var 
postid elem.id.replace('edit_cancel_e''');
        if( !
postid ){ return; }
        
        if( 
ipb.comments.commentCachepostid ] ){
            $( 
'comment_id_' postid ).down('.comment_content').updateipb.comments.commentCachepostid ] );
            $(
'edit_comment_' postid).writeAttribute('_editing''0');
            
            
ipb.textEditor.getEditor'edit-' postid ).remove();
        }
        
        return;
    },
    
    
/**
     * Saves the contents of comment
    */
    
add: function(e)
    {
        
Event.stop(e);

        var 
content ipb.textEditor.getEditor().getText();
        var 
isRte   ipb.textEditor.getEditor().isRte();
        
        if( 
content.blank() )
        {
            
alertipb.lang['post_empty'] );
            return;
        }
        
        
/* Close editor */
        
ipb.textEditor.getEditor().minimizeOpenedEditor();
        
        
in_use 0;
        
        var 
url ipb.comments.data['ajaxSaveUrl'] ? ipb.comments.data['ajaxSaveUrl'] : ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=add&parentId=' ipb.comments.parentId '&fromApp=' ipb.comments.data['fromApp'];

        new 
Ajax.Request(    url,
                            {
                                
method'post',
                                
encodingipb.vars['charset'],
                                
parameters: {
                                    
md5check:            ipb.vars['secure_hash'],
                                    
Post:                content.encodeParam(),
                                    
comment_name:        $('comment_name') ? $('comment_name').value '',
                                    
isRte:                isRte
                                
},
                                
onSuccess: function(t)
                                {
                                    if ( 
t.responseJSON && t.responseJSON['error'] )
                                    {
                                        if( 
t.responseJSON['error'] == 'comment_requires_approval' )
                                        {
                                            
ipb.global.okDialogueipb.lang['comment_requires_approval'] );
                                        }
                                        else if( 
t.responseJSON['error'] == 'NO_COMMENT' )
                                        {
                                            
ipb.global.errorDialogueipb.lang['post_empty'] );
                                        }
                                        else
                                        {
                                            
ipb.global.errorDialogueipb.lang['no_permission'] );
                                        }
                                    }
                                    else if ( 
t.responseText && t.responseText != 'no_permission' )
                                    {
                                        
/* Are we *NOT* on the last page? */
                                        
if ( ! Object.isUndefinedipb.comments.data ) && ! Object.isUndefinedipb.comments.data['counts'] ) )
                                        {
                                            if ( ( 
ipb.comments.data['counts']['commentTotal'] ) && ( ( ipb.comments.data['counts']['commentTotal'] - ipb.comments.data['counts']['curStart'] ) >= ipb.comments.data['counts']['perPage'] ) )
                                            { 
                                                
/* http redirect */
                                                
window.location ipb.comments.data['findLastComment'] ? ipb.comments.data['findLastComment'] : ipb.vars['base_url'] + 'app=core&module=global&section=comments&do=findLastComment&parentId=' +ipb.comments.parentId '&fromApp=' ipb.comments.data['fromApp'];
                                                
                                                return 
false;
                                            }
                                        }
                                        
                                        
/* Fetch latest ID */
                                        
latestId 0;
                                        
m        t.responseText.match( /<a id='comment_(d+?)'>/ );
                                        
                                        if ( 
&& m[1] )
                                        {
                                            
latestId m[1];
                                        }
                                        
                                        $(
'comment_wrap').insertt.responseText );
                                        
//Debug.write( 'inserted data' );
                                        
ipb.comments.data['counts']['thisPageCount']++;
                                        
                                        
/* animate, exterminate, germinate */
                                        
if ( latestId && $('comment_id_' latestId ) )
                                        {
                                            
/* Add dark BG and fetch RGB value */
                                            
$('comment_id_' latestId ).addClassName'row2' );
                                            var 
startColor = $('comment_id_' latestId ).getStyle'background-color' );
                                            
                                            
/* Add light BG and fetch RGB value */
                                            
$('comment_id_' latestId ).removeClassName('row2').addClassName'row1' );
                                            var 
endColor    = $('comment_id_' latestId ).getStyle'background-color' );
                                            var 
endBorderColor = $('comment_id_' latestId ).getStyle'border-top-color' );
                                            
                                            
/* Remove light BG */
                                            
$('comment_id_' latestId).removeClassName('row1').addClassName('row2');
                                            
                                            $(
'comment_id_' latestId ).hide();
                                            new 
Effect.BlindDown'comment_id_' latestId, { duration1.0queue'front' } );
                                            new 
Effect.Morph'comment_id_' latestId, { 'style''border-top-color:' endBorderColorqueue'end' } );
                                            new 
Effect.Morph'comment_id_' latestId, { 'style''background-color:' endColorqueue'end'afterFinish: function() { $('comment_id_' latestId ).removeClassName('row2').addClassName'row1' ); } } );
                                        }
                                        
                                        
prettyPrint();
                                    }
                                }
                            }
                        );
    },
    
    
/**
     * Show quick edit
    */
    
reply: function(eelem)
    {
        if( 
DISABLE_AJAX )
        {
            return 
false;
        }
        
        
// If user is holding ctrl or command, just submit since they
        // want to open a new tab (requested by Luke)
        
if( e.ctrlKey == true || e.metaKey == true || e.keyCode == 91 )
        {
            return 
false;
        }
        
        
Event.stop(e);
        var 
edit = [];
        
Debug.write("Here");
        
        if ( ! 
elem ){ return; }
        
        
commentId elem.id.replace('reply_comment_''');
        
        
url ipb.comments.data['ajaxFetchReplyUrl'] ? ipb.comments.data['ajaxFetchReplyUrl'] : ipb.vars['base_url'] + 'app=core&module=ajax&section=comments&do=fetchReply&parentId=' +ipb.comments.parentId '&fromApp=' ipb.comments.data['fromApp'];
        
        
Effect.ScrollTo( $('fast_reply'), { offset: -100 } );
        
        
Debug.writeurl );
        
// DO TEH AJAX LOL
        
new Ajax.Request(     url
                            {
                                
method'post',
                                
parameters: {
                                    
md5check:     ipb.vars['secure_hash'],
                                    
comment_id:    commentId
                                
},
                                
onSuccess: function(t)
                                {
                                    if( 
t.responseText == 'nopermission' )
                                    {
                                        
alert(ipb.lang['no_permission']);
                                        return;
                                    }
                                    if( 
t.responseText == 'error' )
                                    {
                                        
alert(ipb.lang['action_failed']);
                                        return;
                                    }
                                    
                                    
ipb.textEditor.getEditor('commentFastReply').insertt.responseText );
                                }
                            }
                        );
    },
    
    
/**
     * Show the comment link
     */
    
showLinkToComment: function(eelem)
    {    
        
_t promptipb.lang['copy_topic_link'], $( elem ).readAttribute('href') );
        
Event.stop(e);
    },
    
    
/**
     * Toggles the multimod buttons in posts
     * 
     * @param    {event}        e        The event
     * @param    {element}    elem    The element that fired
    */
    
toggleMultiquote: function(eelem)
    {
        
Event.stop(e);
        
        
// Get list of already quoted posts
        
try {
            
quoted ipb.Cookie.get('gal_pids').split(',').compact();
        } catch(
err){
            
quoted $A();
        }
        
        
id elem.id.replace('multiq_''');
        
        
// Hokay, are we selecting/deselecting?
        
if( elem.hasClassName('selected') )
        {
            
elem.removeClassName('selected');
            
quoted quoted.uniq().withoutid ).join(',');
        }
        else
        {
            
elem.addClassName('selected');
            
quoted.pushid );
            
quoted quoted.uniq().join(',');
        }
        
        
// Save cookie
        
ipb.Cookie.set('gal_pids'quoted0);
    },
    
    
/**
     * Check the files we've selected
     */
    
preCheckComments: function()
    {
        if( $(
'selectedgcids') )
        {
            var 
topics $F('selectedgcids').split(',');
        }
        
        var 
checkboxesOnPage    0;
        var 
checkedOnPage        0;

        if( 
topics )
        {
            
topics.each( function(check){
                if( 
check != '' )
                {
                    if( $(
'pid_' check ) )
                    {
                        
checkedOnPage++;
                        $(
'pid_' check ).checked true;
                    }
                    
                    
ipb.comments.totalChecked++;
                }
            });
        }
        
        $$(
'.comment_mod').each( function(check){
            
checkboxesOnPage++;
        } );
        
        if( $(
'comments_all') )
        {
            if( 
checkedOnPage == checkboxesOnPage )
            {
                $(
'comments_all').checked true;
            }
        }
        
        
ipb.comments.updateModButton();
    },
    
    
/**
     * Confirm they want to delete stuff
     * 
     * @var     {event}        e    The event
    */
    
checkComment: function(eelem)
    {
        
remove = new Array();
        
check elem;
                
        var 
checkboxesOnPage    0;
        var 
checkedOnPage        0;
        
        if( 
check.checked == true )
        {
            
Debug.write("Checked");
            
ipb.comments.totalChecked++;
                        
            switch ( 
check.readAttribute("data-status") )
            {
                case 
'0':
                    
ipb.comments.modOptionsUnapproved += 1;
                    break;
                    
                case 
'-1':
                    
ipb.comments.modOptionsHidden += 1;
                    break;
                    
                default:
                    
ipb.comments.modOptionsUnhidden += 1;
                    break;
            }
        }
        else
        {
            
remove.pushcheck.id.replace('pid_''') );
            
ipb.comments.totalChecked--;
            
            switch ( 
check.readAttribute("data-status") )
            {
                case 
'0':
                    
ipb.comments.modOptionsUnapproved -= 1;
                    break;
                    
                case 
'-1':
                    
ipb.comments.modOptionsHidden -= 1;
                    break;
                    
                default:
                    
ipb.comments.modOptionsUnhidden -= 1;
                    break;
            }
        }
        
        $$(
'.comment_mod').each( function(check){
            
checkboxesOnPage++;
            
            if( $(
check).checked == true )
            {
                
checkedOnPage++;
            }
        } );
        
        if( $(
'comments_all') )
        {
            if( 
checkedOnPage == checkboxesOnPage )
            {
                $(
'comments_all').checked true;
            }
            else
            {
                $(
'comments_all' ).checked false;
            }
        }
        
        
ipb.comments.moderate();
    },
    
    
/**
     * Update the moderation button
     */
    
updateModButton: function( )
    {
        if( $(
'mod_submit') )
        {
            if( 
ipb.comments.totalChecked == ){
                $(
'mod_submit').disabled true;
            } else {
                $(
'mod_submit').disabled false;
            }
        
            $(
'mod_submit').value ipb.lang['with_selected'].replace('{num}'ipb.comments.totalChecked);
        }
    },
    
    
/**
     * Sets the supplied post to hidden
     * 
     * @var        {int}    id        The ID of the post to hide
    */
    
setCommentHidden: function(id)
    {
        if( $( 
'comment_id_' id ).select('.post_wrap')[0] )
        {
            $( 
'comment_id_' id ).select('.post_wrap')[0].hide();
            
            if( $(
'unhide_post_' id ) )
            {
                $(
'unhide_post_' id).observe('click'ipb.comments.showHiddenComment );
            }
        }
    },
    
    
/**
     * Unhides the supplied post
     * 
     * @var        {event}        e    The link event
    */
    
showHiddenComment: function(e)
    {
        
link Event.findElement(e'a');
        
id link.id.replace('unhide_post_''');
        
        if( $(
'comment_id_' id ).select('.post_wrap')[0] )
        {
            
elem = $('comment_id_' id ).select('.post_wrap')[0];
            new 
Effect.Parallel( [
                new 
Effect.BlindDownelem ),
                new 
Effect.Appearelem )
            ], { 
duration0.5 } );
        }
        
        if( $(
'comment_id_' id ).select('.post_ignore')[0] )
        {
            
elem = $('comment_id_' id ).select('.post_ignore')[0];
            
/*new Effect.BlindUp( elem, {duration: 0.2} );*/
            
elem.hide();
        }
        
        
Event.stop(e);
    }
};

ipb.comments.init();
?>
Онлайн: 1
Реклама