Вход Регистрация
Файл: public/js/ips.topic.js
Строк: 1077
<?php
/************************************************/
/* IPB3 Javascript                                */
/* -------------------------------------------- */
/* ips.topic.js - Topic view code                */
/* (c) IPS, Inc 2008                            */
/* -------------------------------------------- */
/* Author: Rikki Tissier                        */
/************************************************/

var _topic window.IPBoard;

_topic.prototype.topic = {
    
totalChecked0,
    
inSection'',
    
postcache: [],
    
poll: [],
    
pollPopups: [],
    
deletePerms: {},
    
deleteUrls: {},
    
deletePopUps: [],
    
hidePopUps: [],
    
restorePopUps: [],
    
counts: {},
    
timers: {},
    
polling: { count},
    
mqBoxShowingfalse,
    
fastReplyId'',
    
isPostingfalse,
    
modOptionsUnapproved0,
    
modOptionsHidden0,
    
modOptionsUnhidden0,
    
    
init: function()
    {
        
Debug.write("Initializing ips.topic.js");
        
        
document.observe("dom:loaded", function(){
        
            if( 
ipb.topic.inSection == 'topicview' )
            {
                if( $(
'show_filters') )
                {
                    $(
'show_filters').observe('click'ipb.topic.toggleFilters );
                    $(
'filter_form').hide();
                }

                
ipb.topic.preCheckPosts();
                
                
// Set up delegates
                
ipb.delegate.register('.multiquote'ipb.topic.toggleMultimod);
                
ipb.delegate.register('._ips_trigger_quote'ipb.topic.ajaxQuote);
                
                
ipb.delegate.register('.edit_post'ipb.topic.ajaxEditShow);
                
ipb.delegate.register('.hide_post'ipb.topic.hidePopUp);
                
ipb.delegate.register('.delete_post'ipb.topic.deletePopUp);
                
ipb.delegate.register('.toggle_post'ipb.topic.ajaxTogglePostApprove);
                
ipb.delegate.register('.sd_content'ipb.topic.sDeletePostShow);
                
ipb.delegate.register('.sd_remove'ipb.topic.confirmSingleDelete);

                
ipb.delegate.register('input.post_mod'ipb.topic.checkPost);
                
                
ipb.delegate.register('.modlink_09'ipb.topic.topicDeletePopUp );
                
                if ( $(
'submit_post') ){
                    $(
'submit_post').observe"click"ipb.topic.ajaxFastReply );
                }
                
                
// Check for existing multi-quoted posts
                
try {
                    
quoted ipb.Cookie.get('mqtids').split(',').compact().without('').size();
                } catch(
err){
                    
quoted 0;
                }

                
// Show button if we have quoted posts
                
if( quoted )
                {
                    $(
'multiQuoteInsert').show();
                    
ipb.topic.mqBoxShowing    true;
                    
                    $(
'mqbutton').updateipb.lang['mq_reply_swap'].replace( /#{num}/, quoted ) );
                
}
                
                
// Set up MQ handler
                
if( $('multiQuoteInsert') ){
                    $(
'mqbutton').observe'click'ipb.topic.insertQuotedPosts );
                    
                    if( $(
'multiQuoteClear') ){
                        $(
'multiQuoteClear').on('click'ipb.topic.clearMultiQuote);
                    }
                }
            
            }
            else if( 
ipb.topic.inSection == 'searchview' )
            {
                
ipb.delegate.register('input.post_mod'ipb.topic.checkPost);
                
ipb.delegate.register('.sd_content'ipb.topic.sDeletePostShow);
            }
        });
        
        
/* Do this regardless */
        
ipb.delegate.register('.hide_signature'ipb.topic.signatureCloseClick);
    },
    
    
/**
     * Delete a topic
     */
    
deleteTopicDialog: function( elem)
    {
        if ( 
confirmipb.lang['delete_confirm'] ) )
        {
            
window.location ipb.vars['base_url'] + "app=forums&module=moderate&section=moderate&do=deleteArchivedTopic&t=" ipb.topic.topic_id "&f=" ipb.topic.forum_id "&auth_key=" ipb.vars['secure_hash'];
        }
    },
    
    
/**
     * Flag an item for being restored
     */
    
restoreTopicDialogGo: function(eleme)
    {
        
Event.stop(e);
        
        
window.location ipb.vars['base_url'] + "app=forums&module=moderate&section=moderate&do=unArchiveTopic&t=" ipb.topic.topic_id "&f=" ipb.topic.forum_id "&auth_key=" ipb.vars['secure_hash'];
    },
    
    
/**
     * Show a pop-up for topic restore dialog
     */
    
restoreTopicDialog: function(eleme)
    {
        
Event.stop(e);
        
        
// Get popup contents
        
var url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;topic_id=" ipb.topic.topic_id "&secure_key=" ipb.vars['secure_hash'] + "&amp;template_group=topic&amp;template_bit=restoreTopicDialog&amp;lang_module=topic&amp;lang_app=forums";
        
        new 
Ajax.Request(    url.replace(/&amp;/g'&'),
                            {
                                
method'post',
                                
evalJSON'force',
                                
onSuccess: function(t)
                                {
                                    
/* Create the pop-up */
                                    
var popid   'pop__restore_popup_' ipb.topic.topic_id;
                                    var 
content = new Templatet.responseJSON['html'] ).evaluate( {  } );
        
                                    
ipb.topic.restorePopUps = new ipb.Popuppopid, { type'pane',
                                                                                      
modaltrue,
                                                                                      
initialcontent,
                                                                                      
hideAtStartfalse,
                                                                                      
w'550px' });
                                }
                            }
                        );        
    },
    
    
/* ------------------------------ */
    /**
     * Event handler for signature closing
     * 
     * @param    {event}        e        The event
    */
    
signatureCloseClick: function( eelem )
    {
        
postId = $(elem).up('.post_block').id.replace( /post_id_/, '' );
        
Debug.writepostId );
        if ( ! 
postId )
        {
            return;
        }
        
        
