Advertisement
Hope-82

global.js

Apr 11th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 71.77 KB | None | 0 0
  1. // AJAX Functions
  2. var jq = jQuery;
  3.  
  4. // Global variable to prevent multiple AJAX requests
  5. var bp_ajax_request = null;
  6.  
  7. jq(document).ready( function() {
  8.     /**** Page Load Actions *******************************************************/
  9.  
  10.     /* Hide Forums Post Form */
  11.     if ( '-1' == window.location.search.indexOf('new') && jq('div.forums').length )
  12.         jq('#new-topic-post').hide();
  13.     else
  14.         jq('#new-topic-post').show();
  15.  
  16.     /* Activity filter and scope set */
  17.     bp_init_activity();
  18.  
  19.     /* Object filter and scope set. */
  20.     var objects = [ 'members', 'groups', 'blogs', 'forums' ];
  21.     bp_init_objects( objects );
  22.  
  23.     /* @mention Compose Scrolling */
  24.     if ( jq.query.get('r') && jq('textarea#whats-new').length ) {
  25.         jq('#whats-new-options').animate({
  26.             height:'40px'
  27.         });
  28.         jq("form#whats-new-form textarea").animate({
  29.             height:'50px'
  30.         });
  31.         jq.scrollTo( jq('textarea#whats-new'), 500, {
  32.             offset:-125,
  33.             easing:'easeOutQuad'
  34.         } );
  35.         jq('textarea#whats-new').focus();
  36.     }
  37.  
  38.     /**** Activity Posting ********************************************************/
  39.  
  40.     /* Textarea focus */
  41.     jq('#whats-new').focus( function(){
  42.         jq("#whats-new-options").animate({
  43.             height:'40px'
  44.         });
  45.         jq("form#whats-new-form textarea").animate({
  46.             height:'50px'
  47.         });
  48.         jq("#aw-whats-new-submit").prop("disabled", false);
  49.     });
  50.  
  51.     /* New posts */
  52.     jq("input#aw-whats-new-submit").click( function() {
  53.         var button = jq(this);
  54.         var form = button.parent().parent().parent().parent();
  55.  
  56.         form.children().each( function() {
  57.             if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") )
  58.                 jq(this).prop( 'disabled', true );
  59.         });
  60.  
  61.         /* Remove any errors */
  62.         jq('div.error').remove();
  63.         button.addClass('loading');
  64.         button.prop('disabled', true);
  65.  
  66.         /* Default POST values */
  67.         var object = '';
  68.         var item_id = jq("#whats-new-post-in").val();
  69.         var content = jq("textarea#whats-new").val();
  70.  
  71.         /* Set object for non-profile posts */
  72.         if ( item_id > 0 ) {
  73.             object = jq("#whats-new-post-object").val();
  74.         }
  75.  
  76.         jq.post( ajaxurl, {
  77.             action: 'post_update',
  78.             'cookie': encodeURIComponent(document.cookie),
  79.             '_wpnonce_post_update': jq("input#_wpnonce_post_update").val(),
  80.             'content': content,
  81.             'object': object,
  82.             'item_id': item_id,
  83.             '_bp_as_nonce': jq('#_bp_as_nonce').val() || ''
  84.         },
  85.         function(response) {
  86.  
  87.             form.children().each( function() {
  88.                 if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) {
  89.                     jq(this).prop( 'disabled', false );
  90.                 }
  91.             });
  92.  
  93.             /* Check for errors and append if found. */
  94.             if ( response[0] + response[1] == '-1' ) {
  95.                 form.prepend( response.substr( 2, response.length ) );
  96.                 jq( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 );
  97.             } else {
  98.                 if ( 0 == jq("ul.activity-list").length ) {
  99.                     jq("div.error").slideUp(100).remove();
  100.                     jq("div#message").slideUp(100).remove();
  101.                     jq("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' );
  102.                 }
  103.  
  104.                 jq("ul#activity-stream").prepend(response);
  105.                 jq("ul#activity-stream li:first").addClass('new-update');
  106.  
  107.                 if ( 0 != jq("#latest-update").length ) {
  108.                     var l = jq("ul#activity-stream li.new-update .activity-content .activity-inner p").html();
  109.                     var v = jq("ul#activity-stream li.new-update .activity-content .activity-header p a.view").attr('href');
  110.  
  111.                     var ltext = jq("ul#activity-stream li.new-update .activity-content .activity-inner p").text();
  112.  
  113.                     var u = '';
  114.                     if ( ltext != '' )
  115.                         u = l + ' ';
  116.  
  117.                     u += '<a href="' + v + '" rel="nofollow">' + BP_DTheme.view + '</a>';
  118.  
  119.                     jq("#latest-update").slideUp(300,function(){
  120.                         jq("#latest-update").html( u );
  121.                         jq("#latest-update").slideDown(300);
  122.                     });
  123.                 }
  124.  
  125.                 jq("li.new-update").hide().slideDown( 300 );
  126.                 jq("li.new-update").removeClass( 'new-update' );
  127.                 jq("textarea#whats-new").val('');
  128.             }
  129.  
  130.             jq("#whats-new-options").animate({
  131.                 height:'0px'
  132.             });
  133.             jq("form#whats-new-form textarea").animate({
  134.                 height:'20px'
  135.             });
  136.             jq("#aw-whats-new-submit").prop("disabled", true).removeClass('loading');
  137.         });
  138.  
  139.         return false;
  140.     });
  141.  
  142.     /* List tabs event delegation */
  143.     jq('div.activity-type-tabs').click( function(event) {
  144.         var target = jq(event.target).parent();
  145.  
  146.         if ( event.target.nodeName == 'STRONG' || event.target.nodeName == 'SPAN' )
  147.             target = target.parent();
  148.         else if ( event.target.nodeName != 'A' )
  149.             return false;
  150.  
  151.         /* Reset the page */
  152.         jq.cookie( 'bp-activity-oldestpage', 1, {
  153.             path: '/'
  154.         } );
  155.  
  156.         /* Activity Stream Tabs */
  157.         var scope = target.attr('id').substr( 9, target.attr('id').length );
  158.         var filter = jq("#activity-filter-select select").val();
  159.  
  160.         if ( scope == 'mentions' )
  161.             jq( 'li#' + target.attr('id') + ' a strong' ).remove();
  162.  
  163.         bp_activity_request(scope, filter);
  164.  
  165.         return false;
  166.     });
  167.  
  168.     /* Activity filter select */
  169.     jq('#activity-filter-select select').change( function() {
  170.         var selected_tab = jq( 'div.activity-type-tabs li.selected' );
  171.  
  172.         if ( !selected_tab.length )
  173.             var scope = null;
  174.         else
  175.             var scope = selected_tab.attr('id').substr( 9, selected_tab.attr('id').length );
  176.  
  177.         var filter = jq(this).val();
  178.  
  179.         bp_activity_request(scope, filter);
  180.         return false;
  181.     });
  182.  
  183.     /* Stream event delegation */
  184.     jq('div.activity').click( function(event) {
  185.         var target = jq(event.target);
  186.  
  187.         /* Favoriting activity stream items */
  188.         if ( target.hasClass('fav') || target.hasClass('unfav') ) {
  189.             var type = target.hasClass('fav') ? 'fav' : 'unfav';
  190.             var parent = target.closest('.activity-item');
  191.             var parent_id = parent.attr('id').substr( 9, parent.attr('id').length );
  192.  
  193.             target.addClass('loading');
  194.  
  195.             jq.post( ajaxurl, {
  196.                 action: 'activity_mark_' + type,
  197.                 'cookie': encodeURIComponent(document.cookie),
  198.                 'id': parent_id
  199.             },
  200.             function(response) {
  201.                 target.removeClass('loading');
  202.  
  203.                 target.fadeOut( 100, function() {
  204.                     jq(this).html(response);
  205.                     jq(this).attr('title', 'fav' == type ? BP_DTheme.remove_fav : BP_DTheme.mark_as_fav);
  206.                     jq(this).fadeIn(100);
  207.                 });
  208.  
  209.                 if ( 'fav' == type ) {
  210.                     if ( !jq('.item-list-tabs li#activity-favorites').length )
  211.                         jq('.item-list-tabs ul li#activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' <span>0</span></a></li>');
  212.  
  213.                     target.removeClass('fav');
  214.                     target.addClass('unfav');
  215.  
  216.                     jq('.item-list-tabs ul li#activity-favorites span').html( Number( jq('.item-list-tabs ul li#activity-favorites span').html() ) + 1 );
  217.                 } else {
  218.                     target.removeClass('unfav');
  219.                     target.addClass('fav');
  220.  
  221.                     jq('.item-list-tabs ul li#activity-favorites span').html( Number( jq('.item-list-tabs ul li#activity-favorites span').html() ) - 1 );
  222.  
  223.                     if ( !Number( jq('.item-list-tabs ul li#activity-favorites span').html() ) ) {
  224.                         if ( jq('.item-list-tabs ul li#activity-favorites').hasClass('selected') )
  225.                             bp_activity_request( null, null );
  226.  
  227.                         jq('.item-list-tabs ul li#activity-favorites').remove();
  228.                     }
  229.                 }
  230.  
  231.                 if ( 'activity-favorites' == jq( '.item-list-tabs li.selected').attr('id') )
  232.                     target.parent().parent().parent().slideUp(100);
  233.             });
  234.  
  235.             return false;
  236.         }
  237.  
  238.         /* Delete activity stream items */
  239.         if ( target.hasClass('delete-activity') ) {
  240.             var li        = target.parents('div.activity ul li');
  241.             var id        = li.attr('id').substr( 9, li.attr('id').length );
  242.             var link_href = target.attr('href');
  243.             var nonce     = link_href.split('_wpnonce=');
  244.  
  245.             nonce = nonce[1];
  246.  
  247.             target.addClass('loading');
  248.  
  249.             jq.post( ajaxurl, {
  250.                 action: 'delete_activity',
  251.                 'cookie': encodeURIComponent(document.cookie),
  252.                 'id': id,
  253.                 '_wpnonce': nonce
  254.             },
  255.             function(response) {
  256.  
  257.                 if ( response[0] + response[1] == '-1' ) {
  258.                     li.prepend( response.substr( 2, response.length ) );
  259.                     li.children('div#message').hide().fadeIn(300);
  260.                 } else {
  261.                     li.slideUp(300);
  262.                 }
  263.             });
  264.  
  265.             return false;
  266.         }
  267.  
  268.         // Spam activity stream items
  269.         if ( target.hasClass( 'spam-activity' ) ) {
  270.             var li = target.parents( 'div.activity ul li' );
  271.             target.addClass( 'loading' );
  272.  
  273.             jq.post( ajaxurl, {
  274.                 action: 'bp_spam_activity',
  275.                 'cookie': encodeURIComponent( document.cookie ),
  276.                 'id': li.attr( 'id' ).substr( 9, li.attr( 'id' ).length ),
  277.                 '_wpnonce': target.attr( 'href' ).split( '_wpnonce=' )[1]
  278.             },
  279.  
  280.             function(response) {
  281.                 if ( response[0] + response[1] === '-1' ) {
  282.                     li.prepend( response.substr( 2, response.length ) );
  283.                     li.children( 'div#message' ).hide().fadeIn(300);
  284.                 } else {
  285.                     li.slideUp( 300 );
  286.                 }
  287.             });
  288.  
  289.             return false;
  290.         }
  291.  
  292.         /* Load more updates at the end of the page */
  293.         if ( target.parent().hasClass('load-more') ) {
  294.             jq("#content li.load-more").addClass('loading');
  295.  
  296.             if ( null == jq.cookie('bp-activity-oldestpage') )
  297.                 jq.cookie('bp-activity-oldestpage', 1, {
  298.                     path: '/'
  299.                 } );
  300.  
  301.             var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
  302.  
  303.             jq.post( ajaxurl, {
  304.                 action: 'activity_get_older_updates',
  305.                 'cookie': encodeURIComponent(document.cookie),
  306.                 'page': oldest_page
  307.             },
  308.             function(response)
  309.             {
  310.                 jq("#content li.load-more").removeClass('loading');
  311.                 jq.cookie( 'bp-activity-oldestpage', oldest_page, {
  312.                     path: '/'
  313.                 } );
  314.                 jq("#content ul.activity-list").append(response.contents);
  315.  
  316.                 target.parent().hide();
  317.             }, 'json' );
  318.  
  319.             return false;
  320.         }
  321.     });
  322.  
  323.     // Activity "Read More" links
  324.     jq('.activity-read-more a').live('click', function(event) {
  325.         var target = jq(event.target);
  326.         var link_id = target.parent().attr('id').split('-');
  327.         var a_id = link_id[3];
  328.         var type = link_id[0]; /* activity or acomment */
  329.  
  330.         var inner_class = type == 'acomment' ? 'acomment-content' : 'activity-inner';
  331.         var a_inner = jq('li#' + type + '-' + a_id + ' .' + inner_class + ':first' );
  332.         jq(target).addClass('loading');
  333.  
  334.         jq.post( ajaxurl, {
  335.             action: 'get_single_activity_content',
  336.             'activity_id': a_id
  337.         },
  338.         function(response) {
  339.             jq(a_inner).slideUp(300).html(response).slideDown(300);
  340.         });
  341.  
  342.         return false;
  343.     });
  344.  
  345.     /**** Activity Comments *******************************************************/
  346.  
  347.     /* Hide all activity comment forms */
  348.     jq('form.ac-form').hide();
  349.  
  350.     /* Hide excess comments */
  351.     if ( jq('.activity-comments').length )
  352.         bp_dtheme_hide_comments();
  353.  
  354.     /* Activity list event delegation */
  355.     jq('div.activity').click( function(event) {
  356.         var target = jq(event.target);
  357.  
  358.         /* Comment / comment reply links */
  359.         if ( target.hasClass('acomment-reply') || target.parent().hasClass('acomment-reply') ) {
  360.             if ( target.parent().hasClass('acomment-reply') )
  361.                 target = target.parent();
  362.  
  363.             var id = target.attr('id');
  364.             ids = id.split('-');
  365.  
  366.             var a_id = ids[2]
  367.             var c_id = target.attr('href').substr( 10, target.attr('href').length );
  368.             var form = jq( '#ac-form-' + a_id );
  369.  
  370.             form.css( 'display', 'none' );
  371.             form.removeClass('root');
  372.             jq('.ac-form').hide();
  373.  
  374.             /* Hide any error messages */
  375.             form.children('div').each( function() {
  376.                 if ( jq(this).hasClass( 'error' ) )
  377.                     jq(this).hide();
  378.             });
  379.  
  380.             if ( ids[1] != 'comment' ) {
  381.                 jq('.activity-comments li#acomment-' + c_id).append( form );
  382.             } else {
  383.                 jq('li#activity-' + a_id + ' .activity-comments').append( form );
  384.             }
  385.  
  386.             if ( form.parent().hasClass( 'activity-comments' ) )
  387.                 form.addClass('root');
  388.  
  389.             form.slideDown( 200 );
  390.             jq.scrollTo( form, 500, {
  391.                 offset:-100,
  392.                 easing:'easeOutQuad'
  393.             } );
  394.             jq('#ac-form-' + ids[2] + ' textarea').focus();
  395.  
  396.             return false;
  397.         }
  398.  
  399.         /* Activity comment posting */
  400.         if ( target.attr('name') == 'ac_form_submit' ) {
  401.             var form        = target.parent().parent();
  402.             var form_parent = form.parent();
  403.             var form_id     = form.attr('id').split('-');
  404.  
  405.             if ( !form_parent.hasClass('activity-comments') ) {
  406.                 var tmp_id = form_parent.attr('id').split('-');
  407.                 var comment_id = tmp_id[1];
  408.             } else {
  409.                 var comment_id = form_id[2];
  410.             }
  411.  
  412.             /* Hide any error messages */
  413.             jq( 'form#' + form.attr('id') + ' div.error').hide();
  414.             target.addClass('loading').prop('disabled', true);
  415.  
  416.             var ajaxdata = {
  417.                 action: 'new_activity_comment',
  418.                 'cookie': encodeURIComponent(document.cookie),
  419.                 '_wpnonce_new_activity_comment': jq("input#_wpnonce_new_activity_comment").val(),
  420.                 'comment_id': comment_id,
  421.                 'form_id': form_id[2],
  422.                 'content': jq('form#' + form.attr('id') + ' textarea').val()
  423.             };
  424.  
  425.             // Akismet
  426.             var ak_nonce = jq('#_bp_as_nonce_' + comment_id).val();
  427.             if ( ak_nonce ) {
  428.                 ajaxdata['_bp_as_nonce_' + comment_id] = ak_nonce;
  429.             }
  430.  
  431.             jq.post( ajaxurl, ajaxdata,
  432.                 function(response)
  433.                 {
  434.                     target.removeClass('loading');
  435.  
  436.                     /* Check for errors and append if found. */
  437.                     if ( response[0] + response[1] == '-1' ) {
  438.                         form.append( response.substr( 2, response.length ) ).hide().fadeIn( 200 );
  439.                     } else {
  440.                         form.fadeOut( 200,
  441.                             function() {
  442.                                 if ( 0 == form.parent().children('ul').length ) {
  443.                                     if ( form.parent().hasClass('activity-comments') )
  444.                                         form.parent().prepend('<ul></ul>');
  445.                                     else
  446.                                         form.parent().append('<ul></ul>');
  447.                                 }
  448.  
  449.                                 form.parent().children('ul').append(response).hide().fadeIn( 200 );
  450.                                 form.children('textarea').val('');
  451.                                 form.parent().parent().addClass('has-comments');
  452.                             }
  453.                             );
  454.                         jq( 'form#' + form.attr('id') + ' textarea').val('');
  455.  
  456.                         /* Increase the "Reply (X)" button count */
  457.                         jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html( Number( jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html() ) + 1 );
  458.                     }
  459.  
  460.                     jq(target).prop("disabled", false);
  461.                 });
  462.  
  463.             return false;
  464.         }
  465.  
  466.         /* Deleting an activity comment */
  467.         if ( target.hasClass('acomment-delete') ) {
  468.             var link_href = target.attr('href');
  469.             var comment_li = target.parent().parent();
  470.             var form = comment_li.parents('div.activity-comments').children('form');
  471.  
  472.             var nonce = link_href.split('_wpnonce=');
  473.             nonce = nonce[1];
  474.  
  475.             var comment_id = link_href.split('cid=');
  476.             comment_id = comment_id[1].split('&');
  477.             comment_id = comment_id[0];
  478.  
  479.             target.addClass('loading');
  480.  
  481.             /* Remove any error messages */
  482.             jq('.activity-comments ul .error').remove();
  483.  
  484.             /* Reset the form position */
  485.             comment_li.parents('.activity-comments').append(form);
  486.  
  487.             jq.post( ajaxurl, {
  488.                 action: 'delete_activity_comment',
  489.                 'cookie': encodeURIComponent(document.cookie),
  490.                 '_wpnonce': nonce,
  491.                 'id': comment_id
  492.             },
  493.             function(response)
  494.             {
  495.                 /* Check for errors and append if found. */
  496.                 if ( response[0] + response[1] == '-1' ) {
  497.                     comment_li.prepend( response.substr( 2, response.length ) ).hide().fadeIn( 200 );
  498.                 } else {
  499.                     var children = jq( 'li#' + comment_li.attr('id') + ' ul' ).children('li');
  500.                     var child_count = 0;
  501.                     jq(children).each( function() {
  502.                         if ( !jq(this).is(':hidden') )
  503.                             child_count++;
  504.                     });
  505.                     comment_li.fadeOut(200);
  506.  
  507.                     /* Decrease the "Reply (X)" button count */
  508.                     var count_span = jq('li#' + comment_li.parents('ul#activity-stream > li').attr('id') + ' a.acomment-reply span');
  509.                     var new_count = count_span.html() - ( 1 + child_count );
  510.                     count_span.html(new_count);
  511.  
  512.                     /* If that was the last comment for the item, remove the has-comments class to clean up the styling */
  513.                     if ( 0 == new_count ) {
  514.                         jq(comment_li.parents('ul#activity-stream > li')).removeClass('has-comments');
  515.                     }
  516.                 }
  517.             });
  518.  
  519.             return false;
  520.         }
  521.  
  522.         // Spam an activity stream comment
  523.         if ( target.hasClass( 'spam-activity-comment' ) ) {
  524.             var link_href  = target.attr( 'href' );
  525.             var comment_li = target.parent().parent();
  526.  
  527.             target.addClass('loading');
  528.  
  529.             // Remove any error messages
  530.             jq( '.activity-comments ul div.error' ).remove();
  531.  
  532.             // Reset the form position
  533.             comment_li.parents( '.activity-comments' ).append( comment_li.parents( '.activity-comments' ).children( 'form' ) );
  534.  
  535.             jq.post( ajaxurl, {
  536.                 action: 'bp_spam_activity_comment',
  537.                 'cookie': encodeURIComponent( document.cookie ),
  538.                 '_wpnonce': link_href.split( '_wpnonce=' )[1],
  539.                 'id': link_href.split( 'cid=' )[1].split( '&' )[0]
  540.             },
  541.  
  542.             function ( response ) {
  543.                 // Check for errors and append if found.
  544.                 if ( response[0] + response[1] == '-1' ) {
  545.                     comment_li.prepend( response.substr( 2, response.length ) ).hide().fadeIn( 200 );
  546.  
  547.                 } else {
  548.                     var children = jq( 'li#' + comment_li.attr( 'id' ) + ' ul' ).children( 'li' );
  549.                     var child_count = 0;
  550.                     jq(children).each( function() {
  551.                         if ( !jq( this ).is( ':hidden' ) ) {
  552.                             child_count++;
  553.                         }
  554.                     });
  555.                     comment_li.fadeOut( 200 );
  556.  
  557.                     // Decrease the "Reply (X)" button count
  558.                     var parent_li = comment_li.parents( 'ul#activity-stream > li' );
  559.                     jq( 'li#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html( jq( 'li#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html() - ( 1 + child_count ) );
  560.                 }
  561.             });
  562.  
  563.             return false;
  564.         }
  565.  
  566.         /* Showing hidden comments - pause for half a second */
  567.         if ( target.parent().hasClass('show-all') ) {
  568.             target.parent().addClass('loading');
  569.  
  570.             setTimeout( function() {
  571.                 target.parent().parent().children('li').fadeIn(200, function() {
  572.                     target.parent().remove();
  573.                 });
  574.             }, 600 );
  575.  
  576.             return false;
  577.         }
  578.     });
  579.  
  580.     /* Escape Key Press for cancelling comment forms */
  581.     jq(document).keydown( function(e) {
  582.         e = e || window.event;
  583.         if (e.target)
  584.             element = e.target;
  585.         else if (e.srcElement)
  586.             element = e.srcElement;
  587.  
  588.         if( element.nodeType == 3)
  589.             element = element.parentNode;
  590.  
  591.         if( e.ctrlKey == true || e.altKey == true || e.metaKey == true )
  592.             return;
  593.  
  594.         var keyCode = (e.keyCode) ? e.keyCode : e.which;
  595.  
  596.         if ( keyCode == 27 ) {
  597.             if (element.tagName == 'TEXTAREA') {
  598.                 if ( jq(element).hasClass('ac-input') )
  599.                     jq(element).parent().parent().parent().slideUp( 200 );
  600.             }
  601.         }
  602.     });
  603.  
  604.     /**** Directory Search ****************************************************/
  605.  
  606.     /* The search form on all directory pages */
  607.     jq('.dir-search').click( function(event) {
  608.         if ( jq(this).hasClass('no-ajax') )
  609.             return;
  610.  
  611.         var target = jq(event.target);
  612.  
  613.         if ( target.attr('type') == 'submit' ) {
  614.             var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' );
  615.             var object = css_id[0];
  616.  
  617.             bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope') , 'div.' + object, target.parent().children('label').children('input').val(), 1, jq.cookie('bp-' + object + '-extras') );
  618.  
  619.             return false;
  620.         }
  621.     });
  622.  
  623.     /**** Tabs and Filters ****************************************************/
  624.  
  625.     /* When a navigation tab is clicked - e.g. | All Groups | My Groups | */
  626.     jq('div.item-list-tabs').click( function(event) {
  627.         if ( jq(this).hasClass('no-ajax') )
  628.             return;
  629.  
  630.         var target = jq(event.target).parent();
  631.  
  632.         if ( 'LI' == event.target.parentNode.nodeName && !target.hasClass('last') && !target.hasClass('no-ajax')) {
  633.             var css_id = target.attr('id').split( '-' );
  634.             var object = css_id[0];
  635.  
  636.             if ( 'activity' == object )
  637.                 return false;
  638.  
  639.             var scope = css_id[1];
  640.             var filter = jq("#" + object + "-order-select select").val();
  641.             var search_terms = jq("#" + object + "_search").val();
  642.  
  643.             bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') );
  644.  
  645.             return false;
  646.         }
  647.     });
  648.  
  649.     /* When the filter select box is changed re-query */
  650.     jq('li.filter select').change( function() {
  651.         if ( jq('div.item-list-tabs li.selected').length )
  652.             var el = jq('div.item-list-tabs li.selected');
  653.         else
  654.             var el = jq(this);
  655.  
  656.         var css_id = el.attr('id').split('-');
  657.         var object = css_id[0];
  658.         var scope = css_id[1];
  659.         var filter = jq(this).val();
  660.         var search_terms = false;
  661.  
  662.         if ( jq('div.dir-search input').length )
  663.             search_terms = jq('div.dir-search input').val();
  664.  
  665.         if ( 'friends' == object )
  666.             object = 'members';
  667.  
  668.         bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') );
  669.  
  670.         return false;
  671.     });
  672.  
  673.     /* Displaymode (list or grid) */
  674.     jq('li.displaymode select').change( function() {
  675.         if ( jq('div.item-list-tabs li.selected').length )
  676.             var el = jq('div.item-list-tabs li.selected');
  677.         else
  678.             var el = jq(this);
  679.  
  680.         var page_number = 1;
  681.         var css_id = el.attr('id').split('-');
  682.         var object = css_id[0];
  683.         var scope = css_id[1];
  684.         var displaymode = jq(this).val();
  685.         var search_terms = false;
  686.  
  687.         if ( jq('div.dir-search input').length )
  688.             search_terms = jq('div.dir-search input').val();
  689.  
  690.         if ( 'friends' == object )
  691.             object = 'members';
  692.  
  693.         if ( jq('div.pagination span.current').length )
  694.             page_number = new Number( jq('div.pagination span.current').html() );
  695.  
  696.         bp_displaymode_request( object, displaymode, scope, 'div.' + object, search_terms, page_number, jq.cookie('bp-' + object + '-extras') );
  697.  
  698.         return false;
  699.     });
  700.  
  701.     /* All pagination links run through this function */
  702.     jq('div#content').click( function(event) {
  703.         var target = jq(event.target);
  704.  
  705.         if ( target.hasClass('button') )
  706.             return true;
  707.  
  708.         if ( target.parent().parent().hasClass('pagination') && !target.parent().parent().hasClass('no-ajax') ) {
  709.             if ( target.hasClass('dots') || target.hasClass('current') )
  710.                 return false;
  711.  
  712.             if ( jq('div.item-list-tabs li.selected').length )
  713.                 var el = jq('div.item-list-tabs li.selected');
  714.             else
  715.                 var el = jq('li.filter select');
  716.  
  717.             var page_number = 1;
  718.             var css_id = el.attr('id').split( '-' );
  719.             var object = css_id[0];
  720.             var search_terms = false;
  721.  
  722.             if ( jq('div.dir-search input').length )
  723.                 search_terms = jq('div.dir-search input').val();
  724.  
  725.             if ( jq(target).hasClass('next') )
  726.                 var page_number = Number( jq('div.pagination span.current').html() ) + 1;
  727.             else if ( jq(target).hasClass('prev') )
  728.                 var page_number = Number( jq('div.pagination span.current').html() ) - 1;
  729.             else
  730.                 var page_number = Number( jq(target).html() );
  731.  
  732.             bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope'), 'div.' + object, search_terms, page_number, jq.cookie('bp-' + object + '-extras') );
  733.  
  734.             return false;
  735.         }
  736.  
  737.     });
  738.    
  739.     /**** New Forum Directory Post **************************************/
  740.  
  741.     /* Hit the "New Topic" button on the forums directory page */
  742.     jq('a.show-hide-new').click( function() {
  743.         if ( !jq('div#new-topic-post').length )
  744.             return false;
  745.  
  746.         if ( jq('div#new-topic-post').is(":visible") )
  747.             jq('div#new-topic-post').slideUp(200);
  748.         else
  749.             jq('#new-topic-post').slideDown(200, function() {
  750.                 jq('#topic_title').focus();
  751.             } );
  752.  
  753.         return false;
  754.     });
  755.  
  756.     /* Cancel the posting of a new forum topic */
  757.     jq('input#submit_topic_cancel').click( function() {
  758.         if ( !jq('div#new-topic-post').length )
  759.             return false;
  760.  
  761.         jq('div#new-topic-post').slideUp(200);
  762.         return false;
  763.     });
  764.  
  765.     /* Clicking a forum tag */
  766.     jq('div#forum-directory-tags a').click( function() {
  767.         bp_filter_request( 'forums', 'tags', jq.cookie('bp-forums-scope'), 'div.forums', jq(this).html().replace( /&nbsp;/g, '-' ), 1, jq.cookie('bp-forums-extras') );
  768.         return false;
  769.     });
  770.  
  771.     /** Invite Friends Interface ****************************************/
  772.  
  773.     /* Select a user from the list of friends and add them to the invite list */
  774.     jq("div#invite-list input").click( function() {
  775.         jq('.ajax-loader').toggle();
  776.  
  777.         var friend_id = jq(this).val();
  778.  
  779.         if ( jq(this).prop('checked') == true )
  780.             var friend_action = 'invite';
  781.         else
  782.             var friend_action = 'uninvite';
  783.  
  784.         jq('div.item-list-tabs li.selected').addClass('loading');
  785.  
  786.         jq.post( ajaxurl, {
  787.             action: 'groups_invite_user',
  788.             'friend_action': friend_action,
  789.             'cookie': encodeURIComponent(document.cookie),
  790.             '_wpnonce': jq("input#_wpnonce_invite_uninvite_user").val(),
  791.             'friend_id': friend_id,
  792.             'group_id': jq("input#group_id").val()
  793.         },
  794.         function(response)
  795.         {
  796.             if ( jq("#message") )
  797.                 jq("#message").hide();
  798.  
  799.             jq('.ajax-loader').toggle();
  800.  
  801.             if ( friend_action == 'invite' ) {
  802.                 jq('#friend-list').append(response);
  803.             } else if ( friend_action == 'uninvite' ) {
  804.                 jq('#friend-list li#uid-' + friend_id).remove();
  805.             }
  806.  
  807.             jq('div.item-list-tabs li.selected').removeClass('loading');
  808.         });
  809.     });
  810.  
  811.     /* Remove a user from the list of users to invite to a group */
  812.     jq("#friend-list li a.remove").live('click', function() {
  813.         jq('.ajax-loader').toggle();
  814.  
  815.         var friend_id = jq(this).attr('id');
  816.         friend_id = friend_id.split('-');
  817.         friend_id = friend_id[1];
  818.  
  819.         jq.post( ajaxurl, {
  820.             action: 'groups_invite_user',
  821.             'friend_action': 'uninvite',
  822.             'cookie': encodeURIComponent(document.cookie),
  823.             '_wpnonce': jq("input#_wpnonce_invite_uninvite_user").val(),
  824.             'friend_id': friend_id,
  825.             'group_id': jq("input#group_id").val()
  826.         },
  827.         function(response)
  828.         {
  829.             jq('.ajax-loader').toggle();
  830.             jq('#friend-list li#uid-' + friend_id).remove();
  831.             jq('#invite-list input#f-' + friend_id).prop('checked', false);
  832.         });
  833.  
  834.         return false;
  835.     });
  836.  
  837.     /** Profile Visibility Settings *********************************/
  838.     jq('.field-visibility-settings').hide();
  839.     jq('.visibility-toggle-link').on( 'click', function() {
  840.         var toggle_div = jq(this).parent();
  841.        
  842.         jq(toggle_div).fadeOut( 600, function(){
  843.             jq(toggle_div).siblings('.field-visibility-settings').slideDown(400);
  844.         });
  845.        
  846.         return false;
  847.     } );
  848.  
  849.     jq('.field-visibility-settings-close').on( 'click', function() {
  850.         var settings_div = jq(this).parent();
  851.        
  852.         jq(settings_div).slideUp( 400, function(){
  853.             jq(settings_div).siblings('.field-visibility-settings-toggle').fadeIn(800);
  854.         });
  855.        
  856.         return false;
  857.     } );
  858.  
  859.  
  860.     /** Friendship Requests **************************************/
  861.  
  862.     /* Accept and Reject friendship request buttons */
  863.     jq("ul#friend-list a.accept, ul#friend-list a.reject").click( function() {
  864.         var button = jq(this);
  865.         var li = jq(this).parents('ul#friend-list li');
  866.         var action_div = jq(this).parents('li div.action');
  867.  
  868.         var id = li.attr('id').substr( 11, li.attr('id').length );
  869.         var link_href = button.attr('href');
  870.  
  871.         var nonce = link_href.split('_wpnonce=');
  872.         nonce = nonce[1];
  873.  
  874.         if ( jq(this).hasClass('accepted') || jq(this).hasClass('rejected') )
  875.             return false;
  876.  
  877.         if ( jq(this).hasClass('accept') ) {
  878.             var action = 'accept_friendship';
  879.             action_div.children('a.reject').css( 'visibility', 'hidden' );
  880.         } else {
  881.             var action = 'reject_friendship';
  882.             action_div.children('a.accept').css( 'visibility', 'hidden' );
  883.         }
  884.  
  885.         button.addClass('loading');
  886.  
  887.         jq.post( ajaxurl, {
  888.             action: action,
  889.             'cookie': encodeURIComponent(document.cookie),
  890.             'id': id,
  891.             '_wpnonce': nonce
  892.         },
  893.         function(response) {
  894.             button.removeClass('loading');
  895.  
  896.             if ( response[0] + response[1] == '-1' ) {
  897.                 li.prepend( response.substr( 2, response.length ) );
  898.                 li.children('div#message').hide().fadeIn(200);
  899.             } else {
  900.                 button.fadeOut( 100, function() {
  901.                     if ( jq(this).hasClass('accept') ) {
  902.                         action_div.children('a.reject').hide();
  903.                         jq(this).html( BP_DTheme.accepted ).fadeIn(50);
  904.                         jq(this).addClass('accepted');
  905.                     } else {
  906.                         action_div.children('a.accept').hide();
  907.                         jq(this).html( BP_DTheme.rejected ).fadeIn(50);
  908.                         jq(this).addClass('rejected');
  909.                     }
  910.                 });
  911.             }
  912.         });
  913.  
  914.         return false;
  915.     });
  916.  
  917.     /* Add / Remove friendship buttons */
  918.     jq("div.friendship-button a").live('click', function() {
  919.         jq(this).parent().addClass('loading');
  920.         var fid = jq(this).attr('id');
  921.         fid = fid.split('-');
  922.         fid = fid[1];
  923.  
  924.         var nonce = jq(this).attr('href');
  925.         nonce = nonce.split('?_wpnonce=');
  926.         nonce = nonce[1].split('&');
  927.         nonce = nonce[0];
  928.  
  929.         var thelink = jq(this);
  930.  
  931.         jq.post( ajaxurl, {
  932.             action: 'addremove_friend',
  933.             'cookie': encodeURIComponent(document.cookie),
  934.             'fid': fid,
  935.             '_wpnonce': nonce
  936.         },
  937.         function(response)
  938.         {
  939.             var action = thelink.attr('rel');
  940.             var parentdiv = thelink.parent();
  941.  
  942.             if ( action == 'add' ) {
  943.                 jq(parentdiv).fadeOut(200,
  944.                     function() {
  945.                         parentdiv.removeClass('add_friend');
  946.                         parentdiv.removeClass('loading');
  947.                         parentdiv.addClass('pending');
  948.                         parentdiv.fadeIn(200).html(response);
  949.                     }
  950.                     );
  951.  
  952.             } else if ( action == 'remove' ) {
  953.                 jq(parentdiv).fadeOut(200,
  954.                     function() {
  955.                         parentdiv.removeClass('remove_friend');
  956.                         parentdiv.removeClass('loading');
  957.                         parentdiv.addClass('add');
  958.                         parentdiv.fadeIn(200).html(response);
  959.                     }
  960.                     );
  961.             }
  962.         });
  963.         return false;
  964.     } );
  965.  
  966.     /** Group Join / Leave Buttons **************************************/
  967.  
  968.     jq("div.group-button a").live('click', function() {
  969.         var gid = jq(this).parent().attr('id');
  970.         gid = gid.split('-');
  971.         gid = gid[1];
  972.  
  973.         var nonce = jq(this).attr('href');
  974.         nonce = nonce.split('?_wpnonce=');
  975.         nonce = nonce[1].split('&');
  976.         nonce = nonce[0];
  977.  
  978.         var thelink = jq(this);
  979.  
  980.         jq.post( ajaxurl, {
  981.             action: 'joinleave_group',
  982.             'cookie': encodeURIComponent(document.cookie),
  983.             'gid': gid,
  984.             '_wpnonce': nonce
  985.         },
  986.         function(response)
  987.         {
  988.             var parentdiv = thelink.parent();
  989.  
  990.             if ( !jq('body.directory').length )
  991.                 location.href = location.href;
  992.             else {
  993.                 jq(parentdiv).fadeOut(200,
  994.                     function() {
  995.                         parentdiv.fadeIn(200).html(response);
  996.                     }
  997.                     );
  998.             }
  999.         });
  1000.         return false;
  1001.     } );
  1002.  
  1003.     /** Button disabling ************************************************/
  1004.  
  1005.     jq('div.pending').click(function() {
  1006.         return false;
  1007.     });
  1008.  
  1009.     /** Private Messaging ******************************************/
  1010.  
  1011.     /** Message search*/
  1012.     jq('.message-search').click( function(event) {
  1013.         if ( jq(this).hasClass('no-ajax') )
  1014.             return;
  1015.  
  1016.         var target = jq(event.target);
  1017.  
  1018.         if ( target.attr('type') == 'submit' ) {
  1019.             //var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' );
  1020.             var object = 'messages';
  1021.  
  1022.             bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope') , 'div.' + object, target.parent().children('label').children('input').val(), 1, jq.cookie('bp-' + object + '-extras') );
  1023.  
  1024.             return false;
  1025.         }
  1026.     });
  1027.  
  1028.     /* AJAX send reply functionality */
  1029.     jq("input#send_reply_button").click(
  1030.         function() {
  1031.             var order = jq('#messages_order').val() || 'ASC',
  1032.             offset = jq('#message-recipients').offset();
  1033.  
  1034.             var button = jq("input#send_reply_button");
  1035.             jq(button).addClass('loading');
  1036.  
  1037.             jq.post( ajaxurl, {
  1038.                 action: 'messages_send_reply',
  1039.                 'cookie': encodeURIComponent(document.cookie),
  1040.                 '_wpnonce': jq("input#send_message_nonce").val(),
  1041.  
  1042.                 'content': jq("#message_content").val(),
  1043.                 'send_to': jq("input#send_to").val(),
  1044.                 'subject': jq("input#subject").val(),
  1045.                 'thread_id': jq("input#thread_id").val()
  1046.             },
  1047.             function(response)
  1048.             {
  1049.                 if ( response[0] + response[1] == "-1" ) {
  1050.                     jq('form#send-reply').prepend( response.substr( 2, response.length ) );
  1051.                 } else {
  1052.                     jq('form#send-reply div#message').remove();
  1053.                     jq("#message_content").val('');
  1054.  
  1055.                     if ( 'ASC' == order ) {
  1056.                         jq('form#send-reply').before( response );
  1057.                     } else {
  1058.                         jq('#message-recipients').after( response );
  1059.                         jq(window).scrollTop(offset.top);
  1060.                     }
  1061.  
  1062.                     jq("div.new-message").hide().slideDown( 200, function() {
  1063.                         jq('div.new-message').removeClass('new-message');
  1064.                     });
  1065.                 }
  1066.                 jq(button).removeClass('loading');
  1067.             });
  1068.  
  1069.             return false;
  1070.         }
  1071.         );
  1072.  
  1073.     /* Marking private messages as read and unread */
  1074.     jq("a#mark_as_read, a#mark_as_unread").click(function() {
  1075.         var checkboxes_tosend = '';
  1076.         var checkboxes = jq("#message-threads tr td input[type='checkbox']");
  1077.  
  1078.         if ( 'mark_as_unread' == jq(this).attr('id') ) {
  1079.             var currentClass = 'read'
  1080.             var newClass = 'unread'
  1081.             var unreadCount = 1;
  1082.             var inboxCount = 0;
  1083.             var unreadCountDisplay = 'inline';
  1084.             var action = 'messages_markunread';
  1085.         } else {
  1086.             var currentClass = 'unread'
  1087.             var newClass = 'read'
  1088.             var unreadCount = 0;
  1089.             var inboxCount = 1;
  1090.             var unreadCountDisplay = 'none';
  1091.             var action = 'messages_markread';
  1092.         }
  1093.  
  1094.         checkboxes.each( function(i) {
  1095.             if(jq(this).is(':checked')) {
  1096.                 if ( jq('tr#m-' + jq(this).attr('value')).hasClass(currentClass) ) {
  1097.                     checkboxes_tosend += jq(this).attr('value');
  1098.                     jq('tr#m-' + jq(this).attr('value')).removeClass(currentClass);
  1099.                     jq('tr#m-' + jq(this).attr('value')).addClass(newClass);
  1100.                     var thread_count = jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').html();
  1101.  
  1102.                     jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').html(unreadCount);
  1103.                     jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').css('display', unreadCountDisplay);
  1104.  
  1105.                     var inboxcount = jq('tr.unread').length;
  1106.  
  1107.                     jq('a#user-messages span').html( inboxcount );
  1108.  
  1109.                     if ( i != checkboxes.length - 1 ) {
  1110.                         checkboxes_tosend += ','
  1111.                     }
  1112.                 }
  1113.             }
  1114.         });
  1115.         jq.post( ajaxurl, {
  1116.             action: action,
  1117.             'thread_ids': checkboxes_tosend
  1118.         });
  1119.         return false;
  1120.     });
  1121.  
  1122.     /* Selecting unread and read messages in inbox */
  1123.     jq("select#message-type-select").change(
  1124.         function() {
  1125.             var selection = jq("select#message-type-select").val();
  1126.             var checkboxes = jq("td input[type='checkbox']");
  1127.             checkboxes.each( function(i) {
  1128.                 checkboxes[i].checked = "";
  1129.             });
  1130.  
  1131.             switch(selection) {
  1132.                 case 'unread':
  1133.                     var checkboxes = jq("tr.unread td input[type='checkbox']");
  1134.                     break;
  1135.                 case 'read':
  1136.                     var checkboxes = jq("tr.read td input[type='checkbox']");
  1137.                     break;
  1138.             }
  1139.             if ( selection != '' ) {
  1140.                 checkboxes.each( function(i) {
  1141.                     checkboxes[i].checked = "checked";
  1142.                 });
  1143.             } else {
  1144.                 checkboxes.each( function(i) {
  1145.                     checkboxes[i].checked = "";
  1146.                 });
  1147.             }
  1148.         }
  1149.         );
  1150.  
  1151.     /* Bulk delete messages */
  1152.     jq("a#delete_inbox_messages, a#delete_sentbox_messages").click( function() {
  1153.         checkboxes_tosend = '';
  1154.         checkboxes = jq("#message-threads tr td input[type='checkbox']");
  1155.  
  1156.         jq('div#message').remove();
  1157.         jq(this).addClass('loading');
  1158.  
  1159.         jq(checkboxes).each( function(i) {
  1160.             if( jq(this).is(':checked') )
  1161.                 checkboxes_tosend += jq(this).attr('value') + ',';
  1162.         });
  1163.  
  1164.         if ( '' == checkboxes_tosend ) {
  1165.             jq(this).removeClass('loading');
  1166.             return false;
  1167.         }
  1168.  
  1169.         jq.post( ajaxurl, {
  1170.             action: 'messages_delete',
  1171.             'thread_ids': checkboxes_tosend
  1172.         }, function(response) {
  1173.             if ( response[0] + response[1] == "-1" ) {
  1174.                 jq('#message-threads').prepend( response.substr( 2, response.length ) );
  1175.             } else {
  1176.                 jq('#message-threads').before( '<div id="message" class="updated"><p>' + response + '</p></div>' );
  1177.  
  1178.                 jq(checkboxes).each( function(i) {
  1179.                     if( jq(this).is(':checked') )
  1180.                         jq(this).parent().parent().fadeOut(150);
  1181.                 });
  1182.             }
  1183.  
  1184.             jq('div#message').hide().slideDown(150);
  1185.             jq("a#delete_inbox_messages, a#delete_sentbox_messages").removeClass('loading');
  1186.         });
  1187.         return false;
  1188.     });
  1189.  
  1190.     /* Close site wide notices in the sidebar */
  1191.     jq("a#close-notice").click( function() {
  1192.         jq(this).addClass('loading');
  1193.         jq('div#sidebar div.error').remove();
  1194.  
  1195.         jq.post( ajaxurl, {
  1196.             action: 'messages_close_notice',
  1197.             'notice_id': jq('.notice').attr('rel').substr( 2, jq('.notice').attr('rel').length )
  1198.         },
  1199.         function(response) {
  1200.             jq("a#close-notice").removeClass('loading');
  1201.  
  1202.             if ( response[0] + response[1] == '-1' ) {
  1203.                 jq('.notice').prepend( response.substr( 2, response.length ) );
  1204.                 jq( 'div#sidebar div.error').hide().fadeIn( 200 );
  1205.             } else {
  1206.                 jq('.notice').slideUp( 100 );
  1207.             }
  1208.         });
  1209.         return false;
  1210.     });
  1211.  
  1212.     /* Admin Bar & wp_list_pages Javascript IE6 hover class */
  1213.     jq("#wp-admin-bar ul.main-nav li, #nav li").mouseover( function() {
  1214.         jq(this).addClass('sfhover');
  1215.     });
  1216.  
  1217.     jq("#wp-admin-bar ul.main-nav li, #nav li").mouseout( function() {
  1218.         jq(this).removeClass('sfhover');
  1219.     });
  1220.  
  1221.     /* Clear BP cookies on logout */
  1222.     jq('a.logout').click( function() {
  1223.         jq.cookie('bp-activity-scope', null, {
  1224.             path: '/'
  1225.         });
  1226.         jq.cookie('bp-activity-filter', null, {
  1227.             path: '/'
  1228.         });
  1229.         jq.cookie('bp-activity-oldestpage', null, {
  1230.             path: '/'
  1231.         });
  1232.  
  1233.         var objects = [ 'members', 'groups', 'blogs', 'forums' ];
  1234.         jq(objects).each( function(i) {
  1235.             jq.cookie('bp-' + objects[i] + '-scope', null, {
  1236.                 path: '/'
  1237.             } );
  1238.             jq.cookie('bp-' + objects[i] + '-filter', null, {
  1239.                 path: '/'
  1240.             } );
  1241.             jq.cookie('bp-' + objects[i] + '-extras', null, {
  1242.                 path: '/'
  1243.             } );
  1244.         });
  1245.     });
  1246.    
  1247.    
  1248.     /* Scroll a lot of menu items in BuddyPress sub nav menu  ------start*/
  1249.    
  1250.    
  1251.     if(screen.width > 1024){
  1252.         var selector_nav_wrap = '.item-list-tabs[role="navigation"]:not("#subnav"), .item-list-tabs#object-nav';
  1253.    
  1254.         jq(selector_nav_wrap).prepend('<button class="prev">&lt;</button><button class="next">&gt;</button>').find('ul').wrap('<div class="bp-nav-wrap">');
  1255.    
  1256.         // Enable or leave the keys
  1257.         jq(selector_nav_wrap).each(function(){
  1258.             if(jq('li:last',this).width()+jq('li:last',this).offset().left-jq('li:first',this).offset().left>jq('div',this).width()){
  1259.                 // enable the buttons
  1260.                 jq('button',this).css('display','inline');
  1261.                 jq('button.prev',this).css('display','none');
  1262.             }
  1263.         });
  1264.    
  1265.    
  1266.         jq(selector_nav_wrap).on('click', '.next', function(){
  1267.             //Remove the exist selector
  1268.             //Set the width to the widest of either
  1269.             var $div =jq('div',this.parentNode)
  1270.             ,maxoffset = jq('li:last',$div).width()+jq('li:last',$div).offset().left - jq('li:first',$div).offset().left - $div.width()
  1271.             ,offset = Math.abs(parseInt( jq('ul',$div).css('marginLeft') ))
  1272.             ,diff = $div.width();
  1273.  
  1274.             if( offset >= maxoffset )
  1275.                 return;
  1276.             else if ( offset + diff >= maxoffset ){
  1277.                 diff = maxoffset - offset + 20;
  1278.                 // Hide this
  1279.                 jq(this).css('display','none');
  1280.             }
  1281.             // enable the other
  1282.             jq('.prev', this.parentNode).css('display','block');       
  1283.        
  1284.             jq("ul", jq(this).parent() ).animate({
  1285.                 marginLeft: "-=" + diff
  1286.             },400, 'swing');
  1287.         });
  1288.    
  1289.         jq(selector_nav_wrap).on('click', '.prev', function(){
  1290.  
  1291.             var offset = Math.abs(parseInt( jq('ul',this.parentNode).css('marginLeft') ));
  1292.             var diff = jq('div',this.parentNode).width();
  1293.             if( offset <= 0 )
  1294.                 return;
  1295.             else if ( offset - diff <= 0 ){
  1296.                 jq(this).css('display','none');    
  1297.                 diff = offset;
  1298.             }
  1299.             jq('.next', this.parentNode).css('display','block');
  1300.  
  1301.             jq("ul",jq(this).parent()).animate({
  1302.                 marginLeft: '+='+diff
  1303.             },400, 'swing');
  1304.         });
  1305.     }
  1306.     /* Scroll a lot of menu items in BuddyPress sub nav menu  ------end*/
  1307.    
  1308.     jq('.allow-dirrect-links').click( function(){
  1309.         window.location = jq(this).attr('data-url');
  1310.     });
  1311.    
  1312.     //add class to plugins pages
  1313.     jq('#content').addClass('span8');
  1314.    
  1315. });
  1316.  
  1317. /* Setup activity scope and filter based on the current cookie settings. */
  1318. function bp_init_activity() {
  1319.     /* Reset the page */
  1320.     jq.cookie( 'bp-activity-oldestpage', 1, {
  1321.         path: '/'
  1322.     } );
  1323.  
  1324.     if ( null != jq.cookie('bp-activity-filter') && jq('#activity-filter-select').length )
  1325.         jq('#activity-filter-select select option[value="' + jq.cookie('bp-activity-filter') + '"]').prop( 'selected', true );
  1326.  
  1327.     /* Activity Tab Set */
  1328.     if ( null != jq.cookie('bp-activity-scope') && jq('div.activity-type-tabs').length ) {
  1329.         jq('div.activity-type-tabs li').each( function() {
  1330.             jq(this).removeClass('selected');
  1331.         });
  1332.         jq('li#activity-' + jq.cookie('bp-activity-scope') + ', div.item-list-tabs li.current').addClass('selected');
  1333.     }
  1334. }
  1335.  
  1336. /* Setup object scope and filter based on the current cookie settings for the object. */
  1337. function bp_init_objects(objects) {
  1338.     jq(objects).each( function(i) {
  1339.         if ( null != jq.cookie('bp-' + objects[i] + '-filter') && jq('li#' + objects[i] + '-order-select select').length ){
  1340.             jq('li#' + objects[i] + '-order-select select option[value="' + jq.cookie('bp-' + objects[i] + '-filter') + '"]').prop( 'selected', true );
  1341.         }
  1342.         //setup displaymode select position
  1343.         if ( null != jq.cookie('bp-' + objects[i] + '-displaymode') && jq('li#' + objects[i] + '-displaymode-select select').length ){
  1344.             jq('li#' + objects[i] + '-displaymode-select select option[value="' + jq.cookie('bp-' + objects[i] + '-displaymode') + '"]').prop( 'selected', true );
  1345.         }
  1346.  
  1347.         if ( null != jq.cookie('bp-' + objects[i] + '-scope') && jq('div.' + objects[i]).length ) {
  1348.             jq('div.item-list-tabs li').removeClass('selected');
  1349.             var set_seleted_class_object = jq('div.item-list-tabs li#' + objects[i] + '-' + jq.cookie('bp-' + objects[i] + '-scope') + ', div.item-list-tabs#object-nav li.current')
  1350.             if(set_seleted_class_object.size() > 0){
  1351.                 set_seleted_class_object.addClass('selected');
  1352.             } else {
  1353.                 jq('div.item-list-tabs li#' + objects[i] + '-all, div.item-list-tabs#object-nav li.current').addClass('selected');
  1354.             }
  1355.         }
  1356.     });
  1357. }
  1358.  
  1359. /* Filter the current content list (groups/members/blogs/topics) */
  1360. function bp_filter_request( object, filter, scope, target, search_terms, page, extras ) {
  1361.     if ( 'activity' == object )
  1362.         return false;
  1363.  
  1364.     if ( jq.query.get('s') && !search_terms )
  1365.         search_terms = jq.query.get('s');
  1366.  
  1367.     if ( null == scope )
  1368.         scope = 'all';
  1369.  
  1370.     /* Save the settings we want to remain persistent to a cookie */
  1371.     jq.cookie( 'bp-' + object + '-scope', scope, {
  1372.         path: '/'
  1373.     } );
  1374.     jq.cookie( 'bp-' + object + '-filter', filter, {
  1375.         path: '/'
  1376.     } );
  1377.     jq.cookie( 'bp-' + object + '-extras', extras, {
  1378.         path: '/'
  1379.     } );
  1380. //    console.log(object, filter, scope, target, search_terms, page, extras)
  1381.     /* Set the correct selected nav and filter */
  1382.     jq('div.item-list-tabs li').removeClass('selected');
  1383.    
  1384.     var current_tab = jq('div.item-list-tabs li#' + object + '-' + scope + ', div.item-list-tabs#object-nav li.current');
  1385.    
  1386.     if(current_tab.size() > 0){
  1387.         current_tab.addClass('selected');
  1388.     } else {
  1389.         jq('div.item-list-tabs li#' + object + '-all').addClass('selected');
  1390.     }
  1391.     jq('div.item-list-tabs li.selected').addClass('loading');
  1392.     jq('div.item-list-tabs select option[value="' + filter + '"]').prop( 'selected', true );
  1393.  
  1394.     if ( 'friends' == object )
  1395.         object = 'members';
  1396.  
  1397.     if ( bp_ajax_request )
  1398.         bp_ajax_request.abort();
  1399.  
  1400.     bp_ajax_request = jq.post( ajaxurl, {
  1401.         action: object + '_filter',
  1402.         'cookie': encodeURIComponent(document.cookie),
  1403.         'object': object,
  1404.         'filter': filter,
  1405.         'search_terms': search_terms,
  1406.         'scope': scope,
  1407.         'page': page,
  1408.         'extras': extras
  1409.     },
  1410.     function(response)
  1411.     {
  1412.         jq(target).fadeOut( 100, function() {
  1413.             jq(this).html(response);
  1414.             jq(this).fadeIn(100);
  1415.         });
  1416.         jq('div.item-list-tabs li.loading').removeClass('loading').addClass('selected');
  1417.     });
  1418. }
  1419.  
  1420. /* Displaymode the current content list or grid (groups/members/group members/member frends) */
  1421. function bp_displaymode_request( object, displaymode, scope, target, search_terms, page, extras ) {
  1422.     if ( 'activity' == object )
  1423.         return false;
  1424.  
  1425.     if ( jq.query.get('s') && !search_terms )
  1426.         search_terms = jq.query.get('s');
  1427.  
  1428.     if ( null == scope )
  1429.         scope = 'all';
  1430.  
  1431.     /* Save the settings we want to remain persistent to a cookie */
  1432.     jq.cookie( 'bp-' + object + '-scope', scope, {
  1433.         path: '/'
  1434.     } );
  1435.     jq.cookie( 'bp-' + object + '-displaymode', displaymode, {
  1436.         path: '/'
  1437.     } );
  1438.     jq.cookie( 'bp-' + object + '-extras', extras, {
  1439.         path: '/'
  1440.     } );
  1441.  
  1442.     /* Set the correct selected nav and displymode */
  1443.     jq('div.item-list-tabs li').removeClass('selected');
  1444.     jq('div.item-list-tabs li#' + object + '-' + scope + ', div.item-list-tabs#object-nav li.current').addClass('selected');
  1445.     jq('div.item-list-tabs li.selected').addClass('loading');
  1446.     jq('div.item-list-tabs select option[value="' + displaymode + '"]').prop( 'selected', true );
  1447.  
  1448.     if ( 'friends' == object )
  1449.         object = 'members';
  1450.  
  1451.     if ( bp_ajax_request )
  1452.         bp_ajax_request.abort();
  1453.     bp_ajax_request = jq.post( ajaxurl, {
  1454.         action: object + '_displaymode',
  1455.         'cookie': encodeURIComponent(document.cookie),
  1456.         'object': object,
  1457.         'displaymode': displaymode,
  1458.         'search_terms': search_terms,
  1459.         'scope': scope,
  1460.         'page': page,
  1461.         'extras': extras
  1462.     },
  1463.     function(response, textStatus, jqXHR)
  1464.     {
  1465.         jq(target).fadeOut( 100, function() {
  1466.             jq(this).html(response);
  1467.             jq(this).fadeIn(100);
  1468.         });
  1469.         jq('div.item-list-tabs li.selected').removeClass('loading').addClass('selected');
  1470.     });
  1471. }
  1472.  
  1473. /* Activity Loop Requesting */
  1474. function bp_activity_request(scope, filter) {
  1475.     /* Save the type and filter to a session cookie */
  1476.     jq.cookie( 'bp-activity-scope', scope, {
  1477.         path: '/'
  1478.     } );
  1479.     jq.cookie( 'bp-activity-filter', filter, {
  1480.         path: '/'
  1481.     } );
  1482.     jq.cookie( 'bp-activity-oldestpage', 1, {
  1483.         path: '/'
  1484.     } );
  1485.  
  1486.     /* Remove selected and loading classes from tabs */
  1487.     jq('div.item-list-tabs li').each( function() {
  1488.         jq(this).removeClass('selected loading');
  1489.     });
  1490.     /* Set the correct selected nav and filter */
  1491.     jq('li#activity-' + scope + ', div.item-list-tabs li.current').addClass('selected');
  1492.     jq('div#object-nav.item-list-tabs li.selected, div.activity-type-tabs li.selected').addClass('loading');
  1493.     jq('#activity-filter-select select option[value="' + filter + '"]').prop( 'selected', true );
  1494.  
  1495.     /* Reload the activity stream based on the selection */
  1496.     jq('.widget_bp_activity_widget h2 span.ajax-loader').show();
  1497.  
  1498.     if ( bp_ajax_request )
  1499.         bp_ajax_request.abort();
  1500.  
  1501.     bp_ajax_request = jq.post( ajaxurl, {
  1502.         action: 'activity_widget_filter',
  1503.         'cookie': encodeURIComponent(document.cookie),
  1504.         '_wpnonce_activity_filter': jq("input#_wpnonce_activity_filter").val(),
  1505.         'scope': scope,
  1506.         'filter': filter
  1507.     },
  1508.     function(response)
  1509.     {
  1510.         jq('.widget_bp_activity_widget h2 span.ajax-loader').hide();
  1511.  
  1512.         jq('div.activity').fadeOut( 100, function() {
  1513.             jq(this).html(response.contents);
  1514.             jq(this).fadeIn(100);
  1515.  
  1516.             /* Selectively hide comments */
  1517.             bp_dtheme_hide_comments();
  1518.         });
  1519.  
  1520.         /* Update the feed link */
  1521.         if ( null != response.feed_url )
  1522.             jq('.directory div#subnav li.feed a, .home-page div#subnav li.feed a').attr('href', response.feed_url);
  1523.  
  1524.         jq('div.item-list-tabs li.selected').removeClass('loading');
  1525.  
  1526.     }, 'json' );
  1527. }
  1528.  
  1529. /* Hide long lists of activity comments, only show the latest five root comments. */
  1530. function bp_dtheme_hide_comments() {
  1531.     var comments_divs = jq('div.activity-comments');
  1532.  
  1533.     if ( !comments_divs.length )
  1534.         return false;
  1535.  
  1536.     comments_divs.each( function() {
  1537.         if ( jq(this).children('ul').children('li').length < 1 ) return;
  1538.  
  1539.         var comments_div = jq(this);
  1540.         var parent_li = comments_div.parents('ul#activity-stream > li');
  1541.         var comment_lis = jq(this).children('ul').children('li');
  1542.         var comment_count = ' ';
  1543.  
  1544.         if ( jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').length )
  1545.             var comment_count = jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').html();
  1546.  
  1547.         comment_lis.each( function(i) {
  1548.             /* Show the latest 5 root comments */
  1549.             if ( i < comment_lis.length - 1 ) {
  1550.                 jq(this).addClass('hidden');
  1551.                 jq(this).toggle();
  1552.  
  1553.                 if ( !i )
  1554.                     jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + BP_DTheme.show_all_comments + '">' + BP_DTheme.show_all + ' ' + comment_count + ' ' + BP_DTheme.comments + '</a></li>' );
  1555.             }
  1556.         });
  1557.  
  1558.     });
  1559. }
  1560.  
  1561. /* Helper Functions */
  1562.  
  1563. function checkAll() {
  1564.     var checkboxes = document.getElementsByTagName("input");
  1565.     for(var i=0; i<checkboxes.length; i++) {
  1566.         if(checkboxes[i].type == "checkbox") {
  1567.             if($("check_all").checked == "") {
  1568.                 checkboxes[i].checked = "";
  1569.             }
  1570.             else {
  1571.                 checkboxes[i].checked = "checked";
  1572.             }
  1573.         }
  1574.     }
  1575. }
  1576.  
  1577. function clear(container) {
  1578.     if( !document.getElementById(container) ) return;
  1579.  
  1580.     var container = document.getElementById(container);
  1581.  
  1582.     if ( radioButtons = container.getElementsByTagName('INPUT') ) {
  1583.         for(var i=0; i<radioButtons.length; i++) {
  1584.             radioButtons[i].checked = '';
  1585.         }
  1586.     }
  1587.  
  1588.     if ( options = container.getElementsByTagName('OPTION') ) {
  1589.         for(var i=0; i<options.length; i++) {
  1590.             options[i].selected = false;
  1591.         }
  1592.     }
  1593.  
  1594.     return;
  1595. }
  1596.  
  1597. /* ScrollTo plugin - just inline and minified */
  1598. ;
  1599. (function(d){
  1600.     var k=d.scrollTo=function(a,i,e){
  1601.         d(window).scrollTo(a,i,e)
  1602.         };
  1603.        
  1604.     k.defaults={
  1605.         axis:'xy',
  1606.         duration:parseFloat(d.fn.jquery)>=1.3?0:1
  1607.         };
  1608.        
  1609.     k.window=function(a){
  1610.         return d(window)._scrollable()
  1611.         };
  1612.        
  1613.     d.fn._scrollable=function(){
  1614.         return this.map(function(){
  1615.             var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;
  1616.             if(!i)return a;
  1617.             var e=(a.contentWindow||a).document||a.ownerDocument||a;
  1618.             return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement
  1619.             })
  1620.         };
  1621.        
  1622.     d.fn.scrollTo=function(n,j,b){
  1623.         if(typeof j=='object'){
  1624.             b=j;
  1625.             j=0
  1626.             }
  1627.             if(typeof b=='function')b={
  1628.             onAfter:b
  1629.         };
  1630.        
  1631.         if(n=='max')n=9e9;
  1632.         b=d.extend({},k.defaults,b);
  1633.         j=j||b.speed||b.duration;
  1634.         b.queue=b.queue&&b.axis.length>1;
  1635.         if(b.queue)j/=2;
  1636.         b.offset=p(b.offset);
  1637.         b.over=p(b.over);
  1638.         return this._scrollable().each(function(){
  1639.             var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');
  1640.             switch(typeof f){
  1641.                 case'number':case'string':
  1642.                     if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){
  1643.                     f=p(f);
  1644.                     break
  1645.                 }
  1646.                 f=d(f,this);
  1647.                 case'object':
  1648.                     if(f.is||f.style)s=(f=d(f)).offset()
  1649.                     }
  1650.                     d.each(b.axis.split(''),function(a,i){
  1651.                 var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);
  1652.                 if(s){
  1653.                     g[c]=s[h]+(u?0:l-r.offset()[h]);
  1654.                     if(b.margin){
  1655.                         g[c]-=parseInt(f.css('margin'+e))||0;
  1656.                         g[c]-=parseInt(f.css('border'+e+'Width'))||0
  1657.                         }
  1658.                         g[c]+=b.offset[h]||0;
  1659.                     if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]
  1660.                         }else{
  1661.                     var o=f[h];
  1662.                     g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o
  1663.                     }
  1664.                     if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);
  1665.                 if(!a&&b.queue){
  1666.                     if(l!=g[c])t(b.onAfterFirst);
  1667.                     delete g[c]
  1668.                 }
  1669.             });
  1670.         t(b.onAfter);
  1671.             function t(a){
  1672.             r.animate(g,j,b.easing,a&&function(){
  1673.                 a.call(this,n,b)
  1674.                 })
  1675.             }
  1676.         }).end()
  1677.     };
  1678.    
  1679. k.max=function(a,i){
  1680.     var e=i=='x'?'Width':'Height',h='scroll'+e;
  1681.     if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();
  1682.     var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;
  1683.     return Math.max(l[h],m[h])-Math.min(l[c],m[c])
  1684.     };
  1685.    
  1686. function p(a){
  1687.     return typeof a=='object'?a:{
  1688.         top:a,
  1689.         left:a
  1690.     }
  1691. }
  1692. })(jQuery);
  1693.  
  1694. /* jQuery Easing Plugin, v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ */
  1695. jQuery.easing.jswing=jQuery.easing.swing;
  1696. jQuery.extend(jQuery.easing,{
  1697.     def:"easeOutQuad",
  1698.     swing:function(e,f,a,h,g){
  1699.         return jQuery.easing[jQuery.easing.def](e,f,a,h,g)
  1700.         },
  1701.     easeInQuad:function(e,f,a,h,g){
  1702.         return h*(f/=g)*f+a
  1703.         },
  1704.     easeOutQuad:function(e,f,a,h,g){
  1705.         return -h*(f/=g)*(f-2)+a
  1706.         },
  1707.     easeInOutQuad:function(e,f,a,h,g){
  1708.         if((f/=g/2)<1){
  1709.             return h/2*f*f+a
  1710.             }
  1711.             return -h/2*((--f)*(f-2)-1)+a
  1712.         },
  1713.     easeInCubic:function(e,f,a,h,g){
  1714.         return h*(f/=g)*f*f+a
  1715.         },
  1716.     easeOutCubic:function(e,f,a,h,g){
  1717.         return h*((f=f/g-1)*f*f+1)+a
  1718.         },
  1719.     easeInOutCubic:function(e,f,a,h,g){
  1720.         if((f/=g/2)<1){
  1721.             return h/2*f*f*f+a
  1722.             }
  1723.             return h/2*((f-=2)*f*f+2)+a
  1724.         },
  1725.     easeInQuart:function(e,f,a,h,g){
  1726.         return h*(f/=g)*f*f*f+a
  1727.         },
  1728.     easeOutQuart:function(e,f,a,h,g){
  1729.         return -h*((f=f/g-1)*f*f*f-1)+a
  1730.         },
  1731.     easeInOutQuart:function(e,f,a,h,g){
  1732.         if((f/=g/2)<1){
  1733.             return h/2*f*f*f*f+a
  1734.             }
  1735.             return -h/2*((f-=2)*f*f*f-2)+a
  1736.         },
  1737.     easeInQuint:function(e,f,a,h,g){
  1738.         return h*(f/=g)*f*f*f*f+a
  1739.         },
  1740.     easeOutQuint:function(e,f,a,h,g){
  1741.         return h*((f=f/g-1)*f*f*f*f+1)+a
  1742.         },
  1743.     easeInOutQuint:function(e,f,a,h,g){
  1744.         if((f/=g/2)<1){
  1745.             return h/2*f*f*f*f*f+a
  1746.             }
  1747.             return h/2*((f-=2)*f*f*f*f+2)+a
  1748.         },
  1749.     easeInSine:function(e,f,a,h,g){
  1750.         return -h*Math.cos(f/g*(Math.PI/2))+h+a
  1751.         },
  1752.     easeOutSine:function(e,f,a,h,g){
  1753.         return h*Math.sin(f/g*(Math.PI/2))+a
  1754.         },
  1755.     easeInOutSine:function(e,f,a,h,g){
  1756.         return -h/2*(Math.cos(Math.PI*f/g)-1)+a
  1757.         },
  1758.     easeInExpo:function(e,f,a,h,g){
  1759.         return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a
  1760.         },
  1761.     easeOutExpo:function(e,f,a,h,g){
  1762.         return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a
  1763.         },
  1764.     easeInOutExpo:function(e,f,a,h,g){
  1765.         if(f==0){
  1766.             return a
  1767.             }
  1768.             if(f==g){
  1769.             return a+h
  1770.             }
  1771.             if((f/=g/2)<1){
  1772.             return h/2*Math.pow(2,10*(f-1))+a
  1773.             }
  1774.             return h/2*(-Math.pow(2,-10*--f)+2)+a
  1775.         },
  1776.     easeInCirc:function(e,f,a,h,g){
  1777.         return -h*(Math.sqrt(1-(f/=g)*f)-1)+a
  1778.         },
  1779.     easeOutCirc:function(e,f,a,h,g){
  1780.         return h*Math.sqrt(1-(f=f/g-1)*f)+a
  1781.         },
  1782.     easeInOutCirc:function(e,f,a,h,g){
  1783.         if((f/=g/2)<1){
  1784.             return -h/2*(Math.sqrt(1-f*f)-1)+a
  1785.             }
  1786.             return h/2*(Math.sqrt(1-(f-=2)*f)+1)+a
  1787.         },
  1788.     easeInElastic:function(f,h,e,l,k){
  1789.         var i=1.70158;
  1790.         var j=0;
  1791.         var g=l;
  1792.         if(h==0){
  1793.             return e
  1794.             }
  1795.             if((h/=k)==1){
  1796.             return e+l
  1797.             }
  1798.             if(!j){
  1799.             j=k*0.3
  1800.             }
  1801.             if(g<Math.abs(l)){
  1802.             g=l;
  1803.             var i=j/4
  1804.             }else{
  1805.             var i=j/(2*Math.PI)*Math.asin(l/g)
  1806.             }
  1807.             return -(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e
  1808.         },
  1809.     easeOutElastic:function(f,h,e,l,k){
  1810.         var i=1.70158;
  1811.         var j=0;
  1812.         var g=l;
  1813.         if(h==0){
  1814.             return e
  1815.             }
  1816.             if((h/=k)==1){
  1817.             return e+l
  1818.             }
  1819.             if(!j){
  1820.             j=k*0.3
  1821.             }
  1822.             if(g<Math.abs(l)){
  1823.             g=l;
  1824.             var i=j/4
  1825.             }else{
  1826.             var i=j/(2*Math.PI)*Math.asin(l/g)
  1827.             }
  1828.             return g*Math.pow(2,-10*h)*Math.sin((h*k-i)*(2*Math.PI)/j)+l+e
  1829.         },
  1830.     easeInOutElastic:function(f,h,e,l,k){
  1831.         var i=1.70158;
  1832.         var j=0;
  1833.         var g=l;
  1834.         if(h==0){
  1835.             return e
  1836.             }
  1837.             if((h/=k/2)==2){
  1838.             return e+l
  1839.             }
  1840.             if(!j){
  1841.             j=k*(0.3*1.5)
  1842.             }
  1843.             if(g<Math.abs(l)){
  1844.             g=l;
  1845.             var i=j/4
  1846.             }else{
  1847.             var i=j/(2*Math.PI)*Math.asin(l/g)
  1848.             }
  1849.             if(h<1){
  1850.             return -0.5*(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e
  1851.             }
  1852.             return g*Math.pow(2,-10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j)*0.5+l+e
  1853.         },
  1854.     easeInBack:function(e,f,a,i,h,g){
  1855.         if(g==undefined){
  1856.             g=1.70158
  1857.             }
  1858.             return i*(f/=h)*f*((g+1)*f-g)+a
  1859.         },
  1860.     easeOutBack:function(e,f,a,i,h,g){
  1861.         if(g==undefined){
  1862.             g=1.70158
  1863.             }
  1864.             return i*((f=f/h-1)*f*((g+1)*f+g)+1)+a
  1865.         },
  1866.     easeInOutBack:function(e,f,a,i,h,g){
  1867.         if(g==undefined){
  1868.             g=1.70158
  1869.             }
  1870.             if((f/=h/2)<1){
  1871.             return i/2*(f*f*(((g*=(1.525))+1)*f-g))+a
  1872.             }
  1873.             return i/2*((f-=2)*f*(((g*=(1.525))+1)*f+g)+2)+a
  1874.         },
  1875.     easeInBounce:function(e,f,a,h,g){
  1876.         return h-jQuery.easing.easeOutBounce(e,g-f,0,h,g)+a
  1877.         },
  1878.     easeOutBounce:function(e,f,a,h,g){
  1879.         if((f/=g)<(1/2.75)){
  1880.             return h*(7.5625*f*f)+a
  1881.             }else{
  1882.             if(f<(2/2.75)){
  1883.                 return h*(7.5625*(f-=(1.5/2.75))*f+0.75)+a
  1884.                 }else{
  1885.                 if(f<(2.5/2.75)){
  1886.                     return h*(7.5625*(f-=(2.25/2.75))*f+0.9375)+a
  1887.                     }else{
  1888.                     return h*(7.5625*(f-=(2.625/2.75))*f+0.984375)+a
  1889.                     }
  1890.                 }
  1891.         }
  1892. },
  1893. easeInOutBounce:function(e,f,a,h,g){
  1894.     if(f<g/2){
  1895.         return jQuery.easing.easeInBounce(e,f*2,0,h,g)*0.5+a
  1896.         }
  1897.         return jQuery.easing.easeOutBounce(e,f*2-g,0,h,g)*0.5+h*0.5+a
  1898.     }
  1899. });
  1900.  
  1901. /* jQuery Cookie plugin */
  1902. jQuery.cookie=function(name,value,options){
  1903.     if(typeof value!='undefined'){
  1904.         options=options||{};
  1905.        
  1906.         if(value===null){
  1907.             value='';
  1908.             options.expires=-1;
  1909.         }
  1910.         var expires='';
  1911.         if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){
  1912.             var date;
  1913.             if(typeof options.expires=='number'){
  1914.                 date=new Date();
  1915.                 date.setTime(date.getTime()+(options.expires*24*60*60*1000));
  1916.             }else{
  1917.                 date=options.expires;
  1918.             }
  1919.             expires='; expires='+date.toUTCString();
  1920.         }
  1921.         var path=options.path?'; path='+(options.path):'';
  1922.         var domain=options.domain?'; domain='+(options.domain):'';
  1923.         var secure=options.secure?'; secure':'';
  1924.         document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');
  1925.     }else{
  1926.         var cookieValue=null;
  1927.         if(document.cookie&&document.cookie!=''){
  1928.             var cookies=document.cookie.split(';');
  1929.             for(var i=0;i<cookies.length;i++){
  1930.                 var cookie=jQuery.trim(cookies[i]);
  1931.                 if(cookie.substring(0,name.length+1)==(name+'=')){
  1932.                     cookieValue=decodeURIComponent(cookie.substring(name.length+1));
  1933.                     break;
  1934.                 }
  1935.             }
  1936.             }
  1937.         return cookieValue;
  1938. }
  1939. };
  1940.  
  1941. /* jQuery querystring plugin */
  1942. eval(function(p,a,c,k,e,d){
  1943.     e=function(c){
  1944.         return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))
  1945.         };
  1946.        
  1947.     if(!''.replace(/^/,String)){
  1948.         while(c--){
  1949.             d[e(c)]=k[c]||e(c)
  1950.             }
  1951.             k=[function(e){
  1952.             return d[e]
  1953.             }];
  1954.         e=function(){
  1955.             return'\\w+'
  1956.             };
  1957.            
  1958.         c=1
  1959.         };
  1960.     while(c--){
  1961.         if(k[c]){
  1962.             p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])
  1963.             }
  1964.         }
  1965.     return p
  1966. }('M 6(A){4 $11=A.11||\'&\';4 $V=A.V===r?r:j;4 $1p=A.1p===r?\'\':\'[]\';4 $13=A.13===r?r:j;4 $D=$13?A.D===j?"#":"?":"";4 $15=A.15===r?r:j;v.1o=M 6(){4 f=6(o,t){8 o!=1v&&o!==x&&(!!t?o.1t==t:j)};4 14=6(1m){4 m,1l=/\\[([^[]*)\\]/g,T=/^([^[]+)(\\[.*\\])?$/.1r(1m),k=T[1],e=[];19(m=1l.1r(T[2]))e.u(m[1]);8[k,e]};4 w=6(3,e,7){4 o,y=e.1b();b(I 3!=\'X\')3=x;b(y===""){b(!3)3=[];b(f(3,L)){3.u(e.h==0?7:w(x,e.z(0),7))}n b(f(3,1a)){4 i=0;19(3[i++]!=x);3[--i]=e.h==0?7:w(3[i],e.z(0),7)}n{3=[];3.u(e.h==0?7:w(x,e.z(0),7))}}n b(y&&y.T(/^\\s*[0-9]+\\s*$/)){4 H=1c(y,10);b(!3)3=[];3[H]=e.h==0?7:w(3[H],e.z(0),7)}n b(y){4 H=y.B(/^\\s*|\\s*$/g,"");b(!3)3={};b(f(3,L)){4 18={};1w(4 i=0;i<3.h;++i){18[i]=3[i]}3=18}3[H]=e.h==0?7:w(3[H],e.z(0),7)}n{8 7}8 3};4 C=6(a){4 p=d;p.l={};b(a.C){v.J(a.Z(),6(5,c){p.O(5,c)})}n{v.J(1u,6(){4 q=""+d;q=q.B(/^[?#]/,\'\');q=q.B(/[;&]$/,\'\');b($V)q=q.B(/[+]/g,\' \');v.J(q.Y(/[&;]/),6(){4 5=1e(d.Y(\'=\')[0]||"");4 c=1e(d.Y(\'=\')[1]||"");b(!5)8;b($15){b(/^[+-]?[0-9]+\\.[0-9]*$/.1d(c))c=1A(c);n b(/^[+-]?[0-9]+$/.1d(c))c=1c(c,10)}c=(!c&&c!==0)?j:c;b(c!==r&&c!==j&&I c!=\'1g\')c=c;p.O(5,c)})})}8 p};C.1H={C:j,1G:6(5,1f){4 7=d.Z(5);8 f(7,1f)},1h:6(5){b(!f(5))8 d.l;4 K=14(5),k=K[0],e=K[1];4 3=d.l[k];19(3!=x&&e.h!=0){3=3[e.1b()]}8 I 3==\'1g\'?3:3||""},Z:6(5){4 3=d.1h(5);b(f(3,1a))8 v.1E(j,{},3);n b(f(3,L))8 3.z(0);8 3},O:6(5,c){4 7=!f(c)?x:c;4 K=14(5),k=K[0],e=K[1];4 3=d.l[k];d.l[k]=w(3,e.z(0),7);8 d},w:6(5,c){8 d.N().O(5,c)},1s:6(5){8 d.O(5,x).17()},1z:6(5){8 d.N().1s(5)},1j:6(){4 p=d;v.J(p.l,6(5,7){1y p.l[5]});8 p},1F:6(Q){4 D=Q.B(/^.*?[#](.+?)(?:\\?.+)?$/,"$1");4 S=Q.B(/^.*?[?](.+?)(?:#.+)?$/,"$1");8 M C(Q.h==S.h?\'\':S,Q.h==D.h?\'\':D)},1x:6(){8 d.N().1j()},N:6(){8 M C(d)},17:6(){6 F(G){4 R=I G=="X"?f(G,L)?[]:{}:G;b(I G==\'X\'){6 1k(o,5,7){b(f(o,L))o.u(7);n o[5]=7}v.J(G,6(5,7){b(!f(7))8 j;1k(R,5,F(7))})}8 R}d.l=F(d.l);8 d},1B:6(){8 d.N().17()},1D:6(){4 i=0,U=[],W=[],p=d;4 16=6(E){E=E+"";b($V)E=E.B(/ /g,"+");8 1C(E)};4 1n=6(1i,5,7){b(!f(7)||7===r)8;4 o=[16(5)];b(7!==j){o.u("=");o.u(16(7))}1i.u(o.P(""))};4 F=6(R,k){4 12=6(5){8!k||k==""?[5].P(""):[k,"[",5,"]"].P("")};v.J(R,6(5,7){b(I 7==\'X\')F(7,12(5));n 1n(W,12(5),7)})};F(d.l);b(W.h>0)U.u($D);U.u(W.P($11));8 U.P("")}};8 M C(1q.S,1q.D)}}(v.1o||{});',62,106,'|||target|var|key|function|value|return|||if|val|this|tokens|is||length||true|base|keys||else||self||false|||push|jQuery|set|null|token|slice|settings|replace|queryObject|hash|str|build|orig|index|typeof|each|parsed|Array|new|copy|SET|join|url|obj|search|match|queryString|spaces|chunks|object|split|get||separator|newKey|prefix|parse|numbers|encode|COMPACT|temp|while|Object|shift|parseInt|test|decodeURIComponent|type|number|GET|arr|EMPTY|add|rx|path|addFields|query|suffix|location|exec|REMOVE|constructor|arguments|undefined|for|empty|delete|remove|parseFloat|compact|encodeURIComponent|toString|extend|load|has|prototype'.split('|'),0,{}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement