It would be nice to make the form empty when the user clicks on input textarea. This will avoid selecting the whole space to create a new status.

Thanks

Comments

icecreamyou’s picture

Status: Active » Postponed

Yeah, it would be nice. But I have no idea how to do it. I'll probably rewrite the module from scratch for a 2.x branch at some point, and I'll look at this when that happens or if someone submits a patch in the mean time.

dave_trigeia’s picture

Status: Needs work » Postponed

This isn't too tough, if you're willing to accept a JavaScript solution. I don't know how to do patches the drupal way, so I'll just share the code I used. I edited the facebook_status.js file in this module. I know it's not "the right way" to do it, but maybe you could add this into the module and then it wouldn't matter next time. I picked the function name that I did because I figured it probably wouldn't conflict with anything else that's out there. Feel free to choose something more appropriate. This is the full contents of the file now:

if (Drupal.jsEnabled) {
  $(document).ready(function () {
    $('div.facebook_status_block').find('div.facebook_status_form').hide().end().find('div.facebook_status_status').click(function() {
      $('div.facebook_status_form').slideToggle();
      facebook_status_form_clear();
    });
  });
  function facebook_status_form_clear(){
    e = document.getElementById('edit-name');
    e.value = "";
    e.focus();
  }
}
icecreamyou’s picture

Status: Postponed » Needs work

Thanks dave:

To get your spacing to stay the same when you submit a post, surround your code with <code></code> tags. Also you should name functions like this: modulename_description(). If you clean that up a little I'll test it out and if it works I'll add it to the module.

dave_trigeia’s picture

Thanks for the <code> hint. I edited the post with it, but that one line is so long that it runs right off the edge. I also renamed the function, I believe properly, so it should be ready for you to test.

icecreamyou’s picture

Status: Postponed » Needs review

Cool. I was inspired enough by a few tweaks I wanted to make that I went and spent an hour learning basic JQuery. Here's the result. I tested on 5.x and 6.x (remember to refresh your JS cache, especially on 6.x at admin/settings/performance, before testing). However I'm far from a JQ expert so I'd like someone to check this and mark it RTBC if it works and can't be simplified. At that point I'll commit it to both branches.

if (Drupal.jsEnabled) {
  $(document).ready(function () {
    facebook_status_count = 1;
    facebook_status_original_value = $('div.facebook_status_block').find('input#edit-name').val();
    //Show or hide status form.
    $('div.facebook_status_block').find('div.facebook_status_form').hide().end().find('div.facebook_status_status').click(function() {
      $('div.facebook_status_form').slideToggle();
    });
    $('div.facebook_status_block').find('input#edit-name').focus(function() {
      facebook_status_form_clear();
    });
  });
  function facebook_status_form_clear() {
    facebook_status_value = $('div.facebook_status_block').find('input#edit-name').val();
    //Clear field on focus unless new text has been entered.
    if (facebook_status_count == 1) {
      facebook_status_value = "";
      $('div.facebook_status_block').find('input#edit-name').val(facebook_status_value);
    }
    $('div.facebook_status_block').find('input#edit-name').keypress(function() {
      facebook_status_count = 0;
    });
    //Set to original value on unfocus if field is empty.
    $('div.facebook_status_block').find('input#edit-name').blur(function() {
      if ($('div.facebook_status_block').find('input#edit-name').val() == "") {
        facebook_status_value = facebook_status_original_value;
        $('div.facebook_status_block').find('input#edit-name').val(facebook_status_value);
      }
    });
  }
}
gausarts’s picture

Thanks for the great support.

I was about to try some theme override I found somewhere which is fine for the login block:

function theme_preprocess_user_login_block(&$variables) {

  $variables['form']['name']['#value'] = $variables['form']['name']['#title'];
  $variables['form']['pass']['#value'] = $variables['form']['pass']['#title'];

  $variables['form']['name']['#attributes']['OnClick'] = 'this.value=""';
  $variables['form']['pass']['#attributes']['OnClick'] = 'this.value=""';

  $variables['form']['name']['#required'] = false;
  $variables['form']['pass']['#required'] = false;

  $variables['rendered'] = drupal_render($variables['form']);
}

But I had no idea to do it right with the facebook_status module:) Thanks

icecreamyou’s picture

Status: Needs review » Fixed

Hah, even if you knew how that code has to be implemented, and assuming it works, it would clear the form every time you clicked it.

Anyway, even though I'd like someone who knows a lot about JQ syntax to review this to make sure I can't dramatically simplify the code, I've been using it and I know it works, and apparently at least one person confirms that, so... committed!

dave_trigeia’s picture

I updated the module with your new release and it works great. Thanks for the attention.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.