Event.stop(e);
        
        $(
elem).removeClassName('hide_signature').addClassName('sigIconStay');
    
        $(
elem).identify();
        
        
/* Create pop-up wrapper */
        
$(elem).addClassName('ipbmenu');
        
        
url ipb.vars['base_url'] + "app=forums&module=ajax&section=topics&do=sigCloseMenu&secure_key=" ipb.vars['secure_hash'] + "&pid=" postId;
        
        if ( 
ipb.topic.inSection == 'messenger' )
        {
            
url ipb.vars['base_url'] + "app=members&module=ajax&section=messenger&do=sigCloseMenu&secure_key=" ipb.vars['secure_hash'] + "&msgid=" postId;
        }
        
        new 
Ajax.Requesturl,
                            {
                                
method'post',
                                
evalJSON'force',
                                
onSuccess: function(t)
                                {
                                    
/*
                                     * Get an error?
                                     */
                                    
if( t.responseJSON && t.responseJSON['error'] )
                                    {
                                        
alertt.responseJSON['error'] );
                                    }
                                    else
                                    {
                                        var 
menuId 'sigClose_' postId '_menucontent';
        
                                        $(
'ipboard_body').insert( new Element'div', { 'id'menuId } ) );
        
                                        $(
menuId).update"<div class='ipsPad ipsForm_center'><img src='" ipb.vars['loading_img'] + "' /></div>" );
        
                                        var 
_newMenu = new ipb.Menu( $(elem), $(menuId), {}, { afterOpen: function(e) { Debug.write('adding'); $(elem).removeClassName('hide_signature').addClassName('sigIconStay'); } } );
                                        
_newMenu.doOpen();    
        
                                        
ipb.topic.deletePopUps['sig_' postId ] = true;
                                        $(
menuId).updatet.responseText );
                                        
                                        
/* Register call back */
                                        
ipb.menus.registerCloseCallBackipb.topic.signatureCloseCleanUp );
                                    }
                                }
                            }
                        );
        
    },
    
    
signatureCloseCleanUp: function()
    {
        $$(
'.sigIconStay').invoke('removeClassName''sigIconStay').invoke('addClassName''hide_signature');
    },
    
    
/**
     * Registers a click for ignore users sig
     */
    
ignoreUsersSig: function( elem)
    { 
        
memberId = $(elem).readAttribute('data-id');
        
        
ipb.menus.closeAll(e);
        
ipb.topic.signatureCloseCleanUp();
        
        new 
Ajax.Request(    ipb.vars['base_url'] + "app=forums&module=ajax&section=topics&do=ignoreSig&secure_key=" ipb.vars['secure_hash'] + "&memberId=" memberId,
                            {
                                
method'post',
                                
evalJSON'force',
                                
onSuccess: function(t)
                                {
                                    
/*
                                     * Get an error?
                                     */
                                    
if ( t.responseJSON && t.responseJSON['status'] == 'ok' )
                                    {
                                        $$(
".signature").each( function( element )
                                        {
                                            try {
                                                
_memberId = $(element).readAttribute('data-memberid');
                                                
                                                if ( 
_memberId && ( memberId == 'all' || _memberId == memberId ) )
                                                {
                                                    new 
Effect.BlindUp( $(element), { duration1.0 } );
                                                }
                                            }
                                            catch(
e) { };
                                        } );

                                    }
                                }
                            }
                        );
                        
    },
    
    
/* ------------------------------ */
    /**
     * Event handler for moderating posts
     * 
     * @param    {event}        e        The event
    */
    
submitPostModeration: function(e)
    {
        if( 
$F('tact') == 'delete' ){
            if( !
confirm(ipb.lang['delete_confirm']) ){
                
Event.stop(e);
            }
        }
    },
    
    
/* ------------------------------ */
    /**
     * Event handler for moderating the topic
     * 
     * @param    {event}        e        The event
    */
    
submitTopicModeration: function(e)
    {
        if( 
$F('topic_moderation') == '03' ){ // Delete code
            
if( !confirm(ipb.lang['delete_confirm']) ){
                
Event.stop(e);
            }
        }
    },
    
    
/**
     * Show a pop-up for soft delete
     */
    
hidePopUp: function(eelem)
    {
        var 
postid elem.up().id.replace( /hide_post_/, '' );
        if( !
postid ){ return; }
        
        
/* First off, fix URLs */
        
var _url_soft   ipb.topic.deleteUrls['softDelete'].evaluate( { 'pid'postid } ).replace(/&amp;/g'&')  + '&nr=1';
        var 
_permaShow  '';
        
Event.stop(e);
        
        
// Get popup contents
        
var url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;secure_key=" ipb.vars['secure_hash'] + "&amp;template_group=topic&amp;template_bit=deletePost&amp;lang_module=topic&amp;lang_app=forums";
        
        new 
Ajax.Request(    url.replace(/&amp;/g'&'),
                            {
                                
method'post',
                                
evalJSON'force',
                                
onSuccess: function(t)
                                {
                                    
/* Create the pop-up */
                                    
var popid   'pop__hide_popup_' postid;
                                    var 
content = new Templatet.responseJSON['html'] ).evaluate( { removeUrl_url_softpermaDelete_permaShow } );
        
                                    
ipb.topic.hidePopUps = new ipb.Popuppopid, { type'balloon',
                                                                                    
stemtrue,
                                                                                     
modalfalse,
                                                                                     
initialcontent,
                                                                                     
hideAtStartfalse,
                                                                                     
w'550px',
                                                                                     
attach: { targetelemposition'auto''event''click' } });
                                }
                            }
                        );        
    },
    
    
/**
     * Show a pop-up for hard delete
     */
    
