/wp-content/plugins/wpmudev-updates/includes/js/community.js

https://gitlab.com/iamgraeme/royalmile · JavaScript · 85 lines · 67 code · 13 blank · 5 comment · 10 complexity · 42e0a418a81e4513cdfdc125acb7b723 MD5 · raw file

  1. jQuery(document).ready(function($) {
  2. jQuery('.most-popular-topics h1').parent().each(function () {
  3. var $me = $(this);
  4. if (!$me.is("li")) return true;
  5. $me.on('click', function (e) {
  6. if ($(e.target).is('a[href^="http://"]')) return true; // Allow external links to do their thing.
  7. var $_content = $me.parent().find('ul');
  8. $_content.is(":visible")
  9. ? $_content.find("table").hide().end().slideUp('fast')
  10. : $_content.slideDown('fast').find("table").show()
  11. ;
  12. return false;
  13. });
  14. });
  15. //handle forum search box
  16. $('#forum-search-go').click(function() {
  17. var searchUrl = 'http://premium.wpmudev.org/forums/search.php?q=' + $('#forum-search-q').val();
  18. window.open(searchUrl, '_blank');
  19. return false;
  20. });
  21. //catch the enter key
  22. $('#forum-search-q').keypress(function(e) {
  23. if(e.which == 13) {
  24. $(this).blur();
  25. $('#forum-search-go').focus().click();
  26. }
  27. });
  28. // handle container heights, raw js because fast & simple
  29. (function(){
  30. var isDisabled = document.getElementById( 'support-disabled' );
  31. if ( isDisabled ) {
  32. document.getElementById( 'wpbody-content' ).style.paddingTop = 0;
  33. processHeight( 'support-layer' );
  34. window.onresize = function(){
  35. processHeight( 'support-layer' );
  36. }
  37. } else {
  38. processHeight( 'wpcontent' );
  39. window.onresize = function(){
  40. processHeight( 'wpcontent' );
  41. }
  42. }
  43. })();
  44. function processHeight( element ) { // accepts ID string, as many agruments as needed
  45. for ( var i = 0, j=arguments.length; i < j; i++ ) {
  46. var el = document.getElementById( arguments[i] ),
  47. docHeight = getDocHeight(),
  48. uaHeight = $(window).height();
  49. if ( el ) {
  50. if ( docHeight > uaHeight ){
  51. el.removeAttribute('style');
  52. docHeight = getDocHeight();
  53. el.style.height = docHeight + 'px';
  54. } else {
  55. el.removeAttribute('style');
  56. docHeight = getDocHeight();
  57. el.style.height = uaHeight + 'px';
  58. }
  59. }
  60. }
  61. // get document height function
  62. // credit to James Padolsey (http://james.padolsey.com/javascript/get-document-height-cross-browser/)
  63. function getDocHeight() {
  64. var D = document;
  65. return Math.max(
  66. Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
  67. Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
  68. Math.max(D.body.clientHeight, D.documentElement.clientHeight)
  69. );
  70. }
  71. }
  72. });