You are here

function _ai_admin_textarea_height in Content Injector (formerly AdSense Injector) 7.3

Same name and namespace in other branches
  1. 6.3 adsense_injector.admin.inc \_ai_admin_textarea_height()

Determine textarea auto-height in rows for a bit of text.

Parameters

$text The text to operate on.:

Return value

The number of rows we should use for a textarea.

1 call to _ai_admin_textarea_height()
adsense_injector_admin_settings in ./adsense_injector.admin.inc
Implements hook_settings().

File

./adsense_injector.admin.inc, line 148
Administrative page callbacks for the adsense_injector module.

Code

function _ai_admin_textarea_height($text) {

  //
  // Determine # of lines in textarea
  // http://stackoverflow.com/questions/1743745/count-new-lines-in-textarea-to-resize-container-in-php
  preg_match_all("/(\n)/", $text, $matches);
  $count = count($matches[0]) + 1;

  // +1 for the last tine
  return max(5, min($count, 20));
}