Вход Регистрация
Файл: static/plugins/admin/js/mass_mailing.js
Строк: 98
<?php
var MassMailing = function( $responderUrl )
{
    var 
self this;


    
this.focusElement null;
        
    
this.responderUrl $responderUrl;

    
this.sentRequest false;
    
//this.userSelection = $(".user_section input");
    
this.userRoles = $("#massMailingForm input[name='userRoles[]']");

    
this.emailFormat = $("#massMailingForm select[name=emailFormat]");
    
this.subject = $("#massMailingForm input[name=subject]");
    
this.body = $("#massMailingForm textarea[name=body]");

    
this.previewSubject = $(".previewSubject");
    
this.previewBody = $(".previewBody");

    
this.emailFormat.change(function(){ this.form.submit() })

    
this.subject.focus( function() {
        
self.focusElement this;
    });

    
this.body.focus( function() {
        
self.focusElement this;
    });

    
this.getCountMassMailingUsers = function()
    {
        if ( 
this.sentRequest === false )
        {
            
this.sentRequest true;

            
self.userRoles.attr'disabled''disabled' );

            var 
values = {};
            var 
roles = {};
            $(
"#massMailingForm input[name='userRoles[]']:checked").each(function(ordero){
                
roles[$(o).val()] = $(o).val();
            });

            
values['roles'] = roles;

            $(
'.total_members').html"<div style='height:30px;width:25px;' class='peep_preloader_content'></div>"  );

            $.
ajax( {
                            
urlthis.responderUrl,
                            
type'POST',
                            
data: {command'countMassMailingUsers'valuesJSON.stringify(values)},
                            
dataType'json',

                            
success: function( data )
                            {
                                
self.sentRequest false;
                                
self.userRoles.removeAttr'disabled' );

                                var 
params = [];
                                
params['count'] = data.result;
                                $(
'.total_members').htmlPEEP.getLanguageText('admin''massmailing_total_members'params) );
                            }
                        } );
        }
    }

    
//this.userRoles.click( function(){self.getCountMassMailingUsers()} );
    
this.userRoles.click( function(){self.getCountMassMailingUsers()} );

    
this.copyPreviewSubject = function()
    {
        var 
$format self.emailFormat.val();

        if( 
$format == 'html' )
        {
            
self.previewSubject.htmlself.subject.val() );
        }
        else
        {
            
self.previewSubject.textself.subject.val() );
        }
    }

    
this.copyPreviewBody = function()
    {
        var 
$format self.emailFormat.val();

        if( 
$format == 'html' )
        {
            
self.previewBody.htmlself.body.val() );
        }
        else
        {
            
self.previewBody.htmlself.nl2brthis.htmlspecialcharsself.body.val() ) ) );
        }
    }
    
    
this.nl2br = function( $str )
    {
        return (
$str '').replace(/([^>rn]?)(rn|nr|r|n)/g'$1''<br />' +'$2');
    }

    
this.htmlspecialchars = function(text)
    {
       var 
chars = Array("&""<"">"'"'"'");
       var 
replacements = Array("&amp;""&lt;""&gt;""&quot;""'");
       for (var 
i=0i<chars.lengthi++)
       {
           var 
re = new RegExp(chars[i], "gi");
           if(
re.test(text))
           {
               
text text.replace(rereplacements[i]);
           }
       }
       return 
text;
    }

    
this.addVar = function( $varname )
    {
        var 
$element = $(self.focusElement);

        if( !
$element.length )
        {
            
$element = $('#mass_mailing_body');
        }

        
$element.val($element.val()+$varname);

    }
}
?>
Онлайн: 3
Реклама