2013-08-05 19:46:39 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a simple preview panel for a bound Remarkup text control.
|
|
|
|
*/
|
|
|
|
final class PHUIRemarkupPreviewPanel extends AphrontTagView {
|
|
|
|
|
|
|
|
private $header;
|
|
|
|
private $loadingText;
|
|
|
|
private $controlID;
|
|
|
|
private $previewURI;
|
|
|
|
|
|
|
|
protected function canAppendChild() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPreviewURI($preview_uri) {
|
|
|
|
$this->previewURI = $preview_uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setControlID($control_id) {
|
|
|
|
$this->controlID = $control_id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHeader($header) {
|
|
|
|
$this->header = $header;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setLoadingText($loading_text) {
|
|
|
|
$this->loadingText = $loading_text;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-01-13 20:54:39 +01:00
|
|
|
protected function getTagName() {
|
2013-08-05 19:46:39 +02:00
|
|
|
return 'div';
|
|
|
|
}
|
|
|
|
|
2015-01-13 20:54:39 +01:00
|
|
|
protected function getTagAttributes() {
|
2013-08-05 19:47:26 +02:00
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phui-remarkup-preview';
|
|
|
|
|
2013-08-05 19:46:39 +02:00
|
|
|
return array(
|
2013-08-05 19:47:26 +02:00
|
|
|
'class' => $classes,
|
2013-08-05 19:46:39 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagContent() {
|
|
|
|
if ($this->previewURI === null) {
|
2015-05-13 23:53:52 +02:00
|
|
|
throw new PhutilInvalidStateException('setPreviewURI');
|
2013-08-05 19:46:39 +02:00
|
|
|
}
|
|
|
|
if ($this->controlID === null) {
|
2015-05-13 23:53:52 +02:00
|
|
|
throw new PhutilInvalidStateException('setControlID');
|
2013-08-05 19:46:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$preview_id = celerity_generate_unique_node_id();
|
|
|
|
|
|
|
|
require_celerity_resource('phui-remarkup-preview-css');
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'remarkup-preview',
|
|
|
|
array(
|
|
|
|
'previewID' => $preview_id,
|
|
|
|
'controlID' => $this->controlID,
|
|
|
|
'uri' => $this->previewURI,
|
|
|
|
));
|
|
|
|
|
|
|
|
$loading = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-preview-loading-text',
|
|
|
|
),
|
|
|
|
nonempty($this->loadingText, pht('Loading preview...')));
|
|
|
|
|
|
|
|
$header = null;
|
|
|
|
if ($this->header) {
|
|
|
|
$header = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-preview-header',
|
|
|
|
),
|
|
|
|
$this->header);
|
|
|
|
}
|
|
|
|
|
|
|
|
$preview = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'id' => $preview_id,
|
2015-06-25 19:17:22 +02:00
|
|
|
'class' => 'phabricator-remarkup phui-preview-body',
|
2013-08-05 19:46:39 +02:00
|
|
|
),
|
|
|
|
$loading);
|
|
|
|
|
2013-08-05 19:47:26 +02:00
|
|
|
$content = array($header, $preview);
|
|
|
|
|
2015-06-25 19:17:22 +02:00
|
|
|
return id(new PHUIObjectBoxView())
|
[Redesign] Move basefont to Lato, remove Source Sans Pro
Summary: Working towards a more unified look and feel. This brings in Lato as a complete base font over Helvetica Neue, as well as removing Source Sans Pro from DocumentView and Conpherence. Design-wise Lato provides the nice readability at larger font sizes that Source Sans Pro did, with the ability to scale down to tables and UI widgets with ease. This gives us one font instead of two, and now Object descriptions and Timeline posts all can benefit from a consistent, readable font.
Test Plan:
Test main UI, smaller elements like tables, menus, DocumentViews, Previews, Conpherence.
{F498135}
{F498136}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: epriestley, Korvin
Differential Revision: https://secure.phabricator.com/D13276
2015-06-13 21:32:45 +02:00
|
|
|
->appendChild($content)
|
2015-06-25 19:17:22 +02:00
|
|
|
->setCollapsed(true);
|
2013-08-05 19:46:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|