mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-18 10:41:08 +01:00
Add a "document" style to PHUIRemarkupPreviewPanel and use it in Legalpad and Phriction
Summary: Ref T3671. Depends on D6674. Continues work in D6673, D6674 and extends it into Legalpad and Phriction. Then deletes a bunch of dead code. Test Plan: Edited documents in Legalpad and Phriction, verified I got reasonable looking previews. Reviewers: btrahan, Firehed Reviewed By: btrahan CC: aran, chad Maniphest Tasks: T3671 Differential Revision: https://secure.phabricator.com/D6675
This commit is contained in:
parent
b2fa1293a7
commit
b712905dc1
18 changed files with 86 additions and 188 deletions
|
@ -1765,19 +1765,6 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'disk' => '/rsrc/js/core/behavior-konami.js',
|
'disk' => '/rsrc/js/core/behavior-konami.js',
|
||||||
),
|
),
|
||||||
'javelin-behavior-legalpad-document-preview' =>
|
|
||||||
array(
|
|
||||||
'uri' => '/res/d0ce5a8c/rsrc/js/application/legalpad/legalpad-document-preview.js',
|
|
||||||
'type' => 'js',
|
|
||||||
'requires' =>
|
|
||||||
array(
|
|
||||||
0 => 'javelin-behavior',
|
|
||||||
1 => 'javelin-dom',
|
|
||||||
2 => 'javelin-util',
|
|
||||||
3 => 'phabricator-shaped-request',
|
|
||||||
),
|
|
||||||
'disk' => '/rsrc/js/application/legalpad/legalpad-document-preview.js',
|
|
||||||
),
|
|
||||||
'javelin-behavior-lightbox-attachments' =>
|
'javelin-behavior-lightbox-attachments' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/72b4d3a8/rsrc/js/core/behavior-lightbox-attachments.js',
|
'uri' => '/res/72b4d3a8/rsrc/js/core/behavior-lightbox-attachments.js',
|
||||||
|
@ -2255,19 +2242,6 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'disk' => '/rsrc/js/application/pholio/behavior-pholio-mock-view.js',
|
'disk' => '/rsrc/js/application/pholio/behavior-pholio-mock-view.js',
|
||||||
),
|
),
|
||||||
'javelin-behavior-phriction-document-preview' =>
|
|
||||||
array(
|
|
||||||
'uri' => '/res/e2fe02de/rsrc/js/application/phriction/phriction-document-preview.js',
|
|
||||||
'type' => 'js',
|
|
||||||
'requires' =>
|
|
||||||
array(
|
|
||||||
0 => 'javelin-behavior',
|
|
||||||
1 => 'javelin-dom',
|
|
||||||
2 => 'javelin-util',
|
|
||||||
3 => 'phabricator-shaped-request',
|
|
||||||
),
|
|
||||||
'disk' => '/rsrc/js/application/phriction/phriction-document-preview.js',
|
|
||||||
),
|
|
||||||
'javelin-behavior-ponder-votebox' =>
|
'javelin-behavior-ponder-votebox' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/c28daa12/rsrc/js/application/ponder/behavior-votebox.js',
|
'uri' => '/res/c28daa12/rsrc/js/application/ponder/behavior-votebox.js',
|
||||||
|
@ -3781,7 +3755,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'phriction-document-css' =>
|
'phriction-document-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/97a9ef40/rsrc/css/application/phriction/phriction-document-css.css',
|
'uri' => '/res/754f6b37/rsrc/css/application/phriction/phriction-document-css.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
@ -3853,7 +3827,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'phui-remarkup-preview-css' =>
|
'phui-remarkup-preview-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/80d54c8c/rsrc/css/phui/phui-remarkup-preview.css',
|
'uri' => '/res/6c886e63/rsrc/css/phui/phui-remarkup-preview.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -647,7 +647,6 @@ phutil_register_library_map(array(
|
||||||
'LegalpadDocumentEditController' => 'applications/legalpad/controller/LegalpadDocumentEditController.php',
|
'LegalpadDocumentEditController' => 'applications/legalpad/controller/LegalpadDocumentEditController.php',
|
||||||
'LegalpadDocumentEditor' => 'applications/legalpad/editor/LegalpadDocumentEditor.php',
|
'LegalpadDocumentEditor' => 'applications/legalpad/editor/LegalpadDocumentEditor.php',
|
||||||
'LegalpadDocumentListController' => 'applications/legalpad/controller/LegalpadDocumentListController.php',
|
'LegalpadDocumentListController' => 'applications/legalpad/controller/LegalpadDocumentListController.php',
|
||||||
'LegalpadDocumentPreviewController' => 'applications/legalpad/controller/LegalpadDocumentPreviewController.php',
|
|
||||||
'LegalpadDocumentQuery' => 'applications/legalpad/query/LegalpadDocumentQuery.php',
|
'LegalpadDocumentQuery' => 'applications/legalpad/query/LegalpadDocumentQuery.php',
|
||||||
'LegalpadDocumentSearchEngine' => 'applications/legalpad/query/LegalpadDocumentSearchEngine.php',
|
'LegalpadDocumentSearchEngine' => 'applications/legalpad/query/LegalpadDocumentSearchEngine.php',
|
||||||
'LegalpadDocumentSignController' => 'applications/legalpad/controller/LegalpadDocumentSignController.php',
|
'LegalpadDocumentSignController' => 'applications/legalpad/controller/LegalpadDocumentSignController.php',
|
||||||
|
@ -2657,7 +2656,6 @@ phutil_register_library_map(array(
|
||||||
0 => 'LegalpadController',
|
0 => 'LegalpadController',
|
||||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||||
),
|
),
|
||||||
'LegalpadDocumentPreviewController' => 'LegalpadController',
|
|
||||||
'LegalpadDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'LegalpadDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'LegalpadDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'LegalpadDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'LegalpadDocumentSignController' => 'LegalpadController',
|
'LegalpadDocumentSignController' => 'LegalpadController',
|
||||||
|
|
|
@ -49,7 +49,7 @@ final class PhabricatorApplicationLegalpad extends PhabricatorApplication {
|
||||||
'comment/(?P<id>\d+)/' => 'LegalpadDocumentCommentController',
|
'comment/(?P<id>\d+)/' => 'LegalpadDocumentCommentController',
|
||||||
'view/(?P<id>\d+)/' => 'LegalpadDocumentViewController',
|
'view/(?P<id>\d+)/' => 'LegalpadDocumentViewController',
|
||||||
'document/' => array(
|
'document/' => array(
|
||||||
'preview/' => 'LegalpadDocumentPreviewController'),
|
'preview/' => 'PhabricatorMarkupPreviewController'),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,34 +172,19 @@ final class LegalpadDocumentEditController extends LegalpadController {
|
||||||
$crumbs->addCrumb(
|
$crumbs->addCrumb(
|
||||||
id(new PhabricatorCrumbView())->setName($short));
|
id(new PhabricatorCrumbView())->setName($short));
|
||||||
|
|
||||||
$preview_header = id(new PhabricatorHeaderView())
|
|
||||||
->setHeader(pht('Document Preview'));
|
$preview = id(new PHUIRemarkupPreviewPanel())
|
||||||
$preview_view = phutil_tag(
|
->setHeader(pht('Document Preview'))
|
||||||
'div',
|
->setPreviewURI($this->getApplicationURI('document/preview/'))
|
||||||
array(
|
->setControlID('document-text')
|
||||||
'id' => 'document-preview'),
|
->setSkin('document');
|
||||||
phutil_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'aphront-panel-preview-loading-text'),
|
|
||||||
pht('Loading preview...')));
|
|
||||||
$preview_panel = id(new PHUIDocumentView())
|
|
||||||
->appendChild($preview_header)
|
|
||||||
->appendChild($preview_view);
|
|
||||||
Javelin::initBehavior(
|
|
||||||
'legalpad-document-preview',
|
|
||||||
array(
|
|
||||||
'preview' => 'document-preview',
|
|
||||||
'title' => 'document-title',
|
|
||||||
'text' => 'document-text',
|
|
||||||
'uri' => $this->getApplicationURI('document/preview/')));
|
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
array(
|
array(
|
||||||
$crumbs,
|
$crumbs,
|
||||||
$error_view,
|
$error_view,
|
||||||
$form,
|
$form,
|
||||||
$preview_panel
|
$preview
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group legalpad
|
|
||||||
*/
|
|
||||||
final class LegalpadDocumentPreviewController
|
|
||||||
extends LegalpadController {
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$user = $request->getUser();
|
|
||||||
$text = $request->getStr('text');
|
|
||||||
|
|
||||||
$body = id(new LegalpadDocumentBody())
|
|
||||||
->setText($text);
|
|
||||||
|
|
||||||
$content = PhabricatorMarkupEngine::renderOneObject(
|
|
||||||
$body,
|
|
||||||
LegalpadDocumentBody::MARKUP_FIELD_TEXT,
|
|
||||||
$user);
|
|
||||||
|
|
||||||
$content = hsprintf('<div class="phabricator-remarkup">%s</div>', $content);
|
|
||||||
|
|
||||||
return id(new AphrontAjaxResponse())->setContent($content);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -52,7 +52,7 @@ final class PhabricatorApplicationPhriction extends PhabricatorApplication {
|
||||||
'new/' => 'PhrictionNewController',
|
'new/' => 'PhrictionNewController',
|
||||||
'move/(?:(?P<id>[1-9]\d*)/)?' => 'PhrictionMoveController',
|
'move/(?:(?P<id>[1-9]\d*)/)?' => 'PhrictionMoveController',
|
||||||
|
|
||||||
'preview/' => 'PhrictionDocumentPreviewController',
|
'preview/' => 'PhabricatorMarkupPreviewController',
|
||||||
'diff/(?P<id>[1-9]\d*)/' => 'PhrictionDiffController',
|
'diff/(?P<id>[1-9]\d*)/' => 'PhrictionDiffController',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -229,24 +229,11 @@ final class PhrictionEditController
|
||||||
$header = id(new PhabricatorHeaderView())
|
$header = id(new PhabricatorHeaderView())
|
||||||
->setHeader($panel_header);
|
->setHeader($panel_header);
|
||||||
|
|
||||||
$preview_content = hsprintf(
|
$preview = id(new PHUIRemarkupPreviewPanel())
|
||||||
'<div class="phriction-document-preview-header plt pll">%s</div>
|
->setHeader(pht('Document Preview'))
|
||||||
<div id="document-preview">
|
->setPreviewURI('/phriction/preview/')
|
||||||
<div class="aphront-panel-preview-loading-text">%s</div>
|
->setControlID('document-textarea')
|
||||||
</div>',
|
->setSkin('document');
|
||||||
pht('Document Preview'),
|
|
||||||
pht('Loading preview...'));
|
|
||||||
|
|
||||||
$preview_panel = id(new PHUIDocumentView())
|
|
||||||
->appendChild($preview_content);
|
|
||||||
|
|
||||||
Javelin::initBehavior(
|
|
||||||
'phriction-document-preview',
|
|
||||||
array(
|
|
||||||
'preview' => 'document-preview',
|
|
||||||
'textarea' => 'document-textarea',
|
|
||||||
'uri' => '/phriction/preview/?draftkey='.$draft_key,
|
|
||||||
));
|
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
if ($document->getID()) {
|
if ($document->getID()) {
|
||||||
|
@ -269,7 +256,7 @@ final class PhrictionEditController
|
||||||
$draft_note,
|
$draft_note,
|
||||||
$error_view,
|
$error_view,
|
||||||
$form,
|
$form,
|
||||||
$preview_panel,
|
$preview,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'title' => pht('Edit Document'),
|
'title' => pht('Edit Document'),
|
||||||
|
|
|
@ -100,7 +100,7 @@ final class PonderAnswer extends PonderDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newMarkupEngine($field) {
|
public function newMarkupEngine($field) {
|
||||||
return PhabricatorMarkupEngine::newPonderMarkupEngine();
|
return PhabricatorMarkupEngine::getEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function didMarkupText(
|
public function didMarkupText(
|
||||||
|
|
|
@ -20,7 +20,7 @@ final class PonderComment extends PonderDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newMarkupEngine($field) {
|
public function newMarkupEngine($field) {
|
||||||
return PhabricatorMarkupEngine::newPonderMarkupEngine();
|
return PhabricatorMarkupEngine::getEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function didMarkupText(
|
public function didMarkupText(
|
||||||
|
|
|
@ -146,7 +146,7 @@ final class PonderQuestion extends PonderDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newMarkupEngine($field) {
|
public function newMarkupEngine($field) {
|
||||||
return PhabricatorMarkupEngine::newPonderMarkupEngine();
|
return PhabricatorMarkupEngine::getEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function didMarkupText(
|
public function didMarkupText(
|
||||||
|
|
|
@ -345,20 +345,6 @@ final class PhabricatorMarkupEngine {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @task engine
|
|
||||||
*/
|
|
||||||
public static function newSlowvoteMarkupEngine() {
|
|
||||||
return self::newMarkupEngine(array(
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static function newPonderMarkupEngine(array $options = array()) {
|
|
||||||
return self::newMarkupEngine($options);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @task engine
|
* @task engine
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,6 +15,12 @@
|
||||||
final class PhabricatorMarkupOneOff implements PhabricatorMarkupInterface {
|
final class PhabricatorMarkupOneOff implements PhabricatorMarkupInterface {
|
||||||
|
|
||||||
private $content;
|
private $content;
|
||||||
|
private $preserveLinebreaks;
|
||||||
|
|
||||||
|
public function setPreserveLinebreaks($preserve_linebreaks) {
|
||||||
|
$this->preserveLinebreaks = $preserve_linebreaks;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setContent($content) {
|
public function setContent($content) {
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
|
@ -32,7 +38,7 @@ final class PhabricatorMarkupOneOff implements PhabricatorMarkupInterface {
|
||||||
public function newMarkupEngine($field) {
|
public function newMarkupEngine($field) {
|
||||||
return PhabricatorMarkupEngine::newMarkupEngine(
|
return PhabricatorMarkupEngine::newMarkupEngine(
|
||||||
array(
|
array(
|
||||||
'preserve-linebreaks' => false,
|
'preserve-linebreaks' => $this->preserveLinebreaks,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@ final class PhabricatorMarkupPreviewController
|
||||||
$text = $request->getStr('text');
|
$text = $request->getStr('text');
|
||||||
|
|
||||||
$output = PhabricatorMarkupEngine::renderOneObject(
|
$output = PhabricatorMarkupEngine::renderOneObject(
|
||||||
id(new PhabricatorMarkupOneOff())->setContent($text),
|
id(new PhabricatorMarkupOneOff())
|
||||||
|
->setPreserveLinebreaks(true)
|
||||||
|
->setContent($text),
|
||||||
'default',
|
'default',
|
||||||
$viewer);
|
$viewer);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ final class PHUIRemarkupPreviewPanel extends AphrontTagView {
|
||||||
private $loadingText;
|
private $loadingText;
|
||||||
private $controlID;
|
private $controlID;
|
||||||
private $previewURI;
|
private $previewURI;
|
||||||
|
private $skin = 'default';
|
||||||
|
|
||||||
protected function canAppendChild() {
|
protected function canAppendChild() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -34,13 +35,35 @@ final class PHUIRemarkupPreviewPanel extends AphrontTagView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setSkin($skin) {
|
||||||
|
static $skins = array(
|
||||||
|
'default' => true,
|
||||||
|
'document' => true,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (empty($skins[$skin])) {
|
||||||
|
$valid = implode(', ', array_keys($skins));
|
||||||
|
throw new Exception("Invalid skin '{$skin}'. Valid skins are: {$valid}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->skin = $skin;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getTagName() {
|
public function getTagName() {
|
||||||
return 'div';
|
return 'div';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTagAttributes() {
|
public function getTagAttributes() {
|
||||||
|
$classes = array();
|
||||||
|
$classes[] = 'phui-remarkup-preview';
|
||||||
|
|
||||||
|
if ($this->skin) {
|
||||||
|
$classes[] = 'phui-remarkup-preview-skin-'.$this->skin;
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'class' => 'phui-remarkup-preview',
|
'class' => $classes,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +111,17 @@ final class PHUIRemarkupPreviewPanel extends AphrontTagView {
|
||||||
),
|
),
|
||||||
$loading);
|
$loading);
|
||||||
|
|
||||||
return array($header, $preview);
|
$content = array($header, $preview);
|
||||||
|
|
||||||
|
switch ($this->skin) {
|
||||||
|
case 'document':
|
||||||
|
$content = id(new PHUIDocumentView())->appendChild($content);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,12 +40,6 @@
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.phriction-document-preview-header {
|
|
||||||
color: #666666;
|
|
||||||
margin-bottom: 1em;
|
|
||||||
font-size: 11px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.phriction-document-history-diff {
|
.phriction-document-history-diff {
|
||||||
padding: 0 2em 2em;
|
padding: 0 2em 2em;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,16 @@
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.phui-remarkup-preview-skin-document {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phui-remarkup-preview-skin-document .phui-preview-header {
|
||||||
|
padding: 8px;
|
||||||
|
background: #f3f3f3;
|
||||||
|
}
|
||||||
|
|
||||||
.device-phone .aphront-panel-preview {
|
.device-phone .aphront-panel-preview {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -21,3 +31,14 @@
|
||||||
.phui-preview-loading-text {
|
.phui-preview-loading-text {
|
||||||
color: #666666;
|
color: #666666;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Classes implementing PhabricatorMarkupInterface are of differing
|
||||||
|
* mindsets about whether output should be wrapped in a `phabricator-remarkup`
|
||||||
|
* <div /> or not. It should probably move to the Engine in all cases, but
|
||||||
|
* until we do that get rid of the extra spacing generated by the inner div.
|
||||||
|
*/
|
||||||
|
.phui-remarkup-preview .phabricator-remarkup .phabricator-remarkup {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
/**
|
|
||||||
* @provides javelin-behavior-legalpad-document-preview
|
|
||||||
* @requires javelin-behavior
|
|
||||||
* javelin-dom
|
|
||||||
* javelin-util
|
|
||||||
* phabricator-shaped-request
|
|
||||||
*/
|
|
||||||
|
|
||||||
JX.behavior('legalpad-document-preview', function(config) {
|
|
||||||
|
|
||||||
var preview = JX.$(config.preview);
|
|
||||||
var title = JX.$(config.title);
|
|
||||||
var text = JX.$(config.text);
|
|
||||||
|
|
||||||
var callback = function(r) {
|
|
||||||
JX.DOM.setContent(JX.$(config.preview), JX.$H(r));
|
|
||||||
};
|
|
||||||
|
|
||||||
var getdata = function() {
|
|
||||||
return {
|
|
||||||
title : title.value,
|
|
||||||
text : text.value
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata);
|
|
||||||
var trigger = JX.bind(request, request.trigger);
|
|
||||||
|
|
||||||
JX.DOM.listen(title, 'keydown', null, trigger);
|
|
||||||
JX.DOM.listen(text, 'keydown', null, trigger);
|
|
||||||
request.start();
|
|
||||||
|
|
||||||
});
|
|
|
@ -1,29 +0,0 @@
|
||||||
/**
|
|
||||||
* @provides javelin-behavior-phriction-document-preview
|
|
||||||
* @requires javelin-behavior
|
|
||||||
* javelin-dom
|
|
||||||
* javelin-util
|
|
||||||
* phabricator-shaped-request
|
|
||||||
*/
|
|
||||||
|
|
||||||
JX.behavior('phriction-document-preview', function(config) {
|
|
||||||
|
|
||||||
var preview = JX.$(config.preview);
|
|
||||||
var textarea = JX.$(config.textarea);
|
|
||||||
|
|
||||||
var callback = function(r) {
|
|
||||||
JX.DOM.setContent(JX.$(config.preview), JX.$H(r));
|
|
||||||
};
|
|
||||||
|
|
||||||
var getdata = function() {
|
|
||||||
return {
|
|
||||||
document : textarea.value
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata);
|
|
||||||
var trigger = JX.bind(request, request.trigger);
|
|
||||||
|
|
||||||
JX.DOM.listen(textarea, 'keydown', null, trigger);
|
|
||||||
request.start();
|
|
||||||
});
|
|
Loading…
Reference in a new issue