ACMS.Config.Edit.tagassistEmptyDialogTitle="タグが登録されていません";ACMS.Config.Edit.tagassistEmptyDialogMessage="エントリーに使用されているタグから入力候補を選択することができます。";ACMS.Dispatch.Edit._tagassist=function(elm){var self=arguments.callee;$(elm).attr("disabled",true);if(!self.$list){var Config=ACMS.Config;var url=ACMS.Library.acmsLink({tpl:"ajax/edit/tag-assist.html"},true);$.get(url,function(html){if(!html.length){var $msg=$("<p></p>");$msg.text(Config.Edit.tagassistEmptyDialogMessage);$("body").append($msg);$msg.dialog({title:Config.Edit.tagassistEmptyDialogTitle,dialogClass:"alert",draggable:false,resizable:false,modal:true,close:function(){$msg.dialog("destroy");$msg.remove()}});$(elm).attr("disabled",false);return true}self.$list=$($.parseHTML(html));$("a.js-tag_assist-candidate",self.$list).click(function(){var tag=$(this).text();var tagPtn=new RegExp("^"+tag+",|,"+tag+"$|^"+tag+"$","g");var tagPtn2=new RegExp(","+tag+",","g");$i=$(':input[name="tag"]');$i.val($i.val().replace(/[,\s]{2,}/,","));if(0<=$i.val().search(tagPtn)){$i.val($i.val().replace(tagPtn,""))}else if(0<=$i.val().search(tagPtn2)){$i.val($i.val().replace(tagPtn2,","))}else{$i.val($i.val()+","+tag)}$i.val($i.val().replace(/^,/,""));return false});$("body").append(self.$list);self.$list.dialog({title:"タグの選択 ",close:function(){$(elm).attr("disabled",false);$(elm).focus()}});$win_h=$(window).height();$win_w=$(window).width();self.$list.dialog("option",{maxHeight:$win_h>300?Math.floor(.6*$win_h):200,width:$win_w>320?Math.floor(.6*$win_w):250});self.$list.dialog("open");self.$list.dialog("widget").position({of:$(':input[name="tag"]'),my:"center top",at:"cehter bottom",collision:"none"});ACMS.Dispatch.Admin(self.$list)})}else{self.$list.dialog("open");self.$list.dialog("widget").position({of:$(':input[name="tag"]'),my:"left top",at:"left bottom",collision:"none"})}};