deletePopUp: function(eelem)
    {
        var 
postid elem.up().id.replace( /del_post_/, '' );
        if( !
postid ){ return; }
        
        
/* First off, fix URLs */
        
var _url_delete ipb.topic.deleteUrls['hardDelete'].evaluate( { 'pid'postid } ).replace(/&amp;/g'&')  + '&nr=1';
        var 
_permaShow  '';
        
Event.stop(e);
        
        
// Get popup contents
        
var url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;secure_key=" ipb.vars['secure_hash'] + "&amp;template_group=topic&amp;template_bit=doDeletePost&amp;lang_module=topic&amp;lang_app=forums";
        
        new 
Ajax.Request(    url.replace(/&amp;/g'&'),
                            {
                                
method'post',
                                
evalJSON'force',
                                
onSuccess: function(t)
                                {
                                    
/* Create the pop-up */
                                    
var popid   'pop__delete_popup_' postid;
                                    var 
content = new Templatet.responseJSON['html'] ).evaluate( { permaDelete_permaShowpermaUrl_url_delete } );
        
                                    
ipb.topic.deletePopUps = new ipb.Popuppopid, { type'balloon',
                                                                                    
stemtrue,
                                                                                     
modalfalse,
                                                                                     
initialcontent,
                                                                                     
hideAtStartfalse,
                                                                                     
w'350px',
                                                                                     
attach: { targetelemposition'auto''event''click' } });
                                }
                            }
                        );        
    },

    
/**
     * Show a pop-up for topic delete
     */
    
topicDeletePopUp: function(eelem)
    {    
        
/* First off, fix URLs */
        
var _url_delete '';
        var 
_permaShow  '';
        
Event.stop(e);
        
        
// Get popup contents
        
var url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;secure_key=" ipb.vars['secure_hash'] + "&amp;template_group=forum&amp;template_bit=deleteTopic&amp;lang_module=forums&amp;lang_app=forums";
        
        new 
Ajax.Request(    url.replace(/&amp;/g'&'),
                            {
                                
method'post',
                                
evalJSON'force',
                                
onSuccess: function(t)
                                {
                                    
/* Create the pop-up */
                                    
var popid   'pop__topic_delete_popup';
                                    var 
content = new Templatet.responseJSON['html'] ).evaluate( { deleteUrlelem.href } );
        
                                    new 
ipb.Popuppopid, { type'pane',
                                                                                    
stemtrue,
                                                                                     
modaltrue,
                                                                                     
initialcontent,
                                                                                     
hideAtStartfalse,
                                                                                     
w'350px' } );
                                }
                            }
                        );        
    },
    
    
/**
     * Show's the content of soft deleted post
     */
    
sDeletePostShow: function(eelem)
    {
        
Event.stop(e);

        var 
postid elem.id.replace( /seeContent_/, '' );
        if( !
postid ){ return; }
        
        if ( ! $(
'postsDelete_' postid )._showing )
        {
            $(
'postsDelete_' postid ).hide();
            $(
'postsDeleteShow_' postid).show();
            $(
'postsDelete_' postid )._showing 1;
        }
        else
        {
            $(
'postsDelete_' postid ).show();
            $(
'postsDeleteShow_' postid).hide();
            $(
'postsDelete_' postid )._showing 0;
        }
    },

    
    
/**
    * MATT
    * Toggle post approval thingy majigy
    */
    
ajaxTogglePostApprove: function(eelem)
    {
        
Event.stop(e);
        
        var 
postid elem.id.replace( /toggle(text)?_post_/, '' );
        if( !
postid ){ return; }
        
        var 
toApprove = ( $('post_id_' postid).hasClassName'moderated' ) ) ? 0;
        
        var 
url ipb.vars['base_url'] + 'app=forums&module=ajax&section=topics&do=postApproveToggle&p=' postid '&t=' ipb.topic.topic_id '&f=' ipb.topic.forum_id '&approve=' toApprove;
        
        new 
Ajax.Request(    url,
                            {
                                
method'post',
                                
evalJSON'force',
                                
parameters: {
                                    
md5check:     ipb.vars['secure_hash']
                                },
                                
onSuccess: function(t)
                                {
                                    if( 
t.responseJSON['error'] )
                                    {
                                        switch( 
t.responseJSON['error'] )
                                        {
                                            case 
'notopic':
                                                
alert(ipb.lang['no_permission']);
                                            break;
                                            case 
'nopermission':
                                                
alert(ipb.lang['no_permission']);
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        $(
'post_id_' postid).removeClassName'moderated' );
                                        $( 
'postControlsUnapproved_' postid ).hide();
                                        $( 
'postControlsNormal_' postid ).show();
                                        
                                        $( 
'checkbox_' postid ).writeAttribute'data-status''0' );
                                        
                                    }
                                }
                            }
                        );
    },
    
/* END MATT */
    
    /* ------------------------------ */
    /**
     * Shows the quick ajax edit box
     * 
     * @var        {event}        e        The event
    */
    
ajaxEditShow: function(eelem)
    {    
        if( 
DISABLE_AJAX || ipb.vars['is_touch'] )
        {
            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_post_''');
        
edit['tid'] = ipb.topic.topic_id;
        
edit['fid'] = ipb.topic.forum_id;
        
edit['post'] = $( 'post_id_' edit['pid'] ).down('.post');
        
        
// Find post content
        
ipb.topic.postcacheedit['pid'] ] = edit['post'].innerHTML;

        
url ipb.vars['base_url'] + 'app=forums&module=ajax&section=topics&do=editBoxShow&p=' edit['pid'] +'&t=' edit['tid'] +'&f=' edit['fid'];
        
        if ( 
Prototype.Browser.IE7 )
        {
            
window.location '#entry' edit['pid'];
        }
        else
        {
            new 
Effect.ScrollToedit['post'], { offset: -50 } );
        }
        
        
// DO TEH AJAX LOL
        
new Ajax.Request(     url
                            {
                                
method'post',
                                
parameters: {
                                    
md5check:     ipb.vars['secure_hash']
                                },
                                
onSuccess: function(t)
                                {
                                    if( 
t.responseText == 'nopermission' || t.responseText == 'NO_POST_FORUM' || t.responseText == 'NO_EDIT_PERMS' || t.responseText == 'NO_POSTING_PPD' )
                                    {
                                        
alert(ipb.lang['no_permission']);
                                        return;
                                    }
                                    if( 
t.responseText == 'error' )
                                    {
                                        
alert(ipb.lang['action_failed']);
                                        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.topic.ajaxEditSave );
                                    }
                                    if( $(
'edit_switch_' edit['pid'] ) ){
                                        $(
'edit_switch_' edit['pid'] ).observe('click'ipb.topic.ajaxEditSwitch );
                                    }
                                    if( $(
'edit_cancel_' edit['pid'] ) ){
                                        $(
'edit_cancel_' edit['pid'] ).observe('click'ipb.topic.ajaxEditCancel );
                                    }
                                }
                            }
                        )
                                
        
Debug.writeurl );
    },
    
    
/* ------------------------------ */
    /**
     * Switches from quick edit to full editor
    */
    
ajaxEditSwitch: function(e)
    {
        
// Because all posts on a topic page are wrapped in a form tag for moderation
        // purposes, to switch editor we have to perform a bit of trickery by building
        // a new form at the bottom of the page, filling it with the right values,
        // and submitting it.
        
        
Event.stop(e);
        var 
elem Event.element(e);
        var 
postid elem.id.replace('edit_switch_e''');
        if( !
postid ){ return; }        
        var 
url ipb.vars['base_url'] + 'app=forums&module=post&section=post&do=edit_post&f=' ipb.topic.forum_id '&t=' ipb.topic.topic_id '&p=' postid '&st=' ipb.topic.start_id '&_from=quickedit';
        
        var 
Post ipb.textEditor.getEditor'edit-' postid ).getText();

        
form = new Element('form', { actionurlmethod'post' } );
        
