some minor improvements to task editing of Questtype ?Textinput?
This commit is contained in:
parent
c93f98f8d8
commit
1a4c9cdfa8
3 changed files with 14 additions and 9 deletions
|
|
@ -215,7 +215,6 @@
|
||||||
{
|
{
|
||||||
// Validate regex
|
// Validate regex
|
||||||
$regex = $field['regex'];
|
$regex = $field['regex'];
|
||||||
//$fieldValidation = $this->Validation->validate($regex, \nre\configs\AppConfig::$validation['regex']);
|
|
||||||
$fieldValidation = @preg_match($regex, '') !== false;
|
$fieldValidation = @preg_match($regex, '') !== false;
|
||||||
if($fieldValidation !== true)
|
if($fieldValidation !== true)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@
|
||||||
*
|
*
|
||||||
* @param int $userId ID of user setting text
|
* @param int $userId ID of user setting text
|
||||||
* @param int $questId ID of Quest to set text for
|
* @param int $questId ID of Quest to set text for
|
||||||
* @param string $text Text for Quset
|
* @param string $text Text for Quest
|
||||||
*/
|
*/
|
||||||
public function setTextForQuest($userId, $questId, $text)
|
public function setTextForQuest($userId, $questId, $text)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><?=_('Text')?></legend>
|
<legend><?=_('Text')?></legend>
|
||||||
<button id="add-field"><?=_('Add field')?></button><br />
|
<button id="add-field" type="button"><?=_('Add field')?></button><br />
|
||||||
<textarea id="text" name="text"><?=$text?></textarea>
|
<textarea id="text" name="text"><?=$text?></textarea>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
'<option value="<?=$size['size']?>"><?=$size['size']?></option>' +
|
'<option value="<?=$size['size']?>"><?=$size['size']?></option>' +
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
'</select>';
|
'</select>';
|
||||||
var inputElement = '<input type="text" name="fields[INDEX][regex]" />';
|
var inputElement = '<input type="text" name="fields[INDEX][regex]" required="required" placeholder="/regex/i" />';
|
||||||
$("#add-field").click(function(event) {
|
$("#add-field").click(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var caret = getCaret("text");
|
var caret = getCaret("text");
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
function updateFields()
|
function updateFields()
|
||||||
{
|
{
|
||||||
var newCount = $("#text").val().split("[textinput]").length - 1;
|
var newCount = $("#text").val().split("[textinput]").length - 1;
|
||||||
var oldCount = $("#fields li").length;
|
var oldCount = $("#fields > li").length;
|
||||||
var caret = getCaret("text");
|
var caret = getCaret("text");
|
||||||
var pos = $("#text").val().substring(0, caret).split("[textinput]").length - 1;
|
var pos = $("#text").val().substring(0, caret).split("[textinput]").length - 1;
|
||||||
if(newCount > oldCount)
|
if(newCount > oldCount)
|
||||||
|
|
@ -86,11 +86,17 @@
|
||||||
{
|
{
|
||||||
index++;
|
index++;
|
||||||
var element = '<li>' + selectElement.replace('INDEX', index) + inputElement.replace('INDEX', index) + '</li>';
|
var element = '<li>' + selectElement.replace('INDEX', index) + inputElement.replace('INDEX', index) + '</li>';
|
||||||
if($("#fields li").length > pos-1) {
|
if($("#fields > li").length > 0)
|
||||||
$($("#fields li")[pos-1]).before(element);
|
{
|
||||||
|
if($("#fields > li").length > pos-1) {
|
||||||
|
$($("#fields > li")[pos-1]).before(element);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$($("#fields > li")[pos-2]).after(element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$($("#fields li")[pos-2]).after(element);
|
$("#fields").append(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +104,7 @@
|
||||||
{
|
{
|
||||||
// Remove fields
|
// Remove fields
|
||||||
for(var i=oldCount; i>newCount; i--) {
|
for(var i=oldCount; i>newCount; i--) {
|
||||||
$($("#fields li")[pos]).remove();
|
$($("#fields > li")[pos]).remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue