Вход Регистрация
Файл: IPBMafia.ru_IPB_3.4.6_Final_Rus _Nulled/board/upload/admin/js/acp.jquery.members.js
Строк: 555
<?php
// ************************************ //
// Member List                            //
// ************************************ //
var memberlist = {};

(function($){
    
    
memberlist = function($){
        
//-------------------------------------
        // PROPERTIES
        
var currentOptions = {
            
st0,
            
type'all',
            
string'',
            
order_by'joined',
            
order_direction'desc'
        
},
        
coreOptions = ['st''type''string''order_by''order_direction'],
        
request_url '',
        
table null,
        
isAdvSearching false,
        
searchTimeout null,
        
lastVal '',
        
resultsCache = {};
        
        
//-------------------------------------
        // PUBLIC METHODS    
        
var init = function( urldefaultType ){
            
request_url    url;
            
table        = $("#member_list");
            
defaultType    defaultType defaultType 'all';
        
            
// Set up events
            
$("#member_types a").clicktoggleType );                                 // Toggle bar
            
$("#member_search").keyupfocusSearch ).blurblurSearch );            // Search box
            
$(".sortable"table).clicksortTable );                                // Column headers
            
$(".member_action"table).live('click'doAction );                    // Row action
            
$(".mass_action"table).live('click'doMassAction );                    // Mass action
            
$("#mfooter_spam .spam_action").live('click'doSpamAction);            // Spam action
            
$(".check_all"table).live('click'checkAll );                        // "Check All"
            
$("#member_results input:checkbox").live("click"checkOne);            // Check one
            
$(".pagination a").live('click'hijackPagination );                     // Hijack navigation
            
$("#advanced_member_search").clickshowAdvancedSearch );                // Advanced search
            
$("#memberListForm").submit( function(e){ e.preventDefault(); } );        // Stop form submission
            
            
prepareAdvancedSearch();
            
preparePruneAndMove();
            
            if( 
window.location.hash ){
                
parseHash();
            } else {
                
//loadDefaults();
            
}
            
            
// Default type
            
if( defaultType )
            {
                
currentOptions['type']    = defaultType;
                
                $(
"#member_types li").removeClass("active");
                $(
'li[data-type|="' defaultType '"]').addClass("active");

                if( $(
"#mheader_" defaultType ":hidden").size() )
                {
                    $(
".member_column_titles").hide();
                    $(
".sortable"table).removeClass("active");
                    $(
"#mheader_" defaultType )
                        .
show()
                        .
find('th[data-key="' currentOptions['order_by'] + '"]')
                            .
addClass("active")
                            .
addClasscurrentOptions['order_direction'] );
                    
                }

                if( !$(
"#mfooter_" defaultType ":visible").size() )
                {
                    $(
"tfoot tr"table).hide();
                    $(
"#mfooter_" defaultType ).show();
                }
            }
            
            $(
"#members_loading").ajaxStart( function(){
                $(
this).fadeIn('fast');
            }).
ajaxStop( function(){
                $(
this).fadeOut('fast');
            });
        },
        
getOption = function(option){
            return 
currentOptionsoption ];
        },
        
setOption = function( optionvalue ){
            
currentOptionsoption ] = value;
        };
        
        
//-------------------------------------
        // PRIVATE METHODS
        // Toggles the type (member, validating, spammer etc.)
        
var toggleType = function(e)
        {
            
e.preventDefault();
            
// Ignore if already active
            
if( $( e.target ).closest(".ipsActionButton.active").size() ){
                return;
            }
            
// Make active
            
$("#member_types li").removeClass("active");
            var 
key = $( e.target ).closest("li").addClass("active").data('type');
            
            
currentOptions['reset_filters']    = 1;
            
currentOptions['type']            = key;
            
currentOptions['st']            = 0;
            
            
// Send request
            
fetchResultscurrentOptions );
        },
        
        
// Handler for sorting the table by column
        
