* code for task #5387.

This commit is contained in:
wangyidong
2019-04-25 09:10:42 +08:00
parent 1daead8b6c
commit 75ebcb18dc
18 changed files with 272 additions and 238 deletions
-39
View File
@@ -679,7 +679,6 @@ class bug extends control
$this->view->openedBuilds = $openedBuilds;
$this->view->resolvedBuilds = array('' => '') + $openedBuilds + $oldResolvedBuild;
$this->view->actions = $this->action->getList('bug', $bugID);
$this->view->templates = $this->bug->getUserBugTemplates($this->app->user->account);
$this->display();
}
@@ -1291,44 +1290,6 @@ class bug extends control
}
}
/**
* Save current template.
*
* @access public
* @return string
*/
public function saveTemplate()
{
$this->bug->saveUserBugTemplate();
if(dao::isError()) echo js::error(dao::getError(), $full = false);
die($this->fetch('bug', 'buildTemplates'));
}
/**
* Build the user templates selection code.
*
* @access public
* @return void
*/
public function buildTemplates()
{
$this->view->templates = $this->bug->getUserBugTemplates($this->app->user->account);
$this->display('bug', 'buildTemplates');
}
/**
* Delete a user template.
*
* @param int $templateID
* @access public
* @return void
*/
public function deleteTemplate($templateID)
{
$this->dao->delete()->from(TABLE_USERTPL)->where('id')->eq($templateID)->andWhere('account')->eq($this->app->user->account)->exec();
die();
}
/**
* AJAX: get bugs of a user in html select.
*
-8
View File
@@ -7,14 +7,6 @@
#buildBoxActions {padding-left: 15px;}
#tplBoxWrapper {position: relative; z-index: 10;}
#tplBoxWrapper > .btn-toolbar {position: absolute; right: 0px; top: 0px;}
#tplBoxWrapper .btn {padding: 4px 8px}
#tplBox li {position: relative;}
#tplBox li .btn-delete {position: absolute; right: 0; top: -5px; display: block; width: 40px; text-align:center;}
#tplBox li:hover .btn-delete {color:#fff;}
#tplBox li .tpl-name {padding-right: 40px;}
#module_chosen.chosen-container .chosen-drop {min-width: 400px; border-top: 1px solid #ddd!important}
#openedBuild_chosen.chosen-container .chosen-drop {min-width: 450px; border-top: 1px solid #ddd!important}
#module + .chosen-container-single .chosen-single,
-50
View File
@@ -64,59 +64,9 @@ function setAssignedTo(moduleID, productID)
});
}
/* Set template. */
function setTemplate(templateID)
{
$('#tplBox .list-group-item.active').removeClass('active');
$('#tplTitleBox' + templateID).closest('.list-group-item').addClass('active');
var steps = $('#template' + templateID).html();
editor['#'].html(steps);
}
/* Delete template. */
function deleteTemplate(templateID)
{
if(!templateID) return;
if(confirm(confirmDeleteTemplate))
{
hiddenwin.location.href = createLink('bug', 'deleteTemplate', 'templateID=' + templateID);
$('#tplBox' + templateID).addClass('hidden');
}
}
/* Display template x icon. */
function displayXIcon(templateID)
{
$('#templateID' + templateID).removeClass('hidden');
}
/* Hide template x icon. */
function hideXIcon(templateID)
{
$('#templateID' + templateID).addClass('hidden');
}
$(function()
{
if($('#project').val()) loadProjectRelated($('#project').val());
$('#saveTplModal').on('hide.zui.modal', function(){$(this).find('#title').val('');});
$('#saveTplBtn').click(function(){$('#saveTplModal').modal('show');});
$('#saveTplModal #submit').click(function()
{
var $inputGroup = $('#saveTplModal div.input-group');
var $publicBox = $inputGroup.find('input[id^="public"]');
var title = $inputGroup.find('#title').val();
var content = $('#steps').val();
var isPublic = ($publicBox.size() > 0 && $publicBox.prop('checked')) ? $publicBox.val() : 0;
if(!title || !content) return;
saveTemplateLink = createLink('bug', 'saveTemplate');
$.post(saveTemplateLink, {title:title, content:content, public:isPublic}, function(data)
{
$('#tplBox').html(data);
// If has error then not hide.
if(data.indexOf('alert') == -1) $('#saveTplModal').modal('hide');
});
});
$('[data-toggle=tooltip]').tooltip();
-6
View File
@@ -95,9 +95,6 @@ $lang->bug->reportChart = '报表统计';
$lang->bug->export = '导出数据';
$lang->bug->delete = '删除';
$lang->bug->deleted = '已删除';
$lang->bug->saveTemplate = '保存模板';
$lang->bug->setPublic = '设为公共模板';
$lang->bug->deleteTemplate = '删除模板';
$lang->bug->confirmStoryChange = '确认需求变动';
$lang->bug->copy = '复制Bug';
$lang->bug->search = '搜索';
@@ -163,11 +160,8 @@ $lang->bug->buttonConfirm = '确认';
$lang->bug->summary = "本页共 <strong>%s</strong> 个Bug,未解决 <strong>%s</strong>。";
$lang->bug->confirmChangeProduct = "修改{$lang->productCommon}会导致相应的{$lang->projectCommon}、需求和任务发生变化,确定吗?";
$lang->bug->confirmDelete = '您确认要删除该Bug吗?';
$lang->bug->setTemplateTitle = '请输入bug模板标题';
$lang->bug->remindTask = '该Bug已经转化为任务,是否更新任务(编号:%s)状态 ?';
$lang->bug->skipClose = 'Bug %s 不是已解决状态,不能关闭。';
$lang->bug->applyTemplate = '应用模板';
$lang->bug->confirmDeleteTemplate = '您确认要删除该模板吗?';
/* 模板。*/
$lang->bug->tplStep = "<p>[步骤]</p><br/>";
-39
View File
@@ -1939,45 +1939,6 @@ class bugModel extends model
foreach($commonOption->graph as $key => $value) if(!isset($chartOption->graph->$key)) $chartOption->graph->$key = $value;
}
/**
* Get bug templates of a user.
*
* @param string $account
* @access public
* @return array
*/
public function getUserBugTemplates($account)
{
$templates = $this->dao->select('id,account,title,content,public')
->from(TABLE_USERTPL)
->where('type')->eq('bug')
->andwhere('account', true)->eq($account)
->orWhere('public')->eq('1')
->markRight(1)
->orderBy('id')
->fetchAll();
return $templates;
}
/**
* Save user template.
*
* @access public
* @return void
*/
public function saveUserBugTemplate()
{
$template = fixer::input('post')
->setDefault('account', $this->app->user->account)
->setDefault('type', 'bug')
->stripTags('content', $this->config->allowedTags)
->get();
$condition = "`type`='bug' and account='{$this->app->user->account}'";
$this->dao->insert(TABLE_USERTPL)->data($template)->batchCheck('title, content', 'notempty')->check('title', 'unique', $condition)->exec();
if(!dao::isError()) $this->loadModel('score')->create('bug', 'saveTplModal', $this->dao->lastInsertID());
}
/**
* Return the file => label pairs of some fields.
*
-11
View File
@@ -1,11 +0,0 @@
<?php
foreach($templates as $key => $template)
{
echo "<li id='tplBox$template->id' onmouseover='displayXIcon($template->id)' onmouseout='hideXIcon($template->id)'>";
echo "<a title='{$lang->bug->applyTemplate}' class='tpl-name' id='tplTitleBox$template->id' href='javascript:setTemplate($template->id)'>";
if($template->public) echo "<span class='label label-info label-badge'>{$lang->public}</span> ";
echo $template->title . "</a>";
if(empty($template->public) or $template->account == $app->user->account)echo "<a href='###' onclick='deleteTemplate($template->id)' id='templateID$template->id' class='btn-delete hidden'><i class='icon-close'></i></a>";
echo "<span id='template$template->id' class='hidden'>$template->content</span>";
echo '</li>';
}
+1 -30
View File
@@ -217,17 +217,7 @@ js::set('confirmDeleteTemplate', $lang->bug->confirmDeleteTemplate);
<tr>
<th><?php echo $lang->bug->steps;?></th>
<td colspan='2'>
<div id='tplBoxWrapper'>
<div class='btn-toolbar'>
<div class='btn-group'>
<button id='saveTplBtn' type='button' class='btn btn-mini' data-toggle='saveTplModal'><?php echo $lang->bug->saveTemplate?></button>
<button type='button' class='btn btn-mini dropdown-toggle' data-toggle='dropdown'><?php echo $lang->bug->applyTemplate?> <span class='caret'></span></button>
<ul id='tplBox' class='dropdown-menu pull-right'>
<?php echo $this->fetch('bug', 'buildTemplates');?>
</ul>
</div>
</div>
</div>
<?php echo $this->fetch('user', 'ajaxPrintTemplates', 'type=bug&link=steps');?>
<?php echo html::textarea('steps', $steps, "rows='10' class='form-control'");?>
</td>
</tr>
@@ -305,24 +295,5 @@ js::set('confirmDeleteTemplate', $lang->bug->confirmDeleteTemplate);
</form>
</div>
</div>
<div class="modal fade" id="saveTplModal" tabindex="-1" role="dialog">
<div class="modal-dialog w-600px">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><i class="icon icon-close"></i></button>
<h4 class="modal-title"><?php echo $lang->bug->setTemplateTitle;?></h4>
</div>
<div class="modal-body">
<div class='input-group'>
<?php echo html::input('title', '' , "class='form-control'")?>
<?php if(common::hasPriv('bug', 'setPublic')):?>
<span class='input-group-addon'><?php echo html::checkbox('public', array('1' => $lang->public))?></span>
<?php endif;?>
<span class='input-group-btn'><?php echo html::submitButton('', '', 'btn btn-primary')?></span>
</div>
</div>
</div>
</div>
</div>
<?php js::set('bugModule', $lang->bug->module);?>
<?php include '../../common/view/footer.html.php';?>
+7
View File
@@ -94,6 +94,13 @@ $lang->preShortcutKey = '[快捷键:←]';
$lang->nextShortcutKey = '[快捷键:→]';
$lang->backShortcutKey = '[快捷键:Alt+↑]';
$lang->saveTemplate = '保存模板';
$lang->setPublic = '设为公共模板';
$lang->deleteTemplate = '删除模板';
$lang->setTemplateTitle = '请输入模板标题';
$lang->applyTemplate = '应用模板';
$lang->confirmDeleteTemplate = '您确认要删除该模板吗?';
$lang->select = '选择';
$lang->selectAll = '全选';
$lang->selectReverse = '反选';
+5 -9
View File
@@ -498,9 +498,6 @@ $lang->resource->bug->report = 'reportChart';
$lang->resource->bug->export = 'export';
$lang->resource->bug->confirmStoryChange = 'confirmStoryChange';
$lang->resource->bug->delete = 'delete';
$lang->resource->bug->saveTemplate = 'saveTemplate';
$lang->resource->bug->deleteTemplate = 'deleteTemplate';
$lang->resource->bug->setPublic = 'setPublic';
$lang->resource->bug->batchChangeModule = 'batchChangeModule';
$lang->resource->bug->batchChangeBranch = 'batchChangeBranch';
@@ -525,12 +522,9 @@ $lang->bug->methodOrder[80] = 'report';
$lang->bug->methodOrder[85] = 'export';
$lang->bug->methodOrder[90] = 'confirmStoryChange';
$lang->bug->methodOrder[95] = 'delete';
$lang->bug->methodOrder[100] = 'saveTemplate';
$lang->bug->methodOrder[105] = 'deleteTemplate';
$lang->bug->methodOrder[110] = 'setPublic';
$lang->bug->methodOrder[115] = 'linkBugs';
$lang->bug->methodOrder[125] = 'batchChangeModule';
$lang->bug->methodOrder[130] = 'batchChangeBranch';
$lang->bug->methodOrder[100] = 'linkBugs';
$lang->bug->methodOrder[105] = 'batchChangeModule';
$lang->bug->methodOrder[110] = 'batchChangeBranch';
/* Test case. */
$lang->resource->testcase = new stdclass();
@@ -856,6 +850,7 @@ $lang->resource->user->dynamic = 'dynamic';
$lang->resource->user->profile = 'profile';
$lang->resource->user->batchEdit = 'batchEdit';
$lang->resource->user->unbind = 'unbind';
$lang->resource->user->setPublicTemplate = 'setPublicTemplate';
$lang->user->methodOrder[5] = 'create';
$lang->user->methodOrder[7] = 'batchCreate';
@@ -871,6 +866,7 @@ $lang->user->methodOrder[50] = 'dynamic';
$lang->user->methodOrder[55] = 'profile';
$lang->user->methodOrder[60] = 'batchEdit';
$lang->user->methodOrder[75] = 'unbind';
$lang->user->methodOrder[80] = 'setPublicTemplate';
/* Tree. */
$lang->resource->tree = new stdclass();
+4 -1
View File
@@ -63,7 +63,10 @@
</tr>
<tr>
<th><?php echo $lang->product->desc;?></th>
<td colspan='2'><?php echo html::textarea('desc', '', "rows='8' class='form-control kindeditor' hidefocus='true' tabindex=''");?></td>
<td colspan='2'>
<?php echo $this->fetch('user', 'ajaxPrintTemplates', "type=product&link=desc");?>
<?php echo html::textarea('desc', '', "rows='8' class='form-control kindeditor' hidefocus='true' tabindex=''");?>
</td>
</tr>
<tr>
<th><?php echo $lang->product->acl;?></th>
+4 -1
View File
@@ -134,7 +134,10 @@
</tr>
<tr>
<th><?php echo $lang->project->desc;?></th>
<td colspan='3'><?php echo html::textarea('desc', '', "rows='6' class='form-control kindeditor' hidefocus='true'");?></td>
<td colspan='3'>
<?php echo $this->fetch('user', 'ajaxPrintTemplates', 'type=project&link=desc');?>
<?php echo html::textarea('desc', '', "rows='6' class='form-control kindeditor' hidefocus='true'");?>
</td>
</tr>
<tr>
<th><?php echo $lang->project->acl;?></th>
+4 -1
View File
@@ -159,7 +159,10 @@
</tr>
<tr>
<th><?php echo $lang->story->spec;?></th>
<td colspan="4"><?php echo html::textarea('spec', $spec, "rows='9' class='form-control kindeditor disabled-ie-placeholder' hidefocus='true' placeholder='" . htmlspecialchars($lang->story->specTemplate) . "'");?></td>
<td colspan="4">
<?php echo $this->fetch('user', 'ajaxPrintTemplates', 'type=story&link=spec');?>
<?php echo html::textarea('spec', $spec, "rows='9' class='form-control kindeditor disabled-ie-placeholder' hidefocus='true' placeholder='" . htmlspecialchars($lang->story->specTemplate) . "'");?>
</td>
</tr>
<?php if(strpos(",$showFields,", ',verify,') !== false):?>
<tr>
+4 -1
View File
@@ -200,7 +200,10 @@
</tr>
<tr>
<th><?php echo $lang->task->desc;?></th>
<td colspan='3'><?php echo html::textarea('desc', $task->desc, "rows='10' class='form-control'");?></td>
<td colspan='3'>
<?php echo $this->fetch('user', 'ajaxPrintTemplates', 'type=task&link=desc');?>
<?php echo html::textarea('desc', $task->desc, "rows='10' class='form-control'");?>
</td>
</tr>
<tr>
<th><?php echo $lang->files;?></th>
+42
View File
@@ -1007,4 +1007,46 @@ class user extends control
if(empty($contactList)) return false;
return print(html::select('', $contactList, '', "class='form-control' onchange=\"setMailto('mailto', this.value)\""));
}
/**
* Ajax print templates.
*
* @param int $type
* @param string $link
* @access public
* @return void
*/
public function ajaxPrintTemplates($type, $link = '')
{
$this->view->link = $link;
$this->view->type = $type;
$this->view->templates = $this->user->getUserTemplates($type);
$this->display();
}
/**
* Save current template.
*
* @access public
* @return string
*/
public function ajaxSaveTemplate($type)
{
$this->user->saveUserTemplate($type);
if(dao::isError()) echo js::error(dao::getError(), $full = false);
die($this->fetch('user', 'ajaxPrintTemplates', "type=$type"));
}
/**
* Delete a user template.
*
* @param int $templateID
* @access public
* @return void
*/
public function ajaxDeleteTemplate($templateID)
{
$this->dao->delete()->from(TABLE_USERTPL)->where('id')->eq($templateID)->andWhere('account')->eq($this->app->user->account)->exec();
die();
}
}
+22 -21
View File
@@ -48,27 +48,28 @@ $lang->user->originalPassword = 'Old Password';
$lang->user->verifyPassword = 'Your Login Password';
$lang->user->resetPassword = 'Forgot Password?';
$lang->user->index = "Home";
$lang->user->view = "Overview";
$lang->user->create = "Add User";
$lang->user->batchCreate = "Batch Add";
$lang->user->edit = "Edit";
$lang->user->batchEdit = "Batch Edit";
$lang->user->unlock = "Unlock";
$lang->user->delete = "Delete";
$lang->user->unbind = "Unbind Zdoo";
$lang->user->login = "Login";
$lang->user->mobileLogin = "Mobile";
$lang->user->editProfile = "Edit";
$lang->user->deny = "Your access is denied.";
$lang->user->confirmDelete = "Do you want to delete this user?";
$lang->user->confirmUnlock = "Do you want to unlock this user?";
$lang->user->confirmUnbind = "Do you want to unbind this user from Zdoo?";
$lang->user->relogin = "Login Again";
$lang->user->asGuest = "Guest";
$lang->user->goback = "Back";
$lang->user->deleted = '(Deleted)';
$lang->user->search = 'Search';
$lang->user->index = "Home";
$lang->user->view = "Overview";
$lang->user->create = "Add User";
$lang->user->batchCreate = "Batch Add";
$lang->user->edit = "Edit";
$lang->user->batchEdit = "Batch Edit";
$lang->user->unlock = "Unlock";
$lang->user->delete = "Delete";
$lang->user->unbind = "Unbind Zdoo";
$lang->user->login = "Login";
$lang->user->mobileLogin = "Mobile";
$lang->user->editProfile = "Edit";
$lang->user->deny = "Your access is denied.";
$lang->user->confirmDelete = "Do you want to delete this user?";
$lang->user->confirmUnlock = "Do you want to unlock this user?";
$lang->user->confirmUnbind = "Do you want to unbind this user from Zdoo?";
$lang->user->relogin = "Login Again";
$lang->user->asGuest = "Guest";
$lang->user->goback = "Back";
$lang->user->deleted = '(Deleted)';
$lang->user->search = 'Search';
$lang->user->setPublicTemplate = 'Set as Public Template';
$lang->user->profile = 'Profile';
$lang->user->project = $lang->projectCommon;
+22 -21
View File
@@ -48,27 +48,28 @@ $lang->user->originalPassword = '原密码';
$lang->user->verifyPassword = '您的系统登录密码';
$lang->user->resetPassword = '忘记密码';
$lang->user->index = "用户视图首页";
$lang->user->view = "用户详情";
$lang->user->create = "添加用户";
$lang->user->batchCreate = "批量添加用户";
$lang->user->edit = "编辑用户";
$lang->user->batchEdit = "批量编辑";
$lang->user->unlock = "解锁用户";
$lang->user->delete = "删除用户";
$lang->user->unbind = "解除然之绑定";
$lang->user->login = "用户登录";
$lang->user->mobileLogin = "手机访问";
$lang->user->editProfile = "修改档案";
$lang->user->deny = "访问受限";
$lang->user->confirmDelete = "您确定删除该用户吗?";
$lang->user->confirmUnlock = "您确定解除该用户的锁定状态吗?";
$lang->user->confirmUnbind = "您确定解除该用户跟然之的绑定吗?";
$lang->user->relogin = "重新登录";
$lang->user->asGuest = "游客访问";
$lang->user->goback = "返回前一页";
$lang->user->deleted = '(已删除)';
$lang->user->search = '搜索';
$lang->user->index = "用户视图首页";
$lang->user->view = "用户详情";
$lang->user->create = "添加用户";
$lang->user->batchCreate = "批量添加用户";
$lang->user->edit = "编辑用户";
$lang->user->batchEdit = "批量编辑";
$lang->user->unlock = "解锁用户";
$lang->user->delete = "删除用户";
$lang->user->unbind = "解除然之绑定";
$lang->user->login = "用户登录";
$lang->user->mobileLogin = "手机访问";
$lang->user->editProfile = "修改档案";
$lang->user->deny = "访问受限";
$lang->user->confirmDelete = "您确定删除该用户吗?";
$lang->user->confirmUnlock = "您确定解除该用户的锁定状态吗?";
$lang->user->confirmUnbind = "您确定解除该用户跟然之的绑定吗?";
$lang->user->relogin = "重新登录";
$lang->user->asGuest = "游客访问";
$lang->user->goback = "返回前一页";
$lang->user->deleted = '(已删除)';
$lang->user->search = '搜索';
$lang->user->setPublicTemplate = '设为公共模板';
$lang->user->profile = '档案';
$lang->user->project = $lang->projectCommon;
+39
View File
@@ -1504,4 +1504,43 @@ class userModel extends model
return true;
}
/**
* Save user template.
*
* @param string $type
* @access public
* @return void
*/
public function saveUserTemplate($type)
{
$template = fixer::input('post')
->setDefault('account', $this->app->user->account)
->setDefault('type', $type)
->stripTags('content', $this->config->allowedTags)
->get();
$condition = "`type`='$type' and account='{$this->app->user->account}'";
$this->dao->insert(TABLE_USERTPL)->data($template)->batchCheck('title, content', 'notempty')->check('title', 'unique', $condition)->exec();
if(!dao::isError()) $this->loadModel('score')->create('bug', 'saveTplModal', $this->dao->lastInsertID());
}
/**
* Get User Template.
*
* @param string $type
* @access public
* @return array
*/
public function getUserTemplates($type)
{
return $this->dao->select('id,account,title,content,public')
->from(TABLE_USERTPL)
->where('type')->eq($type)
->andwhere('account', true)->eq($this->app->user->account)
->orWhere('public')->eq('1')
->markRight(1)
->orderBy('id')
->fetchAll();
}
}
@@ -0,0 +1,118 @@
<?php if(empty($link)):?>
<?php
foreach($templates as $key => $template)
{
echo "<li id='tplBox$template->id' onmouseover='displayXIcon($template->id)' onmouseout='hideXIcon($template->id)'>";
echo "<a title='{$lang->applyTemplate}' class='tpl-name' id='tplTitleBox$template->id' href='javascript:setTemplate($template->id)'>";
if($template->public) echo "<span class='label label-info label-badge'>{$lang->public}</span> ";
echo $template->title . "</a>";
if(empty($template->public) or $template->account == $app->user->account)echo "<a href='###' onclick='deleteTemplate($template->id)' id='templateID$template->id' class='btn-delete hidden'><i class='icon-close'></i></a>";
echo "<span id='template$template->id' class='hidden'>$template->content</span>";
echo '</li>';
}
?>
<?php else:?>
<style>
#tplBoxWrapper {position: relative; z-index: 10;}
#tplBoxWrapper > .btn-toolbar {position: absolute; right: 0px; top: 0px;}
#tplBoxWrapper .btn {padding: 4px 8px}
#tplBox li {position: relative;}
#tplBox li .btn-delete {position: absolute; right: 0; top: -5px; display: block; width: 40px; text-align:center;}
#tplBox li:hover .btn-delete {color:#fff;}
#tplBox li .tpl-name {padding-right: 40px;}
</style>
<div id='tplBoxWrapper'>
<div class='btn-toolbar'>
<div class='btn-group'>
<button id='saveTplBtn' type='button' class='btn btn-mini' data-toggle='saveTplModal'><?php echo $lang->saveTemplate?></button>
<button type='button' class='btn btn-mini dropdown-toggle' data-toggle='dropdown'><?php echo $lang->applyTemplate?> <span class='caret'></span></button>
<ul id='tplBox' class='dropdown-menu pull-right'>
<?php
foreach($templates as $key => $template)
{
echo "<li id='tplBox$template->id' onmouseover='displayXIcon($template->id)' onmouseout='hideXIcon($template->id)'>";
echo "<a title='{$lang->applyTemplate}' class='tpl-name' id='tplTitleBox$template->id' href='javascript:setTemplate($template->id)'>";
if($template->public) echo "<span class='label label-info label-badge'>{$lang->public}</span> ";
echo $template->title . "</a>";
if(empty($template->public) or $template->account == $app->user->account)echo "<a href='###' onclick='deleteTemplate($template->id)' id='templateID$template->id' class='btn-delete hidden'><i class='icon-close'></i></a>";
echo "<span id='template$template->id' class='hidden'>$template->content</span>";
echo '</li>';
}
?>
</ul>
</div>
</div>
</div>
<div class="modal fade" id="saveTplModal" tabindex="-1" role="dialog">
<div class="modal-dialog w-600px">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><i class="icon icon-close"></i></button>
<h4 class="modal-title"><?php echo $lang->setTemplateTitle;?></h4>
</div>
<div class="modal-body">
<div class='input-group'>
<?php echo html::input('title', '' , "class='form-control'")?>
<?php if(common::hasPriv('user', 'setPublicTemplate')):?>
<span class='input-group-addon'><?php echo html::checkbox('public', array('1' => $lang->public))?></span>
<?php endif;?>
<span class='input-group-btn'><?php echo html::commonButton($lang->save, "id='submit'", 'btn btn-primary')?></span>
</div>
</div>
</div>
</div>
</div>
<script>
function setTemplate(templateID)
{
$('#tplBox .list-group-item.active').removeClass('active');
$('#tplTitleBox' + templateID).closest('.list-group-item').addClass('active');
var content = $('#template' + templateID).html();
var cmd = editor['<?php echo $link;?>'].edit.cmd;
editor['<?php echo $link;?>'].html('');
cmd.inserthtml(content);
}
function deleteTemplate(templateID)
{
if(!templateID) return;
if(confirm(<?php echo json_encode($lang->confirmDeleteTemplate);?>))
{
hiddenwin.location.href = createLink('user', 'ajaxDeleteTemplate', 'templateID=' + templateID);
$('#tplBox' + templateID).addClass('hidden');
}
}
function displayXIcon(templateID)
{
$('#templateID' + templateID).removeClass('hidden');
}
function hideXIcon(templateID)
{
$('#templateID' + templateID).addClass('hidden');
}
$(function()
{
$('#saveTplModal').on('hide.zui.modal', function(){$(this).find('#title').val('');});
$('#saveTplBtn').click(function(){$('#saveTplModal').modal('show');});
$('#saveTplModal #submit').click(function()
{
var $inputGroup = $('#saveTplModal div.input-group');
var $publicBox = $inputGroup.find('input[id^="public"]');
var title = $inputGroup.find('#title').val();
var content = editor['<?php echo $link;?>'].html();
var isPublic = ($publicBox.size() > 0 && $publicBox.prop('checked')) ? $publicBox.val() : 0;
if(!title || !content) return;
saveTemplateLink = <?php echo json_encode($this->createLink('user', 'ajaxSaveTemplate', "type=$type"));?>;
$.post(saveTemplateLink, {title:title, content:content, public:isPublic}, function(data)
{
$('#tplBox').html(data);
// If has error then not hide.
if(data.indexOf('alert') == -1) $('#saveTplModal').modal('hide');
});
});
})
</script>
<?php endif;?>