
$("document").ready(function(){$('.edittags li i').click(function(){var pThis=$(this);window.location.href=_reposRoot+'/#'+pThis.prev('span').text();});$('.edittags li span').click(function(){var pThis=$(this);var pParent=pThis.parent();$('i',pParent).hide();pThis.hide();$('<input type="text"/>').prependTo(pParent).val(pThis.text()).focus();$('<span class="edit blueIcon ui-icon ui-icon-check" title="Save"></span>').appendTo(pParent);$('<span class="delete blueIcon ui-icon ui-icon-trash" title="Delete tag"></span>').appendTo(pParent);});$('.edittags li .ui-icon-trash').live('click',function(){var pThis=$(this);var pLi=pThis.closest('li');$('.ui-icon',pLi).remove();$('span',pLi).text($('input',pLi).val()).show();$('i',pLi).show();$('input',pLi).remove();pLi.removeClass('liedited');pLi.addClass('lidel');});$('.edittags li .ui-icon-check').live('click',function(){var pThis=$(this);var pLi=pThis.closest('li');$('.ui-icon',pLi).remove();$('span',pLi).text($('input',pLi).val()).show();$('i',pLi).show();$('input',pLi).remove();pLi.removeClass('lidel');pLi.addClass('liedited');});$('#btnSave').click(function(){var pThis=$(this);if(!pThis.hasClass('saving'))
{$('.edittags li .ui-icon-check').click();pThis.addClass('saving');pThis.text('Saving...');var deleted=[];var renamed=[];$('.lidel').each(function(){var pItem=$(this);deleted.push(pItem.data('tagid'));});$('.liedited').each(function(){var pItem=$(this);renamed.push({tagid:pItem.data('tagid'),name:$('span',pItem).text()});});$.ajax({type:'POST',contentType:"application/json; charset=utf-8",dataType:"json",data:JSON.stringify({deleted:deleted,renamed:renamed}),url:_reposRoot+'/ProcessDefinition.asmx/SaveUpdatedTags',success:function(){window.location.href=_reposRoot;}});}});});