sortTable = function(e)
        {
            
e.preventDefault();
            var 
td = $( e.target ).closest('.sortable');
            
            if( 
td.hasClass('active') ){
                if( 
td.hasClass('desc') ){
                    
td.removeClass('desc').addClass('asc');
                    
fetchResults( { order_direction'asc' } );
                } else {
                    
td.removeClass('asc').addClass('desc');
                    
fetchResults( { order_direction'desc' } );
                }
                return;
            }
            
            $(
".sortable"table).removeClass("active");
            var 
key td.addClass("active").addClass("desc").data('key');
            
            
// Send request
            
fetchResults( { order_bykeyorder_direction'desc' } );
        },
        
        
// Perform an action on a member
        
doAction = function(e)
        {
            
e.preventDefault();
            
            
// Get the type and action
            
var _do currentOptions['type'];
            var 
_action = $( e.target ).data("action");
            if( $.
undefined_do ) || !_do || $.undefined_action ) || !_action ){
                
Debug.write"No type, or no action."); return;
            }
            
            if( 
_action == 'delete' ){
                if( !
confirmipb.lang['confirm_delete_single_mem'] ) ){
                    return 
false;
                }
            }
            
            
// Get the relevant member ID
            
var mid = $( e.target ).closest("tr").data("mid");
            if( $.
undefinedmid ) || !mid ){
                
Debug.write"No member ID found."); return;
            }
            
            if( 
_do == 'all' ){
                var 
url request_url "&do=do_" _action "&type=" _do "&mid_" mid "=1";
            } else {
                var 
url request_url "&do=do_" _do "&type=" _action "&mid_" mid "=1";
            }
            
            
// Send the request
            
$.ajax( {
                
urlurl.replace(/&amp;/g'&'),
                
type'get',
                
success: function(data){
                    if( 
data['ok'] ){
                        if( 
_action == 'resend' )
                        {
                            
alertdata['msg'] );
                        }
                        else
                        {
                            $( 
e.target ).closest(".member_controls")
                                .
addClass("success")
                                .
closest("tr")
                                    .
fadeOut('slow', function(){
                                        $( 
this ).remove();
                                        
checkForEmptyTable();
                                    });
                                    
                            
emptyCache();
                        }                
                    }
                    else if( 
data['error'] ) {
                        
alertdata['error'] );
                    }
                    else {
                        
alertipb.lang['generic_ajax_error'] );
                    }                        
                }
            });            
        },
        
        
doMassAction = function(e)
        {
            
e.preventDefault();
            
            
// Get the type and action
            
var _do currentOptions['type'];
            var 
_action = $( e.target ).data("action");
            if( $.
undefined_do ) || !_do || $.undefined_action ) || !_action ){
                
Debug.write"No type, or no action."); return;
            }
            
            if( 
_action == 'delete' ){
                if( !
confirmipb.lang['confirm_delete_multiple_mem'] ) ){
                    return 
false;
                }
            }
            
            
// Get all MIDs
            
var mids = $("#member_results input:checked").map( function(){
                return 
"mid_" + $(this).closest("tr").data("mid") + "=1";
            }).
get();
            
            if( 
mids == "" ){ return; }
            
mids mids.join("&");
                        
            var 
url request_url "&do=do_" _do "&type=" _action "&" mids;
            
            
//Debug.write( url );
            
$.ajax( {
                
urlurl.replace(/&amp;/g'&'),
                
type'get',
                
success: function(data){
                    if( 
data['ok'] ){
                        $(
"#member_results input:checked").parents(".member_controls")
                            .
addClass("success")
                            .
closest("tr")
                                .
fadeOut('slow', function(){
                                    $( 
this ).remove();
                                    
checkForEmptyTable();
                                });    
                                
                        
emptyCache();
                        
                        if ( 
_action == 'resend' )
                        {
                            
ipb.global.showInlineNotificationipb.lang['members_validation_resent'] );
                        }
                    }
                    else if( 
data['error'] ) {
                        
alertdata['error'] );
                    }
                    else {
                        
alertipb.lang['generic_ajax_error'] );
                    }
                }
            });
        },
        
        
