芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/www/cepali/lib/amd/build/tag.min.js
define(["jquery","core/ajax","core/templates","core/notification","core/str","core/modal_factory","core/modal_events","core/pending"],function(a,b,c,d,e,f,g,h){return{initTagindexPage:function(){a("body").delegate(".tagarea[data-ta] a[data-quickload=1]","click",function(e){var f=new h("core/tag:initTagindexPage");e.preventDefault();var g=a(this),i=g[0].search.replace(/^\?/,""),j=g.closest(".tagarea[data-ta]"),k=i.split("&").reduce(function(a,b){var c=b.split("=");return a[c[0]]=decodeURIComponent(c[1]),a},{});b.call([{methodname:"core_tag_get_tagindex",args:{tagindex:k}}])[0].then(function(a){return c.render("core_tag/index",a)}).then(function(a,b){c.replaceNode(j,a,b)}).always(f.resolve)["catch"](d.exception)})},initManagePage:function(){a("body").on("updated","[data-inplaceeditable]",function(b){var c=new h("core/tag:initManagePage");if(e.get_strings([{key:"selecttag",component:"core_tag"},{key:"now",component:"core"}]).then(function(c){a('label[for="tagselect'+b.ajaxreturn.itemid+'"]').html(c[0]),a(b.target).closest("tr").find("td.col-timemodified").html(c[1])}).always(c.resolve)["catch"](d.exception),"tagflag"===b.ajaxreturn.itemtype){var f=a(b.target).closest("tr");"0"===b.ajaxreturn.value?f.removeClass("flagged-tag"):f.addClass("flagged-tag")}}),a(".tag-management-table").delegate("a.tagdelete","click",function(b){var c=new h("core/tag:tagdelete");b.preventDefault();var f=a(this).attr("href");e.get_strings([{key:"delete",component:"core"},{key:"confirmdeletetag",component:"tag"},{key:"yes",component:"core"},{key:"no",component:"core"}]).then(function(a){return d.confirm(a[0],a[1],a[2],a[3],function(){window.location.href=f})}).always(c.resolve)["catch"](d.exception)}),a("#tag-management-delete").click(function(b){var c=a(this).closest("form").get(0),f=a(c).find("input[type=checkbox]:checked").length;if(f){var g=new h("core/tag:tag-management-delete"),i=a("
").attr("name",this.name);b.preventDefault(),e.get_strings([{key:"delete",component:"core"},{key:"confirmdeletetags",component:"tag"},{key:"yes",component:"core"},{key:"no",component:"core"}]).then(function(a){return d.confirm(a[0],a[1],a[2],a[3],function(){i.appendTo(c),c.submit()})}).always(g.resolve)["catch"](d.exception)}}),a("#tag-management-combine").click(function(b){var i=new h("core/tag:tag-management-combine");b.preventDefault();var j=a(this).closest("form").get(0),k=a(j).find("input[type=checkbox]:checked");if(k.length<=1)return void e.get_strings([{key:"combineselected",component:"tag"},{key:"selectmultipletags",component:"tag"},{key:"ok"}]).then(function(a){return d.alert(a[0],a[1],a[2])}).always(i.resolve)["catch"](d.exception);var l=a("
").attr("name",this.name),m="",n=[];k.each(function(){var b=a(this).val(),c=a(".inplaceeditable[data-itemtype=tagname][data-itemid="+b+"]").attr("data-value");n.push({id:b,name:c})}),e.get_strings([{key:"combineselected",component:"tag"},{key:"continue",component:"core"}]).then(function(a){var b=a[0];m=a[1];var d={tags:n};return f.create({title:b,body:c.render("core_tag/combine_tags",d),type:f.types.SAVE_CANCEL})}).then(function(a){return a.setSaveButtonText(m),a}).then(function(b){b.getRoot().on(g.save,function(b){b.preventDefault(),l.appendTo(j);var c=a("input[name=maintag]:checked","#combinetags_form").val();a("
").attr("name","maintag").attr("value",c).appendTo(j),j.submit()}),b.getRoot().on(g.hidden,function(){b.destroy()}),b.show(),a("#combinetags_form input[type=radio]").first().focus().prop("checked",!0)}).always(i.resolve)["catch"](d.exception)}),a("body").on("updatefailed","[data-inplaceeditable][data-itemtype=tagname]",function(b){var c=b.exception,f=b.newvalue,g=a(b.target).attr("data-itemid");if("namesalreadybeeingused"===c.errorcode){var i=new h("core/tag:updatefailed");b.preventDefault(),e.get_strings([{key:"nameuseddocombine",component:"tag"},{key:"yes"},{key:"cancel"}]).then(function(a){return d.confirm(b.message,a[0],a[1],a[2],function(){window.location.href=window.location.href+"&newname="+encodeURIComponent(f)+"&tagid="+encodeURIComponent(g)+"&action=renamecombine&sesskey="+M.cfg.sesskey})}).always(i.resolve)["catch"](d.exception)}}),a("body").on("click","a[data-action=addstandardtag]",function(b){var i=new h("core/tag:addstandardtag");return b.preventDefault(),f.create({title:e.get_string("addotags","tag"),body:c.render("core_tag/add_tags",{actionurl:window.location.href,sesskey:M.cfg.sesskey}),type:f.types.SAVE_CANCEL}).then(function(b){b.setSaveButtonText(e.get_string("continue","core")),b.getRoot().on(g.save,function(b){var c=a(b.currentTarget).find("#id_tagslist"),d=c.val().trim();c.val(d);var e=a("#addtags_form");return e.on("submit",function(b){var c=a("#addtags_form");c[0].checkValidity()===!1&&(b.preventDefault(),b.stopPropagation()),c.addClass("was-validated"),a('[data-region="tagslistinput"]').addClass("error");var d=a("#id_tagslist_error_message");d.removeAttr("hidden"),d.addClass("help-block")}),e.submit(),!1}),b.getRoot().on(g.hidden,function(){b.destroy()}),b.show()}).always(i.resolve)["catch"](d.exception)})},initManageCollectionsPage:function(){a("body").on("updated","[data-inplaceeditable]",function(b){var c,d,e,f=new h("core/tag:initManageCollectionsPage-updated"),g=b.ajaxreturn;"core_tag"===g.component&&"tagareaenable"===g.itemtype&&(c=a(this).attr("data-itemid"),a(".tag-collections-table ul[data-collectionid] li[data-areaid="+c+"]").hide(),e=g.value,"1"===e?(a(this).closest("tr").removeClass("dimmed_text"),d=a(this).closest("tr").find('[data-itemtype="tagareacollection"]').attr("data-value"),a(".tag-collections-table ul[data-collectionid="+d+"] li[data-areaid="+c+"]").show()):a(this).closest("tr").addClass("dimmed_text")),"core_tag"===g.component&&"tagareacollection"===g.itemtype&&(c=a(this).attr("data-itemid"),a(".tag-collections-table ul[data-collectionid] li[data-areaid="+c+"]").hide(),d=a(this).attr("data-value"),e=a(this).closest("tr").find('[data-itemtype="tagareaenable"]').attr("data-value"),"1"===e&&a(".tag-collections-table ul[data-collectionid="+d+"] li[data-areaid="+c+"]").show()),f.resolve()}),a("body").on("click",".addtagcoll > a",function(b){var i=new h("core/tag:initManageCollectionsPage-addtagcoll");b.preventDefault();var j=[{key:"addtagcoll",component:"tag"},{key:"create",component:"core"}],k=a(this).attr("data-url"),l="";e.get_strings(j).then(function(a){var b=a[0];l=a[1];var d={actionurl:k,sesskey:M.cfg.sesskey};return f.create({title:b,body:c.render("core_tag/add_tag_collection",d),type:f.types.SAVE_CANCEL})}).then(function(b){return b.setSaveButtonText(l),b.getRoot().on(g.save,function(b){var c=a(b.currentTarget).find("#addtagcoll_name"),d=c.val().trim();c.val(d);var e=a("#addtagcoll_form");return e.on("submit",function(b){e[0].checkValidity()===!1&&(b.preventDefault(),b.stopPropagation()),e.addClass("was-validated"),a('[data-region="addtagcoll_nameinput"]').addClass("error");var c=a("#id_addtagcoll_name_error_message");c.removeAttr("hidden"),c.addClass("help-block")}),e.submit(),!1}),b.getRoot().on(g.hidden,function(){b.destroy()}),b.show(),b}).always(i.resolve)["catch"](d.exception)}),a("body").on("click",".tag-collections-table .action_delete",function(b){var c=new h("core/tag:initManageCollectionsPage-action_delete");b.preventDefault();var f=a(this).attr("data-url")+"&sesskey="+M.cfg.sesskey;e.get_strings([{key:"delete"},{key:"suredeletecoll",component:"tag",param:a(this).attr("data-collname")},{key:"yes"},{key:"no"}]).then(function(a){return d.confirm(a[0],a[1],a[2],a[3],function(){window.location.href=f})}).always(c.resolve)["catch"](d.exception)})}}});