textarea = new Element('textarea', { name'Post' } );
        
reason     = new Element('input', { name'post_edit_reason' } );
        
md5check = new Element('input', { type'hidden'name'md5check'valueipb.vars['secure_hash'] } );
        
        
// Opera needs "value", but don't replace the & or it will freak out at you
        
if( Prototype.Browser.Opera ){
            
textarea.value Post;//.replace( /&/g, '&amp;' );
        
} else {
            
textarea.value Post;//.replace( /&/g, '&amp;' );
        
}
        
        
reason.value = ( $('post_edit_reason') ) ? $('post_edit_reason').value '';

        
form.insertmd5check ).inserttextarea ).insertreason ).hide();
        $$(
'body')[0].insertform );
        
        
form.submit();
    },
    
    
/* ------------------------------ */
    /**
     * Ajax fast reply baby!
    */
    
ajaxFastReply: function(e)
    {
        if ( 
DISABLE_AJAX )
        {
            return 
false;
        }
        
        
/* Guest? Just redirect to preview form */
        
if ( ! ipb.vars['member_id'] )
        {
            return 
false;
        }
        
        
// If user is holding ctrl or command, just submit since they
        
if( e.ctrlKey == true || e.metaKey == true || e.keyCode == 91 )
        {
            return 
false;
        }
        
        
Event.stop(e);
                
        
/* Fetch post contents */
        
var Post  ipb.textEditor.getEditoripb.topic.fastReplyId ).getText();
        var 
isRte ipb.textEditor.getEditoripb.topic.fastReplyId ).isRte();
        
        
/* Quick check */
        
if( Post.blank() )
        {
            
alertipb.lang['post_empty'] );
            return 
false;
        }
        
        
// Lock the post buttons
        
var toggleEditorButtons = function( show ){
            if( $(
'fast_reply_controls') ){
                if( 
show ){
                    $(
'fast_reply_controls').select("#fast_reply_msg").invoke('remove');
                    $(
'fast_reply_controls').select("input").invoke("show");
                } else {
                    $(
'fast_reply_controls').select("input").invoke("hide");
                    $(
'fast_reply_controls').insert( new Element('span', { id'fast_reply_msg' }).updateipb.lang['saving_post'] ).addClassName('desc') );
                }
            }            
        };
        
        
toggleEditorButtonsfalse );
        
        
ipb.topic.isPosting true;
        
        var 
url ipb.vars['base_url'] + 'app=forums&module=ajax&section=topics&do=reply&t=' ipb.topic.topic_id '&f=' ipb.topic.forum_id '&pid=' ipb.topic.topPid;
        
Debug.write(url);
        new 
Ajax.Request(    url,
                            {
                                
method'post',
                                
encodingipb.vars['charset'],
                                
evalJSON'force',
                                
parameters: {
                                    
md5check:     ipb.vars['secure_hash'],
                                    
Post:         Post.encodeParam(),
                                    
isRte:         isRte
                                
},
                                
onSuccess: function(t)
                                { 
                                    
toggleEditorButtonstrue );
                                    
                                    if (  
t.responseJSON && t.responseJSON['error'] ){
                                        
ipb.global.errorDialoguet.responseJSON['error'] );
                                        return 
false;
                                    }
                                    else if( 
t.responseJSON && t.responseJSON['success'] )
                                    {
                                        if( 
t.responseJSON['message'] )
                                        {
                                            
ipb.global.okDialoguet.responseJSON['message'] );
                                        }
                                        
                                        if( 
t.responseJSON['post'] && t.responseJSON['postid'] )
                                        {
                                            
/* Are we *NOT* on the last page? */
                                            
if ( ! Object.isUndefinedipb.topic.counts ) && ! Object.isUndefinedipb.topic.counts['perPage'] ) )
                                            {
                                                if ( ( 
ipb.topic.counts['postTotal'] ) && ( ( ipb.topic.counts['postTotal'] - ipb.topic.counts['curStart'] ) >= ipb.topic.counts['perPage'] ) )
                                                { 
                                                    
/* http redirect */
                                                    
window.location ipb.vars['base_url'] + 'showtopic=' ipb.topic.topic_id '&view=getlastpost';
                                                    
                                                    return 
false;
                                                }
                                            }
                                            
                                            
/* Should find a neater solution to this dumbo */
                                            
