mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Differential comment previews.
This commit is contained in:
parent
400524abf8
commit
4736b320ff
17 changed files with 241 additions and 23 deletions
|
@ -27,7 +27,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'aphront-panel-view-css' =>
|
'aphront-panel-view-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/fe62e634/rsrc/css/aphront/panel-view.css',
|
'uri' => '/res/63672373/rsrc/css/aphront/panel-view.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
@ -36,7 +36,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'aphront-request-failure-view-css' =>
|
'aphront-request-failure-view-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/d7df3b42/rsrc/css/aphront/request-failure-view.css',
|
'uri' => '/res/97b8337a/rsrc/css/aphront/request-failure-view.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
@ -89,6 +89,15 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'disk' => '/rsrc/css/application/base/standard-page-view.css',
|
'disk' => '/rsrc/css/application/base/standard-page-view.css',
|
||||||
),
|
),
|
||||||
|
'differential-revision-add-comment-css' =>
|
||||||
|
array(
|
||||||
|
'uri' => '/res/623fef21/rsrc/css/application/differential/add-comment.css',
|
||||||
|
'type' => 'css',
|
||||||
|
'requires' =>
|
||||||
|
array(
|
||||||
|
),
|
||||||
|
'disk' => '/rsrc/css/application/differential/add-comment.css',
|
||||||
|
),
|
||||||
'differential-changeset-view-css' =>
|
'differential-changeset-view-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/658d181a/rsrc/css/application/differential/changeset-view.css',
|
'uri' => '/res/658d181a/rsrc/css/application/differential/changeset-view.css',
|
||||||
|
@ -207,6 +216,16 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'disk' => '/rsrc/js/application/core/behavior-tokenizer.js',
|
'disk' => '/rsrc/js/application/core/behavior-tokenizer.js',
|
||||||
),
|
),
|
||||||
|
'javelin-behavior-differential-feedback-preview' =>
|
||||||
|
array(
|
||||||
|
'uri' => '/res/34fbb670/rsrc/js/application/differential/behavior-comment-preview.js',
|
||||||
|
'type' => 'js',
|
||||||
|
'requires' =>
|
||||||
|
array(
|
||||||
|
0 => 'javelin-lib-dev',
|
||||||
|
),
|
||||||
|
'disk' => '/rsrc/js/application/differential/behavior-comment-preview.js',
|
||||||
|
),
|
||||||
'javelin-behavior-differential-populate' =>
|
'javelin-behavior-differential-populate' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/9982573c/rsrc/js/application/differential/behavior-populate.js',
|
'uri' => '/res/9982573c/rsrc/js/application/differential/behavior-populate.js',
|
||||||
|
@ -274,7 +293,7 @@ celerity_register_resource_map(array(
|
||||||
), array (
|
), array (
|
||||||
'packages' =>
|
'packages' =>
|
||||||
array (
|
array (
|
||||||
'364a306c' =>
|
'd348c79d' =>
|
||||||
array (
|
array (
|
||||||
'name' => 'core.pkg.css',
|
'name' => 'core.pkg.css',
|
||||||
'symbols' =>
|
'symbols' =>
|
||||||
|
@ -291,7 +310,7 @@ celerity_register_resource_map(array(
|
||||||
9 => 'aphront-typeahead-control-css',
|
9 => 'aphront-typeahead-control-css',
|
||||||
10 => 'phabricator-directory-css',
|
10 => 'phabricator-directory-css',
|
||||||
),
|
),
|
||||||
'uri' => '/res/pkg/364a306c/core.pkg.css',
|
'uri' => '/res/pkg/d348c79d/core.pkg.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
),
|
),
|
||||||
'69b11588' =>
|
'69b11588' =>
|
||||||
|
@ -311,17 +330,17 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'reverse' =>
|
'reverse' =>
|
||||||
array (
|
array (
|
||||||
'phabricator-core-css' => '364a306c',
|
'phabricator-core-css' => 'd348c79d',
|
||||||
'phabricator-core-buttons-css' => '364a306c',
|
'phabricator-core-buttons-css' => 'd348c79d',
|
||||||
'phabricator-standard-page-view' => '364a306c',
|
'phabricator-standard-page-view' => 'd348c79d',
|
||||||
'aphront-dialog-view-css' => '364a306c',
|
'aphront-dialog-view-css' => 'd348c79d',
|
||||||
'aphront-form-view-css' => '364a306c',
|
'aphront-form-view-css' => 'd348c79d',
|
||||||
'aphront-panel-view-css' => '364a306c',
|
'aphront-panel-view-css' => 'd348c79d',
|
||||||
'aphront-side-nav-view-css' => '364a306c',
|
'aphront-side-nav-view-css' => 'd348c79d',
|
||||||
'aphront-table-view-css' => '364a306c',
|
'aphront-table-view-css' => 'd348c79d',
|
||||||
'aphront-tokenizer-control-css' => '364a306c',
|
'aphront-tokenizer-control-css' => 'd348c79d',
|
||||||
'aphront-typeahead-control-css' => '364a306c',
|
'aphront-typeahead-control-css' => 'd348c79d',
|
||||||
'phabricator-directory-css' => '364a306c',
|
'phabricator-directory-css' => 'd348c79d',
|
||||||
'differential-core-view-css' => '69b11588',
|
'differential-core-view-css' => '69b11588',
|
||||||
'differential-changeset-view-css' => '69b11588',
|
'differential-changeset-view-css' => '69b11588',
|
||||||
'differential-revision-detail-css' => '69b11588',
|
'differential-revision-detail-css' => '69b11588',
|
||||||
|
|
|
@ -80,6 +80,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialComment' => 'applications/differential/storage/comment',
|
'DifferentialComment' => 'applications/differential/storage/comment',
|
||||||
'DifferentialCommentEditor' => 'applications/differential/editor/comment',
|
'DifferentialCommentEditor' => 'applications/differential/editor/comment',
|
||||||
'DifferentialCommentMail' => 'applications/differential/mail/comment',
|
'DifferentialCommentMail' => 'applications/differential/mail/comment',
|
||||||
|
'DifferentialCommentPreviewController' => 'applications/differential/controller/commentpreview',
|
||||||
'DifferentialCommentSaveController' => 'applications/differential/controller/commentsave',
|
'DifferentialCommentSaveController' => 'applications/differential/controller/commentsave',
|
||||||
'DifferentialController' => 'applications/differential/controller/base',
|
'DifferentialController' => 'applications/differential/controller/base',
|
||||||
'DifferentialDAO' => 'applications/differential/storage/base',
|
'DifferentialDAO' => 'applications/differential/storage/base',
|
||||||
|
@ -253,6 +254,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialChangesetViewController' => 'DifferentialController',
|
'DifferentialChangesetViewController' => 'DifferentialController',
|
||||||
'DifferentialComment' => 'DifferentialDAO',
|
'DifferentialComment' => 'DifferentialDAO',
|
||||||
'DifferentialCommentMail' => 'DifferentialMail',
|
'DifferentialCommentMail' => 'DifferentialMail',
|
||||||
|
'DifferentialCommentPreviewController' => 'DifferentialController',
|
||||||
'DifferentialCommentSaveController' => 'DifferentialController',
|
'DifferentialCommentSaveController' => 'DifferentialController',
|
||||||
'DifferentialController' => 'PhabricatorController',
|
'DifferentialController' => 'PhabricatorController',
|
||||||
'DifferentialDAO' => 'PhabricatorLiskDAO',
|
'DifferentialDAO' => 'PhabricatorLiskDAO',
|
||||||
|
|
|
@ -87,7 +87,7 @@ class AphrontDefaultApplicationConfiguration
|
||||||
'revision/edit/(?:(?<id>\d+)/)?$'
|
'revision/edit/(?:(?<id>\d+)/)?$'
|
||||||
=> 'DifferentialRevisionEditController',
|
=> 'DifferentialRevisionEditController',
|
||||||
'comment/' => array(
|
'comment/' => array(
|
||||||
'preview/$' => 'DifferentialCommentPreviewController',
|
'preview/(?<id>\d+)/$' => 'DifferentialCommentPreviewController',
|
||||||
'save/$' => 'DifferentialCommentSaveController',
|
'save/$' => 'DifferentialCommentSaveController',
|
||||||
'inline/' => array(
|
'inline/' => array(
|
||||||
'preview/$' => 'DifferentialInlineCommentPreviewController',
|
'preview/$' => 'DifferentialInlineCommentPreviewController',
|
||||||
|
|
|
@ -14,6 +14,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/revisi
|
||||||
phutil_require_module('phabricator', 'applications/differential/constants/unitstatus');
|
phutil_require_module('phabricator', 'applications/differential/constants/unitstatus');
|
||||||
phutil_require_module('phabricator', 'applications/differential/storage/diff');
|
phutil_require_module('phabricator', 'applications/differential/storage/diff');
|
||||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
||||||
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class DifferentialCommentPreviewController extends DifferentialController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = $data['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
|
||||||
|
$request = $this->getRequest();
|
||||||
|
|
||||||
|
$author_phid = $request->getUser()->getPHID();
|
||||||
|
|
||||||
|
$handles = id(new PhabricatorObjectHandleData(array($author_phid)))
|
||||||
|
->loadHandles();
|
||||||
|
|
||||||
|
$factory = new DifferentialMarkupEngineFactory();
|
||||||
|
$engine = $factory->newDifferentialCommentMarkupEngine();
|
||||||
|
|
||||||
|
$comment = new DifferentialComment();
|
||||||
|
$comment->setContent($request->getStr('content'));
|
||||||
|
$comment->setAction($request->getStr('action'));
|
||||||
|
$comment->setAuthorPHID($author_phid);
|
||||||
|
|
||||||
|
$view = new DifferentialRevisionCommentView();
|
||||||
|
$view->setComment($comment);
|
||||||
|
$view->setHandles($handles);
|
||||||
|
$view->setMarkupEngine($engine);
|
||||||
|
$view->setPreview(true);
|
||||||
|
|
||||||
|
return id(new AphrontAjaxResponse())
|
||||||
|
->setContent($view->render());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/ajax');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/controller/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/parser/markup');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/storage/comment');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/view/revisioncomment');
|
||||||
|
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DifferentialCommentPreviewController.php');
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'applications/metamta/storage/mail');
|
phutil_require_module('phabricator', 'applications/metamta/storage/mail');
|
||||||
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('DifferentialMail.php');
|
phutil_require_source('DifferentialMail.php');
|
||||||
|
|
|
@ -42,6 +42,9 @@ final class DifferentialAddCommentView extends AphrontView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
|
|
||||||
|
require_celerity_resource('differential-revision-add-comment-css');
|
||||||
|
|
||||||
$revision = $this->revision;
|
$revision = $this->revision;
|
||||||
|
|
||||||
$actions = array();
|
$actions = array();
|
||||||
|
@ -58,19 +61,39 @@ final class DifferentialAddCommentView extends AphrontView {
|
||||||
id(new AphrontFormSelectControl())
|
id(new AphrontFormSelectControl())
|
||||||
->setLabel('Action')
|
->setLabel('Action')
|
||||||
->setName('action')
|
->setName('action')
|
||||||
|
->setID('comment-action')
|
||||||
->setOptions($actions))
|
->setOptions($actions))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTextAreaControl())
|
id(new AphrontFormTextAreaControl())
|
||||||
->setName('comment')
|
->setName('comment')
|
||||||
|
->setID('comment-content')
|
||||||
->setLabel('Comment'))
|
->setLabel('Comment'))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->setValue('Comment'));
|
->setValue('Comment'));
|
||||||
|
|
||||||
|
Javelin::initBehavior(
|
||||||
|
'differential-feedback-preview',
|
||||||
|
array(
|
||||||
|
'uri' => '/differential/comment/preview/'.$revision->getID().'/',
|
||||||
|
'preview' => 'comment-preview',
|
||||||
|
'action' => 'comment-action',
|
||||||
|
'content' => 'comment-content',
|
||||||
|
));
|
||||||
|
|
||||||
return
|
return
|
||||||
'<div class="differential-panel">'.
|
'<div class="differential-add-comment-panel">'.
|
||||||
'<h1>Add Comment</h1>'.
|
'<div class="differential-panel">'.
|
||||||
$form->render().
|
'<h1>Add Comment</h1>'.
|
||||||
|
$form->render().
|
||||||
|
'</div>'.
|
||||||
|
'<div class="differential-comment-preview">'.
|
||||||
|
'<div id="comment-preview">'.
|
||||||
|
'<span class="differential-loading-text">'.
|
||||||
|
'Loading comment preview...'.
|
||||||
|
'</span>'.
|
||||||
|
'</div>'.
|
||||||
|
'</div>'.
|
||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'applications/differential/constants/action');
|
phutil_require_module('phabricator', 'applications/differential/constants/action');
|
||||||
|
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||||
|
phutil_require_module('phabricator', 'infrastructure/javelin/api');
|
||||||
phutil_require_module('phabricator', 'view/base');
|
phutil_require_module('phabricator', 'view/base');
|
||||||
phutil_require_module('phabricator', 'view/form/base');
|
phutil_require_module('phabricator', 'view/form/base');
|
||||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||||
|
|
|
@ -21,6 +21,7 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
||||||
private $comment;
|
private $comment;
|
||||||
private $handles;
|
private $handles;
|
||||||
private $markupEngine;
|
private $markupEngine;
|
||||||
|
private $preview;
|
||||||
|
|
||||||
public function setComment($comment) {
|
public function setComment($comment) {
|
||||||
$this->comment = $comment;
|
$this->comment = $comment;
|
||||||
|
@ -37,6 +38,11 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setPreview($preview) {
|
||||||
|
$this->preview = $preview;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
|
|
||||||
require_celerity_resource('phabricator-remarkup-css');
|
require_celerity_resource('phabricator-remarkup-css');
|
||||||
|
@ -48,7 +54,11 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
||||||
|
|
||||||
$action_class = 'differential-comment-action-'.phutil_escape_html($action);
|
$action_class = 'differential-comment-action-'.phutil_escape_html($action);
|
||||||
|
|
||||||
$date = date('F jS, Y g:i:s A', $comment->getDateCreated());
|
if ($this->preview) {
|
||||||
|
$date = 'COMMENT PREVIEW';
|
||||||
|
} else {
|
||||||
|
$date = date('F jS, Y g:i:s A', $comment->getDateCreated());
|
||||||
|
}
|
||||||
|
|
||||||
$author = $this->handles[$comment->getAuthorPHID()];
|
$author = $this->handles[$comment->getAuthorPHID()];
|
||||||
$author_link = $author->renderLink();
|
$author_link = $author->renderLink();
|
||||||
|
@ -70,12 +80,12 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
||||||
"<p>{$author_link} {$verb} this revision.</p>".
|
"<p>{$author_link} {$verb} this revision.</p>".
|
||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$background = null;
|
$background = null;
|
||||||
$uri = $author->getImageURI();
|
$uri = $author->getImageURI();
|
||||||
if ($uri) {
|
if ($uri) {
|
||||||
$background = "background-image: url('{$uri}');";
|
$background = "background-image: url('{$uri}');";
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
'<div class="differential-comment '.$action_class.'">'.
|
'<div class="differential-comment '.$action_class.'">'.
|
||||||
|
|
|
@ -24,6 +24,16 @@ abstract class AphrontFormControl extends AphrontView {
|
||||||
private $name;
|
private $name;
|
||||||
private $value;
|
private $value;
|
||||||
private $disabled;
|
private $disabled;
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function setID($id) {
|
||||||
|
$this->id = $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getID() {
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
public function setLabel($label) {
|
public function setLabel($label) {
|
||||||
$this->label = $label;
|
$this->label = $label;
|
||||||
|
|
|
@ -30,6 +30,7 @@ class AphrontFormPasswordControl extends AphrontFormControl {
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'value' => $this->getValue(),
|
'value' => $this->getValue(),
|
||||||
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
||||||
|
'id' => $this->getID(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ class AphrontFormSelectControl extends AphrontFormControl {
|
||||||
array(
|
array(
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
||||||
|
'id' => $this->getID(),
|
||||||
),
|
),
|
||||||
implode("\n", $options));
|
implode("\n", $options));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ class AphrontFormTextControl extends AphrontFormControl {
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'value' => $this->getValue(),
|
'value' => $this->getValue(),
|
||||||
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
||||||
|
'id' => $this->getID(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class AphrontFormTextAreaControl extends AphrontFormControl {
|
||||||
|
|
||||||
const HEIGHT_VERY_SHORT = 'very-short';
|
const HEIGHT_VERY_SHORT = 'very-short';
|
||||||
const HEIGHT_SHORT = 'short';
|
const HEIGHT_SHORT = 'short';
|
||||||
|
|
||||||
private $height;
|
private $height;
|
||||||
|
|
||||||
public function setHeight($height) {
|
public function setHeight($height) {
|
||||||
|
@ -48,6 +48,7 @@ class AphrontFormTextAreaControl extends AphrontFormControl {
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
||||||
'class' => $height_class,
|
'class' => $height_class,
|
||||||
|
'id' => $this->getID(),
|
||||||
),
|
),
|
||||||
phutil_escape_html($this->getValue()));
|
phutil_escape_html($this->getValue()));
|
||||||
}
|
}
|
||||||
|
|
23
webroot/rsrc/css/application/differential/add-comment.css
Normal file
23
webroot/rsrc/css/application/differential/add-comment.css
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/**
|
||||||
|
* @provides differential-revision-add-comment-css
|
||||||
|
*/
|
||||||
|
|
||||||
|
.differential-add-comment-panel .aphront-form-view {
|
||||||
|
background: #fffff5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-add-comment-panel .differential-panel {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-comment-preview {
|
||||||
|
background: #f0f0f0;
|
||||||
|
border-bottom: 1px solid #aaaaaa;
|
||||||
|
margin-bottom: 2em;
|
||||||
|
max-width: 1120px;
|
||||||
|
padding: 15px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-comment-preview .differential-loading-text {
|
||||||
|
color: #aaaaaa;
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
* @provides javelin-behavior-differential-feedback-preview
|
||||||
|
* @requires javelin-lib-dev
|
||||||
|
*/
|
||||||
|
|
||||||
|
JX.behavior('differential-feedback-preview', function(config) {
|
||||||
|
|
||||||
|
var action = JX.$(config.action);
|
||||||
|
var content = JX.$(config.content);
|
||||||
|
var preview = JX.$(config.preview);
|
||||||
|
|
||||||
|
var aval = null;//action.value;
|
||||||
|
var cval = null;//content.value;
|
||||||
|
var defer = null;
|
||||||
|
var min = null;
|
||||||
|
var request = null;
|
||||||
|
|
||||||
|
function check() {
|
||||||
|
if (request || (min && (new Date().getTime() < min))) {
|
||||||
|
// Waiting on an async or just got one back, rate-limit.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
defer && defer.stop();
|
||||||
|
|
||||||
|
if (action.value !== aval || content.value !== cval) {
|
||||||
|
aval = action.value;
|
||||||
|
cval = content.value;
|
||||||
|
|
||||||
|
request = new JX.Request(config.uri, function(r) {
|
||||||
|
preview && JX.DOM.setContent(preview, JX.HTML(r));
|
||||||
|
min = new Date().getTime() + 500;
|
||||||
|
defer && defer.stop();
|
||||||
|
defer = JX.defer(check, 500);
|
||||||
|
});
|
||||||
|
request.listen('finally', function() { request = null; });
|
||||||
|
request.setData({action : aval, content : cval});
|
||||||
|
// If we don't get a response back soon, retry on the next action.
|
||||||
|
request.setTimeout(2000);
|
||||||
|
request.send();
|
||||||
|
} else {
|
||||||
|
defer = JX.defer(check, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JX.DOM.listen(content, 'keydown', null, check);
|
||||||
|
JX.DOM.listen(action, 'change', null, check);
|
||||||
|
|
||||||
|
check();
|
||||||
|
});
|
Loading…
Reference in a new issue