$(function () { $("#Title").after( '' + '' + '' + ' 重复的标题' + ' 无重复'); $(".repeat-button-check, input[name=Title]").on("click blur", function () { repeatTitleInfo(); }); $(".title-repeat a").popover({ placement: "bottom", trigger: "click", html: true }); var displaybutton = ""; $(".repeat-button").mouseenter(function () { if ($(this).css("display") !== "none") { $('.repeat-button-check').show(); displaybutton = $(this).find("img"); $(this).find("img").hide(); } }); $(".repeat-button-check").mouseleave(function () { if (displaybutton != "") { $(".repeat-button-check").hide(); displaybutton.show(); displaybutton = ""; } }); $(".norepeat-button").mouseenter(function () { if ($(this).css("display") !== "none") { $('.repeat-button-check').show(); displaybutton = $(this).find("img"); $(this).find("img").hide(); } }); $("#BtnSubmission").click(function () { $("input[name=Status]").val("0"); $("#formBox form").submit(); }); $("#BtnDraft").click(function () { $("input[name=Status]").val("-1"); $("#formBox form").submit(); }); $("#btnAddFeaturedImage").on("click", function () { addPhoto("FeaturedImage", $(this)); }); function addPhoto(fieldName, photo) { var imgWrap = photo.parent().prev(); var imgSrc = imgWrap.find("img").attr('src'); if (imgSrc.indexOf("data:image") > -1) { var datas = $(".upload-multi").data(); var severfilepath = imgWrap.prev().attr("filepath"); if (isImage(severfilepath)) { imgSrc = severfilepath.replace(datas.uploadpathreplacesymbol, datas.uploadpath); } else { // 多视频上传 添加封面图片/添加视频待播放时画面 $.ajax(datas.cropperuploadurl, { data: { uploadProviderKey: 'VideoFeaturedImage', fileName: pe.tools.uuid(16, 4) + '.jpeg', contentType: 'image/jpeg', file: imgSrc, __RequestVerificationToken: pe.security.Csrf.getRequestVerificationTokenValue() }, type: 'post', success: function (result) { if (result.IsError || !result.RelativePath) { return; } addPhotoCore(fieldName, result.RelativePath.replace(datas.uploadpathreplacesymbol, datas.uploadpath)); }, error: function (xhr) { } }); return; } } addPhotoCore(fieldName, imgSrc); } function addPhotoCore(fieldName, imgSrc) { var datas = $(".upload-multi").data(); var inputVal = imgSrc.replace(datas.uploadpath, datas.uploadpathreplacesymbol) $("input[name=" + fieldName + "]").val(inputVal); $("#thumbnail" + fieldName + "").parent(".imgWrap").addClass("imgWrap-upload-success"); $("#thumbnail" + fieldName + "").attr('src', imgSrc); var $uploadPlaceholder = $("#file-picker-" + fieldName + "").parents('#upload-placeholder'); $uploadPlaceholder.css("position", "absolute"); $uploadPlaceholder.css("top", "-15000px"); $("#files-" + fieldName + "").removeClass("hidden"); } function isImage(url) { if (!url) { return false; } var dotIndex = url.lastIndexOf("."); var filePathLength = url.length; var filePathSuffix = url.substring(dotIndex, filePathLength); var imageArr = ['.BMP', '.GIF', '.JPG', '.PIC', '.PNG', '.TIF', '.JPEG']; return imageArr.indexOf(filePathSuffix.toUpperCase()) > -1 } }); function repeatTitleInfo() { var url = $("#repeaturl").val(); var title = $("input[name=Title]").val(); var repeat = $(".title-repeat"); var norepeat = $(".title-norepeat"); var repeatbuttoncheck = $(".repeat-button-check"); var repeatbutton = $(".repeat-button"); var norepeatbutton = $(".norepeat-button"); title = title.replace(/(^\s*)|(\s*$)/g, ""); if (title !== "") { var contentid = $("input[name=ContentId]").val(); $.postPreventCSRF(url, { contentid: contentid, title: title }, function (value) { if (!value && typeof (value) != undefined && typeof (value) != 'undefined' && value != "undefined" && value != "" ) { var html = ""; var list = JSON.parse(value); $.each(list, function (i, v) { var nodeName = v.NodeName.length > 6 ? v.NodeName.substr(0, 6) + "..." : v.NodeName; var status = ""; switch (v.Status) { case -1: status = "草稿"; break; case -2: status = "退稿"; break; case -3: status = "已删除"; break; case 0: status = "待审核"; break; case 1: status = "审核中"; break; case 99: status = "终审通过"; break; default: status = "归档内容"; break; } html += ""; }); html += "
内容id状态所属节点
" + v.ContentId + "" + status + " " + nodeName + "
"; repeat.children("a").attr("data-content", html); repeat.show(); norepeat.hide(); repeatbutton.show(); repeatbuttoncheck.hide(); norepeatbutton.hide(); } else { norepeatbutton.show(); repeatbuttoncheck.hide(); repeatbutton.hide(); norepeat.show(); repeat.hide(); } }); } else { repeatbuttoncheck.show(); repeatbutton.hide(); norepeatbutton.hide(); norepeat.hide(); repeat.hide(); } }