ipb.topic.topPid t.responseJSON['postid'];
                                            
                                            if ( $( 
'newContent-' ipb.topic.topPid ) )
                                            {
                                                $( 
'newContent-' ipb.topic.topPid ).updatet.responseJSON['post'] );
                                            }
                                            else if( $( 
'post_id_' ipb.topic.topPid ) )
                                            {
                                                $( 
'post_id_' ipb.topic.topPid ).replacet.responseJSON['post'] );
                                            }
                                            else
                                            {
                                                $(
'ips_Posts').insert( new Element('div', { id'newContent-' ipb.topic.topPid } ).insertt.responseJSON['post'] ) );
                                            }
                                            
                                            if ( $( 
'newContent-' ipb.topic.topPid ) )
                                            {
                                                $( 
'newContent-' ipb.topic.topPid).hide();
                                                new 
Effect.BlindDown'newContent-' ipb.topic.topPid, { duration0.5queue'front' } );

                                                
prettyPrint();
                                            }
                                        }
                                        
                                        
ipb.topic.isPosting false;
                                        
                                        
ipb.textEditor.getEditoripb.topic.fastReplyId ).minimizeOpenedEditor();                                        
                                        return 
false;
                                    }
                                    else if ( 
t.responseText && t.responseText != 'no_permission' )
                                    {
                                        
/* Are we *NOT* on the last page? */
                                        
if ( ! Object.isUndefinedipb.topic.counts ) && ! Object.isUndefinedipb.topic.counts['perPage'] ) )
                                        {
                                            if ( ( 
ipb.topic.counts['postTotal'] ) && ( ( ipb.topic.counts['postTotal'] - ipb.topic.counts['curStart'] ) >= ipb.topic.counts['perPage'] ) )
                                            { 
                                                
/* http redirect */
                                                
window.location ipb.vars['base_url'] + 'showtopic=' ipb.topic.topic_id '&view=getlastpost';
                                                
                                                return 
false;
                                            }
                                        }
                                        
                                        
/* Should find a neater solution to this dumbo */
                                        
t.responseText.match( /<!--post:(d+?)-->/ );
                                        
                                        if ( 
&& m[1] )
                                        {
                                            
ipb.topic.topPid m[1];
                                        }
                                        else
                                        {
                                            return 
false;
                                        }
                                        
                                        $(
'ips_Posts').insert( new Element('div', { id'newContent-' ipb.topic.topPid } ).insertt.responseText ) );
                                        
                                        if ( $( 
'newContent-' ipb.topic.topPid ) )
                                        {
                                            $( 
'newContent-' ipb.topic.topPid).hide();
                                            new 
Effect.BlindDown'newContent-' ipb.topic.topPid, { duration0.5queue'front' } );
                                            
                                            
/* Close editor */
                                            
ipb.textEditor.getEditoripb.topic.fastReplyId ).minimizeOpenedEditor();
                                    
                                            
prettyPrint();
                                        }
                                        
                                        
ipb.topic.isPosting false;
                                    }
                                }
                            }
                        );
    },
    
    
/* ------------------------------ */
    /**
     * Retrieve quote via AJAX and insert into editor
    */
    
ajaxQuote: function(eelem)
    {
        if ( 
DISABLE_AJAX )
        {
            return 
false;
        }
        
        
// If user is holding ctrl or command, just submit since they
        
if ( e.ctrlKey == true || e.metaKey == true || e.keyCode == 91 )
        {
            return 
false;
        }
        
        
Event.stop(e);
        
        
pid elem.readAttribute('pid');
        
        var 
url ipb.vars['base_url'] + 'app=forums&module=ajax&section=topics&do=quote&t=' ipb.topic.topic_id '&p=' pid '&md5check=' ipb.vars['secure_hash'] + '&isRte=' ipb.textEditor.getEditoripb.topic.fastReplyId ).isRte();
        
Debug.writeurl );
        
        new 
Ajax.Request(    url,
                            {
                                
method'get',
                                
encodingipb.vars['charset'],
                                
onSuccess: function(t)
                                { 
                                    if (  
t.responseJSON && t.responseJSON['error'] )
                                    {
                                        
ipb.global.errorDialoguet.responseJSON['error'] );
                                        
                                        return 
false;
                                    }
                                    else if ( 
t.responseText && t.responseText != 'nopermission' )
                                    {
                                        
editor    ipb.textEditor.getEditoripb.topic.fastReplyId );
                                        
editor.insertt.responseText'always' );
                                    }
                                }
                            }
                        );
    },
    
    
/* ------------------------------ */
    /**
     * Saves the contents of quick edit
    */
    
ajaxEditSave: function(e)
    {
        try {
            
Event.stop(e);
            var 
elem Event.element(e);
            var 
postid elem.id.replace('edit_save_e''');
            if( !
postid ){ alert("No post ID"); return; }

            var 
Post ipb.textEditor.getEditor'edit-' postid ).getText();

            if( 
Post.blank() )
            {
                
alertipb.lang['post_empty'] );
                
//return;
            
}
        
            var 
add_edit    null;
            var 
edit_reason '';
            var 
post_htmlstatus '';
        
            if( $(
'add_edit_' postid ) ){
                
add_edit $F('add_edit_' postid );
            }
        
            if( $(
'post_edit_reason_' postid ) ){
                
edit_reason $F('post_edit_reason_' postid );
            }    
        
            if( $(
'post_htmlstatus_' postid ) ) {
                
post_htmlstatus $F('post_htmlstatus_' postid );
            }

            var 
url ipb.vars['base_url'] + 'app=forums&module=ajax&section=topics&do=editBoxSave&p=' postid '&t=' ipb.topic.topic_id '&f=' ipb.topic.forum_id;
        
            new 
Ajax.Request(    url,
                                {
                                    
method'post',
                                    
evalJSON'force',
                                    
encodingipb.vars['charset'],
                                    
parameters: {
                                        
md5check:             ipb.vars['secure_hash'],
                                        
Post:                 Post.encodeParam(),
                                        
add_edit:            add_edit,
                                        
post_edit_reason:    edit_reason.encodeParam(),
                                        
post_htmlstatus:     post_htmlstatus
                                    
},
                                    
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
                                        {
                                            
// Update post; SKINNOTE: need to fix linked image sizes
                                            // SKINNOTE: also need to reapply "code" javascript
                                            
$('edit_post_' postid).writeAttribute('_editing''0');
                                        
                                            
ipb.textEditor.getEditor'edit-' postid ).remove();
                                        
                                            $(
'post_id_' postid).down('.post').updatet.responseJSON['successString'] );

                                            
prettyPrint();
                                        }
                                    }
                                }
                            );
        } catch(
err) {
            
alerterr );
        }
    },
                                    
        
    
