Changeset View
Changeset View
Standalone View
Standalone View
src/view/phui/PHUIRemarkupPreviewPanel.php
<?php | <?php | ||||
/** | /** | ||||
* Render a simple preview panel for a bound Remarkup text control. | * Render a simple preview panel for a bound Remarkup text control. | ||||
*/ | */ | ||||
final class PHUIRemarkupPreviewPanel extends AphrontTagView { | final class PHUIRemarkupPreviewPanel extends AphrontTagView { | ||||
private $header; | private $header; | ||||
private $loadingText; | private $loadingText; | ||||
private $controlID; | private $controlID; | ||||
private $previewURI; | private $previewURI; | ||||
private $previewType; | |||||
const DOCUMENT = 'document'; | |||||
protected function canAppendChild() { | protected function canAppendChild() { | ||||
return false; | return false; | ||||
} | } | ||||
public function setPreviewURI($preview_uri) { | public function setPreviewURI($preview_uri) { | ||||
$this->previewURI = $preview_uri; | $this->previewURI = $preview_uri; | ||||
return $this; | return $this; | ||||
Show All 9 Lines | public function setHeader($header) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setLoadingText($loading_text) { | public function setLoadingText($loading_text) { | ||||
$this->loadingText = $loading_text; | $this->loadingText = $loading_text; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setPreviewType($type) { | |||||
$this->previewType = $type; | |||||
return $this; | |||||
} | |||||
protected function getTagName() { | protected function getTagName() { | ||||
return 'div'; | return 'div'; | ||||
} | } | ||||
protected function getTagAttributes() { | protected function getTagAttributes() { | ||||
$classes = array(); | $classes = array(); | ||||
$classes[] = 'phui-remarkup-preview'; | $classes[] = 'phui-remarkup-preview'; | ||||
Show All 23 Lines | protected function getTagContent() { | ||||
$loading = phutil_tag( | $loading = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'phui-preview-loading-text', | 'class' => 'phui-preview-loading-text', | ||||
), | ), | ||||
nonempty($this->loadingText, pht('Loading preview...'))); | nonempty($this->loadingText, pht('Loading preview...'))); | ||||
$preview = phutil_tag( | |||||
'div', | |||||
array( | |||||
'id' => $preview_id, | |||||
'class' => 'phabricator-remarkup phui-preview-body', | |||||
), | |||||
$loading); | |||||
if (!$this->previewType) { | |||||
$header = null; | $header = null; | ||||
if ($this->header) { | if ($this->header) { | ||||
$header = phutil_tag( | $header = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'phui-preview-header', | 'class' => 'phui-preview-header', | ||||
), | ), | ||||
$this->header); | $this->header); | ||||
} | } | ||||
$preview = phutil_tag( | |||||
'div', | |||||
array( | |||||
'id' => $preview_id, | |||||
'class' => 'phabricator-remarkup phui-preview-body', | |||||
), | |||||
$loading); | |||||
$content = array($header, $preview); | $content = array($header, $preview); | ||||
} else if ($this->previewType == self::DOCUMENT) { | |||||
$header = id(new PHUIHeaderView()) | |||||
->setHeader(pht('%s (Document Preview)', $this->header)); | |||||
$content = id(new PHUIDocumentViewPro()) | |||||
->setHeader($header) | |||||
->appendChild($preview); | |||||
} | |||||
return id(new PHUIObjectBoxView()) | return id(new PHUIObjectBoxView()) | ||||
->appendChild($content) | ->appendChild($content) | ||||
->setCollapsed(true); | ->setCollapsed(true); | ||||
} | } | ||||
} | } |