Files
EasySoft-ZenTaoPMS/module/testcase/js/common.js
2013-08-26 16:19:03 +08:00

132 lines
2.9 KiB
JavaScript

var newRowID = 0;
/**
* Load modules and stories of a product.
*
* @param int $productID
* @access public
* @return void
*/
function loadAll(productID)
{
loadProductModules(productID);
setStories();
}
/**
* Load stories of module.
*
* @access public
* @return void
*/
function loadModuleRelated()
{
setStories();
}
/**
* Load module.
*
* @param int $productID
* @access public
* @return void
*/
function loadProductModules(productID)
{
link = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=case&rootModuleID=0&returnType=html&needManage=true');
$('#moduleIdBox').load(link);
}
/**
* Set story field.
*
* @access public
* @return void
*/
function setStories()
{
moduleID = $('#module').val();
productID = $('#product').val();
link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&moduleID=' + moduleID);
$.get(link, function(stories)
{
if(!stories) stories = '<select id="story" name="story"></select>';
$('#story').replaceWith(stories);
$('#story_chzn').remove();
$("#story").chosen({no_results_text: ''});
});
}
/**
* Delete a step row.
*
* @param int $rowID
* @access public
* @return void
*/
function deleteRow(rowID)
{
if($('.stepID').size() == 1) return;
$('#row' + rowID).remove();
updateStepID();
}
/**
* Insert before the step.
*
* @param int $rowID
* @access public
* @return void
*/
function preInsert(rowID)
{
$('#row' + rowID).before(createRow());
updateStepID();
}
/**
* Insert after the step.
*
* @param int $rowID
* @access public
* @return void
*/
function postInsert(rowID)
{
$('#row' + rowID).after(createRow());
updateStepID();
}
/**
* Create a step row.
*
* @access public
* @return void
*/
function createRow()
{
if(newRowID == 0) newRowID = $('.stepID').size();
newRowID ++;
var newRow = "<tr class='a-center' id='row" + newRowID + "'>";
newRow += "<th class='stepID'></th>";
newRow += "<td class='w-p50'><textarea name='steps[]' rows=3 class='w-p100'></textarea></td>";
newRow += "<td><textarea name='expects[]' rows=3 class='w-p100'></textarea></td>";
newRow += "<td class='a-left w-100px'><nobr>";
newRow += "<input type='button' tabindex='-1' class='addbutton' value='" + lblBefore + "' onclick='preInsert(" + newRowID + ")' /><br />";
newRow += "<input type='button' tabindex='-1' class='addbutton' value='" + lblAfter + "' onclick='postInsert(" + newRowID + ")' /><br />";
newRow += "<input type='button' tabindex='-1' class='delbutton' value='" + lblDelete + "' onclick='deleteRow(" + newRowID + ")' /><br />";
newRow += "</nobr></td>";
return newRow;
}
/**
* Update the step id.
*
* @access public
* @return void
*/
function updateStepID()
{
var i = 1;
$('.stepID').each(function(){$(this).html(i ++)});
}