/* ------------------------------ */
    /**
     * Cancel the quick edit
     * 
     * @var        {event}        e        The event
    */
    
ajaxEditCancel: function(e)
    {
        
Event.stop(e);
        var 
elem Event.element(e);
        var 
postid elem.id.replace('edit_cancel_e''');
        if( !
postid ){ return; }
        
        if( 
ipb.topic.postcachepostid ] )
        {
            
ipb.textEditor.getEditor'edit-' postid ).remove();
            
            $(
'post_id_' postid).down('.post').updateipb.topic.postcachepostid ] );
            
ipb.editorspostid ] = null;
            $(
'edit_post_' postid).writeAttribute('_editing''0');            
        }
        
        return;
    },

    
/**
     * Callback for fast reply when typing has commenced
     */
    
isTypingCallBack: function()
    {
        
/* Are we *NOT* on the last page? */
        
if ( ! Object.isUndefinedipb.topic.counts ) && ! Object.isUndefinedipb.topic.counts['perPage'] ) )
        {
            if ( ( 
ipb.topic.counts['postTotal'] ) && ( ( ipb.topic.counts['postTotal'] - ipb.topic.counts['curStart'] ) >= ipb.topic.counts['perPage'] ) )
            { 
                return 
false;
            }
        }
        
        
/* set off the timer */
        
ipb.textEditor.getEditor().timers['interval_hasContent'] = setIntervalipb.topic.pollForRepliesipb.textEditor.IPS_NEW_POST_POLLING );
        
        
/* Starting timer */
        
ipb.topic.timers['_startPolling'] = new Date().getTime();
        
        
Debug.write"Starting timer for reply polling: " ipb.topic.timers['_startPolling'] );
    },
    
    
/**
     * Poll for replies
     */
    
pollForReplies: function()
    {
        var 
timeNow  = new Date().getTime();
        var 
timeDiff = ( timeNow ipb.topic.timers['_startPolling'] ) / 1000;
        
        
Debug.write"I have been polling for : " timeDiff " seconds" );
        
        
/* Race condition! */
        
if ( ipb.topic.isPosting === true )
        {
            return;
        }
        
        
/* Only poll for 1 hour. After that, cancel! */
        
if ( timeDiff 3600 )
        {
            
Debug.write"I have stopped polling. Sorry." );
            
            
clearIntervalipb.textEditor.getEditor().timers['interval_hasContent'] );
        }
        else
        {
            
/* poll away */
            
var url ipb.vars['base_url'] + 'app=forums&module=ajax&section=topics&do=pollForReplies&t=' ipb.topic.topic_id '&pid=' ipb.topic.topPid '&md5check=' ipb.vars['secure_hash'];
            
Debug.writeurl );
            
            new 
Ajax.Request(    url,
                                {
                                    
method'get',
                                    
evalJSON'force',
                                    
encodingipb.vars['charset'],
                                    
hideLoadertrue,
                                    
onSuccess: function(t)
                                    {
                                        if ( 
t.responseJSON )
                                        {
                                            var 
count parseIntt.responseJSON['count'] );
                                            
                                            if ( 
count == ipb.topic.polling.count )
                                            {
                                                
/* Nothing new, return */
                                                
return false;
                                            }
                                            
                                            
ipb.topic.polling.count count;
                                            
                                            if ( 
count )
                                            {
                                                
string = new Templateipb.lang['topic_polling'] ).evaluate( { countcountclick'ipb.topic.insertNewPosts(event)' } );
                                                
ipb.global.showInlineNotificationstring, { 'showClose'true'displayForSeconds'20 } );
                                            }
                                        }
                                    }
                                }
                            );
        }
    },
    
    
/**
     * Insert new posts into the topic
     * 
     */
    
insertNewPosts: function(e)
    { 
        
Event.stop(e);
        
        
/* Reset */
        
ipb.topic.polling.count 0;
        
        
/* poll away */
        
var url ipb.vars['base_url'] + 'app=forums&module=ajax&section=topics&do=getNewPosts&t=' ipb.topic.topic_id '&pid=' ipb.topic.topPid '&md5check=' ipb.vars['secure_hash'];
        
Debug.writeurl );
        
        new 
Ajax.Request(    url,
                            {
                                
method'get',
                                
evalJSON'force',
                                
encodingipb.vars['charset'],
                                
onSuccess: function(t)
                                {
                                    if ( 
t.responseText )
                                    {
                                        
/* Should find a neater solution to this dumbo */
                                        
t.responseText.match( /.*<!--post:(d+?)-->/ );
                                        
                                        if ( 
&& m[1] )
                                        {
                                            
ipb.topic.topPid m[1];
                                        }
                                        else
                                        {
                                            return 
false;
                                        }
                                        
                                        $(
'ips_Posts').insert( new Element('div', { id'newContent-' ipb.topic.topPid } ).insertt.responseText ) );
                                        
                                        if ( $( 
'newContent-' ipb.topic.topPid ) )
                                        {
                                            $( 
'newContent-' ipb.topic.topPid).hide();
                                            new 
Effect.BlindDown'newContent-' ipb.topic.topPid, { duration1.0queue'front'afterFinish: function() { $('post_id_' ipb.topic.topPid).scrollTo() } } );
                                            
                                            
prettyPrint();
                                        }
                                        
                                        
/* Close notification */
                                        
ipb.global.closeInlineNotification();
                                    }
                                }
                            }
                        );
        return 
false;
    },
    
    
/* ------------------------------ */
    /**
     * Reads the cookie and checks posts as necessary
    */
    
