Guest User

bp post-form char limit

a guest
Sep 19th, 2010
246
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <form action="<?php bp_activity_post_form_action() ?>" method="post" id="whats-new-form" name="whats-new-form">
  2.  
  3. <?php do_action( 'bp_before_activity_post_form' ) ?>
  4.  
  5. <?php if ( isset( $_GET['r'] ) ) : ?>
  6. <div id="message" class="info">
  7. <p><?php printf( __( 'You are mentioning %s in a new update, this user will be sent a notification of your message.', 'buddypress' ), bp_get_mentioned_user_display_name( $_GET['r'] ) ) ?></p>
  8. </div>
  9. <?php endif; ?>
  10.  
  11. <div id="whats-new-avatar">
  12. <a href="<?php echo bp_loggedin_user_domain() ?>">
  13. <?php bp_loggedin_user_avatar( 'width=60&height=60' ) ?>
  14. </a>
  15. </div>
  16.  
  17. <h5>
  18. <?php if ( bp_is_group() ) : ?>
  19. <?php printf( __( "What's new in %s, %s?", 'buddypress' ), bp_get_group_name(), bp_get_user_firstname() ); ?>
  20. <?php elseif(!bp_is_home()&&bp_is_member()): ?>
  21. <?php printf( __( "Write something to %s?", 'buddypress' ), bp_get_displayed_user_fullname() ) ;?>
  22. <?php else : ?>
  23. <?php printf( __( "What's new %s?", 'buddypress' ), bp_get_user_firstname() ) ;?>
  24. <?php endif; ?>
  25.  
  26. </h5>
  27.  
  28. <script language="javascript">
  29. function limitChars(textarea, limit, infodiv)
  30. {
  31. var text = textarea.value;
  32. var textlength = text.length;
  33. var info = document.getElementById(infodiv);
  34.  
  35. if(textlength > limit)
  36. {
  37. info.innerHTML = 'You cannot write more than '+limit+' characters!';
  38. textarea.value = text.substr(0,limit);
  39. return false;
  40. }
  41. else
  42. {
  43. info.innerHTML = 'You have '+ (limit - textlength) +' characters left.';
  44. return true;
  45. }
  46. }
  47. </script>
  48.  
  49. <div id="whats-new-content">
  50.  
  51. <div id="whats-new-textarea">
  52. <textarea name="whats-new" id="whats-new" onkeyup="limitChars(this, 200, 'charlimitinfo')" /><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_attr( $_GET['r'] ) ?> <?php endif; ?></textarea>
  53. </div>
  54. <span id="charlimitinfo" style=" float:left; color:#aa3333; font-size:11px;" >Maximum 200 characters.<br /></span>
  55.  
  56. <div id="whats-new-options">
  57. <div id="whats-new-submit">
  58. <span class="ajax-loader"></span> &nbsp;
  59. <input type="submit" name="aw-whats-new-submit" id="aw-whats-new-submit" value="<?php _e( 'Post Update', 'buddypress' ) ?>" />
  60. </div>
  61.  
  62. <?php if ( function_exists('bp_has_groups') &&!bp_is_member() &&!bp_is_group() ) : ?>
  63. <div id="whats-new-post-in-box">
  64. <?php _e( 'Post in', 'buddypress' ) ?>:
  65.  
  66. <select id="whats-new-post-in" name="whats-new-post-in">
  67. <option selected="selected" value="0"><?php _e( 'My Profile', 'buddypress' ) ?></option>
  68.  
  69. <?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100&populate_extras=0' ) ) : while ( bp_groups() ) : bp_the_group(); ?>
  70. <option value="<?php bp_group_id() ?>"><?php bp_group_name() ?></option>
  71. <?php endwhile; endif; ?>
  72. </select>
  73. </div>
  74. <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
  75. <?php elseif ( bp_is_group_home() ) : ?>
  76. <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
  77. <input type="hidden" id="whats-new-post-in" name="whats-new-post-in" value="<?php bp_group_id() ?>" />
  78. <?php endif; ?>
  79.  
  80. <?php do_action( 'bp_activity_post_form_options' ) ?>
  81.  
  82. </div><!-- #whats-new-options -->
  83. </div><!-- #whats-new-content -->
  84.  
  85. <?php wp_nonce_field( 'post_update', '_wpnonce_post_update' ); ?>
  86. <?php do_action( 'bp_after_activity_post_form' ) ?>
  87.  
  88. </form><!-- #whats-new-form -->
RAW Paste Data