Commit 1f6a89c1 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'readOnly' into 'master'

View Only codecorrection

See merge request !128
parents 23126819 84c59be9
Pipeline #1676 passed with stage
in 2 minutes and 3 seconds
...@@ -3268,11 +3268,11 @@ Type: annotate ...@@ -3268,11 +3268,11 @@ Type: annotate
Annotate image or text. Typically the image or text has been uploaded during a previous step. The annotation will be Annotate image or text. Typically the image or text has been uploaded during a previous step. The annotation will be
saved in *FormElement.name* column of the current record. The uploaded file itself will not be modified. The annotations saved in *FormElement.name* column of the current record. The uploaded file itself will not be modified. The annotations
can be shown in edit or readonly mode and modified again. can be shown in edit (and might be modified) or in readonly mode.
Two modes are available: Two modes are available:
image grafic
A simple grafic editor to paint on top of the image (best by a tablet with pen or grafic tablet). The uploaded image A simple grafic editor to paint on top of the image (best by a tablet with pen or grafic tablet). The uploaded image
is shown in the background. All drawings are saved as a JSON fabric.js data string. Supported file types: is shown in the background. All drawings are saved as a JSON fabric.js data string. Supported file types:
**png, svg**. PDF files can be easily divided into per page SVG files during upload - see `split-pdf-upload`_ **png, svg**. PDF files can be easily divided into per page SVG files during upload - see `split-pdf-upload`_
...@@ -3287,11 +3287,11 @@ text ...@@ -3287,11 +3287,11 @@ text
Drawing with fabric.js might produce a lot data. Take care the column type/size is big enough (>=64kB). Drawing with fabric.js might produce a lot data. Take care the column type/size is big enough (>=64kB).
Image Grafic
""""" """"""
An image, specified by `FormElement.parameter`: imageSource={{pathFileName}}, will be displayed in the background. On An image, specified by ``FormElement.parameter.imageSource={{pathFileName}}``, will be displayed in the background. On
form load, both, the image and an optional already given JSON fabric.js data string, will be displayed. The image is SIP form load, both, the image and an optional already given grafical annotations, will be displayed. The image is SIP
protected and will be loaded on demand. protected and will be loaded on demand.
**Form.parameter** **Form.parameter**
...@@ -3301,7 +3301,7 @@ protected and will be loaded on demand. ...@@ -3301,7 +3301,7 @@ protected and will be loaded on demand.
+===================+=======================+==================================================================================+ +===================+=======================+==================================================================================+
| annotateType | grafic | *grafic|text*. Default is *grafic*. Select mode. | | annotateType | grafic | *grafic|text*. Default is *grafic*. Select mode. |
+-------------------+-----------------------+----------------------------------------------------------------------------------+ +-------------------+-----------------------+----------------------------------------------------------------------------------+
| imageSource | {{pathFileName2}} | Background image. E.g. `fileadmin/images/scan.png` | | imageSource | <path filename> | Background image. E.g. `fileadmin/images/scan.png` |
+-------------------+-----------------------+----------------------------------------------------------------------------------+ +-------------------+-----------------------+----------------------------------------------------------------------------------+
| defaultPenColor | <rgb hex value> | Pen default color, after loading the fabric element. Default is '0000FF' (blue). | | defaultPenColor | <rgb hex value> | Pen default color, after loading the fabric element. Default is '0000FF' (blue). |
+-------------------+----------------------------------------------------------------------------------------------------------+ +-------------------+----------------------------------------------------------------------------------------------------------+
...@@ -3321,7 +3321,7 @@ Code ...@@ -3321,7 +3321,7 @@ Code
+====================+=======================+==================================================================================+ +====================+=======================+==================================================================================+
| annotateType | text | *grafic|text*. Default is *grafic*. Select mode. | | annotateType | text | *grafic|text*. Default is *grafic*. Select mode. |
+--------------------+-----------------------+----------------------------------------------------------------------------------+ +--------------------+-----------------------+----------------------------------------------------------------------------------+
| textSource | <fileadmin/code.m> | Text file to annotate. | | textSource | <path filename> | Text file to annotate. |
+--------------------+-----------------------+----------------------------------------------------------------------------------+ +--------------------+-----------------------+----------------------------------------------------------------------------------+
| annotateUserName | <john doe> | Will be shown at annotation line. | | annotateUserName | <john doe> | Will be shown at annotation line. |
+--------------------+-----------------------+----------------------------------------------------------------------------------+ +--------------------+-----------------------+----------------------------------------------------------------------------------+
......
...@@ -3192,7 +3192,7 @@ abstract class AbstractBuildForm { ...@@ -3192,7 +3192,7 @@ abstract class AbstractBuildForm {
Support::setIfNotSet($formElement, FE_ANNOTATE_USER_NAME); Support::setIfNotSet($formElement, FE_ANNOTATE_USER_NAME);
Support::setIfNotSet($formElement, FE_ANNOTATE_USER_AVATAR); Support::setIfNotSet($formElement, FE_ANNOTATE_USER_AVATAR);
$dataHighlight=HelperFile::getFileTypeHighlight($formElement[FE_HIGHLIGHT]??'',$formElement[FE_TEXT_SOURCE] ); $dataHighlight = HelperFile::getFileTypeHighlight($formElement[FE_HIGHLIGHT] ?? '', $formElement[FE_TEXT_SOURCE]);
// <div class="codeCorrection" data-uid='{"uid": 1, "name": "Reginald Commenter", "avatar": "http://www"}' data-file="../javascript/src/CodeCorrection.js" data-target="codeCorrection-output1"> // <div class="codeCorrection" data-uid='{"uid": 1, "name": "Reginald Commenter", "avatar": "http://www"}' data-file="../javascript/src/CodeCorrection.js" data-target="codeCorrection-output1">
...@@ -3210,7 +3210,11 @@ abstract class AbstractBuildForm { ...@@ -3210,7 +3210,11 @@ abstract class AbstractBuildForm {
$attributeDiv .= Support::doAttribute('data-target', $formElement[FE_HTML_ID]); $attributeDiv .= Support::doAttribute('data-target', $formElement[FE_HTML_ID]);
$attributeDiv .= Support::doAttribute('data-highlight', $dataHighlight); $attributeDiv .= Support::doAttribute('data-highlight', $dataHighlight);
$attributeDiv .= $this->getAttributeFeMode($formElement[FE_MODE]); $attributeDiv .= $this->getAttributeFeMode($formElement[FE_MODE]);
$htmlAnnotate = Support::wrapTag('<div ' . $attributeDiv . ' data-uid=\''. $jsonDataUid . '\' >', '', false); if ($formElement[FE_MODE] == FE_MODE_READONLY) {
$attributeDiv .= Support::doAttribute('data-view-only', 'true');
}
$htmlAnnotate = Support::wrapTag('<div ' . $attributeDiv . ' data-uid=\'' . $jsonDataUid . '\' >', '', false);
// $htmlAnnotate = Support::wrapTag('<div ' . $attributeDiv .'>', '', false); // $htmlAnnotate = Support::wrapTag('<div ' . $attributeDiv .'>', '', false);
$attributeInput = Support::doAttribute('id', $formElement[FE_HTML_ID]); $attributeInput = Support::doAttribute('id', $formElement[FE_HTML_ID]);
...@@ -3271,6 +3275,9 @@ abstract class AbstractBuildForm { ...@@ -3271,6 +3275,9 @@ abstract class AbstractBuildForm {
$attributeFabric .= Support::doAttribute('data-emojis', 'typo3conf/ext/qfq/Resources/Public/Json/qfq.emoji.json'); $attributeFabric .= Support::doAttribute('data-emojis', 'typo3conf/ext/qfq/Resources/Public/Json/qfq.emoji.json');
$attributeFabric .= Support::doAttribute('data-fabric-color', HelperFormElement::penColorToHex($formElement)); $attributeFabric .= Support::doAttribute('data-fabric-color', HelperFormElement::penColorToHex($formElement));
$attributeFabric .= $this->getAttributeFeMode($formElement[FE_MODE]); $attributeFabric .= $this->getAttributeFeMode($formElement[FE_MODE]);
if ($formElement[FE_MODE] == FE_MODE_READONLY) {
$attributeFabric .= Support::doAttribute('data-view-only', 'true');
}
$htmlFabric = Support::wrapTag('<div ' . $attributeFabric . ' >', '', false); $htmlFabric = Support::wrapTag('<div ' . $attributeFabric . ' >', '', false);
$attributeInput = Support::doAttribute('id', $formElement[FE_HTML_ID]); $attributeInput = Support::doAttribute('id', $formElement[FE_HTML_ID]);
...@@ -3301,8 +3308,7 @@ abstract class AbstractBuildForm { ...@@ -3301,8 +3308,7 @@ abstract class AbstractBuildForm {
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
*/ */
public public function buildImageCut(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
function buildImageCut(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$htmlImage = ''; $htmlImage = '';
if ($mode == FORM_LOAD && !empty($formElement[FE_IMAGE_SOURCE])) { if ($mode == FORM_LOAD && !empty($formElement[FE_IMAGE_SOURCE])) {
...@@ -3340,6 +3346,7 @@ abstract class AbstractBuildForm { ...@@ -3340,6 +3346,7 @@ abstract class AbstractBuildForm {
} }
$attributeFabric .= Support::doAttribute('data-image-output', $htmlFabricImageId); $attributeFabric .= Support::doAttribute('data-image-output', $htmlFabricImageId);
$attributeFabric .= $this->getAttributeFeMode($formElement[FE_MODE]); $attributeFabric .= $this->getAttributeFeMode($formElement[FE_MODE]);
$htmlFabric = Support::wrapTag('<div ' . $attributeFabric . ' >', '', false); $htmlFabric = Support::wrapTag('<div ' . $attributeFabric . ' >', '', false);
// <input id="fabric-output" name="fabric-data" type="hidden"> // <input id="fabric-output" name="fabric-data" type="hidden">
...@@ -3372,8 +3379,7 @@ abstract class AbstractBuildForm { ...@@ -3372,8 +3379,7 @@ abstract class AbstractBuildForm {
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
*/ */
private private function fileToSipUrl($pathFileName) {
function fileToSipUrl($pathFileName) {
$param[DOWNLOAD_MODE] = DOWNLOAD_MODE_FILE; $param[DOWNLOAD_MODE] = DOWNLOAD_MODE_FILE;
$param[SIP_DOWNLOAD_PARAMETER] = base64_encode(TOKEN_FILE . PARAM_TOKEN_DELIMITER . $pathFileName); $param[SIP_DOWNLOAD_PARAMETER] = base64_encode(TOKEN_FILE . PARAM_TOKEN_DELIMITER . $pathFileName);
...@@ -3399,8 +3405,7 @@ abstract class AbstractBuildForm { ...@@ -3399,8 +3405,7 @@ abstract class AbstractBuildForm {
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public public function buildDateTime(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
function buildDateTime(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
$placeholder = ''; $placeholder = '';
...@@ -3522,8 +3527,7 @@ abstract class AbstractBuildForm { ...@@ -3522,8 +3527,7 @@ abstract class AbstractBuildForm {
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
*/ */
public public function buildDateJQW(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
function buildDateJQW(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$arrMinMax = null; $arrMinMax = null;
// if ($formElement[FE_PLACEHOLDER] == '') { // if ($formElement[FE_PLACEHOLDER] == '') {
...@@ -3608,8 +3612,7 @@ abstract class AbstractBuildForm { ...@@ -3608,8 +3612,7 @@ abstract class AbstractBuildForm {
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public public function buildEditor(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
function buildEditor(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
//TODO plugin autoresize nutzen um Editorgroesse anzugeben //TODO plugin autoresize nutzen um Editorgroesse anzugeben
...@@ -3652,8 +3655,7 @@ abstract class AbstractBuildForm { ...@@ -3652,8 +3655,7 @@ abstract class AbstractBuildForm {
* *
* @return array * @return array
*/ */
private private function setEditorConfig(array $formElement, $htmlFormElementName) {
function setEditorConfig(array $formElement, $htmlFormElementName) {
$flagMaxHeight = false; $flagMaxHeight = false;
// plugins // plugins
...@@ -3708,8 +3710,7 @@ abstract class AbstractBuildForm { ...@@ -3708,8 +3710,7 @@ abstract class AbstractBuildForm {
* @return string * @return string
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
private private function getPrefixedElementsAsJSON($prefix, array $formElement) {
function getPrefixedElementsAsJSON($prefix, array $formElement) {
$settings = array(); $settings = array();
// E.g.: $key = editor-plugins // E.g.: $key = editor-plugins
...@@ -3746,8 +3747,7 @@ abstract class AbstractBuildForm { ...@@ -3746,8 +3747,7 @@ abstract class AbstractBuildForm {
* *
* @throws UserFormException * @throws UserFormException
*/ */
public public function buildGridJQW(array $formElement, $htmlFormElementName, $value, $fake, $mode = FORM_LOAD) {
function buildGridJQW(array $formElement, $htmlFormElementName, $value, $fake, $mode = FORM_LOAD) {
// TODO: implement // TODO: implement
throw new UserFormException("Not implemented yet: buildGridJQW()", ERROR_NOT_IMPLEMENTED); throw new UserFormException("Not implemented yet: buildGridJQW()", ERROR_NOT_IMPLEMENTED);
} }
...@@ -3765,8 +3765,7 @@ abstract class AbstractBuildForm { ...@@ -3765,8 +3765,7 @@ abstract class AbstractBuildForm {
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
*/ */
public public function buildNote(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
function buildNote(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement); $json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement);
...@@ -3786,8 +3785,7 @@ abstract class AbstractBuildForm { ...@@ -3786,8 +3785,7 @@ abstract class AbstractBuildForm {
* *
* @return mixed * @return mixed
*/ */
public public function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) {
function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) {
return $value; return $value;
} }
...@@ -3810,8 +3808,7 @@ abstract class AbstractBuildForm { ...@@ -3810,8 +3808,7 @@ abstract class AbstractBuildForm {
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
public public function buildFieldset(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
function buildFieldset(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
// save parent processed FE's // save parent processed FE's
...@@ -3856,8 +3853,7 @@ abstract class AbstractBuildForm { ...@@ -3856,8 +3853,7 @@ abstract class AbstractBuildForm {
* *
* @return array * @return array
*/ */
private private function fillFeSpecNativeCheckboxWithTgMax(array $formElementArr, $tgMaxCopies) {
function fillFeSpecNativeCheckboxWithTgMax(array $formElementArr, $tgMaxCopies) {
foreach ($formElementArr as $key => $formElement) { foreach ($formElementArr as $key => $formElement) {
if ($formElement[FE_TYPE] == FE_TYPE_CHECKBOX) { if ($formElement[FE_TYPE] == FE_TYPE_CHECKBOX) {
...@@ -3888,8 +3884,7 @@ abstract class AbstractBuildForm { ...@@ -3888,8 +3884,7 @@ abstract class AbstractBuildForm {
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
public public function buildTemplateGroup(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
function buildTemplateGroup(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
$html = ''; $html = '';
...@@ -4012,8 +4007,7 @@ EOT; ...@@ -4012,8 +4007,7 @@ EOT;
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
private private function templateGroupCollectFilledElements($max, $htmlDelete, array &$json) {
function templateGroupCollectFilledElements($max, $htmlDelete, array &$json) {
$record = $this->store->getStore(STORE_RECORD); // current values $record = $this->store->getStore(STORE_RECORD); // current values
if ($record === false || count($record) === 0) { if ($record === false || count($record) === 0) {
...@@ -4099,8 +4093,7 @@ EOT; ...@@ -4099,8 +4093,7 @@ EOT;
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
private private function templateGroupDoValue() {
function templateGroupDoValue() {
// Fire 'value' statement // Fire 'value' statement
$tgMax = 0; $tgMax = 0;
......
...@@ -42,6 +42,7 @@ var QfqNS = QfqNS || {}; ...@@ -42,6 +42,7 @@ var QfqNS = QfqNS || {};
this.users = []; this.users = [];
this.currentUser = {}; this.currentUser = {};
this.language = ""; this.language = "";
this.readOnly = false;
this.syntaxHighlight = {}; this.syntaxHighlight = {};
}; };
...@@ -58,22 +59,21 @@ var QfqNS = QfqNS || {}; ...@@ -58,22 +59,21 @@ var QfqNS = QfqNS || {};
}; };
this.page = page; this.page = page;
this.language = this.$parent.data("highlight") || "typo3conf/ext/qfq/Resources/Public/Json/javascript.json"; this.language = this.$parent.data("highlight") || "typo3conf/ext/qfq/Resources/Public/Json/javascript.json";
this.readOnly = this.$parent.data("view-only") || false;
this.currentUser = $container.data("uid"); this.currentUser = $container.data("uid");
var that = this; var that = this;
if (this.$target.val()) { if (this.readOnly) {
var jImport = $.parseJSON(this.$target.val()); if (this.$parent.data("annotations")) {
if (jImport.annotations) { var jsonAnnotations = this.$parent.data("annotations");
this.annotations = jImport.annotations; this.annotations = jsonAnnotations.annotations;
console.log("[CodeCorrection] Imported Annotations: " + this.annotations.length); this.users = jsonAnnotations.users;
} } else {
if (jImport.users) { this._importFromTarget();
this.users = jImport.users;
console.log("[CodeCorrection] Imported Users: " + this.users.length);
} }
} else {
this._importFromTarget();
} }
if (this.data.url) { if (this.data.url) {
// Get data of a file and write it to data.text // Get data of a file and write it to data.text
$.get(this.data.url, function(response) { $.get(this.data.url, function(response) {
...@@ -87,6 +87,20 @@ var QfqNS = QfqNS || {}; ...@@ -87,6 +87,20 @@ var QfqNS = QfqNS || {};
} }
}; };
n.CodeCorrection.prototype._importFromTarget = function() {
if (this.$target.val()) {
var jImport = $.parseJSON(this.$target.val());
if (jImport.annotations) {
this.annotations = jImport.annotations;
console.log("[CodeCorrection] Imported Annotations: " + this.annotations.length);
}
if (jImport.users) {
this.users = jImport.users;
console.log("[CodeCorrection] Imported Users: " + this.users.length);
}
}
};
n.CodeCorrection.prototype._prepareBuild = function() { n.CodeCorrection.prototype._prepareBuild = function() {
var that = this; var that = this;
this.syntaxHighlight = new n.SyntaxHighlighter(); this.syntaxHighlight = new n.SyntaxHighlighter();
...@@ -206,8 +220,11 @@ var QfqNS = QfqNS || {}; ...@@ -206,8 +220,11 @@ var QfqNS = QfqNS || {};
* @private * @private
*/ */
n.CodeCorrection.prototype._buildCommentContainer = function($hook) { n.CodeCorrection.prototype._buildCommentContainer = function($hook) {
var options = {
readOnly: this.readOnly
};
var commentController = new n.CommentController(); var commentController = new n.CommentController();
commentController.buildContainer($hook); commentController.buildContainer($hook, options);
commentController.setCurrentUser(this.currentUser); commentController.setCurrentUser(this.currentUser);
return commentController; return commentController;
}; };
...@@ -350,14 +367,16 @@ var QfqNS = QfqNS || {}; ...@@ -350,14 +367,16 @@ var QfqNS = QfqNS || {};
comments.commentController.toggle(); comments.commentController.toggle();
comments.commentController.emitEvent("new"); comments.commentController.emitEvent("new");
} else { } else {
if (!this.readOnly) {
comments.lineNumber = lineCount; comments.lineNumber = lineCount;
comments.commentController = new n.CommentController(); comments.commentController = new n.CommentController();
comments.commentController.buildContainer($hook); comments.commentController.buildContainer($hook, {readOnly: this.readOnly});
comments.commentController.setCurrentUser(this.currentUser); comments.commentController.setCurrentUser(this.currentUser);
comments.commentController.displayEditor(); comments.commentController.displayEditor();
this._setListeners(comments.commentController); this._setListeners(comments.commentController);
this.annotations.push(comments); this.annotations.push(comments);
} }
}
}; };
/** /**
......
...@@ -30,7 +30,7 @@ var QfqNS = QfqNS || {}; ...@@ -30,7 +30,7 @@ var QfqNS = QfqNS || {};
this.$comment = {}; this.$comment = {};
this.$text = {}; this.$text = {};
if (arguments.length === 3) { if (arguments.length === 3) {
this.options = { readonly: false }; this.options = { readOnly: false };
} else { } else {
this.options = options; this.options = options;
} }
...@@ -81,7 +81,9 @@ var QfqNS = QfqNS || {}; ...@@ -81,7 +81,9 @@ var QfqNS = QfqNS || {};
class: "qfqCommentText" class: "qfqCommentText"
}); });
$comment.html(this.comment.comment); $comment.html(this.comment.comment);
if (!this.options.readOnly) {
$comment.append(this._getCommands()); $comment.append(this._getCommands());
}
this.$text= $comment; this.$text= $comment;
$comment.appendTo($commentWrap); $comment.appendTo($commentWrap);
return $commentWrap; return $commentWrap;
......
...@@ -28,6 +28,7 @@ var QfqNS = QfqNS || {}; ...@@ -28,6 +28,7 @@ var QfqNS = QfqNS || {};
this.$container = {}; this.$container = {};
this.$parent = {}; this.$parent = {};
this.height = "auto"; this.height = "auto";
this.options = {};
// Event Emitter is a Library qfq uses to emit custom Events. // Event Emitter is a Library qfq uses to emit custom Events.
this.eventEmitter = new EventEmitter(); this.eventEmitter = new EventEmitter();
}; };
...@@ -69,10 +70,11 @@ var QfqNS = QfqNS || {}; ...@@ -69,10 +70,11 @@ var QfqNS = QfqNS || {};
this._changeHandler(event); this._changeHandler(event);
}; };
n.CommentController.prototype.buildContainer = function($hook) { n.CommentController.prototype.buildContainer = function($hook, options) {
var $container = $("<div />", { var $container = $("<div />", {
class: "qfqCommentContainer" class: "qfqCommentContainer"
}); });
this.options = options;
$hook.after($container); $hook.after($container);
this.$container = $container; this.$container = $container;
}; };
...@@ -99,7 +101,7 @@ var QfqNS = QfqNS || {}; ...@@ -99,7 +101,7 @@ var QfqNS = QfqNS || {};
}; };
n.CommentController.prototype.addComment = function(comment, user) { n.CommentController.prototype.addComment = function(comment, user) {
var commentObject = new n.Comment(comment, user, this.$container); var commentObject = new n.Comment(comment, user, this.$container, this.options);
commentObject.display(); commentObject.display();
this.comments.push(commentObject); this.comments.push(commentObject);
this._changeHandler("new", commentObject); this._changeHandler("new", commentObject);
...@@ -129,14 +131,16 @@ var QfqNS = QfqNS || {}; ...@@ -129,14 +131,16 @@ var QfqNS = QfqNS || {};
}; };
n.CommentController.prototype.displayEditor = function() { n.CommentController.prototype.displayEditor = function() {
if (!this.options.readOnly) {
var editor = new n.Editor(); var editor = new n.Editor();
var that = this; var that = this;
var $editor = editor.buildEditor(); var $editor = editor.buildEditor();
editor.on("editor.submit", function(editor) { editor.on("editor.submit", function (editor) {
that._handleEditorSubmit(editor); that._handleEditorSubmit(editor);
}); });
$editor.appendTo(this.$container); $editor.appendTo(this.$container);
editor.$textArea.focus(); editor.$textArea.focus();
}
}; };
n.CommentController.prototype._handleEditorSubmit = function(editor) { n.CommentController.prototype._handleEditorSubmit = function(editor) {
......
...@@ -121,6 +121,7 @@ var QfqNS = QfqNS || {}; ...@@ -121,6 +121,7 @@ var QfqNS = QfqNS || {};
$.post(submitUrl, this.$form.serialize()) $.post(submitUrl, this.$form.serialize())
.done(this.ajaxSuccessHandler.bind(this)) .done(this.ajaxSuccessHandler.bind(this))
.fail(this.submitFailureHandler.bind(this)); .fail(this.submitFailureHandler.bind(this));
console.log(this.$form.serialize());
}; };
n.Form.prototype.serialize = function () { n.Form.prototype.serialize = function () {
......
...@@ -491,6 +491,7 @@ select.qfq-locked:invalid { ...@@ -491,6 +491,7 @@ select.qfq-locked:invalid {
.codeCorrectionWrap { .codeCorrectionWrap {
border: 1px solid #ccc; border: 1px solid #ccc;
border-top: unset; border-top: unset;
margin-bottom: 10px;
} }
.qfqCodeCorrectionTitle { .qfqCodeCorrectionTitle {
...@@ -520,6 +521,7 @@ select.qfq-locked:invalid { ...@@ -520,6 +521,7 @@ select.qfq-locked:invalid {
text-align: left; text-align: left;
font-size: 1.2em; font-size: 1.2em;