labelMore = _t('ToggleField.MORE', 'more'); $this->labelLess = _t('ToggleField.LESS', 'less'); $this->startClosed(true); parent::__construct($name, $title, $value); } /** * @inheritdoc * * @param array $properties * * @return string|HTMLText */ public function Field($properties = array()) { Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(FRAMEWORK_DIR . '/javascript/ToggleField.js'); if($this->startClosed) { $this->addExtraClass('startClosed'); } $valueForInput = ''; if($this->value) { $valueForInput = Convert::raw2att($this->value); } $rawInput = Convert::html2raw($valueForInput); if($this->charNum) { $reducedValue = substr($rawInput, 0, $this->charNum); } else { $reducedValue = DBField::create_field('Text', $rawInput)->{$this->truncateMethod}(); } // only create toggle field if the truncated content is shorter if(strlen($reducedValue) < strlen($rawInput)) { $content = << $reducedValue $this->labelMore