preCheckPosts: function()
    {
        if( ! $(
'selectedpidsJS' ) || !$F('selectedpidsJS') ){ return true; }
        
        
// Get the cookie
        
pids $F('selectedpidsJS').split(',');
        
        if( 
pids )
        {
            
pids.each( function(pid)
            {
                if( !
pid.blank() )
                {
                    
ipb.topic.totalChecked++;
                    
                    if( $(
'checkbox_' pid) )
                    {
                        
ipb.topic.checkPostthis, $('checkbox_' pid) );
                        $(
'checkbox_' pid).checked true;
                        
                    }
                }
            });
        }
        
        
ipb.topic.updatePostModButton();
    },
    
    
/* ------------------------------ */
    /**
     * Checks a post
     * 
     * @var        {event}        e        The event
    */
    
checkPost: function(echeck)
    {
        
Debug.write("Check post");
        
remove $A();
        
data $F('selectedpidsJS');
        
        if( 
data != null ){
            
pids data.split(',') || $A();
        } else {
            
pids $A();
        }
                
        if( 
check.checked == true )
        {
            
pids.pushcheck.id.replace('checkbox_''') );
            
ipb.topic.totalChecked++;
            
            switch ( 
check.readAttribute("data-status") )
            {
                case 
'1':
                    
ipb.topic.modOptionsUnapproved += 1;
                    break;
                    
                case 
'2':
                    
ipb.topic.modOptionsHidden += 1;
                    break;
                    
                default:
                    
ipb.topic.modOptionsUnhidden += 1;
                    break;
            }
        }
        else
        {
            
remove.pushcheck.id.replace('checkbox_''') );
            
ipb.topic.totalChecked--;
            
            switch ( 
check.readAttribute("data-status") )
            {
                case 
'1':
                    
ipb.topic.modOptionsUnapproved -= 1;
                    break;
                    
                case 
'2':
                    
ipb.topic.modOptionsHidden -= 1;
                    break;
                    
                default:
                    
ipb.topic.modOptionsUnhidden -= 1;
                    break;
            }
        }
        
        
pids pids.uniq().withoutremove ).join(',');
        
ipb.Cookie.set('modpids'pids0);
        $(
'selectedpidsJS').value pids;
        
ipb.topic.updatePostModButton();
        
    },
    
    
/* ------------------------------ */
    /**
     * Updates the text on the moderation submit button
    */
    
updatePostModButton: function()
    {
        
/* Do we have any checked? */
        
if( ipb.topic.totalChecked )
        {
            
/* Yes! Have we loaded in the HTML for the box? */
            
if( !$('comment_moderate_box') )
            {
                
/* No? Then do it! */
                
$$('body')[0].insert({'bottom'ipb.templates['post_moderation'].evaluate({countipb.topic.totalChecked}) });
                
                
/* And set the action for the submit button */
                
$('submitModAction').on('click'ipb.topic.doModerate);
            }
            else
            {
                
/* Yes, just update the number of checked boxes */
                
$('comment_count').updateipb.topic.totalChecked );
            }
            
            
/* And show the box */
            
if( !$('comment_moderate_box').visible() )
            {
                new 
Effect.Appear( $('comment_moderate_box'), { duration0.3 } );
            }

            $(
'tactInPopup').select('option').invoke('remove');

            
/* Update the available options */
            
if ( ipb.topic.modOptionsUnapproved )
            {
                $(
'tactInPopup').insert( new Element('option', { value'approve' } ).updateipb.lang['cpt_approve'] ) );
            }
            if ( 
ipb.topic.modOptionsUnhidden )
            {
                $(
'tactInPopup').insert( new Element('option', { value'delete' } ).updateipb.lang['cpt_hide'] ) );
            }
            if ( 
ipb.topic.modOptionsHidden )
            {
                $(
'tactInPopup').insert( new Element('option', { value'sundelete' } ).updateipb.lang['cpt_undelete'] ) );
            }
            $(
'tactInPopup').insert( new Element('option', { value'deletedo' } ).updateipb.lang['cpt_delete'] ) );

            if ( 
ipb.topic.totalChecked )
            {
                $(
'tactInPopup').insert( new Element('option', { value'merge' } ).updateipb.lang['cpt_merge'] ) );
            }

            $(
'tactInPopup').insert( new Element('option', { value'split' } ).updateipb.lang['cpt_split'] ) );
            $(
'tactInPopup').insert( new Element('option', { value'move' } ).updateipb.lang['cpt_move'] ) );

        }
        else
        {
            
/* No - get rid of the box */
            
if( $('comment_moderate_box') )
            {
                new 
Effect.Fade( $('comment_moderate_box'), { duration0.3 } );
            }
        }
    },
    
    
doModerate: function()
    {
        if ( 
ipb.topic.totalChecked )
        {            
            $(
'tact').value = $('tactInPopup').value;
        
            if ( $(
'tactInPopup').options[ $('tactInPopup').selectedIndex ].value == 'deletedo' )
            {
                $(
'modform').confirmAction();
            }
            else
            {
                $(
'modform').submit();
            }
        }
    },
    
    
/* ------------------------------ */
    /**
     * Confirm they want to delete stuff
     * 
     * @var     {event}        e    The event
    */
    
confirmSingleDelete: function(eelem)
    {
        if ( ! 
confirmipb.lang['delete_post_confirm'] ) )
        {
            
Event.stop(e);
            return 
false;
        }
        
        return 
true;
    },
    
    
/* ------------------------------ */
    /**
     * Insert multiquoted posts into editor
     * 
     * @var     {event}        e    The event
    */
    
insertQuotedPosts: function(e)
    {
        
// Get quoted post ids
        
quoted ipb.Cookie.get('mqtids');
        
        var 
url ipb.vars['base_url'] + 'app=forums&module=ajax&section=topics&do=mqquote&t=' ipb.topic.topic_id;
        
Debug.writeurl );
        
        new 
