From 680687b75d35067198d56c4f8c9c285f590ad0bd Mon Sep 17 00:00:00 2001 From: Wayne Date: Tue, 30 Jan 2018 13:51:06 +0800 Subject: [PATCH 1/6] asp.net core 2.0.5 --- Dockerfile | 2 +- Dockerfile.MySql | 2 +- ZKEACMS.Standard.zip | Bin 8808 -> 8808 bytes ZKEACMS.sln | 2 +- src/EasyFrameWork/EasyFrameWork.csproj | 6 +- .../Mvc/Plugin/AssemblyLoader.cs | 64 +++++++++--------- src/ZKEACMS.Article/ZKEACMS.Article.csproj | 2 +- .../ZKEACMS.FormGenerator.csproj | 2 +- src/ZKEACMS.Message/ZKEACMS.Message.csproj | 2 +- src/ZKEACMS.Product/ZKEACMS.Product.csproj | 2 +- .../ZKEACMS.Redirection.csproj | 2 +- .../ZKEACMS.SectionWidget.csproj | 2 +- src/ZKEACMS.Shop/ZKEACMS.Shop.csproj | 2 +- src/ZKEACMS.Sitemap/ZKEACMS.Sitemap.csproj | 2 +- src/ZKEACMS.WebHost/ZKEACMS.WebHost.csproj | 3 +- 15 files changed, 46 insertions(+), 49 deletions(-) diff --git a/Dockerfile b/Dockerfile index ab1ef130a..26c1e7ee6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ WORKDIR /build/src/ZKEACMS.WebHost RUN dotnet publish-zkeacms # Build runtime image -FROM microsoft/aspnetcore:2.0.3 +FROM microsoft/aspnetcore:latest WORKDIR /zkeacms COPY --from=builder /build/src/ZKEACMS.WebHost/bin/Release/PublishOutput . EXPOSE 80 diff --git a/Dockerfile.MySql b/Dockerfile.MySql index 49419653f..955868865 100644 --- a/Dockerfile.MySql +++ b/Dockerfile.MySql @@ -11,7 +11,7 @@ RUN dotnet publish-zkeacms RUN cp -f /build/DataBase/MySql/appsettings.json /build/src/ZKEACMS.WebHost/bin/Release/PublishOutput/appsettings.json # Build runtime image -FROM microsoft/aspnetcore:2.0.3 +FROM microsoft/aspnetcore:latest WORKDIR /zkeacms COPY --from=builder /build/src/ZKEACMS.WebHost/bin/Release/PublishOutput . EXPOSE 80 diff --git a/ZKEACMS.Standard.zip b/ZKEACMS.Standard.zip index e394e757ca68eb462ca557a54ffb5a041174f930..b9148a57c97e4f2fce6f567736fbe2cb02c75265 100644 GIT binary patch delta 578 zcmV-I0=@m{MCe4YTM`IyX+BJpUA85YV-hld5xmHBA*87U%?H_NLA*>RZ#H8lJHyPZ zaeETMgT1K7LT?_t2qFay7V*!RR8Rf|XOmf*O;Yf*?DNID&%5uR%O9kp zN|Q4!jT~Cks`rqC&@uEY;r?C_@GkLnogk){)vN<9t}uuN*8O5H|( zw+P;(y{l>rO!^{gIXrxPzh131BNSPh45%IuT%x_DL)nm1!Q2Y`FOPd47H|pS`^LHk-e{`1SqM&&w}YAKooaUo6gF|2}&= zfAw+xW)`eyHvqxc=JJpaID^E%LoLF8k+teB#?$E(os5AZ*AEse+7P_0F9-SE6hX!% z#oUh4K4Nl$BhZ{41II-pHP<}B+g=~q1tkr)QfIpZZwf5?w!-p4LzhDE23G!-9*s@7 z+?$(<%Y@){!fOw~FwIrYhY=X#o`Di+%#&a!b>QbBcwJZgQ>h(EZT@?Yc~;baKI#!% zIDJs_8SBy$scUkgxPW%jN&AAEQ8=W+xH@j+msf%}&t!=XPGuxeBbY`z0j6`~S60-YCfP;sY)?oxgxc2CPxEg=W?sE)xNX*z+a)Z;J#%cKUX)NOQs zi{MS#yQ;>(q%X3T!^6k->(yE_LXoA(fa(FkCE8m$l#OW&jlmB6HRr|c)T-3>G6nVL zq2PT@bw+Rr^~#!5ndb4xhKsMC=jRvm*~_bMv-$grU*A9dy!>+Y;oai&#p3++@3Xh_ zS0CqZX2FVf0}y;|E)V&DGe`_P)FK>zS*z}1Je^L_$rvbd{a~@84Z+*`a**Fm5oBCa z%+yt+Ww!gQW zKM!+ne*sWS0|W{H00000z*wxakrZ?b2y0b)OWRX>caseuJqG}mR(>gG)040u9kXsA F`T-hE7T*8> diff --git a/ZKEACMS.sln b/ZKEACMS.sln index be1dee481..18ed455dd 100644 --- a/ZKEACMS.sln +++ b/ZKEACMS.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27130.2010 +VisualStudioVersion = 15.0.27130.2026 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{43CF214F-8C1A-4433-824E-CBD46BA7223E}" EndProject diff --git a/src/EasyFrameWork/EasyFrameWork.csproj b/src/EasyFrameWork/EasyFrameWork.csproj index afbd4d989..525a6608b 100644 --- a/src/EasyFrameWork/EasyFrameWork.csproj +++ b/src/EasyFrameWork/EasyFrameWork.csproj @@ -14,8 +14,8 @@ - - + + @@ -25,7 +25,7 @@ - + diff --git a/src/EasyFrameWork/Mvc/Plugin/AssemblyLoader.cs b/src/EasyFrameWork/Mvc/Plugin/AssemblyLoader.cs index 5b102bd99..91b26b6c0 100644 --- a/src/EasyFrameWork/Mvc/Plugin/AssemblyLoader.cs +++ b/src/EasyFrameWork/Mvc/Plugin/AssemblyLoader.cs @@ -14,23 +14,24 @@ namespace Easy.Mvc.Plugin { - public class AssemblyLoader : AssemblyLoadContext + public class AssemblyLoader { private const string ControllerTypeNameSuffix = "Controller"; + private static bool Resolving { get; set; } public AssemblyLoader() { + DependencyAssemblies = new List(); } - - public IServiceProvider ServiceProvider { get; set; } - private Assembly CurrentAssembly; - private List DependencyAssemblies = new List(); + + public Assembly CurrentAssembly { get; private set; } + public List DependencyAssemblies { get; private set; } private TypeInfo PluginTypeInfo = typeof(IPluginStartup).GetTypeInfo(); public IEnumerable LoadPlugin(string path) { if (CurrentAssembly == null) { - AssemblyLoadContext.Default.Resolving += Default_Resolving; - var assembly = this.LoadFromAssemblyPath(path); + //AssemblyLoadContext.Default.Resolving += AssemblyResolving; + var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path); CurrentAssembly = assembly; ResolveDenpendency(); RegistAssembly(assembly); @@ -43,10 +44,27 @@ public IEnumerable LoadPlugin(string path) else { throw new Exception("A loader just can load one assembly."); } } - private Assembly Default_Resolving(AssemblyLoadContext arg1, AssemblyName arg2) - { - return Load(arg2); - } + //private Assembly AssemblyResolving(AssemblyLoadContext arg1, AssemblyName arg2) + //{ + // if (arg2.FullName == CurrentAssembly.FullName) + // { + // return CurrentAssembly; + // } + // var deps = DependencyContext.Default; + // if (deps.CompileLibraries.Any(d => d.Name == arg2.Name)) + // { + // return Assembly.Load(arg2); + // } + + // foreach (var item in DependencyAssemblies) + // { + // if (item.FullName == arg2.FullName) + // { + // return item; + // } + // } + // return null; + //} private void ResolveDenpendency() { string currentName = CurrentAssembly.GetName().Name; @@ -62,7 +80,7 @@ private void ResolveDenpendency() var files = new DirectoryInfo(Path.GetDirectoryName(CurrentAssembly.Location)).GetFiles(Path.GetFileName(assembly)); foreach (var file in files) { - DependencyAssemblies.Add(LoadFromAssemblyPath(file.FullName)); + DependencyAssemblies.Add(AssemblyLoadContext.Default.LoadFromAssemblyPath(file.FullName)); depLoaded = true; break; } @@ -73,7 +91,7 @@ private void ResolveDenpendency() { if (File.Exists(item)) { - DependencyAssemblies.Add(LoadFromAssemblyPath(item)); + DependencyAssemblies.Add(AssemblyLoadContext.Default.LoadFromAssemblyPath(item)); break; } } @@ -82,27 +100,7 @@ private void ResolveDenpendency() } - protected override Assembly Load(AssemblyName assemblyName) - { - if (assemblyName.FullName == CurrentAssembly.FullName) - { - return CurrentAssembly; - } - var deps = DependencyContext.Default; - if (deps.CompileLibraries.Any(d => d.Name == assemblyName.Name)) - { - return Assembly.Load(assemblyName); - } - foreach (var item in DependencyAssemblies) - { - if (item.FullName == assemblyName.FullName) - { - return item; - } - } - return null; - } private void RegistAssembly(Assembly assembly) { List controllers = new List(); diff --git a/src/ZKEACMS.Article/ZKEACMS.Article.csproj b/src/ZKEACMS.Article/ZKEACMS.Article.csproj index 44adacd5b..5554ba39b 100644 --- a/src/ZKEACMS.Article/ZKEACMS.Article.csproj +++ b/src/ZKEACMS.Article/ZKEACMS.Article.csproj @@ -24,7 +24,7 @@ - + diff --git a/src/ZKEACMS.FormGenerator/ZKEACMS.FormGenerator.csproj b/src/ZKEACMS.FormGenerator/ZKEACMS.FormGenerator.csproj index efe23d3f7..31e7dfbf3 100644 --- a/src/ZKEACMS.FormGenerator/ZKEACMS.FormGenerator.csproj +++ b/src/ZKEACMS.FormGenerator/ZKEACMS.FormGenerator.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/ZKEACMS.Message/ZKEACMS.Message.csproj b/src/ZKEACMS.Message/ZKEACMS.Message.csproj index 7b961b56c..29d0209fc 100644 --- a/src/ZKEACMS.Message/ZKEACMS.Message.csproj +++ b/src/ZKEACMS.Message/ZKEACMS.Message.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/ZKEACMS.Product/ZKEACMS.Product.csproj b/src/ZKEACMS.Product/ZKEACMS.Product.csproj index d7a64449d..b5b2b8939 100644 --- a/src/ZKEACMS.Product/ZKEACMS.Product.csproj +++ b/src/ZKEACMS.Product/ZKEACMS.Product.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/ZKEACMS.Redirection/ZKEACMS.Redirection.csproj b/src/ZKEACMS.Redirection/ZKEACMS.Redirection.csproj index f14b7f934..319708ac2 100644 --- a/src/ZKEACMS.Redirection/ZKEACMS.Redirection.csproj +++ b/src/ZKEACMS.Redirection/ZKEACMS.Redirection.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/ZKEACMS.SectionWidget/ZKEACMS.SectionWidget.csproj b/src/ZKEACMS.SectionWidget/ZKEACMS.SectionWidget.csproj index 9043d618d..96e2fa2d1 100644 --- a/src/ZKEACMS.SectionWidget/ZKEACMS.SectionWidget.csproj +++ b/src/ZKEACMS.SectionWidget/ZKEACMS.SectionWidget.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/ZKEACMS.Shop/ZKEACMS.Shop.csproj b/src/ZKEACMS.Shop/ZKEACMS.Shop.csproj index d490f6c73..55548f114 100644 --- a/src/ZKEACMS.Shop/ZKEACMS.Shop.csproj +++ b/src/ZKEACMS.Shop/ZKEACMS.Shop.csproj @@ -17,7 +17,7 @@ - + diff --git a/src/ZKEACMS.Sitemap/ZKEACMS.Sitemap.csproj b/src/ZKEACMS.Sitemap/ZKEACMS.Sitemap.csproj index c3e879769..52e5bfa2f 100644 --- a/src/ZKEACMS.Sitemap/ZKEACMS.Sitemap.csproj +++ b/src/ZKEACMS.Sitemap/ZKEACMS.Sitemap.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/ZKEACMS.WebHost/ZKEACMS.WebHost.csproj b/src/ZKEACMS.WebHost/ZKEACMS.WebHost.csproj index 32bfd04b4..d6bcf7ac1 100644 --- a/src/ZKEACMS.WebHost/ZKEACMS.WebHost.csproj +++ b/src/ZKEACMS.WebHost/ZKEACMS.WebHost.csproj @@ -15,7 +15,6 @@ false 2.5 false - false @@ -28,7 +27,7 @@ - + From 8cc2d72ca8583afed1584eb3560fbc9b8e6b4205 Mon Sep 17 00:00:00 2001 From: Wayne Date: Tue, 30 Jan 2018 17:22:43 +0800 Subject: [PATCH 2/6] Refactoring AssemblyLoader --- .../Mvc/Plugin/AssemblyLoader.cs | 21 +++++++++---------- src/ZKEACMS/Controllers/PageController.cs | 4 ++-- src/ZKEACMS/RouteDescriptors.cs | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/EasyFrameWork/Mvc/Plugin/AssemblyLoader.cs b/src/EasyFrameWork/Mvc/Plugin/AssemblyLoader.cs index 91b26b6c0..d48001699 100644 --- a/src/EasyFrameWork/Mvc/Plugin/AssemblyLoader.cs +++ b/src/EasyFrameWork/Mvc/Plugin/AssemblyLoader.cs @@ -22,7 +22,7 @@ public AssemblyLoader() { DependencyAssemblies = new List(); } - + public Assembly CurrentAssembly { get; private set; } public List DependencyAssemblies { get; private set; } private TypeInfo PluginTypeInfo = typeof(IPluginStartup).GetTypeInfo(); @@ -31,11 +31,10 @@ public IEnumerable LoadPlugin(string path) if (CurrentAssembly == null) { //AssemblyLoadContext.Default.Resolving += AssemblyResolving; - var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path); - CurrentAssembly = assembly; - ResolveDenpendency(); - RegistAssembly(assembly); - yield return assembly; + CurrentAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path); + ResolveDenpendency(CurrentAssembly); + RegistAssembly(CurrentAssembly); + yield return CurrentAssembly; foreach (var item in DependencyAssemblies) { yield return item; @@ -65,19 +64,19 @@ public IEnumerable LoadPlugin(string path) // } // return null; //} - private void ResolveDenpendency() + private void ResolveDenpendency(Assembly assembly) { - string currentName = CurrentAssembly.GetName().Name; - var dependencyCompilationLibrary = DependencyContext.Load(CurrentAssembly) + string currentName = assembly.GetName().Name; + var dependencyCompilationLibrary = DependencyContext.Load(assembly) .CompileLibraries.Where(de => de.Name != currentName && !DependencyContext.Default.CompileLibraries.Any(m => m.Name == de.Name)) .ToList(); dependencyCompilationLibrary.Each(libaray => { bool depLoaded = false; - foreach (var assembly in libaray.Assemblies) + foreach (var item in libaray.Assemblies) { - var files = new DirectoryInfo(Path.GetDirectoryName(CurrentAssembly.Location)).GetFiles(Path.GetFileName(assembly)); + var files = new DirectoryInfo(Path.GetDirectoryName(assembly.Location)).GetFiles(Path.GetFileName(item)); foreach (var file in files) { DependencyAssemblies.Add(AssemblyLoadContext.Default.LoadFromAssemblyPath(file.FullName)); diff --git a/src/ZKEACMS/Controllers/PageController.cs b/src/ZKEACMS/Controllers/PageController.cs index a0f4acc31..8b7a5de00 100644 --- a/src/ZKEACMS/Controllers/PageController.cs +++ b/src/ZKEACMS/Controllers/PageController.cs @@ -40,9 +40,9 @@ public PageController(IPageService service, _widgetService = widgetService; } [Widget] - public IActionResult PreView() + public IActionResult Main() { - return View(); + return View("PreView"); } [DefaultAuthorize(Policy = PermissionKeys.ViewPage)] public override IActionResult Index() diff --git a/src/ZKEACMS/RouteDescriptors.cs b/src/ZKEACMS/RouteDescriptors.cs index e47b4d405..ef64c0faf 100644 --- a/src/ZKEACMS/RouteDescriptors.cs +++ b/src/ZKEACMS/RouteDescriptors.cs @@ -14,7 +14,7 @@ public static class RouteDescriptors { RouteName = "pageRoute", Template = "{*path}", - Defaults = new { controller = "Page", action = "PreView" }, + Defaults = new { controller = "Page", action = "Main" }, Constraints = new { path = new PageRouteConstraint() }, Priority = -1 }, From dc2b0b1a3ee34d70e0b5ff605eaed63c963ff57e Mon Sep 17 00:00:00 2001 From: Wayne Date: Wed, 31 Jan 2018 10:29:02 +0800 Subject: [PATCH 3/6] =?UTF-8?q?ListEditor=20=E6=96=B0=E5=A2=9E=E9=A1=B9?= =?UTF-8?q?=E6=97=A0=E5=AE=A2=E6=88=B7=E7=AB=AF=E9=AA=8C=E8=AF=81=20#139?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EasyFrameWork/Constant/DataEnumerate.cs | 3 +- .../Shared/EditorTemplates/ListEditor.cshtml | 22 ++++-- src/ZKEACMS.WebHost/wwwroot/js/admin.js | 70 +++++++++++++------ src/ZKEACMS.WebHost/wwwroot/js/admin.min.js | 2 +- .../Common/Models/CarouselItemEntity.cs | 2 +- 5 files changed, 69 insertions(+), 30 deletions(-) diff --git a/src/EasyFrameWork/Constant/DataEnumerate.cs b/src/EasyFrameWork/Constant/DataEnumerate.cs index 88a76a5d1..c79655fc8 100644 --- a/src/EasyFrameWork/Constant/DataEnumerate.cs +++ b/src/EasyFrameWork/Constant/DataEnumerate.cs @@ -21,7 +21,8 @@ public enum ActionType Design = 4, Publish = 5, Unattached = 6, - Continue = 7 + Continue = 7, + UnAttach = 8 } public enum UserType { diff --git a/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ListEditor.cshtml b/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ListEditor.cshtml index 657771c2f..3412f552a 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ListEditor.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ListEditor.cshtml @@ -5,23 +5,31 @@ { return; } - var type = ViewData.ModelMetadata.ModelType.GetTypeInfo().GetGenericArguments()[0]; + if (Model.Count == 0 || (Model[0] as Easy.Models.EditorEntity)?.ActionType != ActionType.UnAttach) + { + var unAttach = Activator.CreateInstance(ViewData.ModelMetadata.ModelType.GetTypeInfo().GetGenericArguments()[0]) as Easy.Models.EditorEntity; + if (unAttach == null) + { + throw new Exception($"{ViewData.ModelMetadata.ModelType.GetTypeInfo().GetGenericArguments()[0].FullName} 必须继承于 Easy.Models.EditorEntity"); + } + unAttach.ActionType = ActionType.UnAttach; + Model.Insert(0, unAttach); + } + }
- @Html.Partial("ListEditorItemTemplate", Activator.CreateInstance(type)) + @Html.EditorFor(m => m[0], "ListEditorItem")
- @if (Model != null) - { + @{ + Model.RemoveAt(0); for (int i = 0; i < Model.Count; i++) { @Html.EditorFor(m => m[i], "ListEditorItem") } }
- +
\ No newline at end of file diff --git a/src/ZKEACMS.WebHost/wwwroot/js/admin.js b/src/ZKEACMS.WebHost/wwwroot/js/admin.js index 9100a395d..7447df8b7 100644 --- a/src/ZKEACMS.WebHost/wwwroot/js/admin.js +++ b/src/ZKEACMS.WebHost/wwwroot/js/admin.js @@ -26,26 +26,6 @@ $(function () { }).on("click", "input[type=submit]", function () { $("#ActionType").val($(this).data("value")); return true; - }).on("click", ".input-group-collection .add", function () { - var index = $(this).siblings(".items").children(".item").size(); - var namePrefix = $(this).data("name-prefex"); - var template = $($(this).siblings(".Template").html()); - $("input,select,area", template).attr("data-val", true).each(function () { - var name = $(this).attr("name"); - if (name) { - $(this).attr("name", name.replace(namePrefix, namePrefix + "[" + index + "]")); - } - }); - template.find(".ActionType").val($(this).data("value")); - $(this).siblings(".items").append(template); - }).on("click", ".input-group-collection .delete", function () { - $(this).parent().hide(); - $(this).siblings(".hide").find(".ActionType").val($(this).data("value")); - }).on("change", ".input-group-collection .form-control", function () { - var actionType = $(".ActionType", $(this).closest(".item")); - if (actionType.val() !== "Create") { - actionType.val("Update"); - } }).on("click", ".input-group .glyphicon.glyphicon-search", function () { var obj = $(this); window.top.Easy.ShowUrlWindow({ @@ -274,4 +254,54 @@ $(function () { placement: "left" }); $("#main-menu").slimscroll({ height: $(window).height() - 170 }); + + + //list editor + function rebindValidate() { + var form = $("form"); + form.removeData("validator").removeData("unobtrusiveValidation"); + $.validator.unobtrusive.parse(form[0]); + } + $("input,select,textarea", ".input-group-collection .Template").prop("disabled", true); + + $(document).on("click", ".input-group-collection .add", function () { + var index = $(this).siblings(".items").children(".item").size(); + var template = $($(this).siblings(".Template").html()); + $("input,select,textarea", template).attr("data-val", true).each(function () { + $(this).prop("disabled", false); + var name = $(this).attr("name"); + if (name) { + $(this).attr("name", name.replace(/\[(\d+)\]/, "[" + index + "]")); + } + var id = $(this).attr("id"); + if (id) { + $(this).attr("id", id.replace(/\_(\d+)\_/, "_" + index + "_")); + } + }); + $(".field-validation-error,.field-validation-valid", template).each(function () { + var msgFor = $(this).attr("data-valmsg-for"); + $(this).attr("data-valmsg-for", msgFor.replace(/\[(\d+)\]/, "[" + index + "]")) + }); + template.find(".ActionType").val($(this).data("value")); + $(this).siblings(".items").append(template); + rebindValidate(); + + }).on("click", ".input-group-collection .delete", function () { + var form = $(this).closest("form"); + var allValid = true; + $("input,select,textarea", $(this).parent()).each(function () { + if (allValid) { + allValid = form.validate().element("#" + $(this).attr("id")); + } + }); + if (allValid) { + $(this).parent().hide(); + $(this).siblings(".hide").find(".ActionType").val($(this).data("value")); + } + }).on("change", ".input-group-collection .form-control", function () { + var actionType = $(".ActionType", $(this).closest(".item")); + if (actionType.val() !== "Create") { + actionType.val("Update"); + } + }) }); \ No newline at end of file diff --git a/src/ZKEACMS.WebHost/wwwroot/js/admin.min.js b/src/ZKEACMS.WebHost/wwwroot/js/admin.min.js index 9f3ca6ab2..dc9720ec6 100644 --- a/src/ZKEACMS.WebHost/wwwroot/js/admin.min.js +++ b/src/ZKEACMS.WebHost/wwwroot/js/admin.min.js @@ -3,4 +3,4 @@ * Copyright 2017 ZKEASOFT * http://www.zkea.net/licenses */ -$(function(){$(".accordion-group>a").click(function(){return $(this).nextAll(".accordion-inner").hasClass("active")?!1:($(this).parents("ul").find(".accordion-inner.active").removeClass("active").hide(200),$(this).nextAll(".accordion-inner").addClass("active").show(200),!1)});$(document).on("click",".cancel",function(){window.history.back()}).on("click",".publish",function(){return confirm("确认要发布吗?")?!0:!1}).on("click","input[type=submit]",function(){return $("#ActionType").val($(this).data("value")),!0}).on("click",".input-group-collection .add",function(){var i=$(this).siblings(".items").children(".item").size(),t=$(this).data("name-prefex"),n=$($(this).siblings(".Template").html());$("input,select,area",n).attr("data-val",!0).each(function(){var n=$(this).attr("name");n&&$(this).attr("name",n.replace(t,t+"["+i+"]"))});n.find(".ActionType").val($(this).data("value"));$(this).siblings(".items").append(n)}).on("click",".input-group-collection .delete",function(){$(this).parent().hide();$(this).siblings(".hide").find(".ActionType").val($(this).data("value"))}).on("change",".input-group-collection .form-control",function(){var n=$(".ActionType",$(this).closest(".item"));n.val()!=="Create"&&n.val("Update")}).on("click",".input-group .glyphicon.glyphicon-search",function(){var n=$(this);window.top.Easy.ShowUrlWindow({url:n.parent().siblings("input.form-control").data("url"),width:n.parent().siblings("input.form-control").data("width")||800,onLoad:function(t){var i=this;$(this.document).find("#confirm").click(function(){var r=n.parent().siblings("input.form-control");r.val(i.GetSelected());t.close();r.trigger("change")});$(this.document).on("click",".confirm",function(){var i=n.parent().siblings("input.form-control");i.val($(this).data("result"));t.close();i.trigger("change")})}})}).on("click",".form-group select#ZoneID",function(){var n=$(this),t="/admin/Layout/SelectZone?layoutId="+$(".hide #LayoutID").val()+"&pageId="+$(".hide #PageID").val()+"&zoneId="+n.val();window.top.Easy.ShowUrlWindow({url:t,width:1e3,title:"选择区域",onLoad:function(t){var i=this;$(this.document).find("#confirm").click(function(){n.val(i.GetSelected());t.close()})}})}).on("click",".custom-style-editor",function(){window.top.Easy.ShowUrlWindow({url:"/js/StyleEditor/index.html",width:1024,title:"编辑样式",onLoad:function(n){n.addClass("loaded")},isDialog:!1});$(".WeiWindow.BoxShadow").addClass("StyleEditor")}).on("click",".form-group select.select",function(){var n=$(this);window.top.Easy.ShowUrlWindow({url:n.data("url")+"?selected="+n.val(),width:n.data("width")||800,onLoad:function(t){var i=this;$(this.document).find("#confirm").click(function(){n.val(i.GetSelected());t.close();n.trigger("change")});$(this.document).on("click",".confirm",function(){n.val($(this).data("result"));t.close();n.trigger("change")})}})}).on("submit","form",function(){Easy.Block()});$(".form-group select#ZoneID,.form-group select.select").on("mousedown",!1);var i=$("#main-menu"),n,t=0;$("a.menu-item",i).each(function(){var i=$(this).attr("href");i&&location.pathname.toLocaleLowerCase().indexOf(i.toLowerCase())===0&&i.length>t&&(n=$(this),t=i.length)});n&&n.size()&&(n.addClass("active"),n.parent().hasClass("accordion-inner")&&(n.parent().show(),n.parent().prev().addClass("active")));$.fn.datepicker&&$(".Date").each(function(){$(this).prop("readonly")||$(this).prop("disabled")||$(this).datepicker({language:"zh-CN",format:$(this).attr("JsDateFormat")})});$(document).on("click",".nav.nav-tabs a",function(){return $(this).tab("show"),!1});$(".nav.nav-tabs").each(function(){var n=!1;$("li",this).each(function(){$(this).hasClass("active")&&($(this).removeClass("active"),$("a",this).tab("show"),n=!0)});n||($("li:first a",this).tab("show"),location.hash&&$("li a[href='"+location.hash+"']",this).tab("show"))});$("#StyleClass.form-control").popover({trigger:"focus",html:!0,title:"自定义样式用法",content:function(){for(var t=[{name:"边框",value:"border"},{name:"文字居中",value:"align-center"},{name:"文字右对齐",value:"align-right"},{name:"图片边框",value:"image-border"},{name:"阴影",value:"box-shadow"},{name:"图片圆形",value:"image-circle"},{name:"取消外边距",value:"full"},{name:"居中容器",value:"container"}],i="

直接写样式例:style=\"color:#fff\"<\/code><\/p>

预定义样式:

    ",n=0;n"+t[n].name+":"+t[n].value+"<\/code><\/li>";return i+"<\/ol><\/p>"},placement:"bottom"});$("input.select-image").popover({trigger:"focus",html:!0,title:"图片预览",content:function(){var n=$(this).val();return n?(n.indexOf("~")===0&&(n=n.replace("~",location.origin)),"
    <\/div>"):null},placement:"bottom"}).parent().addClass("loading");document.addEventListener&&document.addEventListener("paste",function(n){var t,i,r,e,u,f;if(n.target.className&&n.target.className.indexOf("select-image")>=0&&(t=n.target,n.clipboardData?i=n.clipboardData:window.clipboardData&&(i=window.clipboardData),i&&i.items))for(r=0;r1048e3)continue;t.parentNode.className=t.parentNode.className+" processing";t.value="图片上传中...";u=new XMLHttpRequest;u.open("POST","/admin/media/Upload");u.onload=function(n){t.parentNode.className=t.parentNode.className.replace(" processing","");var i=JSON.parse(n.target.response);i.id&&(t.value="~"+i.url,$(t).blur().focus())};u.onerror=function(){t.parentNode.className=t.parentNode.className.replace(" processing","");t.value="图片上传失败"};f=new FormData;f.append("file",e);f.append("folder","图片");f.append("size",e.size);u.send(f);break}});$(".input-group .glyphicon.glyphicon-play").popover({trigger:"click",html:!0,title:"视频预览",content:function(){var n=$(this).parent().siblings("input").val();return n?(n.indexOf("~")===0&&(n=n.replace("~",location.origin)),"