* add loading indicator.
This commit is contained in:
@@ -83,6 +83,10 @@
|
|||||||
publishButton.addEventListener('click', function(e)
|
publishButton.addEventListener('click', function(e)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
const container = publishButton.ownerDocument.defaultView.parent.document.querySelector('.load-indicator');
|
||||||
|
if(container) container.classList.toggle('loading', true);
|
||||||
|
|
||||||
const promptId = publishButton.dataset.promptid;
|
const promptId = publishButton.dataset.promptid;
|
||||||
const aTag = document.createElement('a');
|
const aTag = document.createElement('a');
|
||||||
aTag.href = createLink('ai', 'promptPublish', 'promptId=' + promptId + '&$backToTestingLocation=true');
|
aTag.href = createLink('ai', 'promptPublish', 'promptId=' + promptId + '&$backToTestingLocation=true');
|
||||||
@@ -91,6 +95,16 @@
|
|||||||
aTag.click();
|
aTag.click();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const regenerateButton = document.getElementById('promptRegenerate');
|
||||||
|
if(regenerateButton)
|
||||||
|
{
|
||||||
|
regenerateButton.addEventListener('click', function()
|
||||||
|
{
|
||||||
|
const container = regenerateButton.ownerDocument.defaultView.parent.document.querySelector('.load-indicator');
|
||||||
|
if(container) container.classList.toggle('loading', true);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
|
|||||||
@@ -128,6 +128,11 @@
|
|||||||
|
|
||||||
function reloadPrompt(promptId, objectId)
|
function reloadPrompt(promptId, objectId)
|
||||||
{
|
{
|
||||||
|
const container = parent.parent.document.querySelector('.load-indicator');
|
||||||
|
if(container) container.classList.toggle('loading', true);
|
||||||
|
|
||||||
|
parent.$.zui.closeModal();
|
||||||
|
|
||||||
let link = createLink('ai', 'promptexecute', 'promptId=' + promptId + '&objectId=' + objectId);
|
let link = createLink('ai', 'promptexecute', 'promptId=' + promptId + '&objectId=' + objectId);
|
||||||
link = link.replace('onlybody=yes', '');
|
link = link.replace('onlybody=yes', '');
|
||||||
const aTag = document.createElement('a');
|
const aTag = document.createElement('a');
|
||||||
|
|||||||
@@ -30,14 +30,14 @@
|
|||||||
$currentObjectId = !empty($this->view->$objectVarName) ? $this->view->$objectVarName->id : 0;
|
$currentObjectId = !empty($this->view->$objectVarName) ? $this->view->$objectVarName->id : 0;
|
||||||
if(count($prompts) > 1)
|
if(count($prompts) > 1)
|
||||||
{
|
{
|
||||||
$html .= '<div class="dropdown' . ((isset($menuOptions->class) ? ' ' . $menuOptions->class : '') . (isset($menuOptions->dropdownClass) ? ' ' . $menuOptions->dropdownClass : '')) . '"><button class="btn btn-link' . (isset($menuOptions->buttonClass) ? ' ' . $menuOptions->buttonClass : '') . '" type="button" data-toggle="dropdown">' . $lang->ai->promptMenu->dropdownTitle . ' <i class="icon-caret-down"></i></button><ul class="dropdown-menu">';
|
$html .= '<div class="prompts dropdown' . ((isset($menuOptions->class) ? ' ' . $menuOptions->class : '') . (isset($menuOptions->dropdownClass) ? ' ' . $menuOptions->dropdownClass : '')) . '"><button class="btn btn-link' . (isset($menuOptions->buttonClass) ? ' ' . $menuOptions->buttonClass : '') . '" type="button" data-toggle="dropdown">' . $lang->ai->promptMenu->dropdownTitle . ' <i class="icon-caret-down"></i></button><ul class="dropdown-menu">';
|
||||||
foreach($prompts as $prompt) $html .= '<li>' . html::linkButton($prompt->name . ($prompt->status != 'active' ? '<span class="label label-info label-badge">' . $lang->ai->prompts->statuses[$prompt->status] . '</span>' : ''), helper::createLink('ai', 'promptExecute', "promptId=$prompt->id&objectId=$currentObjectId"), 'self', "style='width: 100%;'" . (empty($prompt->desc) ? '' : " data-toggle='popover' data-container='body' data-trigger='hover' data-content='$prompt->desc' data-title='$prompt->name' data-placement='left'"), 'btn btn-link text-left') . '</li>';
|
foreach($prompts as $prompt) $html .= '<li>' . html::linkButton($prompt->name . ($prompt->status != 'active' ? '<span class="label label-info label-badge">' . $lang->ai->prompts->statuses[$prompt->status] . '</span>' : ''), helper::createLink('ai', 'promptExecute', "promptId=$prompt->id&objectId=$currentObjectId"), 'self', "style='width: 100%;'" . (empty($prompt->desc) ? '' : " data-toggle='popover' data-container='body' data-trigger='hover' data-content='$prompt->desc' data-title='$prompt->name' data-placement='left'"), 'btn btn-link text-left') . '</li>';
|
||||||
$html .= '</ul></div>';
|
$html .= '</ul></div>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$prompt = current($prompts);
|
$prompt = current($prompts);
|
||||||
$html .= html::linkButton($prompt->name . ($prompt->status != 'active' ? '<span class="label label-info label-badge">' . $lang->ai->prompts->statuses[$prompt->status] . '</span>' : ''), helper::createLink('ai', 'promptExecute', "promptId=$prompt->id&objectId=$currentObjectId"), 'self', (empty($prompt->desc) ? '' : "data-toggle='popover' data-container='body' data-trigger='hover' data-content='$prompt->desc' data-title='$prompt->name' data-placement='bottom'"), 'btn btn-link' . ((isset($menuOptions->class) ? ' ' . $menuOptions->class : '') . (isset($menuOptions->buttonClass) ? ' ' . $menuOptions->buttonClass : '')));
|
$html .= html::linkButton($prompt->name . ($prompt->status != 'active' ? '<span class="label label-info label-badge">' . $lang->ai->prompts->statuses[$prompt->status] . '</span>' : ''), helper::createLink('ai', 'promptExecute', "promptId=$prompt->id&objectId=$currentObjectId"), 'self', (empty($prompt->desc) ? '' : "data-toggle='popover' data-container='body' data-trigger='hover' data-content='$prompt->desc' data-title='$prompt->name' data-placement='bottom'"), 'prompt btn btn-link' . ((isset($menuOptions->class) ? ' ' . $menuOptions->class : '') . (isset($menuOptions->buttonClass) ? ' ' . $menuOptions->buttonClass : '')));
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -51,6 +51,27 @@
|
|||||||
$(`<?php echo $menuOptions->targetContainer;?>`).<?php echo isset($menuOptions->injectMethod) ? $menuOptions->injectMethod : 'append';?>(`<?php echo $html;?>`);
|
$(`<?php echo $menuOptions->targetContainer;?>`).<?php echo isset($menuOptions->injectMethod) ? $menuOptions->injectMethod : 'append';?>(`<?php echo $html;?>`);
|
||||||
$('[data-toggle="popover"]').popover({template: '<div class="popover"><h3 class="popover-title"></h3><div class="popover-content"></div></div>'});
|
$('[data-toggle="popover"]').popover({template: '<div class="popover"><h3 class="popover-title"></h3><div class="popover-content"></div></div>'});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener('load', function()
|
||||||
|
{
|
||||||
|
const promptButton = document.querySelector('.prompt');
|
||||||
|
if(promptButton)
|
||||||
|
{
|
||||||
|
promptButton.addEventListener('click', function(){
|
||||||
|
const container = promptButton.ownerDocument.defaultView.parent.document.querySelector('.load-indicator');
|
||||||
|
if(container) container.classList.toggle('loading', true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const promptDropdown = document.querySelector('.prompts .dropdown-menu');
|
||||||
|
if(promptDropdown)
|
||||||
|
{
|
||||||
|
promptDropdown.addEventListener('click', function(){
|
||||||
|
const container = promptDropdown.ownerDocument.defaultView.parent.document.querySelector('.load-indicator');
|
||||||
|
if(container) container.classList.toggle('loading', true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php endif; endif;?>
|
<?php endif; endif;?>
|
||||||
|
|||||||
@@ -28,9 +28,9 @@
|
|||||||
if(isset($_SESSION['auditPrompt']['time'])) $auditTime = $_SESSION['auditPrompt']['time'];
|
if(isset($_SESSION['auditPrompt']['time'])) $auditTime = $_SESSION['auditPrompt']['time'];
|
||||||
?>
|
?>
|
||||||
<div class="pull-right btn-toolbar">
|
<div class="pull-right btn-toolbar">
|
||||||
<?php echo html::a(helper::createLink('ai', 'promptexecute', "promptId=$prompt->id&objectId=$story->id"), '<i class="icon icon-refresh muted"></i> ' . $lang->ai->audit->regenerate, '', 'class="btn btn-link"');?>
|
<?php echo html::a(helper::createLink('ai', 'promptexecute', "promptId=$prompt->id&objectId=$story->id"), '<i class="icon icon-refresh muted"></i> ' . $lang->ai->audit->regenerate, '', 'id="promptRegenerate" class="btn btn-link"');?>
|
||||||
<?php if(!empty($auditTime) && time() - $auditTime < 30 * 60): ?>
|
<?php if(!empty($auditTime) && time() - $auditTime < 30 * 60): ?>
|
||||||
<?php echo html::a(helper::createLink('ai', 'promptaudit', "promptId=$prompt->id&objectId=$story->id"), $lang->ai->audit->designPrompt, '', 'class="btn btn-info iframe"'); ?>
|
<?php echo html::a(helper::createLink('ai', 'promptaudit', "promptId=$prompt->id&objectId=$story->id"), $lang->ai->audit->designPrompt, '', 'id="promptAudit" class="btn btn-info iframe"'); ?>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
|
|||||||
Reference in New Issue
Block a user