doSpamAction = function(e)
        {
            
e.preventDefault();
            var 
action = $( e.target ).data("action");
            
            if( 
action == 'unspam' )
            {
                $(
"#s_initial").hide();
                $(
"#s_unspam_confirm").show();
                $(
"#s_unspam_yes, #s_unspam_no").click( function(e){
                    
doMassAction(e);
                    $( 
this ).unbind();
                    $(
"#s_unspam_confirm").hide();
                    $(
"#s_initial").show();
                });
            }
            else if( 
action == 'ban' )
            {
                $(
"#s_initial").hide();
                $(
"#s_ban_confirm").show();
                $(
"#s_ban_yes, #s_ban_no").click( function(e){
                    
doMassAction(e);
                    $( 
this ).unbind();
                    $(
"#s_ban_confirm").hide();
                    $(
"#s_initial").show();
                });
            }
            else
            {
                
doMassAction(e);
            }
        },
        
        
// Checks whether the table is empty after performing
        // member row actions
        
checkForEmptyTable = function()
        {
            if( $(
"#member_results tr").size() == )
            {
                $(
".check_all").attr("checked"false);
                $(
"tfoot tr:visible"table).addClass("disabled");
                
fetchResults( {}, true ); // force cache update
            
}
        },
        
        
// Handler for checking all checkboxes in the table
        
checkAll = function(e)
        {
            $(
"#member_results input:checkbox").attr("checked"e.target.checked );
            
            
// Enable the mass-action bar if necessary
            
if( e.target.checked && $("#member_results tr").size() ){
                $(
"tfoot tr:visible").removeClass("disabled");
            }
            else {
                $(
"tfoot tr:visible").addClass("disabled");
            }
        },
        
        
// Handler when a checkbox is clicked. Removes 'check all' check if necessary.
        
checkOne = function(e)
        {
            if( !
e.target.checked ){
                $(
".check_all").attr("checked"false);
            }
            
            
            if( !$(
"#member_results input:not(:checked)").size() ){
                $(
".check_all").attr("checked"true);
            } else {
                $(
".check_all").attr("checked"false);
            }
            
            
// Enable the mass-action bar if necessary
            
if( $("#member_results tr").size() && $("#member_results input:checked").size() ){
                $(
"tfoot tr:visible").removeClass("disabled");
            }
            else {
                $(
"tfoot tr:visible").addClass("disabled");
            }
        },
        
        
// Handler for pagination links
        
hijackPagination = function(e)
        {
            
e.preventDefault();
            
            
// Find the st value
            
try {
                var 
st e.target.href.match(/&st=([0-9]+)/)[1];
            } catch(
err) {
                
Debug.write"No st value found" );
                return;
            }
            
            
fetchResults( { stst } );
        },
        
        
// if there's a url hash, parse it and load results
        
parseHash = function()
        {
            var 
hash window.location.hash;
            var 
params $HgetHashParamshash ) );
            var 
options = {};
            
            if( !
params.size() ){
                return;
            }
            
            
params.each( function(h){
                
optionsh.key ] = h.value;
            });
            
            if( !
options['do_results'] ){
                return;
            }
            
            var 
Object.toQueryStringcurrentOptions );
            
currentOptions = $.extendcurrentOptionsoptions );

            
// do stuff
            
$.ajax( {
                
url: ( request_url "&" ).replace(/&amp;/g'&'),
                
type'post',
                
dataoptions,
                
success: function(data){
                    if( 
data['error'] )
                    {
                        
alertdata['error'] );
                        if( 
data["__session__expired__log__out__"] ){
                            
window.location.reload();
                        }
                    }
                    else
                    {
                        $(
"#member_types").hide();
                        $(
"#m_search_info").show().find("span").htmldata['count'] );
                        
isAdvSearching true;
                        
buildResultsdata );
                        
Debug.write("Done");
                    }
                }
            });    
        },
        
        
