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

var _sharelinks window.IPBoard;

_sharelinks.prototype.sharelinks = {
    
popupsnull,
    
bnamenull,
    
urlnull,
    
titlenull,
    
maxTwitterLen115,
    
    
init: function()
    {
        
Debug.write("Initializing ips.sharelinks.js");
        
        
document.observe("dom:loaded", function(){
            
ipb.sharelinks.initEvents();
        });
    },
    
    
/* ------------------------------ */
    /**
     * Initialize events
    */
    
initEvents: function()
    {
        
ipb.delegate.register('._slink'ipb.sharelinks.sharePop);
    },
    
    
/* ------------------------------ */
    /**
     * Twitter pop innit
     * 
     * @param    {event}        e        The event
    */
    
sharePop: function(eelem)
    {
        var 
shareKey elem.id.replace( /slink_/, '' );
        var 
ok       false;
        var 
callback null;
        var 
h        '190';
        
        if ( 
shareKey == 'twitter' )
        {
            if ( 
ipb.vars['member_id'] && ipb.vars['twitter_id'] )
            {
                
callback ipb.sharelinks.twitterPostPop;
                
ok       true;
                
h        '110';
            }
        }
        
        if ( 
ok === false || DISABLE_AJAX )
        {
            return 
false;
        }
        
        
/* Still here? */
        
Event.stop(e);

        var 
_url  ipb.vars['base_url'] + '&app=core&module=ajax&secure_key=' ipb.vars['secure_hash'] + '&section=sharelinks&do=' shareKey 'Form';
        
        var 
= new ipb.Popup'shareKeyPop_' Math.random(), { type'modal',
                                                                 
ajaxURL_url,
                                                                 
modaltrue,
                                                                 
stemfalse,
                                                                 
hideAtStartfalse,
                                                                 
w'550px'h}, { 'afterAjax'callback'beforeAjax'ipb.sharelinks.resetPop } );
    },
    
    
/**
     * Post process twitter pop-up
     */
    
facebookPostPop: function( eresponseText )
    {
        
/* Issue with FB API? */
        
if( responseText == 'x' )
        {
            
window.location "http://www.facebook.com/sharer.php?u=" ipb.sharelinks.url.encodeParam();
            return 
false;
        }
        
        $(
'fContent').update('');
        $(
'fSubmit').observe('click'ipb.sharelinks.goFacebook);
    },
    
    
/**
     * Post process twitter pop-up
     */
    
twitterPostPop: function( eresponseText )
    {
        
/* Issue with Twitter API? */
        
if( responseText == 'x' )
        {
            
window.location "http://twitter.com/intent/tweet?status=" ipb.sharelinks.title.encodeParam() + '%20-%20' ipb.sharelinks.url.encodeParam();
            return 
false;
        }
        
        
/* clean up title */
        
ipb.sharelinks.title ipb.sharelinks.title.replace(/&#34;/g , '"');
        
ipb.sharelinks.title ipb.sharelinks.title.replace(/&#33;/g , "!");
        
ipb.sharelinks.title ipb.sharelinks.title.replace(/&#39;/g, "'");
        
ipb.sharelinks.title ipb.sharelinks.title.replace(/&quot;/g'"');
        
        
/* Clean up board name */
        
ipb.sharelinks.bname ipb.sharelinks.bname.replace(/&#34;/g , '"');
        
ipb.sharelinks.bname ipb.sharelinks.bname.replace(/&#33;/g , "!");
        
ipb.sharelinks.bname ipb.sharelinks.bname.replace(/&#39;/g , "'");
        
ipb.sharelinks.bname ipb.sharelinks.bname.replace(/&quot;/g'"');
        
Debug.writeipb.sharelinks.title );
        $(
'tContent').value ipb.sharelinks.bname ': ' ipb.sharelinks.title;
        $(
'tContent').observe('keyup'ipb.sharelinks.checkTwitterLength);
        $(
'tSubmit').observe('click'ipb.sharelinks.goTwitter);
        
        
ipb.sharelinks.checkTwitterLength(e);
    },
    
    
/**
     * Reset pop-up
     */
    
resetPop: function(e)
    {
        if ( $(
'tContent') )
        {
            $(
'tContent').stopObserving();
            $(
'tContent').remove();
            $(
'tSubmit').stopObserving();
            $(
'tWrap').remove();
        }
        
        if ( $(
'cLeft') )
        {
            $(
'cLeft').remove();
        }
        
        if ( $(
'fContent') )
        {
            $(
'fContent').remove();
            $(
'fSubmit').stopObserving();
            $(
'fWrap').remove();
        }
    },
    
    
/**
     * Post a comment to twitter
     */
    
goTwitter: function(e)
    {
        if( 
DISABLE_AJAX )
        {
            return 
false;
        }
        
        
Event.stop(e);
        
        if ( ! $(
'tContent') || $F('tContent').blank() )
        {
            return;
        }
        
        new 
Ajax.Requestipb.vars['base_url'] + '&app=core&module=ajax&secure_key=' ipb.vars['secure_hash'] + '&section=sharelinks&do=twitterGo',
                        {
                            
method'post',
                            
parameters: {
                                
'tweet'$F('tContent').encodeParam(),
                                
'title'ipb.sharelinks.title.encodeParam(),
                                
'url'ipb.sharelinks.url.encodeParam()
                            },
                            
onSuccess: function(t)
                            {
                                
/* Check */
                                
if( t.responseText == 'failwhale' )
                                {
                                    
alertipb.lang['action_failed'] );
                                    return;
                                }
                                else
                                {
                                    $(
'tWrap').updatet.responseText );
                                }
                            }
                        });
    },
    
    
/**
     * Post a comment to Facebook
     * @Deprecated as of 3.3 - now using Facebook standard share button
     */
    
goFacebook: function(e)
    {
        if( 
DISABLE_AJAX )
        {
            return 
false;
        }
        
        
Event.stop(e);
        
        new 
Ajax.Requestipb.vars['base_url'] + '&app=core&module=ajax&secure_key=' ipb.vars['secure_hash'] + '&section=sharelinks&do=facebookGo',
                        {
                            
method'post',
                            
parameters: {
                                
'comment'$F('fContent').encodeParam(),
                                
'title'ipb.sharelinks.title.encodeParam(),
                                
'url'ipb.sharelinks.url.encodeParam()
                            },
                            
onSuccess: function(t)
                            {
                                
/* Check */
                                
if( t.responseText == 'finchersaysno' )
                                {
                                    
alertipb.lang['action_failed'] );
                                    return;
                                }
                                else
                                {
                                    $(
'fWrap').updatet.responseText );
                                }
                            }
                        });
    },
        
    
checkTwitterLength: function(e)
    {
        
newTotal parseIntipb.sharelinks.maxTwitterLen ) - parseInt$F('tContent').length );
        
        if( 
newTotal )
        {
            $(
'tContent').value $F('tContent').truncateipb.sharelinks.maxTwitterLen'' );
            
newTotal 0;
        }
        
        $(
'cLeft').updatenewTotal );
    }
};

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