PageRenderTime 61ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/templates/themes/bpm-parent/_inc/global.js

http://buddypress-media.googlecode.com/
JavaScript | 1445 lines | 1067 code | 280 blank | 98 comment | 222 complexity | 43201448959e247b815e74e560a4f9a7 MD5 | raw file
Possible License(s): AGPL-1.0, Apache-2.0, GPL-2.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. // AJAX Functions
  2. var jq = jQuery;
  3. // Global variable to prevent multiple AJAX requests
  4. var bp_ajax_request = null;
  5. jq(document).ready( function() {
  6. /**** Page Load Actions *******************************************************/
  7. /* Hide Forums Post Form */
  8. if ( '-1' == window.location.search.indexOf('new') && jq('div.forums').length )
  9. jq('#new-topic-post').hide();
  10. else
  11. jq('#new-topic-post').show();
  12. /* Activity filter and scope set */
  13. bp_init_activity();
  14. /* Object filter and scope set. */
  15. var objects = [ 'members', 'groups', 'blogs', 'forums' ];
  16. bp_init_objects( objects );
  17. /* @mention Compose Scrolling */
  18. if ( jq.query.get('r') && jq('textarea#whats-new').length ) {
  19. jq('#whats-new-options').animate({
  20. height:'40px'
  21. });
  22. jq("form#whats-new-form textarea").animate({
  23. height:'50px'
  24. });
  25. jq.scrollTo( jq('textarea#whats-new'), 500, {
  26. offset:-125,
  27. easing:'easeOutQuad'
  28. } );
  29. jq('textarea#whats-new').focus();
  30. }
  31. /**** Activity Posting ********************************************************/
  32. /* Textarea focus */
  33. jq('#whats-new').focus( function(){
  34. jq("#whats-new-options").animate({
  35. height:'40px'
  36. });
  37. jq("form#whats-new-form textarea").animate({
  38. height:'50px'
  39. });
  40. jq("#aw-whats-new-submit").prop("disabled", false);
  41. });
  42. /* New posts */
  43. jq("input#aw-whats-new-submit").click( function() {
  44. var button = jq(this);
  45. var form = button.parent().parent().parent().parent();
  46. form.children().each( function() {
  47. if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") )
  48. jq(this).prop( 'disabled', true );
  49. });
  50. /* Remove any errors */
  51. jq('div.error').remove();
  52. button.addClass('loading');
  53. button.prop('disabled', true);
  54. /* Default POST values */
  55. var object = '';
  56. var item_id = jq("#whats-new-post-in").val();
  57. var content = jq("textarea#whats-new").val();
  58. /* Set object for non-profile posts */
  59. if ( item_id > 0 ) {
  60. object = jq("#whats-new-post-object").val();
  61. }
  62. jq.post( ajaxurl, {
  63. action: 'post_update',
  64. 'cookie': encodeURIComponent(document.cookie),
  65. '_wpnonce_post_update': jq("input#_wpnonce_post_update").val(),
  66. 'content': content,
  67. 'object': object,
  68. 'item_id': item_id,
  69. '_bp_as_nonce': jq('#_bp_as_nonce').val() || ''
  70. },
  71. function(response) {
  72. form.children().each( function() {
  73. if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) {
  74. jq(this).prop( 'disabled', false );
  75. }
  76. });
  77. /* Check for errors and append if found. */
  78. if ( response[0] + response[1] == '-1' ) {
  79. form.prepend( response.substr( 2, response.length ) );
  80. jq( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 );
  81. } else {
  82. if ( 0 == jq("ul.activity-list").length ) {
  83. jq("div.error").slideUp(100).remove();
  84. jq("div#message").slideUp(100).remove();
  85. jq("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' );
  86. }
  87. jq("ul#activity-stream").prepend(response);
  88. jq("ul#activity-stream li:first").addClass('new-update');
  89. if ( 0 != jq("#latest-update").length ) {
  90. var l = jq("ul#activity-stream li.new-update .activity-content .activity-inner p").html();
  91. var v = jq("ul#activity-stream li.new-update .activity-content .activity-header p a.view").attr('href');
  92. var ltext = jq("ul#activity-stream li.new-update .activity-content .activity-inner p").text();
  93. var u = '';
  94. if ( ltext != '' )
  95. u = l + ' ';
  96. u += '<a href="' + v + '" rel="nofollow">' + BP_DTheme.view + '</a>';
  97. jq("#latest-update").slideUp(300,function(){
  98. jq("#latest-update").html( u );
  99. jq("#latest-update").slideDown(300);
  100. });
  101. }
  102. jq("li.new-update").hide().slideDown( 300 );
  103. jq("li.new-update").removeClass( 'new-update' );
  104. jq("textarea#whats-new").val('');
  105. }
  106. jq("#whats-new-options").animate({
  107. height:'0px'
  108. });
  109. jq("form#whats-new-form textarea").animate({
  110. height:'20px'
  111. });
  112. jq("#aw-whats-new-submit").prop("disabled", true).removeClass('loading');
  113. });
  114. return false;
  115. });
  116. /* List tabs event delegation */
  117. jq('div.activity-type-tabs').click( function(event) {
  118. var target = jq(event.target).parent();
  119. if ( event.target.nodeName == 'STRONG' || event.target.nodeName == 'SPAN' )
  120. target = target.parent();
  121. else if ( event.target.nodeName != 'A' )
  122. return false;
  123. /* Reset the page */
  124. jq.cookie( 'bp-activity-oldestpage', 1, {
  125. path: '/'
  126. } );
  127. /* Activity Stream Tabs */
  128. var scope = target.attr('id').substr( 9, target.attr('id').length );
  129. var filter = jq("#activity-filter-select select").val();
  130. if ( scope == 'mentions' )
  131. jq( 'li#' + target.attr('id') + ' a strong' ).remove();
  132. bp_activity_request(scope, filter);
  133. return false;
  134. });
  135. /* Activity filter select */
  136. jq('#activity-filter-select select').change( function() {
  137. var selected_tab = jq( 'div.activity-type-tabs li.selected' );
  138. if ( !selected_tab.length )
  139. var scope = null;
  140. else
  141. var scope = selected_tab.attr('id').substr( 9, selected_tab.attr('id').length );
  142. var filter = jq(this).val();
  143. bp_activity_request(scope, filter);
  144. return false;
  145. });
  146. /* Stream event delegation */
  147. jq('div.activity').click( function(event) {
  148. var target = jq(event.target);
  149. /* Favoriting activity stream items */
  150. if ( target.hasClass('fav') || target.hasClass('unfav') ) {
  151. var type = target.hasClass('fav') ? 'fav' : 'unfav';
  152. var parent = target.closest('.activity-item');
  153. var parent_id = parent.attr('id').substr( 9, parent.attr('id').length );
  154. target.addClass('loading');
  155. jq.post( ajaxurl, {
  156. action: 'activity_mark_' + type,
  157. 'cookie': encodeURIComponent(document.cookie),
  158. 'id': parent_id
  159. },
  160. function(response) {
  161. target.removeClass('loading');
  162. target.fadeOut( 100, function() {
  163. jq(this).html(response);
  164. jq(this).attr('title', 'fav' == type ? BP_DTheme.remove_fav : BP_DTheme.mark_as_fav);
  165. jq(this).fadeIn(100);
  166. });
  167. if ( 'fav' == type ) {
  168. if ( !jq('.item-list-tabs li#activity-favorites').length )
  169. jq('.item-list-tabs ul li#activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' <span>0</span></a></li>');
  170. target.removeClass('fav');
  171. target.addClass('unfav');
  172. jq('.item-list-tabs ul li#activity-favorites span').html( Number( jq('.item-list-tabs ul li#activity-favorites span').html() ) + 1 );
  173. } else {
  174. target.removeClass('unfav');
  175. target.addClass('fav');
  176. jq('.item-list-tabs ul li#activity-favorites span').html( Number( jq('.item-list-tabs ul li#activity-favorites span').html() ) - 1 );
  177. if ( !Number( jq('.item-list-tabs ul li#activity-favorites span').html() ) ) {
  178. if ( jq('.item-list-tabs ul li#activity-favorites').hasClass('selected') )
  179. bp_activity_request( null, null );
  180. jq('.item-list-tabs ul li#activity-favorites').remove();
  181. }
  182. }
  183. if ( 'activity-favorites' == jq( '.item-list-tabs li.selected').attr('id') )
  184. target.parent().parent().parent().slideUp(100);
  185. });
  186. return false;
  187. }
  188. /* Delete activity stream items */
  189. if ( target.hasClass('delete-activity') ) {
  190. var li = target.parents('div.activity ul li');
  191. var id = li.attr('id').substr( 9, li.attr('id').length );
  192. var link_href = target.attr('href');
  193. var nonce = link_href.split('_wpnonce=');
  194. nonce = nonce[1];
  195. target.addClass('loading');
  196. jq.post( ajaxurl, {
  197. action: 'delete_activity',
  198. 'cookie': encodeURIComponent(document.cookie),
  199. 'id': id,
  200. '_wpnonce': nonce
  201. },
  202. function(response) {
  203. if ( response[0] + response[1] == '-1' ) {
  204. li.prepend( response.substr( 2, response.length ) );
  205. li.children('div#message').hide().fadeIn(300);
  206. } else {
  207. li.slideUp(300);
  208. }
  209. });
  210. return false;
  211. }
  212. // Spam activity stream items
  213. if ( target.hasClass( 'spam-activity' ) ) {
  214. var li = target.parents( 'div.activity ul li' );
  215. target.addClass( 'loading' );
  216. jq.post( ajaxurl, {
  217. action: 'bp_spam_activity',
  218. 'cookie': encodeURIComponent( document.cookie ),
  219. 'id': li.attr( 'id' ).substr( 9, li.attr( 'id' ).length ),
  220. '_wpnonce': target.attr( 'href' ).split( '_wpnonce=' )[1]
  221. },
  222. function(response) {
  223. if ( response[0] + response[1] === '-1' ) {
  224. li.prepend( response.substr( 2, response.length ) );
  225. li.children( 'div#message' ).hide().fadeIn(300);
  226. } else {
  227. li.slideUp( 300 );
  228. }
  229. });
  230. return false;
  231. }
  232. /* Load more updates at the end of the page */
  233. if ( target.parent().hasClass('load-more') ) {
  234. jq("#content li.load-more").addClass('loading');
  235. if ( null == jq.cookie('bp-activity-oldestpage') )
  236. jq.cookie('bp-activity-oldestpage', 1, {
  237. path: '/'
  238. } );
  239. var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
  240. jq.post( ajaxurl, {
  241. action: 'activity_get_older_updates',
  242. 'cookie': encodeURIComponent(document.cookie),
  243. 'page': oldest_page
  244. },
  245. function(response)
  246. {
  247. jq("#content li.load-more").removeClass('loading');
  248. jq.cookie( 'bp-activity-oldestpage', oldest_page, {
  249. path: '/'
  250. } );
  251. jq("#content ul.activity-list").append(response.contents);
  252. target.parent().hide();
  253. }, 'json' );
  254. return false;
  255. }
  256. });
  257. // Activity "Read More" links
  258. jq('.activity-read-more a').live('click', function(event) {
  259. var target = jq(event.target);
  260. var link_id = target.parent().attr('id').split('-');
  261. var a_id = link_id[3];
  262. var type = link_id[0]; /* activity or acomment */
  263. var inner_class = type == 'acomment' ? 'acomment-content' : 'activity-inner';
  264. var a_inner = jq('li#' + type + '-' + a_id + ' .' + inner_class + ':first' );
  265. jq(target).addClass('loading');
  266. jq.post( ajaxurl, {
  267. action: 'get_single_activity_content',
  268. 'activity_id': a_id
  269. },
  270. function(response) {
  271. jq(a_inner).slideUp(300).html(response).slideDown(300);
  272. });
  273. return false;
  274. });
  275. /**** Activity Comments *******************************************************/
  276. /* Hide all activity comment forms */
  277. jq('form.ac-form').hide();
  278. /* Hide excess comments */
  279. if ( jq('.activity-comments').length )
  280. bp_dtheme_hide_comments();
  281. /* Activity list event delegation */
  282. jq('div.activity').click( function(event) {
  283. var target = jq(event.target);
  284. /* Comment / comment reply links */
  285. if ( target.hasClass('acomment-reply') || target.parent().hasClass('acomment-reply') ) {
  286. if ( target.parent().hasClass('acomment-reply') )
  287. target = target.parent();
  288. var id = target.attr('id');
  289. ids = id.split('-');
  290. var a_id = ids[2]
  291. var c_id = target.attr('href').substr( 10, target.attr('href').length );
  292. var form = jq( '#ac-form-' + a_id );
  293. form.css( 'display', 'none' );
  294. form.removeClass('root');
  295. jq('.ac-form').hide();
  296. /* Hide any error messages */
  297. form.children('div').each( function() {
  298. if ( jq(this).hasClass( 'error' ) )
  299. jq(this).hide();
  300. });
  301. if ( ids[1] != 'comment' ) {
  302. jq('.activity-comments li#acomment-' + c_id).append( form );
  303. } else {
  304. jq('li#activity-' + a_id + ' .activity-comments').append( form );
  305. }
  306. if ( form.parent().hasClass( 'activity-comments' ) )
  307. form.addClass('root');
  308. form.slideDown( 200 );
  309. jq.scrollTo( form, 500, {
  310. offset:-100,
  311. easing:'easeOutQuad'
  312. } );
  313. jq('#ac-form-' + ids[2] + ' textarea').focus();
  314. return false;
  315. }
  316. /* Activity comment posting */
  317. if ( target.attr('name') == 'ac_form_submit' ) {
  318. var form = target.parent().parent();
  319. var form_parent = form.parent();
  320. var form_id = form.attr('id').split('-');
  321. if ( !form_parent.hasClass('activity-comments') ) {
  322. var tmp_id = form_parent.attr('id').split('-');
  323. var comment_id = tmp_id[1];
  324. } else {
  325. var comment_id = form_id[2];
  326. }
  327. /* Hide any error messages */
  328. jq( 'form#' + form + ' div.error').hide();
  329. target.addClass('loading').prop('disabled', true);
  330. var ajaxdata = {
  331. action: 'new_activity_comment',
  332. 'cookie': encodeURIComponent(document.cookie),
  333. '_wpnonce_new_activity_comment': jq("input#_wpnonce_new_activity_comment").val(),
  334. 'comment_id': comment_id,
  335. 'form_id': form_id[2],
  336. 'content': jq('form#' + form.attr('id') + ' textarea').val()
  337. };
  338. // Akismet
  339. var ak_nonce = jq('#_bp_as_nonce_' + comment_id).val();
  340. if ( ak_nonce ) {
  341. ajaxdata['_bp_as_nonce_' + comment_id] = ak_nonce;
  342. }
  343. jq.post( ajaxurl, ajaxdata,
  344. function(response)
  345. {
  346. target.removeClass('loading');
  347. /* Check for errors and append if found. */
  348. if ( response[0] + response[1] == '-1' ) {
  349. form.append( response.substr( 2, response.length ) ).hide().fadeIn( 200 );
  350. } else {
  351. form.fadeOut( 200,
  352. function() {
  353. if ( 0 == form.parent().children('ul').length ) {
  354. if ( form.parent().hasClass('activity-comments') )
  355. form.parent().prepend('<ul></ul>');
  356. else
  357. form.parent().append('<ul></ul>');
  358. }
  359. form.parent().children('ul').append(response).hide().fadeIn( 200 );
  360. form.children('textarea').val('');
  361. form.parent().parent().addClass('has-comments');
  362. }
  363. );
  364. jq( 'form#' + form + ' textarea').val('');
  365. /* Increase the "Reply (X)" button count */
  366. jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html( Number( jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html() ) + 1 );
  367. }
  368. jq(target).prop("disabled", false);
  369. });
  370. return false;
  371. }
  372. /* Deleting an activity comment */
  373. if ( target.hasClass('acomment-delete') ) {
  374. var link_href = target.attr('href');
  375. var comment_li = target.parent().parent();
  376. var form = comment_li.parents('div.activity-comments').children('form');
  377. var nonce = link_href.split('_wpnonce=');
  378. nonce = nonce[1];
  379. var comment_id = link_href.split('cid=');
  380. comment_id = comment_id[1].split('&');
  381. comment_id = comment_id[0];
  382. target.addClass('loading');
  383. /* Remove any error messages */
  384. jq('.activity-comments ul .error').remove();
  385. /* Reset the form position */
  386. comment_li.parents('.activity-comments').append(form);
  387. jq.post( ajaxurl, {
  388. action: 'delete_activity_comment',
  389. 'cookie': encodeURIComponent(document.cookie),
  390. '_wpnonce': nonce,
  391. 'id': comment_id
  392. },
  393. function(response)
  394. {
  395. /* Check for errors and append if found. */
  396. if ( response[0] + response[1] == '-1' ) {
  397. comment_li.prepend( response.substr( 2, response.length ) ).hide().fadeIn( 200 );
  398. } else {
  399. var children = jq( 'li#' + comment_li.attr('id') + ' ul' ).children('li');
  400. var child_count = 0;
  401. jq(children).each( function() {
  402. if ( !jq(this).is(':hidden') )
  403. child_count++;
  404. });
  405. comment_li.fadeOut(200);
  406. /* Decrease the "Reply (X)" button count */
  407. var count_span = jq('li#' + comment_li.parents('ul#activity-stream > li').attr('id') + ' a.acomment-reply span');
  408. var new_count = count_span.html() - ( 1 + child_count );
  409. count_span.html(new_count);
  410. /* If that was the last comment for the item, remove the has-comments class to clean up the styling */
  411. if ( 0 == new_count ) {
  412. jq(comment_li.parents('ul#activity-stream > li')).removeClass('has-comments');
  413. }
  414. }
  415. });
  416. return false;
  417. }
  418. // Spam an activity stream comment
  419. if ( target.hasClass( 'spam-activity-comment' ) ) {
  420. var link_href = target.attr( 'href' );
  421. var comment_li = target.parent().parent();
  422. target.addClass('loading');
  423. // Remove any error messages
  424. jq( '.activity-comments ul div.error' ).remove();
  425. // Reset the form position
  426. comment_li.parents( '.activity-comments' ).append( comment_li.parents( '.activity-comments' ).children( 'form' ) );
  427. jq.post( ajaxurl, {
  428. action: 'bp_spam_activity_comment',
  429. 'cookie': encodeURIComponent( document.cookie ),
  430. '_wpnonce': link_href.split( '_wpnonce=' )[1],
  431. 'id': link_href.split( 'cid=' )[1].split( '&' )[0]
  432. },
  433. function ( response ) {
  434. // Check for errors and append if found.
  435. if ( response[0] + response[1] == '-1' ) {
  436. comment_li.prepend( response.substr( 2, response.length ) ).hide().fadeIn( 200 );
  437. } else {
  438. var children = jq( 'li#' + comment_li.attr( 'id' ) + ' ul' ).children( 'li' );
  439. var child_count = 0;
  440. jq(children).each( function() {
  441. if ( !jq( this ).is( ':hidden' ) ) {
  442. child_count++;
  443. }
  444. });
  445. comment_li.fadeOut( 200 );
  446. // Decrease the "Reply (X)" button count
  447. var parent_li = comment_li.parents( 'ul#activity-stream > li' );
  448. 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 ) );
  449. }
  450. });
  451. return false;
  452. }
  453. /* Showing hidden comments - pause for half a second */
  454. if ( target.parent().hasClass('show-all') ) {
  455. target.parent().addClass('loading');
  456. setTimeout( function() {
  457. target.parent().parent().children('li').fadeIn(200, function() {
  458. target.parent().remove();
  459. });
  460. }, 600 );
  461. return false;
  462. }
  463. });
  464. /* Escape Key Press for cancelling comment forms */
  465. jq(document).keydown( function(e) {
  466. e = e || window.event;
  467. if (e.target)
  468. element = e.target;
  469. else if (e.srcElement)
  470. element = e.srcElement;
  471. if( element.nodeType == 3)
  472. element = element.parentNode;
  473. if( e.ctrlKey == true || e.altKey == true || e.metaKey == true )
  474. return;
  475. var keyCode = (e.keyCode) ? e.keyCode : e.which;
  476. if ( keyCode == 27 ) {
  477. if (element.tagName == 'TEXTAREA') {
  478. if ( jq(element).hasClass('ac-input') )
  479. jq(element).parent().parent().parent().slideUp( 200 );
  480. }
  481. }
  482. });
  483. /**** Directory Search ****************************************************/
  484. /* The search form on all directory pages */
  485. jq('.dir-search').click( function(event) {
  486. if ( jq(this).hasClass('no-ajax') )
  487. return;
  488. var target = jq(event.target);
  489. if ( target.attr('type') == 'submit' ) {
  490. var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' );
  491. var object = css_id[0];
  492. 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') );
  493. return false;
  494. }
  495. });
  496. /**** Tabs and Filters ****************************************************/
  497. /* When a navigation tab is clicked - e.g. | All Groups | My Groups | */
  498. jq('div.item-list-tabs').click( function(event) {
  499. if ( jq(this).hasClass('no-ajax') )
  500. return;
  501. var target = jq(event.target).parent();
  502. if ( 'LI' == event.target.parentNode.nodeName && !target.hasClass('last') ) {
  503. var css_id = target.attr('id').split( '-' );
  504. var object = css_id[0];
  505. if ( 'activity' == object )
  506. return false;
  507. var scope = css_id[1];
  508. var filter = jq("#" + object + "-order-select select").val();
  509. var search_terms = jq("#" + object + "_search").val();
  510. bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') );
  511. return false;
  512. }
  513. });
  514. /* When the filter select box is changed re-query */
  515. jq('li.filter select').change( function() {
  516. if ( jq('.item-list-tabs li.selected').length )
  517. var el = jq('.item-list-tabs li.selected');
  518. else
  519. var el = jq(this);
  520. var css_id = el.attr('id').split('-');
  521. var object = css_id[0];
  522. var scope = css_id[1];
  523. var filter = jq(this).val();
  524. var search_terms = false;
  525. if ( jq('.dir-search input').length )
  526. search_terms = jq('.dir-search input').val();
  527. if ( 'friends' == object )
  528. object = 'members';
  529. bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') );
  530. return false;
  531. });
  532. /* All pagination links run through this function */
  533. jq('div#content').click( function(event) {
  534. var target = jq(event.target);
  535. if ( target.hasClass('button') )
  536. return true;
  537. if ( target.parent().parent().hasClass('pagination') && !target.parent().parent().hasClass('no-ajax') ) {
  538. if ( target.hasClass('dots') || target.hasClass('current') )
  539. return false;
  540. if ( jq('.item-list-tabs li.selected').length )
  541. var el = jq('.item-list-tabs li.selected');
  542. else
  543. var el = jq('li.filter select');
  544. var page_number = 1;
  545. var css_id = el.attr('id').split( '-' );
  546. var object = css_id[0];
  547. var search_terms = false;
  548. if ( jq('div.dir-search input').length )
  549. search_terms = jq('.dir-search input').val();
  550. if ( jq(target).hasClass('next') )
  551. var page_number = Number( jq('.pagination span.current').html() ) + 1;
  552. else if ( jq(target).hasClass('prev') )
  553. var page_number = Number( jq('.pagination span.current').html() ) - 1;
  554. else
  555. var page_number = Number( jq(target).html() );
  556. 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') );
  557. return false;
  558. }
  559. });
  560. /**** New Forum Directory Post **************************************/
  561. /* Hit the "New Topic" button on the forums directory page */
  562. jq('a.show-hide-new').click( function() {
  563. if ( !jq('#new-topic-post').length )
  564. return false;
  565. if ( jq('#new-topic-post').is(":visible") )
  566. jq('#new-topic-post').slideUp(200);
  567. else
  568. jq('#new-topic-post').slideDown(200, function() {
  569. jq('#topic_title').focus();
  570. } );
  571. return false;
  572. });
  573. /* Cancel the posting of a new forum topic */
  574. jq('input#submit_topic_cancel').click( function() {
  575. if ( !jq('#new-topic-post').length )
  576. return false;
  577. jq('#new-topic-post').slideUp(200);
  578. return false;
  579. });
  580. /* Clicking a forum tag */
  581. jq('#forum-directory-tags a').click( function() {
  582. bp_filter_request( 'forums', 'tags', jq.cookie('bp-forums-scope'), 'div.forums', jq(this).html().replace( /&nbsp;/g, '-' ), 1, jq.cookie('bp-forums-extras') );
  583. return false;
  584. });
  585. /** Invite Friends Interface ****************************************/
  586. /* Select a user from the list of friends and add them to the invite list */
  587. jq("div#invite-list input").click( function() {
  588. jq('.ajax-loader').toggle();
  589. var friend_id = jq(this).val();
  590. if ( jq(this).prop('checked') == true )
  591. var friend_action = 'invite';
  592. else
  593. var friend_action = 'uninvite';
  594. jq('.item-list-tabs li.selected').addClass('loading');
  595. jq.post( ajaxurl, {
  596. action: 'groups_invite_user',
  597. 'friend_action': friend_action,
  598. 'cookie': encodeURIComponent(document.cookie),
  599. '_wpnonce': jq("input#_wpnonce_invite_uninvite_user").val(),
  600. 'friend_id': friend_id,
  601. 'group_id': jq("input#group_id").val()
  602. },
  603. function(response)
  604. {
  605. if ( jq("#message") )
  606. jq("#message").hide();
  607. jq('.ajax-loader').toggle();
  608. if ( friend_action == 'invite' ) {
  609. jq('#friend-list').append(response);
  610. } else if ( friend_action == 'uninvite' ) {
  611. jq('#friend-list li#uid-' + friend_id).remove();
  612. }
  613. jq('.item-list-tabs li.selected').removeClass('loading');
  614. });
  615. });
  616. /* Remove a user from the list of users to invite to a group */
  617. jq("#friend-list li a.remove").live('click', function() {
  618. jq('.ajax-loader').toggle();
  619. var friend_id = jq(this).attr('id');
  620. friend_id = friend_id.split('-');
  621. friend_id = friend_id[1];
  622. jq.post( ajaxurl, {
  623. action: 'groups_invite_user',
  624. 'friend_action': 'uninvite',
  625. 'cookie': encodeURIComponent(document.cookie),
  626. '_wpnonce': jq("input#_wpnonce_invite_uninvite_user").val(),
  627. 'friend_id': friend_id,
  628. 'group_id': jq("input#group_id").val()
  629. },
  630. function(response)
  631. {
  632. jq('.ajax-loader').toggle();
  633. jq('#friend-list li#uid-' + friend_id).remove();
  634. jq('#invite-list input#f-' + friend_id).prop('checked', false);
  635. });
  636. return false;
  637. });
  638. /** Profile Visibility Settings *********************************/
  639. jq('.field-visibility-settings').hide();
  640. jq('.visibility-toggle-link').on( 'click', function() {
  641. var toggle_div = jq(this).parent();
  642. jq(toggle_div).fadeOut( 600, function(){
  643. jq(toggle_div).siblings('.field-visibility-settings').slideDown(400);
  644. });
  645. return false;
  646. } );
  647. jq('.field-visibility-settings-close').on( 'click', function() {
  648. var settings_div = jq(this).parent();
  649. jq(settings_div).slideUp( 400, function(){
  650. jq(settings_div).siblings('.field-visibility-settings-toggle').fadeIn(800);
  651. });
  652. return false;
  653. } );
  654. /** Friendship Requests **************************************/
  655. /* Accept and Reject friendship request buttons */
  656. jq("ul#friend-list a.accept, ul#friend-list a.reject").click( function() {
  657. var button = jq(this);
  658. var li = jq(this).parents('ul#friend-list li');
  659. var action_div = jq(this).parents('li div.action');
  660. var id = li.attr('id').substr( 11, li.attr('id').length );
  661. var link_href = button.attr('href');
  662. var nonce = link_href.split('_wpnonce=');
  663. nonce = nonce[1];
  664. if ( jq(this).hasClass('accepted') || jq(this).hasClass('rejected') )
  665. return false;
  666. if ( jq(this).hasClass('accept') ) {
  667. var action = 'accept_friendship';
  668. action_div.children('a.reject').css( 'visibility', 'hidden' );
  669. } else {
  670. var action = 'reject_friendship';
  671. action_div.children('a.accept').css( 'visibility', 'hidden' );
  672. }
  673. button.addClass('loading');
  674. jq.post( ajaxurl, {
  675. action: action,
  676. 'cookie': encodeURIComponent(document.cookie),
  677. 'id': id,
  678. '_wpnonce': nonce
  679. },
  680. function(response) {
  681. button.removeClass('loading');
  682. if ( response[0] + response[1] == '-1' ) {
  683. li.prepend( response.substr( 2, response.length ) );
  684. li.children('div#message').hide().fadeIn(200);
  685. } else {
  686. button.fadeOut( 100, function() {
  687. if ( jq(this).hasClass('accept') ) {
  688. action_div.children('a.reject').hide();
  689. jq(this).html( BP_DTheme.accepted ).fadeIn(50);
  690. jq(this).addClass('accepted');
  691. } else {
  692. action_div.children('a.accept').hide();
  693. jq(this).html( BP_DTheme.rejected ).fadeIn(50);
  694. jq(this).addClass('rejected');
  695. }
  696. });
  697. }
  698. });
  699. return false;
  700. });
  701. /* Add / Remove friendship buttons */
  702. jq(".friendship-button a").live('click', function() {
  703. jq(this).parent().addClass('loading');
  704. var fid = jq(this).attr('id');
  705. fid = fid.split('-');
  706. fid = fid[1];
  707. var nonce = jq(this).attr('href');
  708. nonce = nonce.split('?_wpnonce=');
  709. nonce = nonce[1].split('&');
  710. nonce = nonce[0];
  711. var thelink = jq(this);
  712. jq.post( ajaxurl, {
  713. action: 'addremove_friend',
  714. 'cookie': encodeURIComponent(document.cookie),
  715. 'fid': fid,
  716. '_wpnonce': nonce
  717. },
  718. function(response)
  719. {
  720. var action = thelink.attr('rel');
  721. var parentdiv = thelink.parent();
  722. if ( action == 'add' ) {
  723. jq(parentdiv).fadeOut(200,
  724. function() {
  725. parentdiv.removeClass('add_friend');
  726. parentdiv.removeClass('loading');
  727. parentdiv.addClass('pending_friend');
  728. parentdiv.fadeIn(200).html(response);
  729. }
  730. );
  731. } else if ( action == 'remove' ) {
  732. jq(parentdiv).fadeOut(200,
  733. function() {
  734. parentdiv.removeClass('remove_friend');
  735. parentdiv.removeClass('loading');
  736. parentdiv.addClass('add');
  737. parentdiv.fadeIn(200).html(response);
  738. }
  739. );
  740. }
  741. });
  742. return false;
  743. } );
  744. /** Group Join / Leave Buttons **************************************/
  745. jq(".group-button a").live('click', function() {
  746. var gid = jq(this).parent().attr('id');
  747. gid = gid.split('-');
  748. gid = gid[1];
  749. var nonce = jq(this).attr('href');
  750. nonce = nonce.split('?_wpnonce=');
  751. nonce = nonce[1].split('&');
  752. nonce = nonce[0];
  753. var thelink = jq(this);
  754. jq.post( ajaxurl, {
  755. action: 'joinleave_group',
  756. 'cookie': encodeURIComponent(document.cookie),
  757. 'gid': gid,
  758. '_wpnonce': nonce
  759. },
  760. function(response)
  761. {
  762. var parentdiv = thelink.parent();
  763. if ( !jq('body.directory').length )
  764. location.href = location.href;
  765. else {
  766. jq(parentdiv).fadeOut(200,
  767. function() {
  768. parentdiv.fadeIn(200).html(response);
  769. }
  770. );
  771. }
  772. });
  773. return false;
  774. } );
  775. /** Button disabling ************************************************/
  776. jq('.pending').click(function() {
  777. return false;
  778. });
  779. /** Private Messaging ******************************************/
  780. /** Message search*/
  781. jq('.message-search').click( function(event) {
  782. if ( jq(this).hasClass('no-ajax') )
  783. return;
  784. var target = jq(event.target);
  785. if ( target.attr('type') == 'submit' ) {
  786. //var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' );
  787. var object = 'messages';
  788. 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') );
  789. return false;
  790. }
  791. });
  792. /* AJAX send reply functionality */
  793. jq("input#send_reply_button").click(
  794. function() {
  795. var order = jq('#messages_order').val() || 'ASC',
  796. offset = jq('#message-recipients').offset();
  797. var button = jq("input#send_reply_button");
  798. jq(button).addClass('loading');
  799. jq.post( ajaxurl, {
  800. action: 'messages_send_reply',
  801. 'cookie': encodeURIComponent(document.cookie),
  802. '_wpnonce': jq("input#send_message_nonce").val(),
  803. 'content': jq("#message_content").val(),
  804. 'send_to': jq("input#send_to").val(),
  805. 'subject': jq("input#subject").val(),
  806. 'thread_id': jq("input#thread_id").val()
  807. },
  808. function(response)
  809. {
  810. if ( response[0] + response[1] == "-1" ) {
  811. jq('form#send-reply').prepend( response.substr( 2, response.length ) );
  812. } else {
  813. jq('form#send-reply div#message').remove();
  814. jq("#message_content").val('');
  815. if ( 'ASC' == order ) {
  816. jq('form#send-reply').before( response );
  817. } else {
  818. jq('#message-recipients').after( response );
  819. jq(window).scrollTop(offset.top);
  820. }
  821. jq(".new-message").hide().slideDown( 200, function() {
  822. jq('.new-message').removeClass('new-message');
  823. });
  824. }
  825. jq(button).removeClass('loading');
  826. });
  827. return false;
  828. }
  829. );
  830. /* Marking private messages as read and unread */
  831. jq("a#mark_as_read, a#mark_as_unread").click(function() {
  832. var checkboxes_tosend = '';
  833. var checkboxes = jq("#message-threads tr td input[type='checkbox']");
  834. if ( 'mark_as_unread' == jq(this).attr('id') ) {
  835. var currentClass = 'read'
  836. var newClass = 'unread'
  837. var unreadCount = 1;
  838. var inboxCount = 0;
  839. var unreadCountDisplay = 'inline';
  840. var action = 'messages_markunread';
  841. } else {
  842. var currentClass = 'unread'
  843. var newClass = 'read'
  844. var unreadCount = 0;
  845. var inboxCount = 1;
  846. var unreadCountDisplay = 'none';
  847. var action = 'messages_markread';
  848. }
  849. checkboxes.each( function(i) {
  850. if(jq(this).is(':checked')) {
  851. if ( jq('tr#m-' + jq(this).attr('value')).hasClass(currentClass) ) {
  852. checkboxes_tosend += jq(this).attr('value');
  853. jq('tr#m-' + jq(this).attr('value')).removeClass(currentClass);
  854. jq('tr#m-' + jq(this).attr('value')).addClass(newClass);
  855. var thread_count = jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').html();
  856. jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').html(unreadCount);
  857. jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').css('display', unreadCountDisplay);
  858. var inboxcount = jq('tr.unread').length;
  859. jq('a#user-messages span').html( inboxcount );
  860. if ( i != checkboxes.length - 1 ) {
  861. checkboxes_tosend += ','
  862. }
  863. }
  864. }
  865. });
  866. jq.post( ajaxurl, {
  867. action: action,
  868. 'thread_ids': checkboxes_tosend
  869. });
  870. return false;
  871. });
  872. /* Selecting unread and read messages in inbox */
  873. jq("select#message-type-select").change(
  874. function() {
  875. var selection = jq("select#message-type-select").val();
  876. var checkboxes = jq("td input[type='checkbox']");
  877. checkboxes.each( function(i) {
  878. checkboxes[i].checked = "";
  879. });
  880. switch(selection) {
  881. case 'unread':
  882. var checkboxes = jq("tr.unread td input[type='checkbox']");
  883. break;
  884. case 'read':
  885. var checkboxes = jq("tr.read td input[type='checkbox']");
  886. break;
  887. }
  888. if ( selection != '' ) {
  889. checkboxes.each( function(i) {
  890. checkboxes[i].checked = "checked";
  891. });
  892. } else {
  893. checkboxes.each( function(i) {
  894. checkboxes[i].checked = "";
  895. });
  896. }
  897. }
  898. );
  899. /* Bulk delete messages */
  900. jq("a#delete_inbox_messages, a#delete_sentbox_messages").click( function() {
  901. checkboxes_tosend = '';
  902. checkboxes = jq("#message-threads tr td input[type='checkbox']");
  903. jq('div#message').remove();
  904. jq(this).addClass('loading');
  905. jq(checkboxes).each( function(i) {
  906. if( jq(this).is(':checked') )
  907. checkboxes_tosend += jq(this).attr('value') + ',';
  908. });
  909. if ( '' == checkboxes_tosend ) {
  910. jq(this).removeClass('loading');
  911. return false;
  912. }
  913. jq.post( ajaxurl, {
  914. action: 'messages_delete',
  915. 'thread_ids': checkboxes_tosend
  916. }, function(response) {
  917. if ( response[0] + response[1] == "-1" ) {
  918. jq('#message-threads').prepend( response.substr( 2, response.length ) );
  919. } else {
  920. jq('#message-threads').before( '<div id="message" class="updated"><p>' + response + '</p></div>' );
  921. jq(checkboxes).each( function(i) {
  922. if( jq(this).is(':checked') )
  923. jq(this).parent().parent().fadeOut(150);
  924. });
  925. }
  926. jq('div#message').hide().slideDown(150);
  927. jq("a#delete_inbox_messages, a#delete_sentbox_messages").removeClass('loading');
  928. });
  929. return false;
  930. });
  931. /* Close site wide notices in the sidebar */
  932. jq("a#close-notice").click( function() {
  933. jq(this).addClass('loading');
  934. jq('div#sidebar div.error').remove();
  935. jq.post( ajaxurl, {
  936. action: 'messages_close_notice',
  937. 'notice_id': jq('.notice').attr('rel').substr( 2, jq('.notice').attr('rel').length )
  938. },
  939. function(response) {
  940. jq("a#close-notice").removeClass('loading');
  941. if ( response[0] + response[1] == '-1' ) {
  942. jq('.notice').prepend( response.substr( 2, response.length ) );
  943. jq( 'div#sidebar div.error').hide().fadeIn( 200 );
  944. } else {
  945. jq('.notice').slideUp( 100 );
  946. }
  947. });
  948. return false;
  949. });
  950. /* Toolbar & wp_list_pages Javascript IE6 hover class */
  951. jq("#wp-admin-bar ul.main-nav li, #nav li").mouseover( function() {
  952. jq(this).addClass('sfhover');
  953. });
  954. jq("#wp-admin-bar ul.main-nav li, #nav li").mouseout( function() {
  955. jq(this).removeClass('sfhover');
  956. });
  957. /* Clear BP cookies on logout */
  958. jq('a.logout').click( function() {
  959. jq.cookie('bp-activity-scope', null, {
  960. path: '/'
  961. });
  962. jq.cookie('bp-activity-filter', null, {
  963. path: '/'
  964. });
  965. jq.cookie('bp-activity-oldestpage', null, {
  966. path: '/'
  967. });
  968. var objects = [ 'members', 'groups', 'blogs', 'forums' ];
  969. jq(objects).each( function(i) {
  970. jq.cookie('bp-' + objects[i] + '-scope', null, {
  971. path: '/'
  972. } );
  973. jq.cookie('bp-' + objects[i] + '-filter', null, {
  974. path: '/'
  975. } );
  976. jq.cookie('bp-' + objects[i] + '-extras', null, {
  977. path: '/'
  978. } );
  979. });
  980. });
  981. });
  982. /* Setup activity scope and filter based on the current cookie settings. */
  983. function bp_init_activity() {
  984. /* Reset the page */
  985. jq.cookie( 'bp-activity-oldestpage', 1, {
  986. path: '/'
  987. } );
  988. if ( null != jq.cookie('bp-activity-filter') && jq('#activity-filter-select').length )
  989. jq('#activity-filter-select select option[value="' + jq.cookie('bp-activity-filter') + '"]').prop( 'selected', true );
  990. /* Activity Tab Set */
  991. if ( null != jq.cookie('bp-activity-scope') && jq('.activity-type-tabs').length ) {
  992. jq('.activity-type-tabs li').each( function() {
  993. jq(this).removeClass('selected');
  994. });
  995. jq('li#activity-' + jq.cookie('bp-activity-scope') + ', .item-list-tabs li.current').addClass('selected');
  996. }
  997. }
  998. /* Setup object scope and filter based on the current cookie settings for the object. */
  999. function bp_init_objects(objects) {
  1000. jq(objects).each( function(i) {
  1001. if ( null != jq.cookie('bp-' + objects[i] + '-filter') && jq('li#' + objects[i] + '-order-select select').length )
  1002. jq('li#' + objects[i] + '-order-select select option[value="' + jq.cookie('bp-' + objects[i] + '-filter') + '"]').prop( 'selected', true );
  1003. if ( null != jq.cookie('bp-' + objects[i] + '-scope') && jq('div.' + objects[i]).length ) {
  1004. jq('.item-list-tabs li').each( function() {
  1005. jq(this).removeClass('selected');
  1006. });
  1007. jq('.item-list-tabs li#' + objects[i] + '-' + jq.cookie('bp-' + objects[i] + '-scope') + ', div.item-list-tabs#object-nav li.current').addClass('selected');
  1008. }
  1009. });
  1010. }
  1011. /* Filter the current content list (groups/members/blogs/topics) */
  1012. function bp_filter_request( object, filter, scope, target, search_terms, page, extras ) {
  1013. if ( 'activity' == object )
  1014. return false;
  1015. if ( jq.query.get('s') && !search_terms )
  1016. search_terms = jq.query.get('s');
  1017. if ( null == scope )
  1018. scope = 'all';
  1019. /* Save the settings we want to remain persistent to a cookie */
  1020. jq.cookie( 'bp-' + object + '-scope', scope, {
  1021. path: '/'
  1022. } );
  1023. jq.cookie( 'bp-' + object + '-filter', filter, {
  1024. path: '/'
  1025. } );
  1026. jq.cookie( 'bp-' + object + '-extras', extras, {
  1027. path: '/'
  1028. } );
  1029. /* Set the correct selected nav and filter */
  1030. jq('.item-list-tabs li').each( function() {
  1031. jq(this).removeClass('selected');
  1032. });
  1033. jq('.item-list-tabs li#' + object + '-' + scope + ', .item-list-tabs#object-nav li.current').addClass('selected');
  1034. jq('.item-list-tabs li.selected').addClass('loading');
  1035. jq('.item-list-tabs select option[value="' + filter + '"]').prop( 'selected', true );
  1036. if ( 'friends' == object )
  1037. object = 'members';
  1038. if ( bp_ajax_request )
  1039. bp_ajax_request.abort();
  1040. bp_ajax_request = jq.post( ajaxurl, {
  1041. action: object + '_filter',
  1042. 'cookie': encodeURIComponent(document.cookie),
  1043. 'object': object,
  1044. 'filter': filter,
  1045. 'search_terms': search_terms,
  1046. 'scope': scope,
  1047. 'page': page,
  1048. 'extras': extras
  1049. },
  1050. function(response)
  1051. {
  1052. jq(target).fadeOut( 100, function() {
  1053. jq(this).html(response);
  1054. jq(this).fadeIn(100);
  1055. });
  1056. jq('.item-list-tabs li.selected').removeClass('loading');
  1057. });
  1058. }
  1059. /* Activity Loop Requesting */
  1060. function bp_activity_request(scope, filter) {
  1061. /* Save the type and filter to a session cookie */
  1062. jq.cookie( 'bp-activity-scope', scope, {
  1063. path: '/'
  1064. } );
  1065. jq.cookie( 'bp-activity-filter', filter, {
  1066. path: '/'
  1067. } );
  1068. jq.cookie( 'bp-activity-oldestpage', 1, {
  1069. path: '/'
  1070. } );
  1071. /* Remove selected and loading classes from tabs */
  1072. jq('.item-list-tabs li').each( function() {
  1073. jq(this).removeClass('selected loading');
  1074. });
  1075. /* Set the correct selected nav and filter */
  1076. jq('li#activity-' + scope + ', .item-list-tabs li.current').addClass('selected');
  1077. jq('#object-nav.item-list-tabs li.selected, div.activity-type-tabs li.selected').addClass('loading');
  1078. jq('#activity-filter-select select option[value="' + filter + '"]').prop( 'selected', true );
  1079. /* Reload the activity stream based on the selection */
  1080. jq('.widget_bp_activity_widget h2 span.ajax-loader').show();
  1081. if ( bp_ajax_request )
  1082. bp_ajax_request.abort();
  1083. bp_ajax_request = jq.post( ajaxurl, {
  1084. action: 'activity_widget_filter',
  1085. 'cookie': encodeURIComponent(document.cookie),
  1086. '_wpnonce_activity_filter': jq("input#_wpnonce_activity_filter").val(),
  1087. 'scope': scope,
  1088. 'filter': filter
  1089. },
  1090. function(response)
  1091. {
  1092. jq('.widget_bp_activity_widget h2 span.ajax-loader').hide();
  1093. jq('div.activity').fadeOut( 100, function() {
  1094. jq(this).html(response.contents);
  1095. jq(this).fadeIn(100);
  1096. /* Selectively hide comments */
  1097. bp_dtheme_hide_comments();
  1098. });
  1099. /* Update the feed link */
  1100. if ( null != response.feed_url )
  1101. jq('.directory #subnav li.feed a, .home-page #subnav li.feed a').attr('href', response.feed_url);
  1102. jq('.item-list-tabs li.selected').removeClass('loading');
  1103. }, 'json' );
  1104. }
  1105. /* Hide long lists of activity comments, only show the latest five root comments. */
  1106. function bp_dtheme_hide_comments() {
  1107. var comments_divs = jq('div.activity-comments');
  1108. if ( !comments_divs.length )
  1109. return false;
  1110. comments_divs.each( function() {
  1111. if ( jq(this).children('ul').children('li').length < 5 ) return;
  1112. var comments_div = jq(this);
  1113. var parent_li = comments_div.parents('ul#activity-stream > li');
  1114. var comment_lis = jq(this).children('ul').children('li');
  1115. var comment_count = ' ';
  1116. if ( jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').length )
  1117. var comment_count = jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').html();
  1118. comment_lis.each( function(i) {
  1119. /* Show the latest 5 root comments */
  1120. if ( i < comment_lis.length - 5 ) {
  1121. jq(this).addClass('hidden');
  1122. jq(this).toggle();
  1123. if ( !i )
  1124. 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>' );
  1125. }
  1126. });
  1127. });
  1128. }
  1129. /* Helper Functions */
  1130. function checkAll() {
  1131. var checkboxes = document.getElementsByTagName("input");
  1132. for(var i=0; i<checkboxes.length; i++) {
  1133. if(checkboxes[i].type == "checkbox") {
  1134. if($("check_all").checked == "") {
  1135. checkboxes[i].checked = "";
  1136. }
  1137. else {
  1138. checkboxes[i].checked = "checked";
  1139. }
  1140. }
  1141. }
  1142. }
  1143. function clear(container) {
  1144. if( !document.getElementById(container) ) return;
  1145. var container = document.getElementById(container);
  1146. if ( radioButtons = container.getElementsByTagName('INPUT') ) {
  1147. for(var i=0; i<radioButtons.length; i++) {
  1148. radioButtons[i].checked = '';
  1149. }
  1150. }
  1151. if ( options = container.getElementsByTagName('OPTION') ) {
  1152. for(var i=0; i<options.length; i++) {
  1153. options[i].selected = false;
  1154. }
  1155. }
  1156. return;
  1157. }
  1158. /* ScrollTo plugin - just inline and minified */
  1159. ;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
  1160. /* jQuery Easing Plugin, v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ */
  1161. jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,f,a,h,g){return jQuery.easing[jQuery.easing.def](e,f,a,h,g)},easeInQuad:function(e,f,a,h,g){return h*(f/=g)*f+a},easeOutQuad:function(e,f,a,h,g){return -h*(f/=g)*(f-2)+a},easeInOutQuad:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f+a}return -h/2*((--f)*(f-2)-1)+a},easeInCubic:function(e,f,a,h,g){return h*(f/=g)*f*f+a},easeOutCubic:function(e,f,a,h,g){return h*((f=f/g-1)*f*f+1)+a},easeInOutCubic:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f+a}return h/2*((f-=2)*f*f+2)+a},easeInQuart:function(e,f,a,h,g){return h*(f/=g)*f*f*f+a},easeOutQuart:function(e,f,a,h,g){return -h*((f=f/g-1)*f*f*f-1)+a},easeInOutQuart:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f+a}return -h/2*((f-=2)*f*f*f-2)+a},easeInQuint:function(e,f,a,h,g){return h*(f/=g)*f*f*f*f+a},easeOutQuint:function(e,f,a,h,g){return h*((f=f/g-1)*f*f*f*f+1)+a},easeInOutQuint:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f*f+a}return h/2*((f-=2)*f*f*f*f+2)+a},easeInSine:function(e,f,a,h,g){return -h*Math.cos(f/g*(Math.PI/2))+h+a},easeOutSine:function(e,f,a,h,g){return h*Math.sin(f/g*(Math.PI/2))+a},easeInOutSine:function(e,f,a,h,g){return -h/2*(Math.cos(Math.PI*f/g)-1)+a},easeInExpo:function(e,f,a,h,g){return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a},easeOutExpo:function(e,f,a,h,g){return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a},easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a},easeInCirc:function(e,f,a,h,g){return -h*(Math.sqrt(1-(f/=g)*f)-1)+a},easeOutCirc:function(e,f,a,h,g){return h*Math.sqrt(1-(f=f/g-1)*f)+a},easeInOutCirc:function(e,f,a,h,g){if((f/=g/2)<1){return -h/2*(Math.sqrt(1-f*f)-1)+a}return h/2*(Math.sqrt(1-(f-=2)*f)+1)+a},easeInElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return -(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e},easeOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return g*Math.pow(2,-10*h)*Math.sin((h*k-i)*(2*Math.PI)/j)+l+e},easeInOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k/2)==2){return e+l}if(!j){j=k*(0.3*1.5)}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}if(h<1){return -0.5*(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e}return g*Math.pow(2,-10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j)*0.5+l+e},easeInBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*(f/=h)*f*((g+1)*f-g)+a},easeOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*((f=f/h-1)*f*((g+1)*f+g)+1)+a},easeInOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}if((f/=h/2)<1){return i/2*(f*f*(((g*=(1.525))+1)*f-g))+a}return i/2*((f-=2)*f*(((g*=(1.525))+1)*f+g)+2)+a},easeInBounce:function(e,f,a,h,g){return h-jQuery.easing.easeOutBounce(e,g-f,0,h,g)+a},easeOutBounce:function(e,f,a,h,g){if((f/=g)<(1/2.75)){return h*(7.5625*f*f)+a}else{if(f<(2/2.75)){return h*(7.5625*(f-=(1.5/2.75))*f+0.75)+a}else{if(f<(2.5/2.75)){return h*(7.5625*(f-=(2.25/2.75))*f+0.9375)+a}else{return h*(7.5625*(f-=(2.625/2.75))*f+0.984375)+a}}}},easeInOutBounce:function(e,f,a,h,g){if(f<g/2){return jQuery.easing.easeInBounce(e,f*2,0,h,g)*0.5+a}return jQuery.easing.easeOutBounce(e,f*2-g,0,h,g)*0.5+h*0.5+a}});
  1162. /* jQuery Cookie plugin */
  1163. jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};
  1164. /* jQuery querystring plugin */
  1165. eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('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,…

Large files files are truncated, but you can click here to view the full file