getHashParams = function( hash )
        {
            var 
hashParams = {};
            var 
e,
                
= /+/g,  // Regex for replacing addition symbol with a space
                
= /([^&;=]+)=?([^&;]*)/g,
                
= function (s) { return decodeURIComponent(s.replace(a" ")); },
                
window.location.hash.substring(1);

            while (
r.exec(q))
               
hashParams[d(e[1])] = d(e[2]);

            return 
hashParams;
        },
        
        
// Empties the cache
        
emptyCache = function()
        {
            
resultsCache = {};            
        },
        
        
// Fetches results from the server or cache using our params object
        
fetchResults = function( optionsforce )
        {
            var 
newOpts = {};
            $.
eachcoreOptions, function( i){
                
newOpts] = currentOptions];
            });
            
currentOptions newOpts;
            
            var 
= $.extend( {}, currentOptionsoptions );
            var 
hash Object.toQueryString);
            
            
//o['__update']    = 1;
            
            // Wipe cache?
            
if( force ){
                
resultsCache = {};
            }
            
            if( 
resultsCachehash ] )
            {
                
currentOptions o;
                
buildResultsresultsCache[hash] );
            }
            else
            {
                
// do stuff
                
$.ajax( {
                    
urlrequest_url.replace(/&amp;/g'&') + '&_nosave=1',
                    
type'get',
                    
datao,
                    
success: function(data){
                        if( 
data['error'] )
                        {
                            
alertdata['error'] );
                            if( 
data["__session__expired__log__out__"] ){
                                
window.location.reload();
                            }
                        }
                        else
                        {
                            
currentOptions o;
                            
buildResultsdata );
                            
resultsCachehash ] = data;
                            
Debug.write("Done");
                        }
                    }
                });
            }
            
            
// Set anchor for back button functionality
            
window.location.hash hash/*.replace(/&/g, '/').replace(//amp;/g, '&amp;');*/
        
},
        
buildResults = function( results ){
            
            
// Show headers
            
if( $("#mheader_" currentOptions['type'] + ":hidden").size() )
            {
                $(
".member_column_titles").hide();
                $(
".sortable"table).removeClass("active");
                $(
"#mheader_" currentOptions['type'] )
                    .
show()
                    .
find('th[data-key="' currentOptions['order_by'] + '"]')
                        .
addClass("active")
                        .
addClasscurrentOptions['order_direction'] );
                
            }
            
// Show footers
            
if( !$("#mfooter_" currentOptions['type'] + ":visible").size() )
            {
                $(
"tfoot tr"table).hide();
                $(
"#mfooter_" currentOptions['type'] ).show();
            }
            
            
// Build results and pagination    
            
$("tbody#member_results"table).htmlresults['members'] );
            $(
".pagination").replaceWithresults['pages'] );
            
            
// Reset check all checkbox
            
$(".check_all").attr("checked"false);
            
            
// Check prune/move
            
checkPruneAndMovecurrentOptions['type'] );
        },
        
focusSearch = function(e){
            
clearTimeoutsearchTimeout );

            if( $(
"#member_search").val() )
            {
                
searchTimeout setTimeoutrunSearch300 );
            }
        },
        
blurSearch = function(e){
            
clearTimeoutsearchTimeout );
        },
        
runSearch = function(){
            
searchTimeout setTimeoutrunSearch300 );
            var 
curVal = $("#member_search").val();
            
            if( 
curVal == lastVal || ( curVal.length && curVal.length ) ){
                return;
            }
            
            
fetchResults( { stringcurValst} );
            
lastVal curVal;
        },
        
        
//-------------------------------------------
        // MASS PRUNE/MOVE
        //-------------------------------------------
        
        
preparePruneAndMove = function(){
            $(
"#memberList__prune").click( {doType'prune'}, doPruneMove );
            $(
"#memberList__move").click( {doType'move'}, doPruneMove );
        },
            
        
doPruneMove = function(e){
            
e.preventDefault();
            
            if( $(
"#memberList__" e.data.doType).hasClass("disabled") ){
                return;
            }
            
            var 
type = ( e.data.doType == 'prune' ) ? 'delete' 'move';
            
            var 
currentOptions;
            
delete o['st'];
            
delete o['order_by'];
            
delete o['order_direction'];
            var 
hash Object.toQueryString);
            
            
window.location = $("#memberPruneMoveForm").attr('action') + '&' hash '&f_search_type=' type;
        },
        
checkPruneAndMove = function( type ){
            
// Only enable if we're doing some kind of filtering
            
if( currentOptions['string'] || isAdvSearching ){
                
enablePruneMove();
            } else {
                
disablePruneMove();
            }
        },        
        
disablePruneMove = function(){
            $(
"#memberList__prune, #memberList__move").addClass("disabled");
        },
        
enablePruneMove = function(){
            $(
"#memberList__prune, #memberList__move").removeClass("disabled");
        },
        
        
//-------------------------------------------
        // ADVANCED SEARCH
        //-------------------------------------------
        
        
prepareAdvancedSearch = function(e){
            if( !$(
"#modal").size() ){
                $(
"body").append( $("<div />", { id"modal" } ).hide() );
            }            
            $(
"#modal").css( { height: $(document).height() } );
            
// Submit event
            
$("#do_advanced_search").clickdoAdvancedSearch );
            $(
"#m_search_cancel").clickcancelAdvancedSearch );
            $(
"#close_adv_search, #modal").clickhideAdvancedSearch );
            
            
// Resize event
            
$(window).resize( function(){
                $(
"#modal:visible").css( { height: $(document).height() } );
            });
        },
        
showAdvancedSearch = function(e){
            if(
e){ e.preventDefault(); }
            $(
"#modal").fadeIn();
            $(
"#m_search_pane").fadeIn();
        },
        
hideAdvancedSearch = function(e){
            if(
e){ e.preventDefault(); }
            $(
"#m_search_pane").fadeOut();
            $(
"#modal").fadeOut();
        },
        
cancelAdvancedSearch = function(e){
            if(
e){ e.preventDefault(); }
            
// Remove advanced search fields
            
var newOpts = {};
            $.
eachcoreOptions, function( i){
                
newOpts] = currentOptions];
            });
            
currentOptions newOpts;
            
            
currentOptions['reset_filters']    = 1;
            
            $(
"#m_search_info").hide();
            $(
'.information-box').hide();
            $(
"#member_types").show();
            
isAdvSearching false;
            
fetchResultscurrentOptions );            
        },
        
doAdvancedSearch = function(e){
            
e.preventDefault();
            
// Get form values
            
var vals = {};            
            $.
map( $("#m_search_form").serializeArray(), function( k){
                
valsk['name'] ] = k['value'];
            });
            
            
vals['st']            = 0;
            
vals['__update']    = 1;

            
// @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/also-check-secondary-groups-checkbox-when-unchecked-doesnt-revert-the-inclusion-r42350
            
if( !$("#f_inc_secondary").is(':checked') )
            {
                
vals['f_inc_secondary'] = 0;
            }
            
            
// Remove quick search values
            
$("#member_search").val('');
            
currentOptions['string'] = '';
            
            var 
Object.toQueryStringcurrentOptions );
            
currentOptions = $.extendcurrentOptionsvals );
            
            
// do stuff
            
$.ajax( {
                
url: ( request_url "&" ).replace(/&amp;/g'&'),
                
type'post',
                
datavals,
                
success: function(data){
                    if( 
data['error'] )
                    {
                        
alertdata['error'] );
                        if( 
data["__session__expired__log__out__"] ){
                            
window.location.reload();
                        }
                    }
                    else
                    {
                        $(
"#member_types").hide();
                        $(
"#m_search_info").show().find("span").htmldata['count'] );
                        
isAdvSearching true;
                        
buildResultsdata );
                        
Debug.write("Done");
                    }
                }
            });
            
            
hideAdvancedSearch();
        };
        
        
//-------------------------------------
        // Make public methods public
        
return {
            
initinit,
            
getOptiongetOption,
            
setOptionsetOption
        
};        
    }($);
    
}(
jQuery));
?>
Онлайн: 3
Реклама