Files
EasySoft-ZenTaoPMS/module/tree/js/browse.js
2015-09-01 16:06:47 +08:00

59 lines
2.0 KiB
JavaScript

function syncModule(rootID, type)
{
moduleID = type == 'task' ? $('#projectModule').val() : $('#productModule').val();
type = type == 'task' ? 'task' : 'story';
link = createLink('tree', 'ajaxGetSonModules', 'moduleID=' + moduleID + '&rootID=' + rootID + '&type=' + type);
$.getJSON(link, function(modules)
{
$('.helplink').addClass('hidden');
$.each(modules, function(key, value)
{
moduleName = value;
$('.form-control').each(function()
{
if(this.value == moduleName) modules[key] = null;
if(!this.value) $(this).parent().remove();
})
});
$.each(modules, function(key, value)
{
if(value) $('#sonModule').append("<span><input type='text' name='modules[]' value='" + value + "' style='margin-bottom:5px' class='form-control' /><span>");
})
})
}
function syncProductOrProject(obj, type)
{
if(type == 'product') viewType = 'story';
if(type == 'project') viewType = 'task';
link = createLink('tree', 'ajaxGetOptionMenu', 'rootID=' + obj.value + "&viewType=" + viewType + "&rootModuleID=0&returnType=json");
$.getJSON(link, function(modules)
{
$('.helplink').addClass('hidden');
$('#' + type + 'Module').empty();
$.each(modules, function(key, value)
{
$('#' + type + 'Module').append('<option value=' + key + '>' + value + '</option')
});
$('#' + type + 'Module').trigger("chosen:updated");
})
$('#copyModule').attr('onclick', null);
$('#copyModule').bind('click', function(){syncModule(obj.value, viewType)});
}
function toggleCopy()
{
var $copy = $('table.copy');
if($copy.size() == 0) return false;
$copy.toggle();
}
$(document).ready(function()
{
toggleCopy();
// $("#submenucreate").modalTrigger({type: 'iframe', width: 500});
// $("#submenuedit").modalTrigger({type: 'iframe', width: 500});
});