Skip to content

Instantly share code, notes, and snippets.

@windmitry
Last active September 5, 2016 13:33
Show Gist options
  • Save windmitry/283f7ebe529fe10fca285f44c4fc1fc3 to your computer and use it in GitHub Desktop.
Save windmitry/283f7ebe529fe10fca285f44c4fc1fc3 to your computer and use it in GitHub Desktop.

Revisions

  1. Dmitry renamed this gist Sep 5, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Dmitry created this gist Sep 5, 2016.
    34 changes: 34 additions & 0 deletions features.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    Drupal.behaviors.webformPlaceholders = {
    attach:function (context, settings) {
    var text_search_default = Drupal.t("Enter Here");

    var inputField = $("form.webform-client-form input[type='text']");

    inputField.val(text_search_default);

    inputField.focus(function () {
    if ($(this).val() == text_search_default) {
    $(this).val('').addClass('active');
    }
    }).blur(function () {
    if ($(this).val() == '') {
    $(this).val(text_search_default).removeClass('active');
    }
    });

    $("form.webform-client-form").submit(function () {
    if (inputField.val() == text_search_default) {
    inputField.val('');
    }
    });
    }
    }

    // Render a user image with the default image style
    render(field_view_field('user', $user, 'field_avatar'));

    // and a nodes image
    render(field_view_field('node', $node, 'field_image'));

    // Render with a custom image style, in this case named 'post_avatar'
    render(field_view_field('user', $user, 'field_avatar', array('settings' => array('image_style' => 'post_avatar'))));