Ajax.Request(    url,
                            {
                                
method'post',
                                
parameters: {
                                    
pids:        quoted,
                                    
md5check:    ipb.vars['secure_hash']
                                },
                                
evalJSON'force',
                                
encodingipb.vars['charset'],
                                
onSuccess: function(t)
                                { 
                                    if (  
t.responseJSON && t.responseJSON['error'] )
                                    {
                                        
ipb.global.errorDialoguet.responseJSON['error'] );
                                        
                                        return 
false;
                                    }
                                    else if ( 
t.responseText && t.responseText != 'nopermission' )
                                    {
                                        
editor    ipb.textEditor.getEditoripb.topic.fastReplyId )
                                        
editor.insertt.responseTexttrue );
                                    }
                                }
                            }
                        );
        
        
        
// Turn off
        
$('multiQuoteInsert').hide();
        
ipb.topic.mqBoxShowing    false;
        
        $$(
'.multiquote').each( function(elem){
            $(
elem).removeClassName('selected');
        });
        
        
// Reset cookie
        
ipb.Cookie.set('mqtids'''0);

        
// And return
        
Event.stop(e);
        return 
false;
    },

    
/* ------------------------------ */
    /**
     * Toggles the multimod buttons in posts
     * 
     * @param    {event}        e        The event
     * @param    {element}    elem    The element that fired
    */
    
toggleMultimod: function(eelem)
    {
        
Event.stop(e);
        
        
// Get list of already quoted posts
        
try {
            
quoted ipb.Cookie.get('mqtids').split(',').compact().without('');
        } catch(
err){
            
quoted $A();
        }
        
        
id            elem.id.replace('multiq_''');
        
quotedItems    0;
        
        
// Hokay, are we selecting/deselecting?
        
if( elem.hasClassName('selected') )
        {
            
elem.removeClassName('selected');
            
quoted        quoted.uniq().withoutid );
            
quotedItems    quoted.size();
            
quoted        quoted.join(',');
        }
        else
        {
            
elem.addClassName('selected');
            
quoted.pushid );
            
quotedItems    quoted.size();
            
quoted        quoted.uniq().join(',');
        }
        
        
// If it's just a ',' then empty it
        
if( quoted == ',' ){
            
quoted '';
        }

        
// If we have quoted posts...
        
if( quoted ){
            
// And it's not already showing, then show it.  If it's already showing, no need to recreate
            
if( !ipb.topic.mqBoxShowing )
            {
                $(
'multiQuoteInsert').show();
                
ipb.topic.mqBoxShowing    true;
            }
            
            
// Show nicer string
            
$('mqbutton').updateipb.lang['mq_reply_swap'].replace( /#{num}/, quotedItems ) );
        
}
        
// If we don't, then we should remove the insert button
        
else
        {
            if( 
ipb.topic.mqBoxShowing )
            {
                $(
'multiQuoteInsert').hide();
                
ipb.topic.mqBoxShowing    false;
            }
        }

        
// Save cookie
        
ipb.Cookie.set('mqtids'quoted0);
    },
    
    
/* ------------------------------ */
    /**
     * Clears selected multiquote posts
     * 
     * @param    {event}        e        The event
    */
    
clearMultiQuote: function(e){
        
Event.stop(e);
        
        
// Empty the cookie
        
ipb.Cookie.set('mqtids'''0);
        
        if( $(
'multiQuoteInsert').visible() ){
            $(
'multiQuoteInsert').hide();
            
ipb.topic.mqBoxShowing false;
        }
        
        $$(
'.multiquote.selected').invoke('removeClassName''selected');
    },
    
    
/* ------------------------------ */
    /**
     * Toggles the filters bar
     * 
     * @var        {event}        e    The event
    */
    
toggleFilters: function(e)
    {
        if( $(
'filter_form') )
        {
            
Effect.toggle( $('filter_form'), 'blind', {duration0.2} );
            
Effect.toggle( $('show_filters'), 'blind', {duration0.2} );
        }
    },
    
    
/* ------------------------------ */
    /**
     * Sets the supplied post to hidden
     * 
     * @var        {int}    id        The ID of the post to hide
    */
    
setPostHidden: function(id)
    {
        if( $( 
'post_id_' id ).select('.post_wrap')[0] )
        {
            $( 
'post_id_' id ).select('.post_wrap')[0].hide();

            if( $(
'unhide_post_' id ) )
            {
                $(
'unhide_post_' id).observe('click'ipb.topic.showHiddenPost );
            }
        }
    },
    
    
/* ------------------------------ */
    /**
     * Unhides the supplied post
     * 
     * @var        {event}        e    The link event
    */
    
showHiddenPost: function(e)
    {
        
link Event.findElement(e'a');
        
id link.id.replace('unhide_post_''');
        
        if( $(
'post_id_' id ).select('.post_wrap')[0] )
        {
            
elem = $('post_id_' id ).select('.post_wrap')[0];
            new 
Effect.Parallel( [
                new 
Effect.BlindDownelem ),
                new 
Effect.Appearelem )
            ], { 
duration0.5 } );
        }
        
        if( $(
'post_id_' id ).select('.post_ignore')[0] )
        {
            
ignoreElem = $('post_id_' id ).select('.post_ignore')[0];

            
ignoreElem.hide();
        }
        
        
Event.stop(e);
    },
    
    
/* ------------------------------ */
    /**
     * Scrolls the browser to a particular post
     * 
     * @var     {int}    pid        Post ID to scroll to
    */
    
scrollToPost: function( pid )
    {
        if( !
pid || !Object.isNumberpid ) ){ return; }
        $(
'entry' pid).scrollTo();
    },
    
    
showVoters: function( eqidcid )
    {
        
Event.stop(e);
        
        if( !
ipb.topic.pollqid ] || !ipb.topic.pollqid ][ cid ] ){ return; }

        var 
content ipb.templates['poll_voters'].evaluate( { titleipb.topic.pollqid ][ cid ]['name'], contentipb.topic.pollqid ][ cid ]['users'] } );
    
        
ipb.topic.pollPopupsqid+'_'+cid ] = new ipb.Popup'b_voters_' qid '_' cid, {
                                                        
type'balloon',
                                                        
initialcontent,
                                                        
stemtrue,
                                                        
hideAtStartfalse,
                                                        
attach: { target: $('l_voters_' qid '_' cid ), position'auto''event''click' },
                                                        
w'500px'
                                                    
});
    }
};

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