diff --git a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 index 82a2185..edd2167 100644 Binary files a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 and b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/IoTGateway/project-colors.json b/.vs/IoTGateway/project-colors.json index d28775e..b476955 100644 --- a/.vs/IoTGateway/project-colors.json +++ b/.vs/IoTGateway/project-colors.json @@ -105,7 +105,22 @@ "ProjectGuid": "c8c82c05-defd-4e79-9772-b5ea3d2e5d88", "DisplayName": "DriverAllenBradley", "ColorIndex": 3 + }, + "1f9122c1-19de-4a8b-9a00-d59e592ecc3a": { + "ProjectGuid": "1f9122c1-19de-4a8b-9a00-d59e592ecc3a", + "DisplayName": "IoTGateway", + "ColorIndex": 4 + }, + "5c12ebfb-b152-48c6-aa52-71128f246594": { + "ProjectGuid": "5c12ebfb-b152-48c6-aa52-71128f246594", + "DisplayName": "Plugin", + "ColorIndex": 5 + }, + "96d436b4-4703-4448-a879-b69ace89ca11": { + "ProjectGuid": "96d436b4-4703-4448-a879-b69ace89ca11", + "DisplayName": "WalkingTec.Mvvm.Mvc", + "ColorIndex": 6 } }, - "NextColorIndex": 4 + "NextColorIndex": 7 } \ No newline at end of file diff --git a/.vs/IoTGateway/v16/.suo b/.vs/IoTGateway/v16/.suo index a2abc72..9f0983e 100644 Binary files a/.vs/IoTGateway/v16/.suo and b/.vs/IoTGateway/v16/.suo differ diff --git a/.vs/IoTGateway/v17/.futdcache.v1 b/.vs/IoTGateway/v17/.futdcache.v1 index d09b8b8..187a3e9 100644 Binary files a/.vs/IoTGateway/v17/.futdcache.v1 and b/.vs/IoTGateway/v17/.futdcache.v1 differ diff --git a/.vs/IoTGateway/v17/.suo b/.vs/IoTGateway/v17/.suo index 9b1b4c1..a4a1ed6 100644 Binary files a/.vs/IoTGateway/v17/.suo and b/.vs/IoTGateway/v17/.suo differ diff --git a/.vs/IoTGateway/v17/fileList.bin b/.vs/IoTGateway/v17/fileList.bin index ffdd117..0438d97 100644 Binary files a/.vs/IoTGateway/v17/fileList.bin and b/.vs/IoTGateway/v17/fileList.bin differ diff --git a/Dockerfile b/Dockerfile index 8d50774..9ca4d78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. -FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base +FROM mcr.microsoft.com/dotnet/aspnet:6.0-buster-slim AS base WORKDIR /app EXPOSE 518 EXPOSE 1888 @@ -9,7 +9,7 @@ RUN apt-get update RUN apt-get install libgdiplus -y RUN apt-get install nano -y -FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build +FROM mcr.microsoft.com/dotnet/sdk:6.0-buster-slim AS build WORKDIR /src COPY ["IoTGateway/IoTGateway.csproj", "IoTGateway/"] diff --git a/IoTGateway.DataAccess/IoTGateway.DataAccess.csproj b/IoTGateway.DataAccess/IoTGateway.DataAccess.csproj index 338af31..512bd1c 100644 --- a/IoTGateway.DataAccess/IoTGateway.DataAccess.csproj +++ b/IoTGateway.DataAccess/IoTGateway.DataAccess.csproj @@ -1,16 +1,12 @@  - net5.0 + net6.0 true - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/IoTGateway.DataAccess/Migrations/20220124063657_platforms.Designer.cs b/IoTGateway.DataAccess/Migrations/20220124063657_platforms.Designer.cs new file mode 100644 index 0000000..be73ff9 --- /dev/null +++ b/IoTGateway.DataAccess/Migrations/20220124063657_platforms.Designer.cs @@ -0,0 +1,798 @@ +// +using System; +using IoTGateway.DataAccess; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IoTGateway.DataAccess.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20220124063657_platforms")] + partial class platforms + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.1"); + + modelBuilder.Entity("IoTGateway.Model.Device", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AutoStart") + .HasColumnType("INTEGER"); + + b.Property("CreateBy") + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DeviceName") + .HasColumnType("TEXT"); + + b.Property("DeviceTypeEnum") + .HasColumnType("INTEGER"); + + b.Property("DriverId") + .HasColumnType("TEXT"); + + b.Property("Index") + .HasColumnType("INTEGER"); + + b.Property("ParentId") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("DriverId"); + + b.HasIndex("ParentId"); + + b.ToTable("Devices"); + }); + + modelBuilder.Entity("IoTGateway.Model.DeviceConfig", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DeviceConfigName") + .HasColumnType("TEXT"); + + b.Property("DeviceId") + .HasColumnType("TEXT"); + + b.Property("EnumInfo") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("DeviceId"); + + b.ToTable("DeviceConfigs"); + }); + + modelBuilder.Entity("IoTGateway.Model.DeviceVariable", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("DataType") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DeviceAddress") + .HasColumnType("TEXT"); + + b.Property("DeviceId") + .HasColumnType("TEXT"); + + b.Property("Expressions") + .HasColumnType("TEXT"); + + b.Property("Method") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ProtectType") + .HasColumnType("INTEGER"); + + b.HasKey("ID"); + + b.HasIndex("DeviceId"); + + b.ToTable("DeviceVariables"); + }); + + modelBuilder.Entity("IoTGateway.Model.Driver", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AssembleName") + .HasColumnType("TEXT"); + + b.Property("AuthorizesNum") + .HasColumnType("INTEGER"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("DriverName") + .HasColumnType("TEXT"); + + b.Property("FileName") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("Drivers"); + }); + + modelBuilder.Entity("IoTGateway.Model.SystemConfig", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("GatewayName") + .HasColumnType("TEXT"); + + b.Property("IoTPlatformType") + .HasColumnType("INTEGER"); + + b.Property("MqttIp") + .HasColumnType("TEXT"); + + b.Property("MqttPort") + .HasColumnType("INTEGER"); + + b.Property("MqttUName") + .HasColumnType("TEXT"); + + b.Property("MqttUPwd") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("SystemConfig"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.ActionLog", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ActionName") + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property("ActionTime") + .HasColumnType("TEXT"); + + b.Property("ActionUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("REAL"); + + b.Property("IP") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ITCode") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("LogType") + .HasColumnType("INTEGER"); + + b.Property("ModuleName") + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property("Remark") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("ActionLogs"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.DataPrivilege", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasColumnType("TEXT"); + + b.Property("GroupCode") + .HasColumnType("TEXT"); + + b.Property("RelateId") + .HasColumnType("TEXT"); + + b.Property("TableName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("UserCode") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("DataPrivileges"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FileAttachment", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ExtraInfo") + .HasColumnType("TEXT"); + + b.Property("FileData") + .HasColumnType("BLOB"); + + b.Property("FileExt") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("HandlerInfo") + .HasColumnType("TEXT"); + + b.Property("Length") + .HasColumnType("INTEGER"); + + b.Property("Path") + .HasColumnType("TEXT"); + + b.Property("SaveMode") + .HasColumnType("TEXT"); + + b.Property("UploadTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("FileAttachments"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkGroup", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("GroupCode") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("GroupRemark") + .HasColumnType("TEXT"); + + b.Property("TenantCode") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("FrameworkGroups"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkMenu", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ActionName") + .HasColumnType("TEXT"); + + b.Property("ClassName") + .HasColumnType("TEXT"); + + b.Property("DisplayOrder") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("Domain") + .HasColumnType("TEXT"); + + b.Property("FolderOnly") + .HasColumnType("INTEGER"); + + b.Property("Icon") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsInherit") + .HasColumnType("INTEGER"); + + b.Property("IsInside") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("IsPublic") + .HasColumnType("INTEGER"); + + b.Property("MethodName") + .HasColumnType("TEXT"); + + b.Property("ModuleName") + .HasColumnType("TEXT"); + + b.Property("PageName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ParentId") + .HasColumnType("TEXT"); + + b.Property("ShowOnMenu") + .HasColumnType("INTEGER"); + + b.Property("Url") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("ParentId"); + + b.ToTable("FrameworkMenus"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkRole", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("RoleCode") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("RoleRemark") + .HasColumnType("TEXT"); + + b.Property("TenantCode") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("FrameworkRoles"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUser", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Address") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("CellPhone") + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Gender") + .HasColumnType("INTEGER"); + + b.Property("HomePhone") + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("ITCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("IsValid") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("PhotoId") + .HasColumnType("TEXT"); + + b.Property("TenantCode") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("ZipCode") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("PhotoId"); + + b.ToTable("FrameworkUsers"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUserGroup", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("GroupCode") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("UserCode") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("FrameworkUserGroups"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUserRole", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("RoleCode") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.Property("UserCode") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("FrameworkUserRoles"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FunctionPrivilege", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Allowed") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("CreateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("MenuItemId") + .HasColumnType("TEXT"); + + b.Property("RoleCode") + .HasColumnType("TEXT"); + + b.Property("UpdateBy") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdateTime") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("MenuItemId"); + + b.ToTable("FunctionPrivileges"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.PersistedGrant", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreationTime") + .HasColumnType("TEXT"); + + b.Property("Expiration") + .HasColumnType("TEXT"); + + b.Property("RefreshToken") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UserCode") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("PersistedGrants"); + }); + + modelBuilder.Entity("IoTGateway.Model.Device", b => + { + b.HasOne("IoTGateway.Model.Driver", "Driver") + .WithMany() + .HasForeignKey("DriverId"); + + b.HasOne("IoTGateway.Model.Device", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.Navigation("Driver"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("IoTGateway.Model.DeviceConfig", b => + { + b.HasOne("IoTGateway.Model.Device", "Device") + .WithMany("DeviceConfigs") + .HasForeignKey("DeviceId"); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("IoTGateway.Model.DeviceVariable", b => + { + b.HasOne("IoTGateway.Model.Device", "Device") + .WithMany("DeviceVariables") + .HasForeignKey("DeviceId"); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkMenu", b => + { + b.HasOne("WalkingTec.Mvvm.Core.FrameworkMenu", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUser", b => + { + b.HasOne("WalkingTec.Mvvm.Core.FileAttachment", "Photo") + .WithMany() + .HasForeignKey("PhotoId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Photo"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FunctionPrivilege", b => + { + b.HasOne("WalkingTec.Mvvm.Core.FrameworkMenu", "MenuItem") + .WithMany("Privileges") + .HasForeignKey("MenuItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MenuItem"); + }); + + modelBuilder.Entity("IoTGateway.Model.Device", b => + { + b.Navigation("Children"); + + b.Navigation("DeviceConfigs"); + + b.Navigation("DeviceVariables"); + }); + + modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkMenu", b => + { + b.Navigation("Children"); + + b.Navigation("Privileges"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IoTGateway.DataAccess/Migrations/20220124063657_platforms.cs b/IoTGateway.DataAccess/Migrations/20220124063657_platforms.cs new file mode 100644 index 0000000..fb86a02 --- /dev/null +++ b/IoTGateway.DataAccess/Migrations/20220124063657_platforms.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IoTGateway.DataAccess.Migrations +{ + public partial class platforms : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Disperse", + table: "SystemConfig", + newName: "IoTPlatformType"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "IoTPlatformType", + table: "SystemConfig", + newName: "Disperse"); + } + } +} diff --git a/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs b/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs index ff4c994..206af2a 100644 --- a/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs +++ b/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs @@ -5,6 +5,8 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +#nullable disable + namespace IoTGateway.DataAccess.Migrations { [DbContext(typeof(DataContext))] @@ -13,8 +15,7 @@ namespace IoTGateway.DataAccess.Migrations protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "5.0.9"); + modelBuilder.HasAnnotation("ProductVersion", "6.0.1"); modelBuilder.Entity("IoTGateway.Model.Device", b => { @@ -193,12 +194,12 @@ namespace IoTGateway.DataAccess.Migrations b.Property("CreateTime") .HasColumnType("TEXT"); - b.Property("Disperse") - .HasColumnType("INTEGER"); - b.Property("GatewayName") .HasColumnType("TEXT"); + b.Property("IoTPlatformType") + .HasColumnType("INTEGER"); + b.Property("MqttIp") .HasColumnType("TEXT"); diff --git a/IoTGateway.Model/IoTGateway.Model.csproj b/IoTGateway.Model/IoTGateway.Model.csproj index 0623834..4c6324f 100644 --- a/IoTGateway.Model/IoTGateway.Model.csproj +++ b/IoTGateway.Model/IoTGateway.Model.csproj @@ -1,11 +1,10 @@  - net5.0 + net6.0 true - diff --git a/IoTGateway.Model/SystemConfig.cs b/IoTGateway.Model/SystemConfig.cs index ad68b9e..536a40d 100644 --- a/IoTGateway.Model/SystemConfig.cs +++ b/IoTGateway.Model/SystemConfig.cs @@ -15,7 +15,23 @@ namespace IoTGateway.Model public string MqttUName { get; set; } [Display(Name = "Mqtt密码")] public string MqttUPwd { get; set; } - [Display(Name = "离散输出")] - public bool Disperse { get; set; } + [Display(Name = "输出平台")] + public IoTPlatformType IoTPlatformType { get; set; } + } + public enum IoTPlatformType + { + [Display(Name = "ThingsBoard")] + ThingsBoard =0, + [Display(Name = "IoTSharp")] + IoTSharp =1, + [Display(Name = "阿里物联网平台")] + AliCloudIoT=2, + [Display(Name = "腾讯智能云")] + TencentIoTHub =3, + [Display(Name = "百度物联网通信")] + BaiduIoTCore =4, + [Display(Name = "中移OneNet")] + OneNET =5 + } } \ No newline at end of file diff --git a/IoTGateway.ViewModel/BasicData/DeviceVMs/DeviceSearcher.cs b/IoTGateway.ViewModel/BasicData/DeviceVMs/DeviceSearcher.cs index ec08d33..58bff78 100644 --- a/IoTGateway.ViewModel/BasicData/DeviceVMs/DeviceSearcher.cs +++ b/IoTGateway.ViewModel/BasicData/DeviceVMs/DeviceSearcher.cs @@ -15,6 +15,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVMs [Display(Name = "名称")] public String DeviceName { get; set; } public List AllDrivers { get; set; } + [Display(Name = "驱动")] public Guid? DriverId { get; set; } [Display(Name = "自启动")] public Boolean? AutoStart { get; set; } diff --git a/IoTGateway.ViewModel/Config/SystemConfigVMs/SystemConfigListVM.cs b/IoTGateway.ViewModel/Config/SystemConfigVMs/SystemConfigListVM.cs index c7cf5c5..bbdac64 100644 --- a/IoTGateway.ViewModel/Config/SystemConfigVMs/SystemConfigListVM.cs +++ b/IoTGateway.ViewModel/Config/SystemConfigVMs/SystemConfigListVM.cs @@ -33,11 +33,11 @@ namespace IoTGateway.ViewModel.Config.SystemConfigVMs { return new List>{ this.MakeGridHeader(x => x.GatewayName), + this.MakeGridHeader(x => x.IoTPlatformType), this.MakeGridHeader(x => x.MqttIp), this.MakeGridHeader(x => x.MqttPort), this.MakeGridHeader(x => x.MqttUName), this.MakeGridHeader(x => x.MqttUPwd), - this.MakeGridHeader(x => x.Disperse), this.MakeGridHeaderAction(width: 200) }; } @@ -53,7 +53,7 @@ namespace IoTGateway.ViewModel.Config.SystemConfigVMs MqttPort = x.MqttPort, MqttUName = x.MqttUName, MqttUPwd = x.MqttUPwd, - Disperse = x.Disperse, + IoTPlatformType = x.IoTPlatformType, }) .OrderBy(x => x.ID); return query; diff --git a/IoTGateway.ViewModel/IoTGateway.ViewModel.csproj b/IoTGateway.ViewModel/IoTGateway.ViewModel.csproj index 5121da2..556ce4e 100644 --- a/IoTGateway.ViewModel/IoTGateway.ViewModel.csproj +++ b/IoTGateway.ViewModel/IoTGateway.ViewModel.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 true diff --git a/IoTGateway.ViewModel/_Admin/FrameworkMenuVMs/FrameworkMenuListVM.cs b/IoTGateway.ViewModel/_Admin/FrameworkMenuVMs/FrameworkMenuListVM.cs index fb43bed..15ec47d 100644 --- a/IoTGateway.ViewModel/_Admin/FrameworkMenuVMs/FrameworkMenuListVM.cs +++ b/IoTGateway.ViewModel/_Admin/FrameworkMenuVMs/FrameworkMenuListVM.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Text; using WalkingTec.Mvvm.Core; using WalkingTec.Mvvm.Core.Extensions; @@ -56,33 +57,34 @@ namespace WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkMenuVMs private object GenerateCheckBox(FrameworkMenu_ListView item) { - string rv = ""; + StringBuilder rv = new StringBuilder(); if (item.FolderOnly == false) { + rv.Append($""); if (item.IsInside == true) { - var others = item.Children?.ToList(); - rv += UIService.MakeCheckBox(item.Allowed, Localizer["Sys.MainPage"], "menu_" + item.ID, "1"); + rv.Append(UIService.MakeCheckBox(item.Allowed, Localizer["Sys.MainPage"], "menu_" + item.ID, "1")); if (others != null) { foreach (var c in others) { string actionname = ""; - if(c.ActionName != null) + if (c.ActionName != null) { - actionname = Localizer[c.ActionName]; + actionname = Localizer[c.ActionName]; } - rv += UIService.MakeCheckBox(c.Allowed, actionname, "menu_" + c.ID, "1"); + rv.Append(UIService.MakeCheckBox(c.Allowed, actionname, "menu_" + c.ID, "1")); } } } else { - rv += UIService.MakeCheckBox(item.Allowed, Localizer["Sys.MainPage"], "menu_" + item.ID, "1"); + rv.Append(UIService.MakeCheckBox(item.Allowed, Localizer["Sys.MainPage"], "menu_" + item.ID, "1")); } } - return rv; + + return rv.ToString(); } @@ -122,16 +124,16 @@ namespace WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkMenuVMs { var data = DC.Set().ToList(); - var topdata = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder).Where(x => x.IsInside == false || x.FolderOnly == true || x.Url.EndsWith("/Index") || x.MethodName == null).ToList(); + var topdata = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder).Where(x => x.IsInside == false || x.FolderOnly == true || x.Url.EndsWith("/Index") || string.IsNullOrEmpty(x.MethodName)).ToList(); foreach (var item in topdata) { if (item.PageName?.StartsWith("MenuKey.") == true) { - item.PageName =Localizer[item.PageName]; + item.PageName = Localizer[item.PageName]; } if (item.ModuleName?.StartsWith("MenuKey.") == true) { - item.ModuleName = Localizer[item.ModuleName]; + item.ModuleName = Localizer[item.ModuleName]; } } @@ -139,7 +141,7 @@ namespace WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkMenuVMs if (SearcherMode == ListVMSearchModeEnum.Custom2) { var pris = DC.Set() - .Where(x => x.RoleCode == DC.Set().CheckID(Searcher.RoleID,null).Select(x=>x.RoleCode).FirstOrDefault()).ToList(); + .Where(x => x.RoleCode == DC.Set().CheckID(Searcher.RoleID, null).Select(x => x.RoleCode).FirstOrDefault()).ToList(); var allowed = pris.Where(x => x.Allowed == true).Select(x => x.MenuItemId).ToList(); var denied = pris.Where(x => x.Allowed == false).Select(x => x.MenuItemId).ToList(); int order = 0; diff --git a/IoTGateway.ViewModel/_Admin/FrameworkMenuVMs/FrameworkMenuVM.cs b/IoTGateway.ViewModel/_Admin/FrameworkMenuVMs/FrameworkMenuVM.cs index 08c503a..132ae6f 100644 --- a/IoTGateway.ViewModel/_Admin/FrameworkMenuVMs/FrameworkMenuVM.cs +++ b/IoTGateway.ViewModel/_Admin/FrameworkMenuVMs/FrameworkMenuVM.cs @@ -75,16 +75,7 @@ namespace WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkMenuVMs } var modules = Wtm.GlobaInfo.AllModule; - var toRemove = new List(); - foreach (var item in modules) - { - if (item.IgnorePrivillege) - { - toRemove.Add(item); - } - } var m = Utils.ResetModule(modules); - toRemove.ForEach(x => m.Remove(x)); AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName); if (string.IsNullOrEmpty(SelectedModule) == false || (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true)) @@ -113,7 +104,7 @@ namespace WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkMenuVMs MSD.AddModelError("SelectedModule", Localizer["Validate.{0}required", Localizer["_Admin.Module"]]); } var modules = Wtm.GlobaInfo.AllModule; - var test = DC.Set().Where(x => x.ClassName == this.SelectedModule && (x.MethodName == null || x.MethodName == "Index") && x.ID != Entity.ID).FirstOrDefault(); + var test = DC.Set().Where(x => x.ClassName == this.SelectedModule && (string.IsNullOrEmpty(x.MethodName) || x.MethodName == "Index") && x.ID != Entity.ID).FirstOrDefault(); if (test != null) { MSD.AddModelError(" error", Localizer["_Admin.ModuleHasSet"]); diff --git a/IoTGateway.ViewModel/_Admin/FrameworkRoleVMs/FrameworkRoleMDVM2.cs b/IoTGateway.ViewModel/_Admin/FrameworkRoleVMs/FrameworkRoleMDVM2.cs index e775285..fa3eecf 100644 --- a/IoTGateway.ViewModel/_Admin/FrameworkRoleVMs/FrameworkRoleMDVM2.cs +++ b/IoTGateway.ViewModel/_Admin/FrameworkRoleVMs/FrameworkRoleMDVM2.cs @@ -25,7 +25,7 @@ namespace WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkRoleVMs .Where(x => x.RoleCode == Entity.RoleCode && x.Allowed == true).Select(x => x.MenuItemId) .ToList(); var data = DC.Set().ToList(); - var topdata = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder).Where(x => x.IsInside == false || x.FolderOnly == true || x.MethodName == null).ToList(); + var topdata = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder).Where(x => x.IsInside == false || x.FolderOnly == true || string.IsNullOrEmpty(x.MethodName)).ToList(); int order = 0; var data2 = topdata.Select(x => new Page_View { diff --git a/IoTGateway.ViewModel/_Admin/FrameworkUserVms/FrameworkUserBatchVM.cs b/IoTGateway.ViewModel/_Admin/FrameworkUserVms/FrameworkUserBatchVM.cs index 2239786..c96fb24 100644 --- a/IoTGateway.ViewModel/_Admin/FrameworkUserVms/FrameworkUserBatchVM.cs +++ b/IoTGateway.ViewModel/_Admin/FrameworkUserVms/FrameworkUserBatchVM.cs @@ -3,20 +3,30 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Text.Json.Serialization; using Microsoft.EntityFrameworkCore; using WalkingTec.Mvvm.Core; using WalkingTec.Mvvm.Core.Extensions; +using WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkRoleVMs; namespace WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkUserVms { public class FrameworkUserBatchVM : BaseBatchVM { + [JsonIgnore] + public FrameworkRoleListVM RoleListVM { get; set; } + public FrameworkUserBatchVM() { ListVM = new FrameworkUserListVM(); LinkedVM = new FrameworkUser_BatchEdit(); } + protected override void InitVM() + { + RoleListVM = Wtm.CreateVM(); + } + public override bool DoBatchEdit() { var entityList = DC.Set().AsNoTracking().CheckIDs(Ids.ToList()).ToList(); diff --git a/IoTGateway.sln b/IoTGateway.sln index ebda7cf..3d23c18 100644 --- a/IoTGateway.sln +++ b/IoTGateway.sln @@ -3,43 +3,43 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31919.166 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTGateway", "IoTGateway\IoTGateway.csproj", "{68ABBDF2-1485-4756-9A94-6AFA874D69A3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTGateway", "IoTGateway\IoTGateway.csproj", "{1F9122C1-19DE-4A8B-9A00-D59E592ECC3A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTGateway.Model", "IoTGateway.Model\IoTGateway.Model.csproj", "{C2978E5D-E71E-4882-8EF1-4014E8565A77}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTGateway.Model", "IoTGateway.Model\IoTGateway.Model.csproj", "{44619988-9F09-4714-9532-A44FAF8275FE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTGateway.DataAccess", "IoTGateway.DataAccess\IoTGateway.DataAccess.csproj", "{9E7C8C77-643F-45CF-8EDC-5B032C51D563}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTGateway.DataAccess", "IoTGateway.DataAccess\IoTGateway.DataAccess.csproj", "{27FF2D65-0BBA-4C69-9DD7-311A4F21541E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTGateway.ViewModel", "IoTGateway.ViewModel\IoTGateway.ViewModel.csproj", "{00E91FC1-D5CF-416A-AAAF-61567E368DCD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTGateway.ViewModel", "IoTGateway.ViewModel\IoTGateway.ViewModel.csproj", "{E63C22D5-5F9B-4671-B115-40721B27F09F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{FBED048F-7AB9-4348-AD56-F9BF4D9E3A55}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{2C665127-D9D0-445E-80A9-FD459673D454}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plugin", "Plugins\Plugin\Plugin.csproj", "{61D79F77-09EF-4A98-A50B-043B1D72C111}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WalkingTec.Mvvm", "WalkingTec.Mvvm", "{0DD65BFB-EDC4-49CD-857C-6CCAAAF1CDFB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginInterface", "Plugins\PluginInterface\PluginInterface.csproj", "{E5F79995-AB61-41F4-820D-BA39967B406B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.Core", "WalkingTec.Mvvm\WalkingTec.Mvvm.Core\WalkingTec.Mvvm.Core.csproj", "{89DE240E-5393-4DD4-87C9-3AD9D44B6E7E}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Drivers", "Drivers", "{52D96C24-2F2F-49B5-9F29-00414DEA41D8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.Mvc", "WalkingTec.Mvvm\WalkingTec.Mvvm.Mvc\WalkingTec.Mvvm.Mvc.csproj", "{96D436B4-4703-4448-A879-B69ACE89CA11}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WalkingTec.Mvvm", "WalkingTec.Mvvm", "{98B1C9F0-028C-48D8-8148-54B69CCA4590}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.TagHelpers.LayUI", "WalkingTec.Mvvm\WalkingTec.Mvvm.TagHelpers.LayUI\WalkingTec.Mvvm.TagHelpers.LayUI.csproj", "{816DDA22-F7E8-4FB2-83A4-0954A0EEEBBF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.Core", "WalkingTec.Mvvm\WalkingTec.Mvvm.Core\WalkingTec.Mvvm.Core.csproj", "{C2672620-8E65-486C-B967-C4C673F8DA0F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plugin", "Plugins\Plugin\Plugin.csproj", "{5C12EBFB-B152-48C6-AA52-71128F246594}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.Mvc", "WalkingTec.Mvvm\WalkingTec.Mvvm.Mvc\WalkingTec.Mvvm.Mvc.csproj", "{B370F699-965B-4D86-93B1-0F022C95B5C9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginInterface", "Plugins\PluginInterface\PluginInterface.csproj", "{7752AD8C-04BF-4BD2-9272-CDA4F78FA954}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.TagHelpers.LayUI", "WalkingTec.Mvvm\WalkingTec.Mvvm.TagHelpers.LayUI\WalkingTec.Mvvm.TagHelpers.LayUI.csproj", "{81CBFD0E-1D89-440A-8CC3-E32672504FF4}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Drivers", "Drivers", "{D05CFF72-D58C-418A-8F52-B06848DAC4F1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverModbusMaster", "Plugins\Drivers\DriverModbusMaster\DriverModbusMaster.csproj", "{4FC43620-00B1-48C1-A5A0-02FCC038FB08}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverAllenBradley", "Plugins\Drivers\DriverAllenBradley\DriverAllenBradley.csproj", "{3106F31C-0502-42D3-A27B-BDD2199D72CC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverSiemensS7", "Plugins\Drivers\DriverSiemensS7\DriverSiemensS7.csproj", "{B884FBE3-C8C5-471E-B629-12ECA0FC5DAC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverMitsubishi", "Plugins\Drivers\DriverMitsubishi\DriverMitsubishi.csproj", "{8919CDA5-23A6-4C04-87F9-C83DF4BEF357}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverOPCUaClient", "Plugins\Drivers\DriverOPCUaClient\DriverOPCUaClient.csproj", "{DABB562D-5EB7-4F9D-90EF-424C2BF63A4D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverModbusMaster", "Plugins\Drivers\DriverModbusMaster\DriverModbusMaster.csproj", "{8E2D91DC-DEE4-4843-8D09-6FC06651527E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverMTConnect", "Plugins\Drivers\DriverMTConnect\DriverMTConnect.csproj", "{0602DC6C-FB26-41B1-972E-298679826E3F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverMTConnect", "Plugins\Drivers\DriverMTConnect\DriverMTConnect.csproj", "{64D4C755-33DD-4103-908B-82FA63C5BFB2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverMitsubishi", "Plugins\Drivers\DriverMitsubishi\DriverMitsubishi.csproj", "{6D926CD7-5FF9-489B-9049-7030AE8059C9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverOPCUaClient", "Plugins\Drivers\DriverOPCUaClient\DriverOPCUaClient.csproj", "{AAC81E6C-C62E-4F52-85B5-1EA8D54AE9F6}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverOmronFins", "Plugins\Drivers\OmronFins\DriverOmronFins.csproj", "{92E2BB84-C7EC-418E-879A-40B891CAE6E7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverSiemensS7", "Plugins\Drivers\DriverSiemensS7\DriverSiemensS7.csproj", "{28FEF3AF-4CAA-4B5C-B16F-E74BAD70BCE2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverAllenBradley", "Plugins\Drivers\DriverAllenBradley\DriverAllenBradley.csproj", "{C8C82C05-DEFD-4E79-9772-B5EA3D2E5D88}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DriverOmronFins", "Plugins\Drivers\DriverOmronFins\DriverOmronFins.csproj", "{FE2BFDBD-E021-45EA-B327-C56F6114D7A1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -47,88 +47,88 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {68ABBDF2-1485-4756-9A94-6AFA874D69A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {68ABBDF2-1485-4756-9A94-6AFA874D69A3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {68ABBDF2-1485-4756-9A94-6AFA874D69A3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {68ABBDF2-1485-4756-9A94-6AFA874D69A3}.Release|Any CPU.Build.0 = Release|Any CPU - {C2978E5D-E71E-4882-8EF1-4014E8565A77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C2978E5D-E71E-4882-8EF1-4014E8565A77}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C2978E5D-E71E-4882-8EF1-4014E8565A77}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C2978E5D-E71E-4882-8EF1-4014E8565A77}.Release|Any CPU.Build.0 = Release|Any CPU - {9E7C8C77-643F-45CF-8EDC-5B032C51D563}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9E7C8C77-643F-45CF-8EDC-5B032C51D563}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9E7C8C77-643F-45CF-8EDC-5B032C51D563}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9E7C8C77-643F-45CF-8EDC-5B032C51D563}.Release|Any CPU.Build.0 = Release|Any CPU - {00E91FC1-D5CF-416A-AAAF-61567E368DCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00E91FC1-D5CF-416A-AAAF-61567E368DCD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00E91FC1-D5CF-416A-AAAF-61567E368DCD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00E91FC1-D5CF-416A-AAAF-61567E368DCD}.Release|Any CPU.Build.0 = Release|Any CPU - {61D79F77-09EF-4A98-A50B-043B1D72C111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {61D79F77-09EF-4A98-A50B-043B1D72C111}.Debug|Any CPU.Build.0 = Debug|Any CPU - {61D79F77-09EF-4A98-A50B-043B1D72C111}.Release|Any CPU.ActiveCfg = Release|Any CPU - {61D79F77-09EF-4A98-A50B-043B1D72C111}.Release|Any CPU.Build.0 = Release|Any CPU - {E5F79995-AB61-41F4-820D-BA39967B406B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E5F79995-AB61-41F4-820D-BA39967B406B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E5F79995-AB61-41F4-820D-BA39967B406B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E5F79995-AB61-41F4-820D-BA39967B406B}.Release|Any CPU.Build.0 = Release|Any CPU - {C2672620-8E65-486C-B967-C4C673F8DA0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C2672620-8E65-486C-B967-C4C673F8DA0F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C2672620-8E65-486C-B967-C4C673F8DA0F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C2672620-8E65-486C-B967-C4C673F8DA0F}.Release|Any CPU.Build.0 = Release|Any CPU - {B370F699-965B-4D86-93B1-0F022C95B5C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B370F699-965B-4D86-93B1-0F022C95B5C9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B370F699-965B-4D86-93B1-0F022C95B5C9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B370F699-965B-4D86-93B1-0F022C95B5C9}.Release|Any CPU.Build.0 = Release|Any CPU - {81CBFD0E-1D89-440A-8CC3-E32672504FF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {81CBFD0E-1D89-440A-8CC3-E32672504FF4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {81CBFD0E-1D89-440A-8CC3-E32672504FF4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {81CBFD0E-1D89-440A-8CC3-E32672504FF4}.Release|Any CPU.Build.0 = Release|Any CPU - {4FC43620-00B1-48C1-A5A0-02FCC038FB08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4FC43620-00B1-48C1-A5A0-02FCC038FB08}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4FC43620-00B1-48C1-A5A0-02FCC038FB08}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4FC43620-00B1-48C1-A5A0-02FCC038FB08}.Release|Any CPU.Build.0 = Release|Any CPU - {B884FBE3-C8C5-471E-B629-12ECA0FC5DAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B884FBE3-C8C5-471E-B629-12ECA0FC5DAC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B884FBE3-C8C5-471E-B629-12ECA0FC5DAC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B884FBE3-C8C5-471E-B629-12ECA0FC5DAC}.Release|Any CPU.Build.0 = Release|Any CPU - {DABB562D-5EB7-4F9D-90EF-424C2BF63A4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DABB562D-5EB7-4F9D-90EF-424C2BF63A4D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DABB562D-5EB7-4F9D-90EF-424C2BF63A4D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DABB562D-5EB7-4F9D-90EF-424C2BF63A4D}.Release|Any CPU.Build.0 = Release|Any CPU - {0602DC6C-FB26-41B1-972E-298679826E3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0602DC6C-FB26-41B1-972E-298679826E3F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0602DC6C-FB26-41B1-972E-298679826E3F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0602DC6C-FB26-41B1-972E-298679826E3F}.Release|Any CPU.Build.0 = Release|Any CPU - {6D926CD7-5FF9-489B-9049-7030AE8059C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6D926CD7-5FF9-489B-9049-7030AE8059C9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6D926CD7-5FF9-489B-9049-7030AE8059C9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6D926CD7-5FF9-489B-9049-7030AE8059C9}.Release|Any CPU.Build.0 = Release|Any CPU - {92E2BB84-C7EC-418E-879A-40B891CAE6E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {92E2BB84-C7EC-418E-879A-40B891CAE6E7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {92E2BB84-C7EC-418E-879A-40B891CAE6E7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {92E2BB84-C7EC-418E-879A-40B891CAE6E7}.Release|Any CPU.Build.0 = Release|Any CPU - {C8C82C05-DEFD-4E79-9772-B5EA3D2E5D88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C8C82C05-DEFD-4E79-9772-B5EA3D2E5D88}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C8C82C05-DEFD-4E79-9772-B5EA3D2E5D88}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C8C82C05-DEFD-4E79-9772-B5EA3D2E5D88}.Release|Any CPU.Build.0 = Release|Any CPU + {1F9122C1-19DE-4A8B-9A00-D59E592ECC3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F9122C1-19DE-4A8B-9A00-D59E592ECC3A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F9122C1-19DE-4A8B-9A00-D59E592ECC3A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F9122C1-19DE-4A8B-9A00-D59E592ECC3A}.Release|Any CPU.Build.0 = Release|Any CPU + {44619988-9F09-4714-9532-A44FAF8275FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44619988-9F09-4714-9532-A44FAF8275FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44619988-9F09-4714-9532-A44FAF8275FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44619988-9F09-4714-9532-A44FAF8275FE}.Release|Any CPU.Build.0 = Release|Any CPU + {27FF2D65-0BBA-4C69-9DD7-311A4F21541E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27FF2D65-0BBA-4C69-9DD7-311A4F21541E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27FF2D65-0BBA-4C69-9DD7-311A4F21541E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27FF2D65-0BBA-4C69-9DD7-311A4F21541E}.Release|Any CPU.Build.0 = Release|Any CPU + {E63C22D5-5F9B-4671-B115-40721B27F09F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E63C22D5-5F9B-4671-B115-40721B27F09F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E63C22D5-5F9B-4671-B115-40721B27F09F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E63C22D5-5F9B-4671-B115-40721B27F09F}.Release|Any CPU.Build.0 = Release|Any CPU + {89DE240E-5393-4DD4-87C9-3AD9D44B6E7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89DE240E-5393-4DD4-87C9-3AD9D44B6E7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89DE240E-5393-4DD4-87C9-3AD9D44B6E7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89DE240E-5393-4DD4-87C9-3AD9D44B6E7E}.Release|Any CPU.Build.0 = Release|Any CPU + {96D436B4-4703-4448-A879-B69ACE89CA11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96D436B4-4703-4448-A879-B69ACE89CA11}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96D436B4-4703-4448-A879-B69ACE89CA11}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96D436B4-4703-4448-A879-B69ACE89CA11}.Release|Any CPU.Build.0 = Release|Any CPU + {816DDA22-F7E8-4FB2-83A4-0954A0EEEBBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {816DDA22-F7E8-4FB2-83A4-0954A0EEEBBF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {816DDA22-F7E8-4FB2-83A4-0954A0EEEBBF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {816DDA22-F7E8-4FB2-83A4-0954A0EEEBBF}.Release|Any CPU.Build.0 = Release|Any CPU + {5C12EBFB-B152-48C6-AA52-71128F246594}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C12EBFB-B152-48C6-AA52-71128F246594}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C12EBFB-B152-48C6-AA52-71128F246594}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C12EBFB-B152-48C6-AA52-71128F246594}.Release|Any CPU.Build.0 = Release|Any CPU + {7752AD8C-04BF-4BD2-9272-CDA4F78FA954}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7752AD8C-04BF-4BD2-9272-CDA4F78FA954}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7752AD8C-04BF-4BD2-9272-CDA4F78FA954}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7752AD8C-04BF-4BD2-9272-CDA4F78FA954}.Release|Any CPU.Build.0 = Release|Any CPU + {3106F31C-0502-42D3-A27B-BDD2199D72CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3106F31C-0502-42D3-A27B-BDD2199D72CC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3106F31C-0502-42D3-A27B-BDD2199D72CC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3106F31C-0502-42D3-A27B-BDD2199D72CC}.Release|Any CPU.Build.0 = Release|Any CPU + {8919CDA5-23A6-4C04-87F9-C83DF4BEF357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8919CDA5-23A6-4C04-87F9-C83DF4BEF357}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8919CDA5-23A6-4C04-87F9-C83DF4BEF357}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8919CDA5-23A6-4C04-87F9-C83DF4BEF357}.Release|Any CPU.Build.0 = Release|Any CPU + {8E2D91DC-DEE4-4843-8D09-6FC06651527E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E2D91DC-DEE4-4843-8D09-6FC06651527E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E2D91DC-DEE4-4843-8D09-6FC06651527E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E2D91DC-DEE4-4843-8D09-6FC06651527E}.Release|Any CPU.Build.0 = Release|Any CPU + {64D4C755-33DD-4103-908B-82FA63C5BFB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {64D4C755-33DD-4103-908B-82FA63C5BFB2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {64D4C755-33DD-4103-908B-82FA63C5BFB2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {64D4C755-33DD-4103-908B-82FA63C5BFB2}.Release|Any CPU.Build.0 = Release|Any CPU + {AAC81E6C-C62E-4F52-85B5-1EA8D54AE9F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AAC81E6C-C62E-4F52-85B5-1EA8D54AE9F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AAC81E6C-C62E-4F52-85B5-1EA8D54AE9F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AAC81E6C-C62E-4F52-85B5-1EA8D54AE9F6}.Release|Any CPU.Build.0 = Release|Any CPU + {28FEF3AF-4CAA-4B5C-B16F-E74BAD70BCE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FEF3AF-4CAA-4B5C-B16F-E74BAD70BCE2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FEF3AF-4CAA-4B5C-B16F-E74BAD70BCE2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FEF3AF-4CAA-4B5C-B16F-E74BAD70BCE2}.Release|Any CPU.Build.0 = Release|Any CPU + {FE2BFDBD-E021-45EA-B327-C56F6114D7A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE2BFDBD-E021-45EA-B327-C56F6114D7A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE2BFDBD-E021-45EA-B327-C56F6114D7A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE2BFDBD-E021-45EA-B327-C56F6114D7A1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {61D79F77-09EF-4A98-A50B-043B1D72C111} = {FBED048F-7AB9-4348-AD56-F9BF4D9E3A55} - {E5F79995-AB61-41F4-820D-BA39967B406B} = {FBED048F-7AB9-4348-AD56-F9BF4D9E3A55} - {52D96C24-2F2F-49B5-9F29-00414DEA41D8} = {FBED048F-7AB9-4348-AD56-F9BF4D9E3A55} - {C2672620-8E65-486C-B967-C4C673F8DA0F} = {98B1C9F0-028C-48D8-8148-54B69CCA4590} - {B370F699-965B-4D86-93B1-0F022C95B5C9} = {98B1C9F0-028C-48D8-8148-54B69CCA4590} - {81CBFD0E-1D89-440A-8CC3-E32672504FF4} = {98B1C9F0-028C-48D8-8148-54B69CCA4590} - {4FC43620-00B1-48C1-A5A0-02FCC038FB08} = {52D96C24-2F2F-49B5-9F29-00414DEA41D8} - {B884FBE3-C8C5-471E-B629-12ECA0FC5DAC} = {52D96C24-2F2F-49B5-9F29-00414DEA41D8} - {DABB562D-5EB7-4F9D-90EF-424C2BF63A4D} = {52D96C24-2F2F-49B5-9F29-00414DEA41D8} - {0602DC6C-FB26-41B1-972E-298679826E3F} = {52D96C24-2F2F-49B5-9F29-00414DEA41D8} - {6D926CD7-5FF9-489B-9049-7030AE8059C9} = {52D96C24-2F2F-49B5-9F29-00414DEA41D8} - {92E2BB84-C7EC-418E-879A-40B891CAE6E7} = {52D96C24-2F2F-49B5-9F29-00414DEA41D8} - {C8C82C05-DEFD-4E79-9772-B5EA3D2E5D88} = {52D96C24-2F2F-49B5-9F29-00414DEA41D8} + {89DE240E-5393-4DD4-87C9-3AD9D44B6E7E} = {0DD65BFB-EDC4-49CD-857C-6CCAAAF1CDFB} + {96D436B4-4703-4448-A879-B69ACE89CA11} = {0DD65BFB-EDC4-49CD-857C-6CCAAAF1CDFB} + {816DDA22-F7E8-4FB2-83A4-0954A0EEEBBF} = {0DD65BFB-EDC4-49CD-857C-6CCAAAF1CDFB} + {5C12EBFB-B152-48C6-AA52-71128F246594} = {2C665127-D9D0-445E-80A9-FD459673D454} + {7752AD8C-04BF-4BD2-9272-CDA4F78FA954} = {2C665127-D9D0-445E-80A9-FD459673D454} + {D05CFF72-D58C-418A-8F52-B06848DAC4F1} = {2C665127-D9D0-445E-80A9-FD459673D454} + {3106F31C-0502-42D3-A27B-BDD2199D72CC} = {D05CFF72-D58C-418A-8F52-B06848DAC4F1} + {8919CDA5-23A6-4C04-87F9-C83DF4BEF357} = {D05CFF72-D58C-418A-8F52-B06848DAC4F1} + {8E2D91DC-DEE4-4843-8D09-6FC06651527E} = {D05CFF72-D58C-418A-8F52-B06848DAC4F1} + {64D4C755-33DD-4103-908B-82FA63C5BFB2} = {D05CFF72-D58C-418A-8F52-B06848DAC4F1} + {AAC81E6C-C62E-4F52-85B5-1EA8D54AE9F6} = {D05CFF72-D58C-418A-8F52-B06848DAC4F1} + {28FEF3AF-4CAA-4B5C-B16F-E74BAD70BCE2} = {D05CFF72-D58C-418A-8F52-B06848DAC4F1} + {FE2BFDBD-E021-45EA-B327-C56F6114D7A1} = {D05CFF72-D58C-418A-8F52-B06848DAC4F1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1F219808-E6E8-4C1D-B846-41F2F7CF20FA} diff --git a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Index.cshtml b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Index.cshtml index 8edf80b..559b26e 100644 --- a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Index.cshtml +++ b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Index.cshtml @@ -1,462 +1,18 @@ @model IoTGateway.ViewModel.BasicData.DeviceVariableVMs.DeviceVariableListVM @inject IStringLocalizer Localizer; -@using Newtonsoft.Json - -
-
-
-
-
-
-
-
-
-

- 搜索条件 -
- 搜索 - -
-

-
- - -
- -
- -
- -
- -
-
- -
- - - - -
- -
- -
- -
-
- -
- - -
- -
- -
- -
-
- -
- - -
- -
- -
- -
-
- -
- - -
- -
- -
- -
-
- -
- - - -
- -
-
-
- -
- - -
- - - - - - - -
- -
- - - - - - - - - + + + + + + + + + + + + @@ -489,7 +45,7 @@ //加工值 $('#id' + objmsg.VarId + '_CookedValue').text(objmsg.CookedValue); - $('#id' + objmsg.VarId + '_CookedValue').addClass('animated bounceIn'); + $('#id' + objmsg.VarId + '_CookedValue').addClass('animated bounceIn'); setTimeout(function(){ $('#id' + objmsg.VarId + '_CookedValue').removeClass('bounceIn'); }, 1500); diff --git a/IoTGateway/Areas/Config/Views/SystemConfig/Edit.cshtml b/IoTGateway/Areas/Config/Views/SystemConfig/Edit.cshtml index e8c410f..f3bdf4e 100644 --- a/IoTGateway/Areas/Config/Views/SystemConfig/Edit.cshtml +++ b/IoTGateway/Areas/Config/Views/SystemConfig/Edit.cshtml @@ -2,14 +2,14 @@ @inject IStringLocalizer Localizer; - 注意:tb只能使用非离散输出模式,否则平台无法解析 + 注意:目前只实现了iotsharp和tb的遥测数据上传 + - diff --git a/IoTGateway/Areas/Config/Views/SystemConfig/Index.cshtml b/IoTGateway/Areas/Config/Views/SystemConfig/Index.cshtml index 9d0e60b..cdc3ba1 100644 --- a/IoTGateway/Areas/Config/Views/SystemConfig/Index.cshtml +++ b/IoTGateway/Areas/Config/Views/SystemConfig/Index.cshtml @@ -5,5 +5,5 @@ -注意:tb只能使用非离散输出模式,否则平台无法解析 +注意:目前只实现了iotsharp和tb的遥测数据上传 diff --git a/IoTGateway/Areas/_Admin/ApiControllers/AccountController.cs b/IoTGateway/Areas/_Admin/ApiControllers/AccountController.cs index a9740d0..996d2ce 100644 --- a/IoTGateway/Areas/_Admin/ApiControllers/AccountController.cs +++ b/IoTGateway/Areas/_Admin/ApiControllers/AccountController.cs @@ -78,7 +78,7 @@ namespace WalkingTec.Mvvm.Admin.Api forapi.Groups = user.Groups; forapi.PhotoId = user.PhotoId; var roleIDs = Wtm.LoginUserInfo.Roles.Select(x => x.RoleCode).ToList(); - var data = DC.Set().Where(x => x.MethodName == null).ToList(); + var data = DC.Set().Where(x => string.IsNullOrEmpty(x.MethodName)).ToList(); var topdata = data.Where(x => x.ParentId == null && x.ShowOnMenu).ToList().FlatTree(x => x.DisplayOrder).Where(x => (x.IsInside == false || x.FolderOnly == true || string.IsNullOrEmpty(x.MethodName)) && x.ShowOnMenu).ToList(); var allowed = DC.Set() .AsNoTracking() @@ -193,7 +193,7 @@ namespace WalkingTec.Mvvm.Admin.Api var ms = new List(); var roleIDs = Wtm.LoginUserInfo.Roles.Select(x => x.RoleCode).ToList(); - var data = DC.Set().Where(x => x.MethodName == null).ToList(); + var data = DC.Set().Where(x => string.IsNullOrEmpty(x.MethodName)).ToList(); var topdata = data.Where(x => x.ParentId == null && x.ShowOnMenu).ToList().FlatTree(x => x.DisplayOrder).Where(x => (x.IsInside == false || x.FolderOnly == true || string.IsNullOrEmpty(x.MethodName)) && x.ShowOnMenu).ToList(); var allowed = DC.Set() .AsNoTracking() @@ -259,7 +259,7 @@ namespace WalkingTec.Mvvm.Admin.Api { HttpContext.Session.Clear(); await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - HttpContext.Response.Redirect("/"); + Ok(); } } diff --git a/IoTGateway/Areas/_Admin/ApiControllers/FileApiController.cs b/IoTGateway/Areas/_Admin/ApiControllers/FileApiController.cs index bc735f5..6fc29e3 100644 --- a/IoTGateway/Areas/_Admin/ApiControllers/FileApiController.cs +++ b/IoTGateway/Areas/_Admin/ApiControllers/FileApiController.cs @@ -1,8 +1,8 @@ -// WTM默认页面 Wtm buidin page +// WTM默认页面 Wtm buidin page using System; -using System.Drawing; using System.IO; -using System.Linq; +using SixLabors.ImageSharp; +using SixLabors.ImageSharp.Processing; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.StaticFiles; @@ -21,24 +21,24 @@ namespace WalkingTec.Mvvm.Admin.Api { [HttpPost("[action]")] [ActionDescription("UploadFile")] - public IActionResult Upload([FromServices] WtmFileProvider fp, string sm = null, string groupName = null, string subdir=null,string extra = null,string csName= null) + public IActionResult Upload([FromServices] WtmFileProvider fp, string sm = null, string groupName = null, string subdir = null, string extra = null, string csName = null) { var FileData = Request.Form.Files[0]; - var file = fp.Upload(FileData.FileName, FileData.Length, FileData.OpenReadStream(),groupName,subdir,extra,sm,Wtm.CreateDC(cskey:csName)); + var file = fp.Upload(FileData.FileName, FileData.Length, FileData.OpenReadStream(), groupName, subdir, extra, sm, Wtm.CreateDC(cskey: csName)); return Ok(new { Id = file.GetID(), Name = file.FileName }); } [HttpPost("[action]")] [ActionDescription("UploadPic")] - public IActionResult UploadImage([FromServices] WtmFileProvider fp,int? width = null, int? height = null, string sm = null, string groupName = null, string subdir = null, string extra = null, string csName = null) + public IActionResult UploadImage([FromServices] WtmFileProvider fp, int? width = null, int? height = null, string sm = null, string groupName = null, string subdir = null, string extra = null, string csName = null) { if (width == null && height == null) { - return Upload(fp,sm,groupName,csName); + return Upload(fp, sm, groupName, csName); } var FileData = Request.Form.Files[0]; - Image oimage = Image.FromStream(FileData.OpenReadStream()); + Image oimage = Image.Load(FileData.OpenReadStream()); if (oimage == null) { return BadRequest(Localizer["Sys.UploadFailed"]); @@ -52,9 +52,10 @@ namespace WalkingTec.Mvvm.Admin.Api height = width * oimage.Height / oimage.Width; } MemoryStream ms = new MemoryStream(); - oimage.GetThumbnailImage(width.Value, height.Value, null, IntPtr.Zero).Save(ms, System.Drawing.Imaging.ImageFormat.Png); + oimage.Mutate(x => x.Resize(width.Value, height.Value)); + oimage.SaveAsJpeg(ms); ms.Position = 0; - var file = fp.Upload(FileData.FileName, FileData.Length, ms, groupName,subdir, extra, sm, Wtm.CreateDC(cskey: csName)); + var file = fp.Upload(FileData.FileName, FileData.Length, ms, groupName, subdir, extra, sm, Wtm.CreateDC(cskey: csName)); oimage.Dispose(); ms.Dispose(); @@ -68,6 +69,7 @@ namespace WalkingTec.Mvvm.Admin.Api [HttpGet("[action]/{id}")] [ActionDescription("GetFileName")] + [Public] public IActionResult GetFileName([FromServices] WtmFileProvider fp, string id, string csName = null) { return Ok(fp.GetFileName(id, ConfigInfo.CreateDC(csName))); @@ -75,6 +77,7 @@ namespace WalkingTec.Mvvm.Admin.Api [HttpGet("[action]/{id}")] [ActionDescription("GetFile")] + [Public] public async Task GetFile([FromServices] WtmFileProvider fp, string id, string csName = null, int? width = null, int? height = null) { var file = fp.GetFile(id, true, ConfigInfo.CreateDC(csName)); @@ -88,7 +91,7 @@ namespace WalkingTec.Mvvm.Admin.Api { if (width != null || height != null) { - Image oimage = Image.FromStream(file.DataStream); + Image oimage = Image.Load(file.DataStream); if (oimage != null) { if (width == null) @@ -100,7 +103,8 @@ namespace WalkingTec.Mvvm.Admin.Api height = oimage.Height * width / oimage.Width; } var ms = new MemoryStream(); - oimage.GetThumbnailImage(width.Value, height.Value, null, IntPtr.Zero).Save(ms, System.Drawing.Imaging.ImageFormat.Png); + oimage.Mutate(x => x.Resize(width.Value, height.Value)); + oimage.SaveAsJpeg(ms); ms.Position = 0; await ms?.CopyToAsync(Response.Body); file.DataStream.Dispose(); @@ -125,8 +129,10 @@ namespace WalkingTec.Mvvm.Admin.Api } } + [HttpGet("[action]/{id}")] [ActionDescription("DownloadFile")] + [Public] public IActionResult DownloadFile([FromServices] WtmFileProvider fp, string id, string csName = null) { var file = fp.GetFile(id, true, ConfigInfo.CreateDC(csName)); @@ -149,7 +155,7 @@ namespace WalkingTec.Mvvm.Admin.Api public IActionResult DeletedFile([FromServices] WtmFileProvider fp, string id, string csName = null) { fp.DeleteFile(id, ConfigInfo.CreateDC(csName)); - return Ok(); + return Ok(true); } } } diff --git a/IoTGateway/Areas/_Admin/Controllers/FrameworkMenuController.cs b/IoTGateway/Areas/_Admin/Controllers/FrameworkMenuController.cs index 5987081..0e2e17b 100644 --- a/IoTGateway/Areas/_Admin/Controllers/FrameworkMenuController.cs +++ b/IoTGateway/Areas/_Admin/Controllers/FrameworkMenuController.cs @@ -175,7 +175,7 @@ namespace WalkingTec.Mvvm.Mvc.Admin.Controllers public async Task RefreshMenu() { Cache.Delete("FFMenus"); - var userids = DC.Set().Select(x => x.ID.ToString().ToLower()).ToArray(); + var userids = DC.Set().Select(x => x.ITCode.ToString().ToLower()).ToArray(); await Wtm.RemoveUserCache(userids); return FFResult().Alert(Localizer["Sys.OprationSuccess"]); } diff --git a/IoTGateway/Areas/_Admin/Views/FrameworkGroup/DataFunction.cshtml b/IoTGateway/Areas/_Admin/Views/FrameworkGroup/DataFunction.cshtml index 6d6927f..645412a 100644 --- a/IoTGateway/Areas/_Admin/Views/FrameworkGroup/DataFunction.cshtml +++ b/IoTGateway/Areas/_Admin/Views/FrameworkGroup/DataFunction.cshtml @@ -8,7 +8,7 @@ - + diff --git a/IoTGateway/Areas/_Admin/Views/FrameworkRole/PageFunction.cshtml b/IoTGateway/Areas/_Admin/Views/FrameworkRole/PageFunction.cshtml index 18e785e..d74216b 100644 --- a/IoTGateway/Areas/_Admin/Views/FrameworkRole/PageFunction.cshtml +++ b/IoTGateway/Areas/_Admin/Views/FrameworkRole/PageFunction.cshtml @@ -13,5 +13,26 @@ + diff --git a/IoTGateway/Areas/_Admin/Views/FrameworkUser/BatchEdit.cshtml b/IoTGateway/Areas/_Admin/Views/FrameworkUser/BatchEdit.cshtml index ad2c5a7..08995af 100644 --- a/IoTGateway/Areas/_Admin/Views/FrameworkUser/BatchEdit.cshtml +++ b/IoTGateway/Areas/_Admin/Views/FrameworkUser/BatchEdit.cshtml @@ -4,9 +4,14 @@
@Localizer["Sys.BatchEditConfirm"]
- - - + + + + + + + + diff --git a/IoTGateway/Areas/_Admin/Views/FrameworkUser/Create.cshtml b/IoTGateway/Areas/_Admin/Views/FrameworkUser/Create.cshtml index 4997b72..2a5d139 100644 --- a/IoTGateway/Areas/_Admin/Views/FrameworkUser/Create.cshtml +++ b/IoTGateway/Areas/_Admin/Views/FrameworkUser/Create.cshtml @@ -26,7 +26,7 @@ - + diff --git a/IoTGateway/Areas/_Admin/Views/FrameworkUser/Details.cshtml b/IoTGateway/Areas/_Admin/Views/FrameworkUser/Details.cshtml index 4cf2939..3255b9c 100644 --- a/IoTGateway/Areas/_Admin/Views/FrameworkUser/Details.cshtml +++ b/IoTGateway/Areas/_Admin/Views/FrameworkUser/Details.cshtml @@ -2,7 +2,7 @@ - + diff --git a/IoTGateway/Areas/_Admin/Views/FrameworkUser/Edit.cshtml b/IoTGateway/Areas/_Admin/Views/FrameworkUser/Edit.cshtml index 07efbf7..2b52ada 100644 --- a/IoTGateway/Areas/_Admin/Views/FrameworkUser/Edit.cshtml +++ b/IoTGateway/Areas/_Admin/Views/FrameworkUser/Edit.cshtml @@ -26,7 +26,7 @@ - + diff --git a/IoTGateway/IoTGateway.csproj b/IoTGateway/IoTGateway.csproj index 38b8428..c14d9b7 100644 --- a/IoTGateway/IoTGateway.csproj +++ b/IoTGateway/IoTGateway.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 true InProcess zh-Hans,en @@ -9,32 +9,24 @@ true Linux - - 109f0b79-49c8-4cb6-9aa4-44ab3b35b753 - - - - + - +
- - -
diff --git a/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml b/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml index 38104a1..20ed980 100644 --- a/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml +++ b/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml @@ -14,6 +14,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem net5.0 + win-x64 68abbdf2-1485-4756-9a94-6afa874d69a3 false diff --git a/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml.user b/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml.user index b2c70af..95754c8 100644 --- a/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -5,6 +5,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_PublishTargetUrl>E:\workbench\iotgateway\IoTGateway\bin\Release\net5.0\publish\ - True|2022-01-16T14:02:51.6829056Z;True|2022-01-16T13:59:48.3664224+08:00;True|2021-12-24T19:18:19.0736393+08:00;True|2021-12-24T16:46:49.1192015+08:00;True|2021-12-24T16:23:28.9214784+08:00;True|2021-12-24T15:20:08.6401847+08:00;True|2021-12-17T19:11:07.1655146+08:00;True|2021-12-12T14:11:08.8380502+08:00; + True|2021-12-24T11:18:19.0736393Z;True|2021-12-24T16:46:49.1192015+08:00;True|2021-12-24T16:23:28.9214784+08:00;True|2021-12-24T15:20:08.6401847+08:00;True|2021-12-17T19:11:07.1655146+08:00;True|2021-12-12T14:11:08.8380502+08:00; \ No newline at end of file diff --git a/IoTGateway/Startup.cs b/IoTGateway/Startup.cs index af19d44..b529133 100644 --- a/IoTGateway/Startup.cs +++ b/IoTGateway/Startup.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -36,7 +35,7 @@ namespace IoTGateway public void ConfigureServices(IServiceCollection services) { services.AddDistributedMemoryCache(); - services.AddWtmSession(36000, ConfigRoot); + services.AddWtmSession(360000, ConfigRoot); services.AddWtmCrossDomain(ConfigRoot); services.AddWtmAuthentication(ConfigRoot); services.AddWtmHttpClient(ConfigRoot); @@ -47,20 +46,18 @@ namespace IoTGateway { options.UseWtmMvcOptions(); }) - .AddJsonOptions(options => - { + .AddJsonOptions(options => { options.UseWtmJsonOptions(); }) - .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) + .ConfigureApiBehaviorOptions(options => { options.UseWtmApiOptions(); }) .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix) .AddWtmDataAnnotationsLocalization(typeof(Program)); - - services.AddWtmContext(ConfigRoot, (options) => - { + + services.AddWtmContext(ConfigRoot, (options)=> { options.DataPrivileges = DataPrivilegeSettings(); options.CsSelector = CSSelector; options.FileSubDirSelector = SubDirSelector; @@ -69,9 +66,9 @@ namespace IoTGateway //MQTTServer services.AddHostedMqttServer(mqttServer => - { - mqttServer.WithoutDefaultEndpoint(); - }) + { + mqttServer.WithoutDefaultEndpoint(); + }) .AddMqttConnectionHandler() .AddConnections(); @@ -81,6 +78,7 @@ namespace IoTGateway services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -108,7 +106,6 @@ namespace IoTGateway }) }; - app.UseExceptionHandler(configs.CurrentValue.ErrorHandler); app.UseStaticFiles(pvd); app.UseWtmStaticFiles(); @@ -138,6 +135,8 @@ namespace IoTGateway }); app.UseWtmContext(); + + } /// diff --git a/IoTGateway/Views/Login/Login.cshtml b/IoTGateway/Views/Login/Login.cshtml index d3501e4..0bc0062 100644 --- a/IoTGateway/Views/Login/Login.cshtml +++ b/IoTGateway/Views/Login/Login.cshtml @@ -46,12 +46,12 @@
  • - -
  • + + @*@Model.Localizer["Login.InputUserName"]*@
  • - -
  • + + @*@Model.Localizer["Login.InputPassword"]*@
  • diff --git a/IoTGateway/appsettings.json b/IoTGateway/appsettings.json index c10185a..f0dbb3f 100644 --- a/IoTGateway/appsettings.json +++ b/IoTGateway/appsettings.json @@ -83,19 +83,19 @@ "JwtOptions": { "Issuer": "http://localhost", "Audience": "http://localhost", - "Expires": 36000, + "Expires": 360000, "SecurityKey": "superSecretKey@345", - "RefreshTokenExpires": 864000, + "RefreshTokenExpires": 8640000, "LoginPath": "/_Framework/Redirect401" }, "CookieOptions": { "Issuer": "http://localhost", "Audience": "http://localhost", "Domain": "", - "Expires": 36000, + "Expires": 360000, "SlidingExpiration": true, "SecurityKey": "superSecretKey@345", - "RefreshTokenExpires": 864000, + "RefreshTokenExpires": 8640000, "LoginPath": "/Login/Login" }, "Domains": { diff --git a/IoTGateway/iotgateway.db b/IoTGateway/iotgateway.db index 11bc6a2..132bff3 100644 Binary files a/IoTGateway/iotgateway.db and b/IoTGateway/iotgateway.db differ diff --git a/IoTGateway/wwwroot/favicon.ico b/IoTGateway/wwwroot/favicon.ico index 0c3ef18..b33a3f7 100644 Binary files a/IoTGateway/wwwroot/favicon.ico and b/IoTGateway/wwwroot/favicon.ico differ diff --git a/IoTGateway/wwwroot/images/10.png b/IoTGateway/wwwroot/images/10.png new file mode 100644 index 0000000..01328c9 Binary files /dev/null and b/IoTGateway/wwwroot/images/10.png differ diff --git a/IoTGateway/wwwroot/layui/lay/modules/carousel.js b/IoTGateway/wwwroot/layui/lay/modules/carousel.js index 6f56bde..fe8ca8e 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/carousel.js +++ b/IoTGateway/wwwroot/layui/lay/modules/carousel.js @@ -1,314 +1,2 @@ -/** - - @Name:carousel 轮播模块 - @License:MIT - - */ - -layui.define('jquery', function(exports){ - "use strict"; - - var $ = layui.$ - ,hint = layui.hint() - ,device = layui.device() - - //外部接口 - ,carousel = { - config: {} //全局配置项 - - //设置全局项 - ,set: function(options){ - var that = this; - that.config = $.extend({}, that.config, options); - return that; - } - - //事件 - ,on: function(events, callback){ - return layui.onevent.call(this, MOD_NAME, events, callback); - } - } - - //字符常量 - ,MOD_NAME = 'carousel', ELEM = '.layui-carousel', THIS = 'layui-this', SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled' - - ,ELEM_ITEM = '>*[carousel-item]>*', ELEM_LEFT = 'layui-carousel-left', ELEM_RIGHT = 'layui-carousel-right', ELEM_PREV = 'layui-carousel-prev', ELEM_NEXT = 'layui-carousel-next', ELEM_ARROW = 'layui-carousel-arrow', ELEM_IND = 'layui-carousel-ind' - - //构造器 - ,Class = function(options){ - var that = this; - that.config = $.extend({}, that.config, carousel.config, options); - that.render(); - }; - - //默认配置 - Class.prototype.config = { - width: '600px' - ,height: '280px' - ,full: false //是否全屏 - ,arrow: 'hover' //切换箭头默认显示状态:hover/always/none - ,indicator: 'inside' //指示器位置:inside/outside/none - ,autoplay: true //是否自动切换 - ,interval: 3000 //自动切换的时间间隔,不能低于800ms - ,anim: '' //动画类型:default/updown/fade - ,trigger: 'click' //指示器的触发方式:click/hover - ,index: 0 //初始开始的索引 - }; - - //轮播渲染 - Class.prototype.render = function(){ - var that = this - ,options = that.config; - - options.elem = $(options.elem); - if(!options.elem[0]) return; - that.elemItem = options.elem.find(ELEM_ITEM); - - if(options.index < 0) options.index = 0; - if(options.index >= that.elemItem.length) options.index = that.elemItem.length - 1; - if(options.interval < 800) options.interval = 800; - - //是否全屏模式 - if(options.full){ - options.elem.css({ - position: 'fixed' - ,width: '100%' - ,height: '100%' - ,zIndex: 9999 - }); - } else { - options.elem.css({ - width: options.width - ,height: options.height - }); - } - - options.elem.attr('lay-anim', options.anim); - - //初始焦点状态 - that.elemItem.eq(options.index).addClass(THIS); - - //指示器等动作 - if(that.elemItem.length <= 1) return; - that.indicator(); - that.arrow(); - that.autoplay(); - that.events(); - }; - - //重置轮播 - Class.prototype.reload = function(options){ - var that = this; - clearInterval(that.timer); - that.config = $.extend({}, that.config, options); - that.render(); - }; - - //获取上一个等待条目的索引 - Class.prototype.prevIndex = function(){ - var that = this - ,options = that.config; - - var prevIndex = options.index - 1; - if(prevIndex < 0){ - prevIndex = that.elemItem.length - 1; - } - return prevIndex; - }; - - //获取下一个等待条目的索引 - Class.prototype.nextIndex = function(){ - var that = this - ,options = that.config; - - var nextIndex = options.index + 1; - if(nextIndex >= that.elemItem.length){ - nextIndex = 0; - } - return nextIndex; - }; - - //索引递增 - Class.prototype.addIndex = function(num){ - var that = this - ,options = that.config; - - num = num || 1; - options.index = options.index + num; - - //index不能超过轮播总数量 - if(options.index >= that.elemItem.length){ - options.index = 0; - } - }; - - //索引递减 - Class.prototype.subIndex = function(num){ - var that = this - ,options = that.config; - - num = num || 1; - options.index = options.index - num; - - //index不能超过轮播总数量 - if(options.index < 0){ - options.index = that.elemItem.length - 1; - } - }; - - //自动轮播 - Class.prototype.autoplay = function(){ - var that = this - ,options = that.config; - - if(!options.autoplay) return; - clearInterval(that.timer); - - that.timer = setInterval(function(){ - that.slide(); - }, options.interval); - }; - - //箭头 - Class.prototype.arrow = function(){ - var that = this - ,options = that.config; - - //模板 - var tplArrow = $([ - '' - ,'' - ].join('')); - - //预设基础属性 - options.elem.attr('lay-arrow', options.arrow); - - //避免重复插入 - if(options.elem.find('.'+ELEM_ARROW)[0]){ - options.elem.find('.'+ELEM_ARROW).remove(); - }; - options.elem.append(tplArrow); - - //事件 - tplArrow.on('click', function(){ - var othis = $(this) - ,type = othis.attr('lay-type') - that.slide(type); - }); - }; - - //指示器 - Class.prototype.indicator = function(){ - var that = this - ,options = that.config; - - //模板 - var tplInd = that.elemInd = $(['
      ' - ,function(){ - var li = []; - layui.each(that.elemItem, function(index){ - li.push(''); - }); - return li.join(''); - }() - ,'
    '].join('')); - - //预设基础属性 - options.elem.attr('lay-indicator', options.indicator); - - //避免重复插入 - if(options.elem.find('.'+ELEM_IND)[0]){ - options.elem.find('.'+ELEM_IND).remove(); - }; - options.elem.append(tplInd); - - if(options.anim === 'updown'){ - tplInd.css('margin-top', -(tplInd.height()/2)); - } - - //事件 - tplInd.find('li').on(options.trigger === 'hover' ? 'mouseover' : options.trigger, function(){ - var othis = $(this) - ,index = othis.index(); - if(index > options.index){ - that.slide('add', index - options.index); - } else if(index < options.index){ - that.slide('sub', options.index - index); - } - }); - }; - - //滑动切换 - Class.prototype.slide = function(type, num){ - var that = this - ,elemItem = that.elemItem - ,options = that.config - ,thisIndex = options.index - ,filter = options.elem.attr('lay-filter'); - - if(that.haveSlide) return; - - //滑动方向 - if(type === 'sub'){ - that.subIndex(num); - elemItem.eq(options.index).addClass(ELEM_PREV); - setTimeout(function(){ - elemItem.eq(thisIndex).addClass(ELEM_RIGHT); - elemItem.eq(options.index).addClass(ELEM_RIGHT); - }, 50); - } else { //默认递增滑 - that.addIndex(num); - elemItem.eq(options.index).addClass(ELEM_NEXT); - setTimeout(function(){ - elemItem.eq(thisIndex).addClass(ELEM_LEFT); - elemItem.eq(options.index).addClass(ELEM_LEFT); - }, 50); - }; - - //移除过度类 - setTimeout(function(){ - elemItem.removeClass(THIS + ' ' + ELEM_PREV + ' ' + ELEM_NEXT + ' ' + ELEM_LEFT + ' ' + ELEM_RIGHT); - elemItem.eq(options.index).addClass(THIS); - that.haveSlide = false; //解锁 - }, 300); - - //指示器焦点 - that.elemInd.find('li').eq(options.index).addClass(THIS) - .siblings().removeClass(THIS); - - that.haveSlide = true; - - layui.event.call(this, MOD_NAME, 'change('+ filter +')', { - index: options.index - ,prevIndex: thisIndex - ,item: elemItem.eq(options.index) - }); - }; - - //事件处理 - Class.prototype.events = function(){ - var that = this - ,options = that.config; - - if(options.elem.data('haveEvents')) return; - - //移入移出容器 - options.elem.on('mouseenter', function(){ - clearInterval(that.timer); - }).on('mouseleave', function(){ - that.autoplay(); - }); - - options.elem.data('haveEvents', true); - }; - - //核心入口 - carousel.render = function(options){ - var inst = new Class(options); - return inst; - }; - - exports(MOD_NAME, carousel); -}); - - +/** layui-v2.5.7 MIT License */ + ;layui.define("jquery",function(e){"use strict";var i=layui.$,n=(layui.hint(),layui.device(),{config:{},set:function(e){var n=this;return n.config=i.extend({},n.config,e),n},on:function(e,i){return layui.onevent.call(this,t,e,i)}}),t="carousel",a="layui-this",l=">*[carousel-item]>*",o="layui-carousel-left",r="layui-carousel-right",d="layui-carousel-prev",s="layui-carousel-next",u="layui-carousel-arrow",c="layui-carousel-ind",m=function(e){var t=this;t.config=i.extend({},t.config,n.config,e),t.render()};m.prototype.config={width:"600px",height:"280px",full:!1,arrow:"hover",indicator:"inside",autoplay:!0,interval:3e3,anim:"",trigger:"click",index:0},m.prototype.render=function(){var e=this,n=e.config;n.elem=i(n.elem),n.elem[0]&&(e.elemItem=n.elem.find(l),n.index<0&&(n.index=0),n.index>=e.elemItem.length&&(n.index=e.elemItem.length-1),n.interval<800&&(n.interval=800),n.full?n.elem.css({position:"fixed",width:"100%",height:"100%",zIndex:9999}):n.elem.css({width:n.width,height:n.height}),n.elem.attr("lay-anim",n.anim),e.elemItem.eq(n.index).addClass(a),e.elemItem.length<=1||(e.indicator(),e.arrow(),e.autoplay(),e.events()))},m.prototype.reload=function(e){var n=this;clearInterval(n.timer),n.config=i.extend({},n.config,e),n.render()},m.prototype.prevIndex=function(){var e=this,i=e.config,n=i.index-1;return n<0&&(n=e.elemItem.length-1),n},m.prototype.nextIndex=function(){var e=this,i=e.config,n=i.index+1;return n>=e.elemItem.length&&(n=0),n},m.prototype.addIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index+e,n.index>=i.elemItem.length&&(n.index=0)},m.prototype.subIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index-e,n.index<0&&(n.index=i.elemItem.length-1)},m.prototype.autoplay=function(){var e=this,i=e.config;i.autoplay&&(clearInterval(e.timer),e.timer=setInterval(function(){e.slide()},i.interval))},m.prototype.arrow=function(){var e=this,n=e.config,t=i(['",'"].join(""));n.elem.attr("lay-arrow",n.arrow),n.elem.find("."+u)[0]&&n.elem.find("."+u).remove(),n.elem.append(t),t.on("click",function(){var n=i(this),t=n.attr("lay-type");e.slide(t)})},m.prototype.indicator=function(){var e=this,n=e.config,t=e.elemInd=i(['
      ',function(){var i=[];return layui.each(e.elemItem,function(e){i.push("")}),i.join("")}(),"
    "].join(""));n.elem.attr("lay-indicator",n.indicator),n.elem.find("."+c)[0]&&n.elem.find("."+c).remove(),n.elem.append(t),"updown"===n.anim&&t.css("margin-top",-(t.height()/2)),t.find("li").on("hover"===n.trigger?"mouseover":n.trigger,function(){var t=i(this),a=t.index();a>n.index?e.slide("add",a-n.index):a/g, '>').replace(/'/g, ''').replace(/"/g, '"') - } - - othis.html('
    1. ' + html.replace(/[\r\t\n]+/g, '
    2. ') + '
    ') - - if(!othis.find('>.layui-code-h3')[0]){ - othis.prepend('

    '+ (othis.attr('lay-title')||options.title||'</>') + ''+ (othis.attr('lay-lang')||options.lang||'') +'' + '

    '); - } - - var ol = othis.find('>.layui-code-ol'); - othis.addClass('layui-box layui-code-view'); - - //识别皮肤 - if(othis.attr('lay-skin') || options.skin){ - othis.addClass('layui-code-' +(othis.attr('lay-skin') || options.skin)); - } - - //按行数适配左边距 - if((ol.find('li').length/100|0) > 0){ - ol.css('margin-left', (ol.find('li').length/100|0) + 'px'); - } - - //设置最大高度 - if(othis.attr('lay-height') || options.height){ - ol.css('max-height', othis.attr('lay-height') || options.height); - } - - }); - - }); -}).addcss('modules/code.css?v=1', 'skincodecss'); - +/** layui-v2.5.7 MIT License */ + ;layui.define("jquery",function(e){"use strict";var a=layui.$,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
    1. '+o.replace(/[\r\t\n]+/g,"
    2. ")+"
    "),c.find(">.layui-code-h3")[0]||c.prepend('

    '+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

    ");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/colorpicker.js b/IoTGateway/wwwroot/layui/lay/modules/colorpicker.js index 7e22fa3..8b62c4a 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/colorpicker.js +++ b/IoTGateway/wwwroot/layui/lay/modules/colorpicker.js @@ -1,720 +1,2 @@ -/** - - @Title: colorpicker 颜色选择器组件 - @License:MIT - - */ - -layui.define('jquery', function(exports){ - "use strict"; - - var $ = layui.jquery - - //外部接口 - ,colorpicker = { - config: {} - ,index: layui.colorpicker ? (layui.colorpicker.index + 10000) : 0 - - //设置全局项 - ,set: function(options){ - var that = this; - that.config = $.extend({}, that.config, options); - return that; - } - - //事件 - ,on: function(events, callback){ - return layui.onevent.call(this, 'colorpicker', events, callback); - } - } - - //操作当前实例 - ,thisColorPicker = function(){ - var that = this - ,options = that.config; - - return { - config: options - } - } - - //字符常量 - ,MOD_NAME = 'colorpicker', SHOW = 'layui-show', THIS = 'layui-this', ELEM = 'layui-colorpicker' - - ,ELEM_MAIN = '.layui-colorpicker-main', ICON_PICKER_DOWN = 'layui-icon-down', ICON_PICKER_CLOSE = 'layui-icon-close' - ,PICKER_TRIG_SPAN = 'layui-colorpicker-trigger-span', PICKER_TRIG_I = 'layui-colorpicker-trigger-i', PICKER_SIDE = 'layui-colorpicker-side', PICKER_SIDE_SLIDER = 'layui-colorpicker-side-slider' - ,PICKER_BASIS = 'layui-colorpicker-basis', PICKER_ALPHA_BG = 'layui-colorpicker-alpha-bgcolor', PICKER_ALPHA_SLIDER = 'layui-colorpicker-alpha-slider', PICKER_BASIS_CUR = 'layui-colorpicker-basis-cursor', PICKER_INPUT = 'layui-colorpicker-main-input' - - //RGB转HSB - ,RGBToHSB = function(rgb){ - var hsb = {h:0, s:0, b:0}; - var min = Math.min(rgb.r, rgb.g, rgb.b); - var max = Math.max(rgb.r, rgb.g, rgb.b); - var delta = max - min; - hsb.b = max; - hsb.s = max != 0 ? 255*delta/max : 0; - if(hsb.s != 0){ - if(rgb.r == max){ - hsb.h = (rgb.g - rgb.b) / delta; - }else if(rgb.g == max){ - hsb.h = 2 + (rgb.b - rgb.r) / delta; - }else{ - hsb.h = 4 + (rgb.r - rgb.g) / delta; - } - }else{ - hsb.h = -1; - }; - if(max == min){ - hsb.h = 0; - }; - hsb.h *= 60; - if(hsb.h < 0) { - hsb.h += 360; - }; - hsb.s *= 100/255; - hsb.b *= 100/255; - return hsb; - } - - //HEX转HSB - ,HEXToHSB = function(hex){ - var hex = hex.indexOf('#') > -1 ? hex.substring(1) : hex; - if(hex.length == 3){ - var num = hex.split(""); - hex = num[0]+num[0]+num[1]+num[1]+num[2]+num[2] - }; - hex = parseInt(hex, 16); - var rgb = {r:hex >> 16, g:(hex & 0x00FF00) >> 8, b:(hex & 0x0000FF)}; - return RGBToHSB(rgb); - } - - //HSB转RGB - ,HSBToRGB = function(hsb){ - var rgb = {}; - var h = hsb.h; - var s = hsb.s*255/100; - var b = hsb.b*255/100; - if(s == 0){ - rgb.r = rgb.g = rgb.b = b; - }else{ - var t1 = b; - var t2 = (255 - s) * b /255; - var t3 = (t1 - t2) * (h % 60) /60; - if(h == 360) h = 0; - if(h < 60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3} - else if(h < 120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3} - else if(h < 180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3} - else if(h < 240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3} - else if(h < 300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3} - else if(h < 360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3} - else {rgb.r=0; rgb.g=0; rgb.b=0} - } - return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)}; - } - - //HSB转HEX - ,HSBToHEX = function(hsb){ - var rgb = HSBToRGB(hsb); - var hex = [ - rgb.r.toString(16) - ,rgb.g.toString(16) - ,rgb.b.toString(16) - ]; - $.each(hex, function(nr, val){ - if(val.length == 1){ - hex[nr] = '0' + val; - } - }); - return hex.join(''); - } - - //转化成所需rgb格式 - ,RGBSTo = function(rgbs){ - var regexp = /[0-9]{1,3}/g; - var re = rgbs.match(regexp) || []; - return {r:re[0], g:re[1], b:re[2]}; - } - - ,$win = $(window) - ,$doc = $(document) - - //构造器 - ,Class = function(options){ - var that = this; - that.index = ++colorpicker.index; - that.config = $.extend({}, that.config, colorpicker.config, options); - that.render(); - }; - - //默认配置 - Class.prototype.config = { - color: '' //默认颜色,默认没有 - ,size: null //选择器大小 - ,alpha: false //是否开启透明度 - ,format: 'hex' //颜色显示/输入格式,可选 rgb,hex - ,predefine: false //预定义颜色是否开启 - ,colors: [ //默认预定义颜色列表 - '#009688', '#5FB878', '#1E9FFF', '#FF5722', '#FFB800', '#01AAED', '#999', '#c00', '#ff8c00','#ffd700' - ,'#90ee90', '#00ced1', '#1e90ff', '#c71585', 'rgb(0, 186, 189)', 'rgb(255, 120, 0)', 'rgb(250, 212, 0)', '#393D49', 'rgba(0,0,0,.5)', 'rgba(255, 69, 0, 0.68)', 'rgba(144, 240, 144, 0.5)', 'rgba(31, 147, 255, 0.73)' - ] - }; - - //初始颜色选择框 - Class.prototype.render = function(){ - var that = this - ,options = that.config - - //颜色选择框对象 - ,elemColorBox = $(['
    ' - ,'' - ,'' - ,'' - ,'' - ,'' - ,'
    '].join('')) - - //初始化颜色选择框 - var othis = $(options.elem); - options.size && elemColorBox.addClass('layui-colorpicker-'+ options.size); //初始化颜色选择框尺寸 - - //插入颜色选择框 - othis.addClass('layui-inline').html( - that.elemColorBox = elemColorBox - ); - - //获取背景色值 - that.color = that.elemColorBox.find('.'+ PICKER_TRIG_SPAN)[0].style.background; - - //相关事件 - that.events(); - }; - - //渲染颜色选择器 - Class.prototype.renderPicker = function(){ - var that = this - ,options = that.config - ,elemColorBox = that.elemColorBox[0] - - //颜色选择器对象 - ,elemPicker = that.elemPicker = $(['
    ' - //颜色面板 - ,'
    ' - ,'
    ' - ,'
    ' - ,'
    ' - ,'
    ' - ,'
    ' - ,'
    ' - ,'
    ' - ,'
    ' - ,'
    ' - - //透明度条块 - ,'
    ' - ,'
    ' - ,'
    ' - ,'
    ' - ,'
    ' - - //预设颜色列表 - ,function(){ - if(options.predefine){ - var list = ['
    ']; - layui.each(options.colors, function(i, v){ - list.push(['
    ' - ,'
    ' - ,'
    '].join('')); - }); - list.push('
    '); - return list.join(''); - } else { - return ''; - } - }() - - //底部表单元素区域 - ,'
    ' - ,'
    ' - ,'' - ,'
    ' - ,'
    ' - ,'' - ,'' - ,'' - ,'
    '].join('')) - - ,elemColorBoxSpan = that.elemColorBox.find('.' + PICKER_TRIG_SPAN)[0]; - - //如果当前点击的颜色盒子已经存在选择器,则关闭 - if($(ELEM_MAIN)[0] && $(ELEM_MAIN).data('index') == that.index){ - that.removePicker(Class.thisElemInd); - } else { //插入颜色选择器 - that.removePicker(Class.thisElemInd); - $('body').append(elemPicker); - } - - Class.thisElemInd = that.index; //记录最新打开的选择器索引 - Class.thisColor = elemColorBox.style.background //记录最新打开的选择器颜色选中值 - - that.position(); - that.pickerEvents(); - }; - - //颜色选择器移除 - Class.prototype.removePicker = function(index){ - var that = this - ,options = that.config; - $('#layui-colorpicker'+ (index || that.index)).remove(); - return that; - }; - - //定位算法 - Class.prototype.position = function(){ - var that = this - ,options = that.config - ,elem = that.bindElem || that.elemColorBox[0] - ,elemPicker = that.elemPicker[0] - ,rect = elem.getBoundingClientRect() //绑定元素的坐标 - ,elemWidth = elemPicker.offsetWidth //控件的宽度 - ,elemHeight = elemPicker.offsetHeight //控件的高度 - - //滚动条高度 - ,scrollArea = function(type){ - type = type ? 'scrollLeft' : 'scrollTop'; - return document.body[type] | document.documentElement[type]; - } - ,winArea = function(type){ - return document.documentElement[type ? 'clientWidth' : 'clientHeight'] - }, margin = 5, left = rect.left, top = rect.bottom; - - left = left - (elemWidth - elem.offsetWidth)/2; - top = top + margin - - //如果右侧超出边界 - if(left + elemWidth + margin > winArea('width')){ - left = winArea('width') - elemWidth - margin; - } else if(left < margin){ //如果左侧超出边界 - left = margin; - } - - //如果底部超出边界 - if(top + elemHeight + margin > winArea()){ - top = rect.top > elemHeight //顶部是否有足够区域显示完全 - ? rect.top - elemHeight - : winArea() - elemHeight; - top = top - margin*2; - } - - if(options.position){ - elemPicker.style.position = options.position; - } - elemPicker.style.left = left + (options.position === 'fixed' ? 0 : scrollArea(1)) + 'px'; - elemPicker.style.top = top + (options.position === 'fixed' ? 0 : scrollArea()) + 'px'; - }; - - //颜色选择器赋值 - Class.prototype.val = function(){ - var that = this - ,options = that.config - - ,elemColorBox = that.elemColorBox.find('.' + PICKER_TRIG_SPAN) - ,elemPickerInput = that.elemPicker.find('.' + PICKER_INPUT) - ,e = elemColorBox[0] - ,bgcolor = e.style.backgroundColor; - - //判断是否有背景颜色 - if(bgcolor){ - - //转化成hsb格式 - var hsb = RGBToHSB(RGBSTo(bgcolor)) - ,type = elemColorBox.attr('lay-type'); - - //同步滑块的位置及颜色选择器的选择 - that.select(hsb.h, hsb.s, hsb.b); - - //如果格式要求为rgb - if(type === 'torgb'){ - elemPickerInput.find('input').val(bgcolor); - }; - - //如果格式要求为rgba - if(type === 'rgba'){ - var rgb = RGBSTo(bgcolor); - - //如果开启透明度而没有设置,则给默认值 - if((bgcolor.match(/[0-9]{1,3}/g) || []).length == 3){ - elemPickerInput.find('input').val('rgba('+ rgb.r +', '+ rgb.g +', '+ rgb.b +', 1)'); - that.elemPicker.find('.'+ PICKER_ALPHA_SLIDER).css("left", 280); - } else { - elemPickerInput.find('input').val(bgcolor); - var left = bgcolor.slice(bgcolor.lastIndexOf(",") + 1, bgcolor.length - 1) * 280; - that.elemPicker.find('.'+ PICKER_ALPHA_SLIDER).css("left", left); - }; - - //设置span背景色 - that.elemPicker.find('.'+ PICKER_ALPHA_BG)[0].style.background = 'linear-gradient(to right, rgba('+ rgb.r +', '+ rgb.g +', '+ rgb.b +', 0), rgb('+ rgb.r +', '+ rgb.g +', '+ rgb.b +'))'; - }; - - }else{ - //如果没有背景颜色则默认到最初始的状态 - that.select(0,100,100); - elemPickerInput.find('input').val(""); - that.elemPicker.find('.'+ PICKER_ALPHA_BG)[0].style.background = ''; - that.elemPicker.find('.'+ PICKER_ALPHA_SLIDER).css("left", 280); - } - }; - - //颜色选择器滑动 / 点击 - Class.prototype.side = function(){ - var that = this - ,options = that.config - - ,span = that.elemColorBox.find('.' + PICKER_TRIG_SPAN) - ,type = span.attr('lay-type') - - ,side = that.elemPicker.find('.' + PICKER_SIDE) - ,slider = that.elemPicker.find('.' + PICKER_SIDE_SLIDER) - ,basis = that.elemPicker.find('.' + PICKER_BASIS) - ,choose = that.elemPicker.find('.' + PICKER_BASIS_CUR) - ,alphacolor = that.elemPicker.find('.' + PICKER_ALPHA_BG) - ,alphaslider = that.elemPicker.find('.' + PICKER_ALPHA_SLIDER) - - ,_h = slider[0].offsetTop/180*360 - ,_b = 100 - (choose[0].offsetTop + 3)/180*100 - ,_s = (choose[0].offsetLeft + 3)/260*100 - ,_a = Math.round(alphaslider[0].offsetLeft/280*100)/100 - - ,i = that.elemColorBox.find('.' + PICKER_TRIG_I) - ,pre = that.elemPicker.find('.layui-colorpicker-pre').children('div') - - ,change = function(x,y,z,a){ - that.select(x, y, z); - var rgb = HSBToRGB({h:x, s:y, b:z}); - i.addClass(ICON_PICKER_DOWN).removeClass(ICON_PICKER_CLOSE); - span[0].style.background = 'rgb('+ rgb.r +', '+ rgb.g +', '+ rgb.b +')'; - - if(type === 'torgb'){ - that.elemPicker.find('.' + PICKER_INPUT).find('input').val('rgb('+ rgb.r +', '+ rgb.g +', '+ rgb.b +')'); - }; - - if(type === 'rgba'){ - var left = 0; - left = a * 280; - alphaslider.css("left", left); - that.elemPicker.find('.' + PICKER_INPUT).find('input').val('rgba('+ rgb.r +', '+ rgb.g +', '+ rgb.b +', '+ a +')'); - span[0].style.background = 'rgba('+ rgb.r +', '+ rgb.g +', '+ rgb.b +', '+ a +')'; - alphacolor[0].style.background = 'linear-gradient(to right, rgba('+ rgb.r +', '+ rgb.g +', '+ rgb.b +', 0), rgb('+ rgb.r +', '+ rgb.g +', '+ rgb.b +'))' - }; - - //回调更改的颜色 - options.change && options.change(that.elemPicker.find('.' + PICKER_INPUT).find('input').val()); - } - - //拖拽元素 - ,elemMove = $(['
    maxh)top = maxh; - var h = top/180*360; - _h = h; - change(h, _s, _b, _a); - e.preventDefault(); - }; - - createMoveElem(move); - e.preventDefault(); - }); - - side.on('click', function(e){ - var top = e.clientY - $(this).offset().top; - if(top < 0)top = 0; - if(top > this.offsetHeight)top = this.offsetHeight; - var h = top/180*360; - _h = h; - change(h, _s, _b, _a); - e.preventDefault(); - }); - - //中间小圆点颜色选择 - choose.on('mousedown', function(e){ - var oldtop = this.offsetTop - ,oldleft = this.offsetLeft - ,oldy = e.clientY - ,oldx = e.clientX; - var move = function(e){ - var top = oldtop + (e.clientY - oldy) - ,left = oldleft + (e.clientX - oldx) - ,maxh = basis[0].offsetHeight - 3 - ,maxw = basis[0].offsetWidth - 3; - if(top < -3)top = -3; - if(top > maxh)top = maxh; - if(left < -3)left = -3; - if(left > maxw)left = maxw; - var s = (left + 3)/260*100 - ,b = 100 - (top + 3)/180*100; - _b = b; - _s = s; - change(_h, s, b, _a); - e.preventDefault(); - }; - layui.stope(e); - createMoveElem(move); - e.preventDefault(); - }); - - basis.on('mousedown', function(e){ - var top = e.clientY - $(this).offset().top - 3 + $win.scrollTop() - ,left = e.clientX - $(this).offset().left - 3 + $win.scrollLeft() - if(top < -3)top = -3; - if(top > this.offsetHeight - 3)top = this.offsetHeight - 3; - if(left < -3)left = -3; - if(left > this.offsetWidth - 3)left = this.offsetWidth - 3; - var s = (left + 3)/260*100 - ,b = 100 - (top + 3)/180*100; - _b = b; - _s = s; - change(_h, s, b, _a); - e.preventDefault(); - choose.trigger(e, 'mousedown'); - }); - - //底部透明度选择 - alphaslider.on('mousedown', function(e){ - var oldleft = this.offsetLeft - ,oldx = e.clientX; - var move = function(e){ - var left = oldleft + (e.clientX - oldx) - ,maxw = alphacolor[0].offsetWidth; - if(left < 0)left = 0; - if(left > maxw)left = maxw; - var a = Math.round(left /280*100) /100; - _a = a; - change(_h, _s, _b, a); - e.preventDefault(); - }; - - createMoveElem(move); - e.preventDefault(); - }); - alphacolor.on('click', function(e){ - var left = e.clientX - $(this).offset().left - if(left < 0)left = 0; - if(left > this.offsetWidth)left = this.offsetWidth; - var a = Math.round(left /280*100) /100; - _a = a; - change(_h, _s, _b, a); - e.preventDefault(); - }); - - //预定义颜色选择 - pre.each(function(){ - $(this).on('click', function(){ - $(this).parent('.layui-colorpicker-pre').addClass('selected').siblings().removeClass('selected'); - var color = this.style.backgroundColor - ,hsb = RGBToHSB(RGBSTo(color)) - ,a = color.slice(color.lastIndexOf(",") + 1, color.length - 1),left; - _h = hsb.h; - _s = hsb.s; - _b = hsb.b; - if((color.match(/[0-9]{1,3}/g) || []).length == 3) a = 1; - _a = a; - left = a * 280; - change(hsb.h, hsb.s, hsb.b, a); - }) - }); - }; - - //颜色选择器hsb转换 - Class.prototype.select = function(h, s, b, type){ - var that = this - ,options = that.config - ,hex = HSBToHEX({h:h, s:100, b:100}) - ,color = HSBToHEX({h:h, s:s, b:b}) - ,sidetop = h/360*180 - ,top = 180 - b/100*180 - 3 - ,left = s/100*260 - 3; - - that.elemPicker.find('.' + PICKER_SIDE_SLIDER).css("top", sidetop); //滑块的top - that.elemPicker.find('.' + PICKER_BASIS)[0].style.background = '#' + hex; //颜色选择器的背景 - - //选择器的top left - that.elemPicker.find('.' + PICKER_BASIS_CUR).css({ - "top": top - ,"left": left - }); - - if(type === 'change') return; - - //选中的颜色 - that.elemPicker.find('.' + PICKER_INPUT).find('input').val('#' + color); - }; - - Class.prototype.pickerEvents = function(){ - var that = this - ,options = that.config - - ,elemColorBoxSpan = that.elemColorBox.find('.' + PICKER_TRIG_SPAN) //颜色盒子 - ,elemPickerInput = that.elemPicker.find('.' + PICKER_INPUT + ' input') //颜色选择器表单 - - ,pickerEvents = { - //清空 - clear: function(othis){ - elemColorBoxSpan[0].style.background =''; - that.elemColorBox.find('.' + PICKER_TRIG_I).removeClass(ICON_PICKER_DOWN).addClass(ICON_PICKER_CLOSE); - that.color = ''; - - options.done && options.done(''); - that.removePicker(); - } - - //确认 - ,confirm: function(othis, change){ - var value = elemPickerInput.val() - ,colorValue = value - ,hsb = {}; - - if(value.indexOf(',') > -1){ - hsb = RGBToHSB(RGBSTo(value)); - that.select(hsb.h, hsb.s, hsb.b); - elemColorBoxSpan[0].style.background = (colorValue = '#' + HSBToHEX(hsb)); - - if((value.match(/[0-9]{1,3}/g) || []).length > 3 && elemColorBoxSpan.attr('lay-type') === 'rgba'){ - var left = value.slice(value.lastIndexOf(",") + 1, value.length - 1) * 280; - that.elemPicker.find('.' + PICKER_ALPHA_SLIDER).css("left", left); - elemColorBoxSpan[0].style.background = value; - colorValue = value; - }; - } else { - hsb = HEXToHSB(value); - elemColorBoxSpan[0].style.background = (colorValue = '#' + HSBToHEX(hsb)); - that.elemColorBox.find('.' + PICKER_TRIG_I).removeClass(ICON_PICKER_CLOSE).addClass(ICON_PICKER_DOWN); - }; - - if(change === 'change'){ - that.select(hsb.h, hsb.s, hsb.b, change); - options.change && options.change(colorValue); - return; - } - that.color = value; - - options.done && options.done(value); - that.removePicker(); - } - }; - - //选择器面板点击事件 - that.elemPicker.on('click', '*[colorpicker-events]', function(){ - var othis = $(this) - ,attrEvent = othis.attr('colorpicker-events'); - pickerEvents[attrEvent] && pickerEvents[attrEvent].call(this, othis); - }); - - //输入框事件 - elemPickerInput.on('keyup', function(e){ - var othis = $(this) - pickerEvents.confirm.call(this, othis, e.keyCode === 13 ? null : 'change'); - }); - } - - //颜色选择器输入 - Class.prototype.events = function(){ - var that = this - ,options = that.config - - ,elemColorBoxSpan = that.elemColorBox.find('.' + PICKER_TRIG_SPAN) - - //弹出颜色选择器 - that.elemColorBox.on('click' , function(){ - that.renderPicker(); - if($(ELEM_MAIN)[0]){ - that.val(); - that.side(); - }; - }); - - if(!options.elem[0] || that.elemColorBox[0].eventHandler) return; - - //绑定关闭控件事件 - $doc.on('click', function(e){ - //如果点击的元素是颜色框 - if($(e.target).hasClass(ELEM) - || $(e.target).parents('.'+ELEM)[0] - ) return; - - //如果点击的元素是选择器 - if($(e.target).hasClass(ELEM_MAIN.replace(/\./g, '')) - || $(e.target).parents(ELEM_MAIN)[0] - ) return; - - if(!that.elemPicker) return; - - if(that.color){ - var hsb = RGBToHSB(RGBSTo(that.color)); - that.select(hsb.h, hsb.s, hsb.b); - } else { - that.elemColorBox.find('.' + PICKER_TRIG_I).removeClass(ICON_PICKER_DOWN).addClass(ICON_PICKER_CLOSE); - } - elemColorBoxSpan[0].style.background = that.color || ''; - - that.removePicker(); - }); - - //自适应定位 - $win.on('resize', function(){ - if(!that.elemPicker || !$(ELEM_MAIN)[0]){ - return false; - } - that.position(); - }); - - that.elemColorBox[0].eventHandler = true; - }; - - //核心入口 - colorpicker.render = function(options){ - var inst = new Class(options); - return thisColorPicker.call(inst); - }; - - exports(MOD_NAME, colorpicker); -}); +/** layui-v2.5.7 MIT License */ + ;layui.define("jquery",function(e){"use strict";var i=layui.jquery,o={config:{},index:layui.colorpicker?layui.colorpicker.index+1e4:0,set:function(e){var o=this;return o.config=i.extend({},o.config,e),o},on:function(e,i){return layui.onevent.call(this,"colorpicker",e,i)}},r=function(){var e=this,i=e.config;return{config:i}},t="colorpicker",n="layui-show",l="layui-colorpicker",c=".layui-colorpicker-main",a="layui-icon-down",s="layui-icon-close",f="layui-colorpicker-trigger-span",d="layui-colorpicker-trigger-i",u="layui-colorpicker-side",p="layui-colorpicker-side-slider",g="layui-colorpicker-basis",v="layui-colorpicker-alpha-bgcolor",h="layui-colorpicker-alpha-slider",m="layui-colorpicker-basis-cursor",b="layui-colorpicker-main-input",k=function(e){var i={h:0,s:0,b:0},o=Math.min(e.r,e.g,e.b),r=Math.max(e.r,e.g,e.b),t=r-o;return i.b=r,i.s=0!=r?255*t/r:0,0!=i.s?e.r==r?i.h=(e.g-e.b)/t:e.g==r?i.h=2+(e.b-e.r)/t:i.h=4+(e.r-e.g)/t:i.h=-1,r==o&&(i.h=0),i.h*=60,i.h<0&&(i.h+=360),i.s*=100/255,i.b*=100/255,i},y=function(e){var e=e.indexOf("#")>-1?e.substring(1):e;if(3==e.length){var i=e.split("");e=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]}e=parseInt(e,16);var o={r:e>>16,g:(65280&e)>>8,b:255&e};return k(o)},x=function(e){var i={},o=e.h,r=255*e.s/100,t=255*e.b/100;if(0==r)i.r=i.g=i.b=t;else{var n=t,l=(255-r)*t/255,c=(n-l)*(o%60)/60;360==o&&(o=0),o<60?(i.r=n,i.b=l,i.g=l+c):o<120?(i.g=n,i.b=l,i.r=n-c):o<180?(i.g=n,i.r=l,i.b=l+c):o<240?(i.b=n,i.r=l,i.g=n-c):o<300?(i.b=n,i.g=l,i.r=l+c):o<360?(i.r=n,i.g=l,i.b=n-c):(i.r=0,i.g=0,i.b=0)}return{r:Math.round(i.r),g:Math.round(i.g),b:Math.round(i.b)}},C=function(e){var o=x(e),r=[o.r.toString(16),o.g.toString(16),o.b.toString(16)];return i.each(r,function(e,i){1==i.length&&(r[e]="0"+i)}),r.join("")},P=function(e){var i=/[0-9]{1,3}/g,o=e.match(i)||[];return{r:o[0],g:o[1],b:o[2]}},B=i(window),w=i(document),D=function(e){var r=this;r.index=++o.index,r.config=i.extend({},r.config,o.config,e),r.render()};D.prototype.config={color:"",size:null,alpha:!1,format:"hex",predefine:!1,colors:["#009688","#5FB878","#1E9FFF","#FF5722","#FFB800","#01AAED","#999","#c00","#ff8c00","#ffd700","#90ee90","#00ced1","#1e90ff","#c71585","rgb(0, 186, 189)","rgb(255, 120, 0)","rgb(250, 212, 0)","#393D49","rgba(0,0,0,.5)","rgba(255, 69, 0, 0.68)","rgba(144, 240, 144, 0.5)","rgba(31, 147, 255, 0.73)"]},D.prototype.render=function(){var e=this,o=e.config,r=i(['
    ',"",'3&&(o.alpha&&"rgb"==o.format||(e="#"+C(k(P(o.color))))),"background: "+e):e}()+'">','',"","","
    "].join("")),t=i(o.elem);o.size&&r.addClass("layui-colorpicker-"+o.size),t.addClass("layui-inline").html(e.elemColorBox=r),e.color=e.elemColorBox.find("."+f)[0].style.background,e.events()},D.prototype.renderPicker=function(){var e=this,o=e.config,r=e.elemColorBox[0],t=e.elemPicker=i(['
    ','
    ','
    ','
    ','
    ','
    ',"
    ",'
    ','
    ',"
    ","
    ",'
    ','
    ','
    ',"
    ","
    ",function(){if(o.predefine){var e=['
    '];return layui.each(o.colors,function(i,o){e.push(['
    ','
    ',"
    "].join(""))}),e.push("
    "),e.join("")}return""}(),'
    ','
    ','',"
    ",'
    ','','',"","
    "].join(""));e.elemColorBox.find("."+f)[0];i(c)[0]&&i(c).data("index")==e.index?e.removePicker(D.thisElemInd):(e.removePicker(D.thisElemInd),i("body").append(t)),D.thisElemInd=e.index,D.thisColor=r.style.background,e.position(),e.pickerEvents()},D.prototype.removePicker=function(e){var o=this;o.config;return i("#layui-colorpicker"+(e||o.index)).remove(),o},D.prototype.position=function(){var e=this,i=e.config,o=e.bindElem||e.elemColorBox[0],r=e.elemPicker[0],t=o.getBoundingClientRect(),n=r.offsetWidth,l=r.offsetHeight,c=function(e){return e=e?"scrollLeft":"scrollTop",document.body[e]|document.documentElement[e]},a=function(e){return document.documentElement[e?"clientWidth":"clientHeight"]},s=5,f=t.left,d=t.bottom;f-=(n-o.offsetWidth)/2,d+=s,f+n+s>a("width")?f=a("width")-n-s:fa()&&(d=t.top>l?t.top-l:a()-l,d-=2*s),i.position&&(r.style.position=i.position),r.style.left=f+("fixed"===i.position?0:c(1))+"px",r.style.top=d+("fixed"===i.position?0:c())+"px"},D.prototype.val=function(){var e=this,i=(e.config,e.elemColorBox.find("."+f)),o=e.elemPicker.find("."+b),r=i[0],t=r.style.backgroundColor;if(t){var n=k(P(t)),l=i.attr("lay-type");if(e.select(n.h,n.s,n.b),"torgb"===l&&o.find("input").val(t),"rgba"===l){var c=P(t);if(3==(t.match(/[0-9]{1,3}/g)||[]).length)o.find("input").val("rgba("+c.r+", "+c.g+", "+c.b+", 1)"),e.elemPicker.find("."+h).css("left",280);else{o.find("input").val(t);var a=280*t.slice(t.lastIndexOf(",")+1,t.length-1);e.elemPicker.find("."+h).css("left",a)}e.elemPicker.find("."+v)[0].style.background="linear-gradient(to right, rgba("+c.r+", "+c.g+", "+c.b+", 0), rgb("+c.r+", "+c.g+", "+c.b+"))"}}else e.select(0,100,100),o.find("input").val(""),e.elemPicker.find("."+v)[0].style.background="",e.elemPicker.find("."+h).css("left",280)},D.prototype.side=function(){var e=this,o=e.config,r=e.elemColorBox.find("."+f),t=r.attr("lay-type"),n=e.elemPicker.find("."+u),l=e.elemPicker.find("."+p),c=e.elemPicker.find("."+g),y=e.elemPicker.find("."+m),C=e.elemPicker.find("."+v),w=e.elemPicker.find("."+h),D=l[0].offsetTop/180*360,E=100-(y[0].offsetTop+3)/180*100,H=(y[0].offsetLeft+3)/260*100,W=Math.round(w[0].offsetLeft/280*100)/100,j=e.elemColorBox.find("."+d),F=e.elemPicker.find(".layui-colorpicker-pre").children("div"),L=function(i,n,l,c){e.select(i,n,l);var f=x({h:i,s:n,b:l});if(j.addClass(a).removeClass(s),r[0].style.background="rgb("+f.r+", "+f.g+", "+f.b+")","torgb"===t&&e.elemPicker.find("."+b).find("input").val("rgb("+f.r+", "+f.g+", "+f.b+")"),"rgba"===t){var d=0;d=280*c,w.css("left",d),e.elemPicker.find("."+b).find("input").val("rgba("+f.r+", "+f.g+", "+f.b+", "+c+")"),r[0].style.background="rgba("+f.r+", "+f.g+", "+f.b+", "+c+")",C[0].style.background="linear-gradient(to right, rgba("+f.r+", "+f.g+", "+f.b+", 0), rgb("+f.r+", "+f.g+", "+f.b+"))"}o.change&&o.change(e.elemPicker.find("."+b).find("input").val())},M=i(['
    t&&(r=t);var l=r/180*360;D=l,L(l,H,E,W),e.preventDefault()};Y(r),e.preventDefault()}),n.on("click",function(e){var o=e.clientY-i(this).offset().top;o<0&&(o=0),o>this.offsetHeight&&(o=this.offsetHeight);var r=o/180*360;D=r,L(r,H,E,W),e.preventDefault()}),y.on("mousedown",function(e){var i=this.offsetTop,o=this.offsetLeft,r=e.clientY,t=e.clientX,n=function(e){var n=i+(e.clientY-r),l=o+(e.clientX-t),a=c[0].offsetHeight-3,s=c[0].offsetWidth-3;n<-3&&(n=-3),n>a&&(n=a),l<-3&&(l=-3),l>s&&(l=s);var f=(l+3)/260*100,d=100-(n+3)/180*100;E=d,H=f,L(D,f,d,W),e.preventDefault()};layui.stope(e),Y(n),e.preventDefault()}),c.on("mousedown",function(e){var o=e.clientY-i(this).offset().top-3+B.scrollTop(),r=e.clientX-i(this).offset().left-3+B.scrollLeft();o<-3&&(o=-3),o>this.offsetHeight-3&&(o=this.offsetHeight-3),r<-3&&(r=-3),r>this.offsetWidth-3&&(r=this.offsetWidth-3);var t=(r+3)/260*100,n=100-(o+3)/180*100;E=n,H=t,L(D,t,n,W),e.preventDefault(),y.trigger(e,"mousedown")}),w.on("mousedown",function(e){var i=this.offsetLeft,o=e.clientX,r=function(e){var r=i+(e.clientX-o),t=C[0].offsetWidth;r<0&&(r=0),r>t&&(r=t);var n=Math.round(r/280*100)/100;W=n,L(D,H,E,n),e.preventDefault()};Y(r),e.preventDefault()}),C.on("click",function(e){var o=e.clientX-i(this).offset().left;o<0&&(o=0),o>this.offsetWidth&&(o=this.offsetWidth);var r=Math.round(o/280*100)/100;W=r,L(D,H,E,r),e.preventDefault()}),F.each(function(){i(this).on("click",function(){i(this).parent(".layui-colorpicker-pre").addClass("selected").siblings().removeClass("selected");var e,o=this.style.backgroundColor,r=k(P(o)),t=o.slice(o.lastIndexOf(",")+1,o.length-1);D=r.h,H=r.s,E=r.b,3==(o.match(/[0-9]{1,3}/g)||[]).length&&(t=1),W=t,e=280*t,L(r.h,r.s,r.b,t)})})},D.prototype.select=function(e,i,o,r){var t=this,n=(t.config,C({h:e,s:100,b:100})),l=C({h:e,s:i,b:o}),c=e/360*180,a=180-o/100*180-3,s=i/100*260-3;t.elemPicker.find("."+p).css("top",c),t.elemPicker.find("."+g)[0].style.background="#"+n,t.elemPicker.find("."+m).css({top:a,left:s}),"change"!==r&&t.elemPicker.find("."+b).find("input").val("#"+l)},D.prototype.pickerEvents=function(){var e=this,o=e.config,r=e.elemColorBox.find("."+f),t=e.elemPicker.find("."+b+" input"),n={clear:function(i){r[0].style.background="",e.elemColorBox.find("."+d).removeClass(a).addClass(s),e.color="",o.done&&o.done(""),e.removePicker()},confirm:function(i,n){var l=t.val(),c=l,f={};if(l.indexOf(",")>-1){if(f=k(P(l)),e.select(f.h,f.s,f.b),r[0].style.background=c="#"+C(f),(l.match(/[0-9]{1,3}/g)||[]).length>3&&"rgba"===r.attr("lay-type")){var u=280*l.slice(l.lastIndexOf(",")+1,l.length-1);e.elemPicker.find("."+h).css("left",u),r[0].style.background=l,c=l}}else f=y(l),r[0].style.background=c="#"+C(f),e.elemColorBox.find("."+d).removeClass(s).addClass(a);return"change"===n?(e.select(f.h,f.s,f.b,n),void(o.change&&o.change(c))):(e.color=l,o.done&&o.done(l),void e.removePicker())}};e.elemPicker.on("click","*[colorpicker-events]",function(){var e=i(this),o=e.attr("colorpicker-events");n[o]&&n[o].call(this,e)}),t.on("keyup",function(e){var o=i(this);n.confirm.call(this,o,13===e.keyCode?null:"change")})},D.prototype.events=function(){var e=this,o=e.config,r=e.elemColorBox.find("."+f);e.elemColorBox.on("click",function(){e.renderPicker(),i(c)[0]&&(e.val(),e.side())}),o.elem[0]&&!e.elemColorBox[0].eventHandler&&(w.on("click",function(o){if(!i(o.target).hasClass(l)&&!i(o.target).parents("."+l)[0]&&!i(o.target).hasClass(c.replace(/\./g,""))&&!i(o.target).parents(c)[0]&&e.elemPicker){if(e.color){var t=k(P(e.color));e.select(t.h,t.s,t.b)}else e.elemColorBox.find("."+d).removeClass(a).addClass(s);r[0].style.background=e.color||"",e.removePicker()}}),B.on("resize",function(){return!(!e.elemPicker||!i(c)[0])&&void e.position()}),e.elemColorBox[0].eventHandler=!0)},o.render=function(e){var i=new D(e);return r.call(i)},e(t,o)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/element.js b/IoTGateway/wwwroot/layui/lay/modules/element.js index 7453128..a24bb61 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/element.js +++ b/IoTGateway/wwwroot/layui/lay/modules/element.js @@ -1,471 +1,2 @@ -/** - - @Name:element 常用元素操作 - @License:MIT - - */ - -layui.define('jquery', function(exports){ - "use strict"; - - var $ = layui.$ - ,hint = layui.hint() - ,device = layui.device() - - ,MOD_NAME = 'element', THIS = 'layui-this', SHOW = 'layui-show' - - ,Element = function(){ - this.config = {}; - }; - - //全局设置 - Element.prototype.set = function(options){ - var that = this; - $.extend(true, that.config, options); - return that; - }; - - //表单事件 - Element.prototype.on = function(events, callback){ - return layui.onevent.call(this, MOD_NAME, events, callback); - }; - - //外部Tab新增 - Element.prototype.tabAdd = function(filter, options){ - var TITLE = '.layui-tab-title' - ,tabElem = $('.layui-tab[lay-filter='+ filter +']') - ,titElem = tabElem.children(TITLE) - ,barElem = titElem.children('.layui-tab-bar') - ,contElem = tabElem.children('.layui-tab-content') - ,li = '
  • '+ (options.title||'unnaming') +'
  • '; - - barElem[0] ? barElem.before(li) : titElem.append(li); - contElem.append('
    '+ (options.content||'') +'
    '); - call.hideTabMore(true); - call.tabAuto(); - return this; - }; - - //外部Tab删除 - Element.prototype.tabDelete = function(filter, layid){ - var TITLE = '.layui-tab-title' - ,tabElem = $('.layui-tab[lay-filter='+ filter +']') - ,titElem = tabElem.children(TITLE) - ,liElem = titElem.find('>li[lay-id="'+ layid +'"]'); - call.tabDelete(null, liElem); - return this; - }; - - //外部Tab切换 - Element.prototype.tabChange = function(filter, layid){ - var TITLE = '.layui-tab-title' - ,tabElem = $('.layui-tab[lay-filter='+ filter +']') - ,titElem = tabElem.children(TITLE) - ,liElem = titElem.find('>li[lay-id="'+ layid +'"]'); - call.tabClick.call(liElem[0], null, null, liElem); - return this; - }; - - //自定义Tab选项卡 - Element.prototype.tab = function(options){ - options = options || {}; - dom.on('click', options.headerElem, function(e){ - var index = $(this).index(); - call.tabClick.call(this, e, index, null, options); - }); - }; - - - //动态改变进度条 - Element.prototype.progress = function(filter, percent){ - var ELEM = 'layui-progress' - ,elem = $('.'+ ELEM +'[lay-filter='+ filter +']') - ,elemBar = elem.find('.'+ ELEM +'-bar') - ,text = elemBar.find('.'+ ELEM +'-text'); - elemBar.css('width', percent); - text.text(percent); - return this; - }; - - var NAV_ELEM = '.layui-nav', NAV_ITEM = 'layui-nav-item', NAV_BAR = 'layui-nav-bar' - ,NAV_TREE = 'layui-nav-tree', NAV_CHILD = 'layui-nav-child', NAV_MORE = 'layui-nav-more' - ,NAV_ANIM = 'layui-anim layui-anim-upbit' - - //基础事件体 - ,call = { - //Tab点击 - tabClick: function(e, index, liElem, options){ - options = options || {}; - var othis = liElem || $(this) - ,index = index || othis.parent().children('li').index(othis) - ,parents = options.headerElem ? othis.parent() : othis.parents('.layui-tab').eq(0) - ,item = options.bodyElem ? $(options.bodyElem) : parents.children('.layui-tab-content').children('.layui-tab-item') - ,elemA = othis.find('a') - ,filter = parents.attr('lay-filter'); - - if(!(elemA.attr('href') !== 'javascript:;' && elemA.attr('target') === '_blank')){ - othis.addClass(THIS).siblings().removeClass(THIS); - item.eq(index).addClass(SHOW).siblings().removeClass(SHOW); - } - - layui.event.call(this, MOD_NAME, 'tab('+ filter +')', { - elem: parents - ,index: index - }); - } - - //Tab删除 - ,tabDelete: function(e, othis){ - var li = othis || $(this).parent(), index = li.index() - ,parents = li.parents('.layui-tab').eq(0) - ,item = parents.children('.layui-tab-content').children('.layui-tab-item') - ,filter = parents.attr('lay-filter'); - - if(li.hasClass(THIS)){ - if(li.next()[0]){ - call.tabClick.call(li.next()[0], null, index + 1); - } else if(li.prev()[0]){ - call.tabClick.call(li.prev()[0], null, index - 1); - } - } - - li.remove(); - item.eq(index).remove(); - setTimeout(function(){ - call.tabAuto(); - }, 50); - - layui.event.call(this, MOD_NAME, 'tabDelete('+ filter +')', { - elem: parents - ,index: index - }); - } - - //Tab自适应 - ,tabAuto: function(){ - var SCROLL = 'layui-tab-scroll', MORE = 'layui-tab-more', BAR = 'layui-tab-bar' - ,CLOSE = 'layui-tab-close', that = this; - - $('.layui-tab').each(function(){ - var othis = $(this) - ,title = othis.children('.layui-tab-title') - ,item = othis.children('.layui-tab-content').children('.layui-tab-item') - ,STOPE = 'lay-stope="tabmore"' - ,span = $(''); - - if(that === window && device.ie != 8){ - call.hideTabMore(true) - } - - //允许关闭 - if(othis.attr('lay-allowClose')){ - title.find('li').each(function(){ - var li = $(this); - if(!li.find('.'+CLOSE)[0]){ - var close = $(''); - close.on('click', call.tabDelete); - li.append(close); - } - }); - } - - if(typeof othis.attr('lay-unauto') === 'string') return; - - //响应式 - if(title.prop('scrollWidth') > title.outerWidth()+1){ - if(title.find('.'+BAR)[0]) return; - title.append(span); - othis.attr('overflow', ''); - span.on('click', function(e){ - title[this.title ? 'removeClass' : 'addClass'](MORE); - this.title = this.title ? '' : '收缩'; - }); - } else { - title.find('.'+BAR).remove(); - othis.removeAttr('overflow'); - } - }); - } - //隐藏更多Tab - ,hideTabMore: function(e){ - var tsbTitle = $('.layui-tab-title'); - if(e === true || $(e.target).attr('lay-stope') !== 'tabmore'){ - tsbTitle.removeClass('layui-tab-more'); - tsbTitle.find('.layui-tab-bar').attr('title',''); - } - } - - //点击一级菜单 - /* - ,clickThis: function(){ - var othis = $(this), parents = othis.parents(NAV_ELEM) - ,filter = parents.attr('lay-filter') - ,elemA = othis.find('a') - ,unselect = typeof othis.attr('lay-unselect') === 'string'; - - if(othis.find('.'+NAV_CHILD)[0]) return; - - if(!(elemA.attr('href') !== 'javascript:;' && elemA.attr('target') === '_blank') && !unselect){ - parents.find('.'+THIS).removeClass(THIS); - othis.addClass(THIS); - } - - layui.event.call(this, MOD_NAME, 'nav('+ filter +')', othis); - } - ) - */ - - //点击菜单 - a标签触发 - ,clickThis: function(){ - var othis = $(this) - ,parents = othis.parents(NAV_ELEM) - ,filter = parents.attr('lay-filter') - ,parent = othis.parent() - ,child = othis.siblings('.'+NAV_CHILD) - ,unselect = typeof parent.attr('lay-unselect') === 'string'; - - if(!(othis.attr('href') !== 'javascript:;' && othis.attr('target') === '_blank') && !unselect){ - if(!child[0]){ - parents.find('.'+THIS).removeClass(THIS); - parent.addClass(THIS); - } - } - - //如果是垂直菜单 - if(parents.hasClass(NAV_TREE)){ - child.removeClass(NAV_ANIM); - - //如果有子菜单,则展开 - if(child[0]){ - parent[child.css('display') === 'none' ? 'addClass': 'removeClass'](NAV_ITEM+'ed'); - if(parents.attr('lay-shrink') === 'all'){ - parent.siblings().removeClass(NAV_ITEM + 'ed'); - } - } - } - - layui.event.call(this, MOD_NAME, 'nav('+ filter +')', othis); - } - - //点击子菜单选中 - /* - ,clickChild: function(){ - var othis = $(this), parents = othis.parents(NAV_ELEM) - ,filter = parents.attr('lay-filter'); - parents.find('.'+THIS).removeClass(THIS); - othis.addClass(THIS); - layui.event.call(this, MOD_NAME, 'nav('+ filter +')', othis); - } - */ - - //折叠面板 - ,collapse: function(){ - var othis = $(this), icon = othis.find('.layui-colla-icon') - ,elemCont = othis.siblings('.layui-colla-content') - ,parents = othis.parents('.layui-collapse').eq(0) - ,filter = parents.attr('lay-filter') - ,isNone = elemCont.css('display') === 'none'; - - //是否手风琴 - if(typeof parents.attr('lay-accordion') === 'string'){ - var show = parents.children('.layui-colla-item').children('.'+SHOW); - show.siblings('.layui-colla-title').children('.layui-colla-icon').html(''); - show.removeClass(SHOW); - } - - elemCont[isNone ? 'addClass' : 'removeClass'](SHOW); - icon.html(isNone ? '' : ''); - - layui.event.call(this, MOD_NAME, 'collapse('+ filter +')', { - title: othis - ,content: elemCont - ,show: isNone - }); - } - }; - - //初始化元素操作 - Element.prototype.init = function(type, filter){ - var that = this, elemFilter = function(){ - return filter ? ('[lay-filter="' + filter +'"]') : ''; - }(), items = { - - //Tab选项卡 - tab: function(){ - call.tabAuto.call({}); - } - - //导航菜单 - ,nav: function(){ - var TIME = 200, timer = {}, timerMore = {}, timeEnd = {}, follow = function(bar, nav, index){ - var othis = $(this), child = othis.find('.'+NAV_CHILD); - - if(nav.hasClass(NAV_TREE)){ - bar.css({ - top: othis.position().top - ,height: othis.children('a').outerHeight() - ,opacity: 1 - }); - } else { - child.addClass(NAV_ANIM); - bar.css({ - left: othis.position().left + parseFloat(othis.css('marginLeft')) - ,top: othis.position().top + othis.height() - bar.height() - }); - - timer[index] = setTimeout(function(){ - bar.css({ - width: othis.width() - ,opacity: 1 - }); - }, device.ie && device.ie < 10 ? 0 : TIME); - - clearTimeout(timeEnd[index]); - if(child.css('display') === 'block'){ - clearTimeout(timerMore[index]); - } - timerMore[index] = setTimeout(function(){ - child.addClass(SHOW) - othis.find('.'+NAV_MORE).addClass(NAV_MORE+'d'); - }, 300); - } - } - - $(NAV_ELEM + elemFilter).each(function(index){ - var othis = $(this) - ,bar = $('') - ,itemElem = othis.find('.'+NAV_ITEM); - - //Hover滑动效果 - if(!othis.find('.'+NAV_BAR)[0]){ - othis.append(bar); - itemElem.on('mouseenter', function(){ - follow.call(this, bar, othis, index); - }).on('mouseleave', function(){ - if(!othis.hasClass(NAV_TREE)){ - clearTimeout(timerMore[index]); - timerMore[index] = setTimeout(function(){ - othis.find('.'+NAV_CHILD).removeClass(SHOW); - othis.find('.'+NAV_MORE).removeClass(NAV_MORE+'d'); - }, 300); - } - }); - othis.on('mouseleave', function(){ - clearTimeout(timer[index]) - timeEnd[index] = setTimeout(function(){ - if(othis.hasClass(NAV_TREE)){ - bar.css({ - height: 0 - ,top: bar.position().top + bar.height()/2 - ,opacity: 0 - }); - } else { - bar.css({ - width: 0 - ,left: bar.position().left + bar.width()/2 - ,opacity: 0 - }); - } - }, TIME); - }); - } - - //展开子菜单 - itemElem.find('a').each(function(){ - var thisA = $(this) - ,parent = thisA.parent() - ,child = thisA.siblings('.'+NAV_CHILD); - - //输出小箭头 - if(child[0] && !thisA.children('.'+NAV_MORE)[0]){ - thisA.append(''); - } - - thisA.off('click', call.clickThis).on('click', call.clickThis); //点击菜单 - }); - }); - } - - //面包屑 - ,breadcrumb: function(){ - var ELEM = '.layui-breadcrumb'; - - $(ELEM + elemFilter).each(function(){ - var othis = $(this) - ,ATTE_SPR = 'lay-separator' - ,separator = othis.attr(ATTE_SPR) || '/' - ,aNode = othis.find('a'); - if(aNode.next('span['+ ATTE_SPR +']')[0]) return; - aNode.each(function(index){ - if(index === aNode.length - 1) return; - $(this).after(''+ separator +''); - }); - othis.css('visibility', 'visible'); - }); - } - - //进度条 - ,progress: function(){ - var ELEM = 'layui-progress'; - $('.' + ELEM + elemFilter).each(function(){ - var othis = $(this) - ,elemBar = othis.find('.layui-progress-bar') - ,percent = elemBar.attr('lay-percent'); - - elemBar.css('width', function(){ - return /^.+\/.+$/.test(percent) - ? (new Function('return '+ percent)() * 100) + '%' - : percent; - }()); - - if(othis.attr('lay-showPercent')){ - setTimeout(function(){ - elemBar.html(''+ percent +''); - },350); - } - }); - } - - //折叠面板 - ,collapse: function(){ - var ELEM = 'layui-collapse'; - - $('.' + ELEM + elemFilter).each(function(){ - var elemItem = $(this).find('.layui-colla-item') - elemItem.each(function(){ - var othis = $(this) - ,elemTitle = othis.find('.layui-colla-title') - ,elemCont = othis.find('.layui-colla-content') - ,isNone = elemCont.css('display') === 'none'; - - //初始状态 - elemTitle.find('.layui-colla-icon').remove(); - elemTitle.append(''+ (isNone ? '' : '') +''); - - //点击标题 - elemTitle.off('click', call.collapse).on('click', call.collapse); - }); - - }); - } - }; - - return items[type] ? items[type]() : layui.each(items, function(index, item){ - item(); - }); - }; - - Element.prototype.render = Element.prototype.init; - - var element = new Element(), dom = $(document); - element.render(); - - var TITLE = '.layui-tab-title li'; - dom.on('click', TITLE, call.tabClick); //Tab切换 - dom.on('click', call.hideTabMore); //隐藏展开的Tab - $(window).on('resize', call.tabAuto); //自适应 - - exports(MOD_NAME, element); -}); - +/** layui-v2.5.7 MIT License */ + ;layui.define("jquery",function(t){"use strict";var a=layui.$,i=(layui.hint(),layui.device()),e="element",l="layui-this",n="layui-show",s=function(){this.config={}};s.prototype.set=function(t){var i=this;return a.extend(!0,i.config,t),i},s.prototype.on=function(t,a){return layui.onevent.call(this,e,t,a)},s.prototype.tabAdd=function(t,i){var e=".layui-tab-title",l=a(".layui-tab[lay-filter="+t+"]"),n=l.children(e),s=n.children(".layui-tab-bar"),o=l.children(".layui-tab-content"),r='
  • "+(i.title||"unnaming")+"
  • ";return s[0]?s.before(r):n.append(r),o.append('
    '+(i.content||"")+"
    "),f.hideTabMore(!0),f.tabAuto(),this},s.prototype.tabDelete=function(t,i){var e=".layui-tab-title",l=a(".layui-tab[lay-filter="+t+"]"),n=l.children(e),s=n.find('>li[lay-id="'+i+'"]');return f.tabDelete(null,s),this},s.prototype.tabChange=function(t,i){var e=".layui-tab-title",l=a(".layui-tab[lay-filter="+t+"]"),n=l.children(e),s=n.find('>li[lay-id="'+i+'"]');return f.tabClick.call(s[0],null,null,s),this},s.prototype.tab=function(t){t=t||{},b.on("click",t.headerElem,function(i){var e=a(this).index();f.tabClick.call(this,i,e,null,t)})},s.prototype.progress=function(t,i){var e="layui-progress",l=a("."+e+"[lay-filter="+t+"]"),n=l.find("."+e+"-bar"),s=n.find("."+e+"-text");return n.css("width",i),s.text(i),this};var o=".layui-nav",r="layui-nav-item",c="layui-nav-bar",u="layui-nav-tree",d="layui-nav-child",y="layui-nav-more",h="layui-anim layui-anim-upbit",f={tabClick:function(t,i,s,o){o=o||{};var r=s||a(this),i=i||r.parent().children("li").index(r),c=o.headerElem?r.parent():r.parents(".layui-tab").eq(0),u=o.bodyElem?a(o.bodyElem):c.children(".layui-tab-content").children(".layui-tab-item"),d=r.find("a"),y=c.attr("lay-filter");"javascript:;"!==d.attr("href")&&"_blank"===d.attr("target")||(r.addClass(l).siblings().removeClass(l),u.eq(i).addClass(n).siblings().removeClass(n)),layui.event.call(this,e,"tab("+y+")",{elem:c,index:i})},tabDelete:function(t,i){var n=i||a(this).parent(),s=n.index(),o=n.parents(".layui-tab").eq(0),r=o.children(".layui-tab-content").children(".layui-tab-item"),c=o.attr("lay-filter");n.hasClass(l)&&(n.next()[0]?f.tabClick.call(n.next()[0],null,s+1):n.prev()[0]&&f.tabClick.call(n.prev()[0],null,s-1)),n.remove(),r.eq(s).remove(),setTimeout(function(){f.tabAuto()},50),layui.event.call(this,e,"tabDelete("+c+")",{elem:o,index:s})},tabAuto:function(){var t="layui-tab-more",e="layui-tab-bar",l="layui-tab-close",n=this;a(".layui-tab").each(function(){var s=a(this),o=s.children(".layui-tab-title"),r=(s.children(".layui-tab-content").children(".layui-tab-item"),'lay-stope="tabmore"'),c=a('');if(n===window&&8!=i.ie&&f.hideTabMore(!0),s.attr("lay-allowClose")&&o.find("li").each(function(){var t=a(this);if(!t.find("."+l)[0]){var i=a('');i.on("click",f.tabDelete),t.append(i)}}),"string"!=typeof s.attr("lay-unauto"))if(o.prop("scrollWidth")>o.outerWidth()+1){if(o.find("."+e)[0])return;o.append(c),s.attr("overflow",""),c.on("click",function(a){o[this.title?"removeClass":"addClass"](t),this.title=this.title?"":"收缩"})}else o.find("."+e).remove(),s.removeAttr("overflow")})},hideTabMore:function(t){var i=a(".layui-tab-title");t!==!0&&"tabmore"===a(t.target).attr("lay-stope")||(i.removeClass("layui-tab-more"),i.find(".layui-tab-bar").attr("title",""))},clickThis:function(){var t=a(this),i=t.parents(o),n=i.attr("lay-filter"),s=t.parent(),c=t.siblings("."+d),y="string"==typeof s.attr("lay-unselect");"javascript:;"!==t.attr("href")&&"_blank"===t.attr("target")||y||c[0]||(i.find("."+l).removeClass(l),s.addClass(l)),i.hasClass(u)&&(c.removeClass(h),c[0]&&(s["none"===c.css("display")?"addClass":"removeClass"](r+"ed"),"all"===i.attr("lay-shrink")&&s.siblings().removeClass(r+"ed"))),layui.event.call(this,e,"nav("+n+")",t)},collapse:function(){var t=a(this),i=t.find(".layui-colla-icon"),l=t.siblings(".layui-colla-content"),s=t.parents(".layui-collapse").eq(0),o=s.attr("lay-filter"),r="none"===l.css("display");if("string"==typeof s.attr("lay-accordion")){var c=s.children(".layui-colla-item").children("."+n);c.siblings(".layui-colla-title").children(".layui-colla-icon").html(""),c.removeClass(n)}l[r?"addClass":"removeClass"](n),i.html(r?"":""),layui.event.call(this,e,"collapse("+o+")",{title:t,content:l,show:r})}};s.prototype.init=function(t,e){var l=function(){return e?'[lay-filter="'+e+'"]':""}(),s={tab:function(){f.tabAuto.call({})},nav:function(){var t=200,e={},s={},p={},b=function(l,o,r){var c=a(this),f=c.find("."+d);o.hasClass(u)?l.css({top:c.position().top,height:c.children("a").outerHeight(),opacity:1}):(f.addClass(h),l.css({left:c.position().left+parseFloat(c.css("marginLeft")),top:c.position().top+c.height()-l.height()}),e[r]=setTimeout(function(){l.css({width:c.width(),opacity:1})},i.ie&&i.ie<10?0:t),clearTimeout(p[r]),"block"===f.css("display")&&clearTimeout(s[r]),s[r]=setTimeout(function(){f.addClass(n),c.find("."+y).addClass(y+"d")},300))};a(o+l).each(function(i){var l=a(this),o=a(''),h=l.find("."+r);l.find("."+c)[0]||(l.append(o),h.on("mouseenter",function(){b.call(this,o,l,i)}).on("mouseleave",function(){l.hasClass(u)||(clearTimeout(s[i]),s[i]=setTimeout(function(){l.find("."+d).removeClass(n),l.find("."+y).removeClass(y+"d")},300))}),l.on("mouseleave",function(){clearTimeout(e[i]),p[i]=setTimeout(function(){l.hasClass(u)?o.css({height:0,top:o.position().top+o.height()/2,opacity:0}):o.css({width:0,left:o.position().left+o.width()/2,opacity:0})},t)})),h.find("a").each(function(){var t=a(this),i=(t.parent(),t.siblings("."+d));i[0]&&!t.children("."+y)[0]&&t.append(''),t.off("click",f.clickThis).on("click",f.clickThis)})})},breadcrumb:function(){var t=".layui-breadcrumb";a(t+l).each(function(){var t=a(this),i="lay-separator",e=t.attr(i)||"/",l=t.find("a");l.next("span["+i+"]")[0]||(l.each(function(t){t!==l.length-1&&a(this).after(""+e+"")}),t.css("visibility","visible"))})},progress:function(){var t="layui-progress";a("."+t+l).each(function(){var i=a(this),e=i.find(".layui-progress-bar"),l=e.attr("lay-percent");e.css("width",function(){return/^.+\/.+$/.test(l)?100*new Function("return "+l)()+"%":l}()),i.attr("lay-showPercent")&&setTimeout(function(){e.html(''+l+"")},350)})},collapse:function(){var t="layui-collapse";a("."+t+l).each(function(){var t=a(this).find(".layui-colla-item");t.each(function(){var t=a(this),i=t.find(".layui-colla-title"),e=t.find(".layui-colla-content"),l="none"===e.css("display");i.find(".layui-colla-icon").remove(),i.append(''+(l?"":"")+""),i.off("click",f.collapse).on("click",f.collapse)})})}};return s[t]?s[t]():layui.each(s,function(t,a){a()})},s.prototype.render=s.prototype.init;var p=new s,b=a(document);p.render();var v=".layui-tab-title li";b.on("click",v,f.tabClick),b.on("click",f.hideTabMore),a(window).on("resize",f.tabAuto),t(e,p)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/flow.js b/IoTGateway/wwwroot/layui/lay/modules/flow.js index 9739f07..1106eaf 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/flow.js +++ b/IoTGateway/wwwroot/layui/lay/modules/flow.js @@ -1,176 +1,2 @@ -/** - - @Name flow 流加载组件 - @License:MIT - - */ - - -layui.define('jquery', function(exports){ - "use strict"; - - var $ = layui.$, Flow = function(options){} - ,ELEM_MORE = 'layui-flow-more' - ,ELEM_LOAD = ''; - - //主方法 - Flow.prototype.load = function(options){ - var that = this, page = 0, lock, isOver, lazyimg, timer; - options = options || {}; - - var elem = $(options.elem); if(!elem[0]) return; - var scrollElem = $(options.scrollElem || document); //滚动条所在元素 - var mb = options.mb || 50; //与底部的临界距离 - var isAuto = 'isAuto' in options ? options.isAuto : true; //是否自动滚动加载 - var end = options.end || '没有更多了'; //“末页”显示文案 - - //滚动条所在元素是否为document - var notDocment = options.scrollElem && options.scrollElem !== document; - - //加载更多 - var ELEM_TEXT = '加载更多' - ,more = $(''); - - if(!elem.find('.layui-flow-more')[0]){ - elem.append(more); - } - - //加载下一个元素 - var next = function(html, over){ - html = $(html); - more.before(html); - over = over == 0 ? true : null; - over ? more.html(end) : more.find('a').html(ELEM_TEXT); - isOver = over; - lock = null; - lazyimg && lazyimg(); - }; - - //触发请求 - var done = function(){ - lock = true; - more.find('a').html(ELEM_LOAD); - typeof options.done === 'function' && options.done(++page, next); - }; - - done(); - - //不自动滚动加载 - more.find('a').on('click', function(){ - var othis = $(this); - if(isOver) return; - lock || done(); - }); - - //如果允许图片懒加载 - if(options.isLazyimg){ - var lazyimg = that.lazyimg({ - elem: options.elem + ' img' - ,scrollElem: options.scrollElem - }); - } - - if(!isAuto) return that; - - scrollElem.on('scroll', function(){ - var othis = $(this), top = othis.scrollTop(); - - if(timer) clearTimeout(timer); - if(isOver || !elem.width()) return; //如果已经结束,或者元素处于隐藏状态,则不执行滚动加载 - - timer = setTimeout(function(){ - //计算滚动所在容器的可视高度 - var height = notDocment ? othis.height() : $(window).height(); - - //计算滚动所在容器的实际高度 - var scrollHeight = notDocment - ? othis.prop('scrollHeight') - : document.documentElement.scrollHeight; - - //临界点 - if(scrollHeight - top - height <= mb){ - lock || done(); - } - }, 100); - }); - - return that; - }; - - //图片懒加载 - Flow.prototype.lazyimg = function(options){ - var that = this, index = 0, haveScroll; - options = options || {}; - - var scrollElem = $(options.scrollElem || document); //滚动条所在元素 - var elem = options.elem || 'img'; - - //滚动条所在元素是否为document - var notDocment = options.scrollElem && options.scrollElem !== document; - - //显示图片 - var show = function(item, height){ - var start = scrollElem.scrollTop(), end = start + height; - var elemTop = notDocment ? function(){ - return item.offset().top - scrollElem.offset().top + start; - }() : item.offset().top; - - /* 始终只加载在当前屏范围内的图片 */ - if(elemTop >= start && elemTop <= end){ - if(!item.attr('src')){ - var src = item.attr('lay-src'); - layui.img(src, function(){ - var next = that.lazyimg.elem.eq(index); - item.attr('src', src).removeAttr('lay-src'); - - /* 当前图片加载就绪后,检测下一个图片是否在当前屏 */ - next[0] && render(next); - index++; - }); - } - } - }, render = function(othis, scroll){ - - //计算滚动所在容器的可视高度 - var height = notDocment ? (scroll||scrollElem).height() : $(window).height(); - var start = scrollElem.scrollTop(), end = start + height; - - that.lazyimg.elem = $(elem); - - if(othis){ - show(othis, height); - } else { - //计算未加载过的图片 - for(var i = 0; i < that.lazyimg.elem.length; i++){ - var item = that.lazyimg.elem.eq(i), elemTop = notDocment ? function(){ - return item.offset().top - scrollElem.offset().top + start; - }() : item.offset().top; - - show(item, height); - index = i; - - //如果图片的top坐标,超出了当前屏,则终止后续图片的遍历 - if(elemTop > end) break; - } - } - }; - - render(); - - if(!haveScroll){ - var timer; - scrollElem.on('scroll', function(){ - var othis = $(this); - if(timer) clearTimeout(timer) - timer = setTimeout(function(){ - render(null, othis); - }, 50); - }); - haveScroll = true; - } - return render; - }; - - //暴露接口 - exports('flow', new Flow()); -}); +/** layui-v2.5.7 MIT License */ + ;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),!i&&f.width()&&(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;su)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/form.js b/IoTGateway/wwwroot/layui/lay/modules/form.js index 33e82af..c88c8b5 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/form.js +++ b/IoTGateway/wwwroot/layui/lay/modules/form.js @@ -1,719 +1,2 @@ -/** - - @Name:form 表单组件 - @License:MIT - - */ - -layui.define('layer', function(exports){ - "use strict"; - - var $ = layui.$ - ,layer = layui.layer - ,hint = layui.hint() - ,device = layui.device() - - ,MOD_NAME = 'form', ELEM = '.layui-form', THIS = 'layui-this' - ,SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled' - - ,Form = function(){ - this.config = { - verify: { - required: [ - /[\S]+/ - ,'必填项不能为空' - ] - ,phone: [ - /^1\d{10}$/ - ,'请输入正确的手机号' - ] - ,email: [ - /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/ - ,'邮箱格式不正确' - ] - ,url: [ - /(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/ - ,'链接格式不正确' - ] - ,number: function(value){ - if(!value || isNaN(value)) return '只能填写数字' - } - ,date: [ - /^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/ - ,'日期格式不正确' - ] - ,identity: [ - /(^\d{15}$)|(^\d{17}(x|X|\d)$)/ - ,'请输入正确的身份证号' - ] - } - }; - }; - - //全局设置 - Form.prototype.set = function(options){ - var that = this; - $.extend(true, that.config, options); - return that; - }; - - //验证规则设定 - Form.prototype.verify = function(settings){ - var that = this; - $.extend(true, that.config.verify, settings); - return that; - }; - - //表单事件 - Form.prototype.on = function(events, callback){ - return layui.onevent.call(this, MOD_NAME, events, callback); - }; - - //赋值/取值 - Form.prototype.val = function(filter, object){ - var that = this - ,formElem = $(ELEM + '[lay-filter="' + filter +'"]'); - - //遍历 - formElem.each(function(index, item){ - var itemForm = $(this); - - //赋值 - layui.each(object, function(key, value){ - var itemElem = itemForm.find('[name="'+ key +'"]') - ,type; - - //如果对应的表单不存在,则不执行 - if(!itemElem[0]) return; - type = itemElem[0].type; - - //如果为复选框 - if(type === 'checkbox'){ - itemElem[0].checked = value; - } else if(type === 'radio') { //如果为单选框 - itemElem.each(function(){ - if(this.value == value ){ - this.checked = true - } - }); - } else { //其它类型的表单 - itemElem.val(value); - } - }); - }); - - form.render(null, filter); - - //返回值 - return that.getValue(filter); - }; - - //取值 - Form.prototype.getValue = function(filter, itemForm){ - itemForm = itemForm || $(ELEM + '[lay-filter="' + filter +'"]').eq(0); - - var nameIndex = {} //数组 name 索引 - ,field = {} - ,fieldElem = itemForm.find('input,select,textarea') //获取所有表单域 - - layui.each(fieldElem, function(_, item){ - item.name = (item.name || '').replace(/^\s*|\s*&/, ''); - - if(!item.name) return; - - //用于支持数组 name - if(/^.*\[\]$/.test(item.name)){ - var key = item.name.match(/^(.*)\[\]$/g)[0]; - nameIndex[key] = nameIndex[key] | 0; - item.name = item.name.replace(/^(.*)\[\]$/, '$1['+ (nameIndex[key]++) +']'); - } - - if(/^checkbox|radio$/.test(item.type) && !item.checked) return; - field[item.name] = item.value; - }); - - return field; - }; - - //表单控件渲染 - Form.prototype.render = function(type, filter){ - var that = this - ,elemForm = $(ELEM + function(){ - return filter ? ('[lay-filter="' + filter +'"]') : ''; - }()) - ,items = { - - //下拉选择框 - select: function(){ - var TIPS = '请选择', CLASS = 'layui-form-select', TITLE = 'layui-select-title' - ,NONE = 'layui-select-none', initValue = '', thatInput - ,selects = elemForm.find('select') - - //隐藏 select - ,hide = function(e, clear){ - if(!$(e.target).parent().hasClass(TITLE) || clear){ - $('.'+CLASS).removeClass(CLASS+'ed ' + CLASS+'up'); - thatInput && initValue && thatInput.val(initValue); - } - thatInput = null; - } - - //各种事件 - ,events = function(reElem, disabled, isSearch){ - var select = $(this) - ,title = reElem.find('.' + TITLE) - ,input = title.find('input') - ,dl = reElem.find('dl') - ,dds = dl.children('dd') - ,index = this.selectedIndex //当前选中的索引 - ,nearElem; //select 组件当前选中的附近元素,用于辅助快捷键功能 - - if(disabled) return; - - //展开下拉 - var showDown = function(){ - var top = reElem.offset().top + reElem.outerHeight() + 5 - $win.scrollTop() - ,dlHeight = dl.outerHeight(); - - index = select[0].selectedIndex; //获取最新的 selectedIndex - reElem.addClass(CLASS+'ed'); - dds.removeClass(HIDE); - nearElem = null; - - //初始选中样式 - dds.eq(index).addClass(THIS).siblings().removeClass(THIS); - - //上下定位识别 - if(top + dlHeight > $win.height() && top >= dlHeight){ - reElem.addClass(CLASS + 'up'); - } - - followScroll(); - } - - //隐藏下拉 - ,hideDown = function(choose){ - reElem.removeClass(CLASS+'ed ' + CLASS+'up'); - input.blur(); - nearElem = null; - - if(choose) return; - - notOption(input.val(), function(none){ - var selectedIndex = select[0].selectedIndex; - - //未查询到相关值 - if(none){ - initValue = $(select[0].options[selectedIndex]).html(); //重新获得初始选中值 - - //如果是第一项,且文本值等于 placeholder,则清空初始值 - if(selectedIndex === 0 && initValue === input.attr('placeholder')){ - initValue = ''; - }; - - //如果有选中值,则将输入框纠正为该值。否则清空输入框 - input.val(initValue || ''); - } - }); - } - - //定位下拉滚动条 - ,followScroll = function(){ - var thisDd = dl.children('dd.'+ THIS); - - if(!thisDd[0]) return; - - var posTop = thisDd.position().top - ,dlHeight = dl.height() - ,ddHeight = thisDd.height(); - - //若选中元素在滚动条不可见底部 - if(posTop > dlHeight){ - dl.scrollTop(posTop + dl.scrollTop() - dlHeight + ddHeight - 5); - } - - //若选择玄素在滚动条不可见顶部 - if(posTop < 0){ - dl.scrollTop(posTop + dl.scrollTop() - 5); - } - }; - - //点击标题区域 - title.on('click', function(e){ - reElem.hasClass(CLASS+'ed') ? ( - hideDown() - ) : ( - hide(e, true), - showDown() - ); - dl.find('.'+NONE).remove(); - }); - - //点击箭头获取焦点 - title.find('.layui-edge').on('click', function(){ - input.focus(); - }); - - //select 中 input 键盘事件 - input.on('keyup', function(e){ //键盘松开 - var keyCode = e.keyCode; - - //Tab键展开 - if(keyCode === 9){ - showDown(); - } - }).on('keydown', function(e){ //键盘按下 - var keyCode = e.keyCode; - - //Tab键隐藏 - if(keyCode === 9){ - hideDown(); - } - - //标注 dd 的选中状态 - var setThisDd = function(prevNext, thisElem1){ - var nearDd, cacheNearElem - e.preventDefault(); - - //得到当前队列元素 - var thisElem = function(){ - var thisDd = dl.children('dd.'+ THIS); - - //如果是搜索状态,且按 Down 键,且当前可视 dd 元素在选中元素之前, - //则将当前可视 dd 元素的上一个元素作为虚拟的当前选中元素,以保证递归不中断 - if(dl.children('dd.'+ HIDE)[0] && prevNext === 'next'){ - var showDd = dl.children('dd:not(.'+ HIDE +',.'+ DISABLED +')') - ,firstIndex = showDd.eq(0).index(); - if(firstIndex >=0 && firstIndex < thisDd.index() && !showDd.hasClass(THIS)){ - return showDd.eq(0).prev()[0] ? showDd.eq(0).prev() : dl.children(':last'); - } - } - - if(thisElem1 && thisElem1[0]){ - return thisElem1; - } - if(nearElem && nearElem[0]){ - return nearElem; - } - - return thisDd; - //return dds.eq(index); - }(); - - cacheNearElem = thisElem[prevNext](); //当前元素的附近元素 - nearDd = thisElem[prevNext]('dd:not(.'+ HIDE +')'); //当前可视元素的 dd 元素 - - //如果附近的元素不存在,则停止执行,并清空 nearElem - if(!cacheNearElem[0]) return nearElem = null; - - //记录附近的元素,让其成为下一个当前元素 - nearElem = thisElem[prevNext](); - - //如果附近不是 dd ,或者附近的 dd 元素是禁用状态,则进入递归查找 - if((!nearDd[0] || nearDd.hasClass(DISABLED)) && nearElem[0]){ - return setThisDd(prevNext, nearElem); - } - - nearDd.addClass(THIS).siblings().removeClass(THIS); //标注样式 - followScroll(); //定位滚动条 - }; - - if(keyCode === 38) setThisDd('prev'); //Up 键 - if(keyCode === 40) setThisDd('next'); //Down 键 - - //Enter 键 - if(keyCode === 13){ - e.preventDefault(); - dl.children('dd.'+THIS).trigger('click'); - } - }); - - //检测值是否不属于 select 项 - var notOption = function(value, callback, origin){ - var num = 0; - layui.each(dds, function(){ - var othis = $(this) - ,text = othis.text() - ,not = text.indexOf(value) === -1; - if(value === '' || (origin === 'blur') ? value !== text : not) num++; - origin === 'keyup' && othis[not ? 'addClass' : 'removeClass'](HIDE); - }); - var none = num === dds.length; - return callback(none), none; - }; - - //搜索匹配 - var search = function(e){ - var value = this.value, keyCode = e.keyCode; - - if(keyCode === 9 || keyCode === 13 - || keyCode === 37 || keyCode === 38 - || keyCode === 39 || keyCode === 40 - ){ - return false; - } - - notOption(value, function(none){ - if(none){ - dl.find('.'+NONE)[0] || dl.append('

    无匹配项

    '); - } else { - dl.find('.'+NONE).remove(); - } - }, 'keyup'); - - if(value === ''){ - dl.find('.'+NONE).remove(); - } - - followScroll(); //定位滚动条 - }; - - if(isSearch){ - input.on('keyup', search).on('blur', function(e){ - var selectedIndex = select[0].selectedIndex; - - thatInput = input; //当前的 select 中的 input 元素 - initValue = $(select[0].options[selectedIndex]).html(); //重新获得初始选中值 - - //如果是第一项,且文本值等于 placeholder,则清空初始值 - if(selectedIndex === 0 && initValue === input.attr('placeholder')){ - initValue = ''; - }; - - setTimeout(function(){ - notOption(input.val(), function(none){ - initValue || input.val(''); //none && !initValue - }, 'blur'); - }, 200); - }); - } - - //选择 - dds.on('click', function(){ - var othis = $(this), value = othis.attr('lay-value'); - var filter = select.attr('lay-filter'); //获取过滤器 - - if(othis.hasClass(DISABLED)) return false; - - if(othis.hasClass('layui-select-tips')){ - input.val(''); - } else { - input.val(othis.text()); - othis.addClass(THIS); - } - - othis.siblings().removeClass(THIS); - select.val(value).removeClass('layui-form-danger') - layui.event.call(this, MOD_NAME, 'select('+ filter +')', { - elem: select[0] - ,value: value - ,othis: reElem - }); - - hideDown(true); - return false; - }); - - reElem.find('dl>dt').on('click', function(e){ - return false; - }); - - $(document).off('click', hide).on('click', hide); //点击其它元素关闭 select - } - - selects.each(function(index, select){ - var othis = $(this) - ,hasRender = othis.next('.'+CLASS) - ,disabled = this.disabled - ,value = select.value - ,selected = $(select.options[select.selectedIndex]) //获取当前选中项 - ,optionsFirst = select.options[0]; - - if(typeof othis.attr('lay-ignore') === 'string') return othis.show(); - - var isSearch = typeof othis.attr('lay-search') === 'string' - ,placeholder = optionsFirst ? ( - optionsFirst.value ? TIPS : (optionsFirst.innerHTML || TIPS) - ) : TIPS; - - //替代元素 - var reElem = $(['
    ' - ,'
    ' - ,('') //禁用状态 - ,'
    ' - ,'
    ' - ,function(options){ - var arr = []; - layui.each(options, function(index, item){ - if(index === 0 && !item.value){ - arr.push('
    '+ (item.innerHTML || TIPS) +'
    '); - } else if(item.tagName.toLowerCase() === 'optgroup'){ - arr.push('
    '+ item.label +'
    '); - } else { - arr.push('
    '+ item.innerHTML +'
    '); - } - }); - arr.length === 0 && arr.push('
    没有选项
    '); - return arr.join(''); - }(othis.find('*')) +'
    ' - ,'
    '].join('')); - - hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender - othis.after(reElem); - events.call(this, reElem, disabled, isSearch); - }); - } - - //复选框/开关 - ,checkbox: function(){ - var CLASS = { - checkbox: ['layui-form-checkbox', 'layui-form-checked', 'checkbox'] - ,_switch: ['layui-form-switch', 'layui-form-onswitch', 'switch'] - } - ,checks = elemForm.find('input[type=checkbox]') - - ,events = function(reElem, RE_CLASS){ - var check = $(this); - - //勾选 - reElem.on('click', function(){ - var filter = check.attr('lay-filter') //获取过滤器 - ,text = (check.attr('lay-text')||'').split('|'); - - if(check[0].disabled) return; - - check[0].checked ? ( - check[0].checked = false - ,reElem.removeClass(RE_CLASS[1]).find('em').text(text[1]) - ) : ( - check[0].checked = true - ,reElem.addClass(RE_CLASS[1]).find('em').text(text[0]) - ); - - layui.event.call(check[0], MOD_NAME, RE_CLASS[2]+'('+ filter +')', { - elem: check[0] - ,value: check[0].value - ,othis: reElem - }); - }); - } - - checks.each(function(index, check){ - var othis = $(this), skin = othis.attr('lay-skin') - ,text = (othis.attr('lay-text') || '').split('|'), disabled = this.disabled; - if(skin === 'switch') skin = '_'+skin; - var RE_CLASS = CLASS[skin] || CLASS.checkbox; - - if(typeof othis.attr('lay-ignore') === 'string') return othis.show(); - - //替代元素 - var hasRender = othis.next('.' + RE_CLASS[0]) - ,reElem = $(['
    ' - ,function(){ //不同风格的内容 - var title = check.title.replace(/\s/g, '') - ,type = { - //复选框 - checkbox: [ - (title ? (''+ check.title +'') : '') - ,'' - ].join('') - - //开关 - ,_switch: ''+ ((check.checked ? text[0] : text[1]) || '') +'' - }; - return type[skin] || type['checkbox']; - }() - ,'
    '].join('')); - - hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender - othis.after(reElem); - events.call(this, reElem, RE_CLASS); - }); - } - - //单选框 - ,radio: function(){ - var CLASS = 'layui-form-radio', ICON = ['', ''] - ,radios = elemForm.find('input[type=radio]') - - ,events = function(reElem){ - var radio = $(this), ANIM = 'layui-anim-scaleSpring'; - - reElem.on('click', function(){ - var name = radio[0].name, forms = radio.parents(ELEM); - var filter = radio.attr('lay-filter'); //获取过滤器 - var sameRadio = forms.find('input[name='+ name.replace(/(\.|#|\[|\])/g, '\\$1') +']'); //找到相同name的兄弟 - - if(radio[0].disabled) return; - - layui.each(sameRadio, function(){ - var next = $(this).next('.'+CLASS); - this.checked = false; - next.removeClass(CLASS+'ed'); - next.find('.layui-icon').removeClass(ANIM).html(ICON[1]); - }); - - radio[0].checked = true; - reElem.addClass(CLASS+'ed'); - reElem.find('.layui-icon').addClass(ANIM).html(ICON[0]); - - layui.event.call(radio[0], MOD_NAME, 'radio('+ filter +')', { - elem: radio[0] - ,value: radio[0].value - ,othis: reElem - }); - }); - }; - - radios.each(function(index, radio){ - var othis = $(this), hasRender = othis.next('.' + CLASS), disabled = this.disabled; - - if(typeof othis.attr('lay-ignore') === 'string') return othis.show(); - hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender - - //替代元素 - var reElem = $(['
    ' //禁用状态 - ,''+ ICON[radio.checked ? 0 : 1] +'' - ,'
    '+ function(){ - var title = radio.title || ''; - if(typeof othis.next().attr('lay-radio') === 'string'){ - title = othis.next().html(); - othis.next().remove(); - } - return title - }() +'
    ' - ,'
    '].join('')); - - othis.after(reElem); - events.call(this, reElem); - }); - } - }; - type ? ( - items[type] ? items[type]() : hint.error('不支持的'+ type + '表单渲染') - ) : layui.each(items, function(index, item){ - item(); - }); - return that; - }; - - //表单提交校验 - var submit = function(){ - var stop = null //验证不通过状态 - ,verify = form.config.verify //验证规则 - ,DANGER = 'layui-form-danger' //警示样式 - ,field = {} //字段集合 - ,button = $(this) //当前触发的按钮 - ,elem = button.parents(ELEM) //当前所在表单域 - ,verifyElem = elem.find('*[lay-verify]') //获取需要校验的元素 - ,formElem = button.parents('form')[0] //获取当前所在的 form 元素,如果存在的话 - ,filter = button.attr('lay-filter'); //获取过滤器 - - - //开始校验 - layui.each(verifyElem, function(_, item){ - var othis = $(this) - ,vers = othis.attr('lay-verify').split('|') - ,verType = othis.attr('lay-verType') //提示方式 - ,value = othis.val(); - - othis.removeClass(DANGER); //移除警示样式 - - //遍历元素绑定的验证规则 - layui.each(vers, function(_, thisVer){ - var isTrue //是否命中校验 - ,errorText = '' //错误提示文本 - ,isFn = typeof verify[thisVer] === 'function'; - - //匹配验证规则 - if(verify[thisVer]){ - var isTrue = isFn ? errorText = verify[thisVer](value, item) : !verify[thisVer][0].test(value); - errorText = errorText || verify[thisVer][1]; - - if(thisVer === 'required'){ - errorText = othis.attr('lay-reqText') || errorText; - } - - //如果是必填项或者非空命中校验,则阻止提交,弹出提示 - if(isTrue){ - //提示层风格 - if(verType === 'tips'){ - layer.tips(errorText, function(){ - if(typeof othis.attr('lay-ignore') !== 'string'){ - if(item.tagName.toLowerCase() === 'select' || /^checkbox|radio$/.test(item.type)){ - return othis.next(); - } - } - return othis; - }(), {tips: 1}); - } else if(verType === 'alert') { - layer.alert(errorText, {title: '提示', shadeClose: true}); - } - //如果返回的为字符或数字,则自动弹出默认提示框;否则由 verify 方法中处理提示 - else if(/\bstring|number\b/.test(typeof errorText)){ - layer.msg(errorText, {icon: 5, shift: 6}); - } - - //非移动设备自动定位焦点 - if(!device.android && !device.ios){ - setTimeout(function(){ - item.focus(); - }, 7); - } - - othis.addClass(DANGER); - return stop = true; - } - } - }); - if(stop) return stop; - }); - - if(stop) return false; - - //获取当前表单值 - field = form.getValue(null, elem); - - //返回字段 - return layui.event.call(this, MOD_NAME, 'submit('+ filter +')', { - elem: this - ,form: formElem - ,field: field - }); - }; - - //自动完成渲染 - var form = new Form() - ,$dom = $(document), $win = $(window); - - form.render(); - - //表单reset重置渲染 - $dom.on('reset', ELEM, function(){ - var filter = $(this).attr('lay-filter'); - setTimeout(function(){ - form.render(null, filter); - }, 50); - }); - - //表单提交事件 - $dom.on('submit', ELEM, submit) - .on('click', '*[lay-submit]', submit); - - exports(MOD_NAME, form); -}); - - +/** layui-v2.5.7 MIT License */ + ;layui.define("layer",function(e){"use strict";var t=layui.$,i=layui.layer,a=layui.hint(),n=layui.device(),l="form",r=".layui-form",s="layui-this",o="layui-hide",c="layui-disabled",u=function(){this.config={verify:{required:[/[\S]+/,"必填项不能为空"],phone:[/^1\d{10}$/,"请输入正确的手机号"],email:[/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,"邮箱格式不正确"],url:[/(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/,"链接格式不正确"],number:function(e){if(!e||isNaN(e))return"只能填写数字"},date:[/^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/,"日期格式不正确"],identity:[/(^\d{15}$)|(^\d{17}(x|X|\d)$)/,"请输入正确的身份证号"]}}};u.prototype.set=function(e){var i=this;return t.extend(!0,i.config,e),i},u.prototype.verify=function(e){var i=this;return t.extend(!0,i.config.verify,e),i},u.prototype.on=function(e,t){return layui.onevent.call(this,l,e,t)},u.prototype.val=function(e,i){var a=this,n=t(r+'[lay-filter="'+e+'"]');return n.each(function(e,a){var n=t(this);layui.each(i,function(e,t){var i,a=n.find('[name="'+e+'"]');a[0]&&(i=a[0].type,"checkbox"===i?a[0].checked=t:"radio"===i?a.each(function(){this.value==t&&(this.checked=!0)}):a.val(t))})}),f.render(null,e),a.getValue(e)},u.prototype.getValue=function(e,i){i=i||t(r+'[lay-filter="'+e+'"]').eq(0);var a={},n={},l=i.find("input,select,textarea");return layui.each(l,function(e,t){if(t.name=(t.name||"").replace(/^\s*|\s*&/,""),t.name){if(/^.*\[\]$/.test(t.name)){var i=t.name.match(/^(.*)\[\]$/g)[0];a[i]=0|a[i],t.name=t.name.replace(/^(.*)\[\]$/,"$1["+a[i]++ +"]")}/^checkbox|radio$/.test(t.type)&&!t.checked||(n[t.name]=t.value)}}),n},u.prototype.render=function(e,i){var n=this,u=t(r+function(){return i?'[lay-filter="'+i+'"]':""}()),d={select:function(){var e,i="请选择",a="layui-form-select",n="layui-select-title",r="layui-select-none",d="",f=u.find("select"),v=function(i,l){t(i.target).parent().hasClass(n)&&!l||(t("."+a).removeClass(a+"ed "+a+"up"),e&&d&&e.val(d)),e=null},y=function(i,u,f){var y,p=t(this),m=i.find("."+n),g=m.find("input"),x=i.find("dl"),k=x.children("dd"),b=this.selectedIndex;if(!u){var C=function(){var e=i.offset().top+i.outerHeight()+5-h.scrollTop(),t=x.outerHeight();b=p[0].selectedIndex,i.addClass(a+"ed"),k.removeClass(o),y=null,k.eq(b).addClass(s).siblings().removeClass(s),e+t>h.height()&&e>=t&&i.addClass(a+"up"),T()},w=function(e){i.removeClass(a+"ed "+a+"up"),g.blur(),y=null,e||$(g.val(),function(e){var i=p[0].selectedIndex;e&&(d=t(p[0].options[i]).html(),0===i&&d===g.attr("placeholder")&&(d=""),g.val(d||""))})},T=function(){var e=x.children("dd."+s);if(e[0]){var t=e.position().top,i=x.height(),a=e.height();t>i&&x.scrollTop(t+x.scrollTop()-i+a-5),t<0&&x.scrollTop(t+x.scrollTop()-5)}};m.on("click",function(e){i.hasClass(a+"ed")?w():(v(e,!0),C()),x.find("."+r).remove()}),m.find(".layui-edge").on("click",function(){g.focus()}),g.on("keyup",function(e){var t=e.keyCode;9===t&&C()}).on("keydown",function(e){var t=e.keyCode;9===t&&w();var i=function(t,a){var n,l;e.preventDefault();var r=function(){var e=x.children("dd."+s);if(x.children("dd."+o)[0]&&"next"===t){var i=x.children("dd:not(."+o+",."+c+")"),n=i.eq(0).index();if(n>=0&&n无匹配项

    '):x.find("."+r).remove()},"keyup"),""===t&&x.find("."+r).remove(),void T())};f&&g.on("keyup",q).on("blur",function(i){var a=p[0].selectedIndex;e=g,d=t(p[0].options[a]).html(),0===a&&d===g.attr("placeholder")&&(d=""),setTimeout(function(){$(g.val(),function(e){d||g.val("")},"blur")},200)}),k.on("click",function(){var e=t(this),a=e.attr("lay-value"),n=p.attr("lay-filter");return!e.hasClass(c)&&(e.hasClass("layui-select-tips")?g.val(""):(g.val(e.text()),e.addClass(s)),e.siblings().removeClass(s),p.val(a).removeClass("layui-form-danger"),layui.event.call(this,l,"select("+n+")",{elem:p[0],value:a,othis:i}),w(!0),!1)}),i.find("dl>dt").on("click",function(e){return!1}),t(document).off("click",v).on("click",v)}};f.each(function(e,l){var r=t(this),o=r.next("."+a),u=this.disabled,d=l.value,f=t(l.options[l.selectedIndex]),v=l.options[0];if("string"==typeof r.attr("lay-ignore"))return r.show();var h="string"==typeof r.attr("lay-search"),p=v?v.value?i:v.innerHTML||i:i,m=void 0===f[0].attributes.icon||null===f[0].attributes.icon?"":'',g=t(['
    ','
    ',m,'','
    ','
    ',function(e){var t=[];return layui.each(e,function(e,a){if(0!==e||a.value)if("optgroup"===a.tagName.toLowerCase())t.push("
    "+a.label+"
    ");else{var n="undefined"==typeof a.getAttribute("icon")||null===typeof a.getAttribute("icon")?"":'';t.push('
    '+n+a.innerHTML+"
    ")}else t.push('
    '+(a.innerHTML||i)+"
    ")}),0===t.length&&t.push('
    没有选项
    '),t.join("")}(r.find("*"))+"
    ","
    "].join(""));o[0]&&o.remove(),r.after(g),y.call(this,g,u,h)})},checkbox:function(){var e={checkbox:["layui-form-checkbox","layui-form-checked","checkbox"],_switch:["layui-form-switch","layui-form-onswitch","switch"]},i=u.find("input[type=checkbox]"),a=function(e,i){var a=t(this);e.on("click",function(){var t=a.attr("lay-filter"),n=(a.attr("lay-text")||"").split("|");a[0].disabled||(a[0].checked?(a[0].checked=!1,e.removeClass(i[1]).find("em").text(n[1])):(a[0].checked=!0,e.addClass(i[1]).find("em").text(n[0])),layui.event.call(a[0],l,i[2]+"("+t+")",{elem:a[0],value:a[0].value,othis:e}))})};i.each(function(i,n){var l=t(this),r=l.attr("lay-skin"),s=(l.attr("lay-text")||"").split("|"),o=this.disabled;"switch"===r&&(r="_"+r);var u=e[r]||e.checkbox;if("string"==typeof l.attr("lay-ignore"))return l.show();var d=l.next("."+u[0]),f=t(['
    ",function(){var e=n.title.replace(/\s/g,""),t={checkbox:[e?""+n.title+"":"",''].join(""),_switch:""+((n.checked?s[0]:s[1])||"")+""};return t[r]||t.checkbox}(),"
    "].join(""));d[0]&&d.remove(),l.after(f),a.call(this,f,u)})},radio:function(){var e="layui-form-radio",i=["",""],a=u.find("input[type=radio]"),n=function(a){var n=t(this),s="layui-anim-scaleSpring";a.on("click",function(){var o=n[0].name,c=n.parents(r),u=n.attr("lay-filter"),d=c.find("input[name="+o.replace(/(\.|#|\[|\])/g,"\\$1")+"]");n[0].disabled||(layui.each(d,function(){var a=t(this).next("."+e);this.checked=!1,a.removeClass(e+"ed"),a.find(".layui-icon").removeClass(s).html(i[1])}),n[0].checked=!0,a.addClass(e+"ed"),a.find(".layui-icon").addClass(s).html(i[0]),layui.event.call(n[0],l,"radio("+u+")",{elem:n[0],value:n[0].value,othis:a}))})};a.each(function(a,l){var r=t(this),s=r.next("."+e),o=this.disabled;if("string"==typeof r.attr("lay-ignore"))return r.show();s[0]&&s.remove();var u=t(['
    ',''+i[l.checked?0:1]+"","
    "+function(){var e=l.title||"";return"string"==typeof r.next().attr("lay-radio")&&(e=r.next().html(),r.next().remove()),e}()+"
    ","
    "].join(""));r.after(u),n.call(this,u)})}};return e?d[e]?d[e]():a.error("不支持的"+e+"表单渲染"):layui.each(d,function(e,t){t()}),n};var d=function(){var e=null,a=f.config.verify,s="layui-form-danger",o={},c=t(this),u=c.parents(r),d=u.find("*[lay-verify]"),v=c.parents("form")[0],h=c.attr("lay-filter");return layui.each(d,function(l,r){var o=t(this),c=o.attr("lay-verify").split("|"),u=o.attr("lay-verType"),d=o.val();if(o.removeClass(s),layui.each(c,function(t,l){var c,f="",v="function"==typeof a[l];if(a[l]){var c=v?f=a[l](d,r):!a[l][0].test(d);if(f=f||a[l][1],"required"===l&&(f=o.attr("lay-reqText")||f),c)return"tips"===u?i.tips(f,function(){return"string"==typeof o.attr("lay-ignore")||"select"!==r.tagName.toLowerCase()&&!/^checkbox|radio$/.test(r.type)?o:o.next()}(),{tips:1}):"alert"===u?i.alert(f,{title:"提示",shadeClose:!0}):/\bstring|number\b/.test(typeof f)&&i.msg(f,{icon:5,shift:6}),n.android||n.ios||setTimeout(function(){r.focus()},7),o.addClass(s),e=!0}}),e)return e}),!e&&(o=f.getValue(null,u),layui.event.call(this,l,"submit("+h+")",{elem:this,form:v,field:o}))},f=new u,v=t(document),h=t(window);f.render(),v.on("reset",r,function(){var e=t(this).attr("lay-filter");setTimeout(function(){f.render(null,e)},50)}),v.on("submit",r,d).on("click","*[lay-submit]",d),e(l,f)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/jquery.js b/IoTGateway/wwwroot/layui/lay/modules/jquery.js index bc82158..3c68308 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/jquery.js +++ b/IoTGateway/wwwroot/layui/lay/modules/jquery.js @@ -1,10981 +1,5 @@ -/*! - * jQuery JavaScript Library v1.12.4 - * http://jquery.com/ - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license - * http://jquery.org/license - * - * Date: 2016-05-20T17:17Z - */ - -(function( global, factory ) { - - if ( typeof module === "object" && typeof module.exports === "object" ) { - // For CommonJS and CommonJS-like environments where a proper `window` - // is present, execute the factory and get jQuery. - // For environments that do not have a `window` with a `document` - // (such as Node.js), expose a factory as module.exports. - // This accentuates the need for the creation of a real `window`. - // e.g. var jQuery = require("jquery")(window); - // See ticket #14549 for more info. - module.exports = global.document ? - factory( global, true ) : - function( w ) { - if ( !w.document ) { - throw new Error( "jQuery requires a window with a document" ); - } - return factory( w ); - }; - } else { - factory( global ); - } - -// Pass this if window is not defined yet -}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { - -// Support: Firefox 18+ -// Can't be in strict mode, several libs including ASP.NET trace -// the stack via arguments.caller.callee and Firefox dies if -// you try to trace through "use strict" call chains. (#13335) -//"use strict"; -var deletedIds = []; - -var document = window.document; - -var slice = deletedIds.slice; - -var concat = deletedIds.concat; - -var push = deletedIds.push; - -var indexOf = deletedIds.indexOf; - -var class2type = {}; - -var toString = class2type.toString; - -var hasOwn = class2type.hasOwnProperty; - -var support = {}; - - - -var - version = "1.12.4", - - // Define a local copy of jQuery - jQuery = function( selector, context ) { - - // The jQuery object is actually just the init constructor 'enhanced' - // Need init if jQuery is called (just allow error to be thrown if not included) - return new jQuery.fn.init( selector, context ); - }, - - // Support: Android<4.1, IE<9 - // Make sure we trim BOM and NBSP - rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, - - // Matches dashed string for camelizing - rmsPrefix = /^-ms-/, - rdashAlpha = /-([\da-z])/gi, - - // Used by jQuery.camelCase as callback to replace() - fcamelCase = function( all, letter ) { - return letter.toUpperCase(); - }; - -jQuery.fn = jQuery.prototype = { - - // The current version of jQuery being used - jquery: version, - - constructor: jQuery, - - // Start with an empty selector - selector: "", - - // The default length of a jQuery object is 0 - length: 0, - - toArray: function() { - return slice.call( this ); - }, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - return num != null ? - - // Return just the one element from the set - ( num < 0 ? this[ num + this.length ] : this[ num ] ) : - - // Return all the elements in a clean array - slice.call( this ); - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems ) { - - // Build a new jQuery matched element set - var ret = jQuery.merge( this.constructor(), elems ); - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - ret.context = this.context; - - // Return the newly-formed element set - return ret; - }, - - // Execute a callback for every element in the matched set. - each: function( callback ) { - return jQuery.each( this, callback ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map( this, function( elem, i ) { - return callback.call( elem, i, elem ); - } ) ); - }, - - slice: function() { - return this.pushStack( slice.apply( this, arguments ) ); - }, - - first: function() { - return this.eq( 0 ); - }, - - last: function() { - return this.eq( -1 ); - }, - - eq: function( i ) { - var len = this.length, - j = +i + ( i < 0 ? len : 0 ); - return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); - }, - - end: function() { - return this.prevObject || this.constructor(); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: push, - sort: deletedIds.sort, - splice: deletedIds.splice -}; - -jQuery.extend = jQuery.fn.extend = function() { - var src, copyIsArray, copy, name, options, clone, - target = arguments[ 0 ] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - - // skip the boolean and the target - target = arguments[ i ] || {}; - i++; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { - target = {}; - } - - // extend jQuery itself if only one argument is passed - if ( i === length ) { - target = this; - i--; - } - - for ( ; i < length; i++ ) { - - // Only deal with non-null/undefined values - if ( ( options = arguments[ i ] ) != null ) { - - // Extend the base object - for ( name in options ) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if ( deep && copy && ( jQuery.isPlainObject( copy ) || - ( copyIsArray = jQuery.isArray( copy ) ) ) ) { - - if ( copyIsArray ) { - copyIsArray = false; - clone = src && jQuery.isArray( src ) ? src : []; - - } else { - clone = src && jQuery.isPlainObject( src ) ? src : {}; - } - - // Never move original objects, clone them - target[ name ] = jQuery.extend( deep, clone, copy ); - - // Don't bring in undefined values - } else if ( copy !== undefined ) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -jQuery.extend( { - - // Unique for each copy of jQuery on the page - expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), - - // Assume jQuery is ready without the ready module - isReady: true, - - error: function( msg ) { - throw new Error( msg ); - }, - - noop: function() {}, - - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). - isFunction: function( obj ) { - return jQuery.type( obj ) === "function"; - }, - - isArray: Array.isArray || function( obj ) { - return jQuery.type( obj ) === "array"; - }, - - isWindow: function( obj ) { - /* jshint eqeqeq: false */ - return obj != null && obj == obj.window; - }, - - isNumeric: function( obj ) { - - // parseFloat NaNs numeric-cast false positives (null|true|false|"") - // ...but misinterprets leading-number strings, particularly hex literals ("0x...") - // subtraction forces infinities to NaN - // adding 1 corrects loss of precision from parseFloat (#15100) - var realStringObj = obj && obj.toString(); - return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0; - }, - - isEmptyObject: function( obj ) { - var name; - for ( name in obj ) { - return false; - } - return true; - }, - - isPlainObject: function( obj ) { - var key; - - // Must be an Object. - // Because of IE, we also have to check the presence of the constructor property. - // Make sure that DOM nodes and window objects don't pass through, as well - if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { - return false; - } - - try { - - // Not own constructor property must be Object - if ( obj.constructor && - !hasOwn.call( obj, "constructor" ) && - !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { - return false; - } - } catch ( e ) { - - // IE8,9 Will throw exceptions on certain host objects #9897 - return false; - } - - // Support: IE<9 - // Handle iteration over inherited properties before own properties. - if ( !support.ownFirst ) { - for ( key in obj ) { - return hasOwn.call( obj, key ); - } - } - - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - for ( key in obj ) {} - - return key === undefined || hasOwn.call( obj, key ); - }, - - type: function( obj ) { - if ( obj == null ) { - return obj + ""; - } - return typeof obj === "object" || typeof obj === "function" ? - class2type[ toString.call( obj ) ] || "object" : - typeof obj; - }, - - // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context - globalEval: function( data ) { - if ( data && jQuery.trim( data ) ) { - - // We use execScript on Internet Explorer - // We use an anonymous function so that context is window - // rather than jQuery in Firefox - ( window.execScript || function( data ) { - window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation - } )( data ); - } - }, - - // Convert dashed to camelCase; used by the css and data modules - // Microsoft forgot to hump their vendor prefix (#9572) - camelCase: function( string ) { - return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); - }, - - each: function( obj, callback ) { - var length, i = 0; - - if ( isArrayLike( obj ) ) { - length = obj.length; - for ( ; i < length; i++ ) { - if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { - break; - } - } - } else { - for ( i in obj ) { - if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { - break; - } - } - } - - return obj; - }, - - // Support: Android<4.1, IE<9 - trim: function( text ) { - return text == null ? - "" : - ( text + "" ).replace( rtrim, "" ); - }, - - // results is for internal usage only - makeArray: function( arr, results ) { - var ret = results || []; - - if ( arr != null ) { - if ( isArrayLike( Object( arr ) ) ) { - jQuery.merge( ret, - typeof arr === "string" ? - [ arr ] : arr - ); - } else { - push.call( ret, arr ); - } - } - - return ret; - }, - - inArray: function( elem, arr, i ) { - var len; - - if ( arr ) { - if ( indexOf ) { - return indexOf.call( arr, elem, i ); - } - - len = arr.length; - i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; - - for ( ; i < len; i++ ) { - - // Skip accessing in sparse arrays - if ( i in arr && arr[ i ] === elem ) { - return i; - } - } - } - - return -1; - }, - - merge: function( first, second ) { - var len = +second.length, - j = 0, - i = first.length; - - while ( j < len ) { - first[ i++ ] = second[ j++ ]; - } - - // Support: IE<9 - // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists) - if ( len !== len ) { - while ( second[ j ] !== undefined ) { - first[ i++ ] = second[ j++ ]; - } - } - - first.length = i; - - return first; - }, - - grep: function( elems, callback, invert ) { - var callbackInverse, - matches = [], - i = 0, - length = elems.length, - callbackExpect = !invert; - - // Go through the array, only saving the items - // that pass the validator function - for ( ; i < length; i++ ) { - callbackInverse = !callback( elems[ i ], i ); - if ( callbackInverse !== callbackExpect ) { - matches.push( elems[ i ] ); - } - } - - return matches; - }, - - // arg is for internal usage only - map: function( elems, callback, arg ) { - var length, value, - i = 0, - ret = []; - - // Go through the array, translating each of the items to their new values - if ( isArrayLike( elems ) ) { - length = elems.length; - for ( ; i < length; i++ ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret.push( value ); - } - } - - // Go through every key on the object, - } else { - for ( i in elems ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret.push( value ); - } - } - } - - // Flatten any nested arrays - return concat.apply( [], ret ); - }, - - // A global GUID counter for objects - guid: 1, - - // Bind a function to a context, optionally partially applying any - // arguments. - proxy: function( fn, context ) { - var args, proxy, tmp; - - if ( typeof context === "string" ) { - tmp = fn[ context ]; - context = fn; - fn = tmp; - } - - // Quick check to determine if target is callable, in the spec - // this throws a TypeError, but we will just return undefined. - if ( !jQuery.isFunction( fn ) ) { - return undefined; - } - - // Simulated bind - args = slice.call( arguments, 2 ); - proxy = function() { - return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); - }; - - // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || jQuery.guid++; - - return proxy; - }, - - now: function() { - return +( new Date() ); - }, - - // jQuery.support is not used in Core but other projects attach their - // properties to it so it needs to exist. - support: support -} ); - -// JSHint would error on this code due to the Symbol not being defined in ES5. -// Defining this global in .jshintrc would create a danger of using the global -// unguarded in another place, it seems safer to just disable JSHint for these -// three lines. -/* jshint ignore: start */ -if ( typeof Symbol === "function" ) { - jQuery.fn[ Symbol.iterator ] = deletedIds[ Symbol.iterator ]; -} -/* jshint ignore: end */ - -// Populate the class2type map -jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), -function( i, name ) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); -} ); - -function isArrayLike( obj ) { - - // Support: iOS 8.2 (not reproducible in simulator) - // `in` check used to prevent JIT error (gh-2145) - // hasOwn isn't used here due to false negatives - // regarding Nodelist length in IE - var length = !!obj && "length" in obj && obj.length, - type = jQuery.type( obj ); - - if ( type === "function" || jQuery.isWindow( obj ) ) { - return false; - } - - return type === "array" || length === 0 || - typeof length === "number" && length > 0 && ( length - 1 ) in obj; -} -var Sizzle = -/*! - * Sizzle CSS Selector Engine v2.2.1 - * http://sizzlejs.com/ - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license - * http://jquery.org/license - * - * Date: 2015-10-17 - */ -(function( window ) { - -var i, - support, - Expr, - getText, - isXML, - tokenize, - compile, - select, - outermostContext, - sortInput, - hasDuplicate, - - // Local document vars - setDocument, - document, - docElem, - documentIsHTML, - rbuggyQSA, - rbuggyMatches, - matches, - contains, - - // Instance-specific data - expando = "sizzle" + 1 * new Date(), - preferredDoc = window.document, - dirruns = 0, - done = 0, - classCache = createCache(), - tokenCache = createCache(), - compilerCache = createCache(), - sortOrder = function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - } - return 0; - }, - - // General-purpose constants - MAX_NEGATIVE = 1 << 31, - - // Instance methods - hasOwn = ({}).hasOwnProperty, - arr = [], - pop = arr.pop, - push_native = arr.push, - push = arr.push, - slice = arr.slice, - // Use a stripped-down indexOf as it's faster than native - // http://jsperf.com/thor-indexof-vs-for/5 - indexOf = function( list, elem ) { - var i = 0, - len = list.length; - for ( ; i < len; i++ ) { - if ( list[i] === elem ) { - return i; - } - } - return -1; - }, - - booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", - - // Regular expressions - - // http://www.w3.org/TR/css3-selectors/#whitespace - whitespace = "[\\x20\\t\\r\\n\\f]", - - // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier - identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", - - // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors - attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + - // Operator (capture 2) - "*([*^$|!~]?=)" + whitespace + - // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" - "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + - "*\\]", - - pseudos = ":(" + identifier + ")(?:\\((" + - // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: - // 1. quoted (capture 3; capture 4 or capture 5) - "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + - // 2. simple (capture 6) - "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + - // 3. anything else (capture 2) - ".*" + - ")\\)|)", - - // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter - rwhitespace = new RegExp( whitespace + "+", "g" ), - rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), - - rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), - rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), - - rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), - - rpseudo = new RegExp( pseudos ), - ridentifier = new RegExp( "^" + identifier + "$" ), - - matchExpr = { - "ID": new RegExp( "^#(" + identifier + ")" ), - "CLASS": new RegExp( "^\\.(" + identifier + ")" ), - "TAG": new RegExp( "^(" + identifier + "|[*])" ), - "ATTR": new RegExp( "^" + attributes ), - "PSEUDO": new RegExp( "^" + pseudos ), - "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + - "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + - "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), - "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), - // For use in libraries implementing .is() - // We use this for POS matching in `select` - "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + - whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) - }, - - rinputs = /^(?:input|select|textarea|button)$/i, - rheader = /^h\d$/i, - - rnative = /^[^{]+\{\s*\[native \w/, - - // Easily-parseable/retrievable ID or TAG or CLASS selectors - rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, - - rsibling = /[+~]/, - rescape = /'|\\/g, - - // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters - runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), - funescape = function( _, escaped, escapedWhitespace ) { - var high = "0x" + escaped - 0x10000; - // NaN means non-codepoint - // Support: Firefox<24 - // Workaround erroneous numeric interpretation of +"0x" - return high !== high || escapedWhitespace ? - escaped : - high < 0 ? - // BMP codepoint - String.fromCharCode( high + 0x10000 ) : - // Supplemental Plane codepoint (surrogate pair) - String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); - }, - - // Used for iframes - // See setDocument() - // Removing the function wrapper causes a "Permission Denied" - // error in IE - unloadHandler = function() { - setDocument(); - }; - -// Optimize for push.apply( _, NodeList ) -try { - push.apply( - (arr = slice.call( preferredDoc.childNodes )), - preferredDoc.childNodes - ); - // Support: Android<4.0 - // Detect silently failing push.apply - arr[ preferredDoc.childNodes.length ].nodeType; -} catch ( e ) { - push = { apply: arr.length ? - - // Leverage slice if possible - function( target, els ) { - push_native.apply( target, slice.call(els) ); - } : - - // Support: IE<9 - // Otherwise append directly - function( target, els ) { - var j = target.length, - i = 0; - // Can't trust NodeList.length - while ( (target[j++] = els[i++]) ) {} - target.length = j - 1; - } - }; -} - -function Sizzle( selector, context, results, seed ) { - var m, i, elem, nid, nidselect, match, groups, newSelector, - newContext = context && context.ownerDocument, - - // nodeType defaults to 9, since context defaults to document - nodeType = context ? context.nodeType : 9; - - results = results || []; - - // Return early from calls with invalid selector or context - if ( typeof selector !== "string" || !selector || - nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { - - return results; - } - - // Try to shortcut find operations (as opposed to filters) in HTML documents - if ( !seed ) { - - if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { - setDocument( context ); - } - context = context || document; - - if ( documentIsHTML ) { - - // If the selector is sufficiently simple, try using a "get*By*" DOM method - // (excepting DocumentFragment context, where the methods don't exist) - if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { - - // ID selector - if ( (m = match[1]) ) { - - // Document context - if ( nodeType === 9 ) { - if ( (elem = context.getElementById( m )) ) { - - // Support: IE, Opera, Webkit - // TODO: identify versions - // getElementById can match elements by name instead of ID - if ( elem.id === m ) { - results.push( elem ); - return results; - } - } else { - return results; - } - - // Element context - } else { - - // Support: IE, Opera, Webkit - // TODO: identify versions - // getElementById can match elements by name instead of ID - if ( newContext && (elem = newContext.getElementById( m )) && - contains( context, elem ) && - elem.id === m ) { - - results.push( elem ); - return results; - } - } - - // Type selector - } else if ( match[2] ) { - push.apply( results, context.getElementsByTagName( selector ) ); - return results; - - // Class selector - } else if ( (m = match[3]) && support.getElementsByClassName && - context.getElementsByClassName ) { - - push.apply( results, context.getElementsByClassName( m ) ); - return results; - } - } - - // Take advantage of querySelectorAll - if ( support.qsa && - !compilerCache[ selector + " " ] && - (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { - - if ( nodeType !== 1 ) { - newContext = context; - newSelector = selector; - - // qSA looks outside Element context, which is not what we want - // Thanks to Andrew Dupont for this workaround technique - // Support: IE <=8 - // Exclude object elements - } else if ( context.nodeName.toLowerCase() !== "object" ) { - - // Capture the context ID, setting it first if necessary - if ( (nid = context.getAttribute( "id" )) ) { - nid = nid.replace( rescape, "\\$&" ); - } else { - context.setAttribute( "id", (nid = expando) ); - } - - // Prefix every selector in the list - groups = tokenize( selector ); - i = groups.length; - nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']"; - while ( i-- ) { - groups[i] = nidselect + " " + toSelector( groups[i] ); - } - newSelector = groups.join( "," ); - - // Expand context for sibling selectors - newContext = rsibling.test( selector ) && testContext( context.parentNode ) || - context; - } - - if ( newSelector ) { - try { - push.apply( results, - newContext.querySelectorAll( newSelector ) - ); - return results; - } catch ( qsaError ) { - } finally { - if ( nid === expando ) { - context.removeAttribute( "id" ); - } - } - } - } - } - } - - // All others - return select( selector.replace( rtrim, "$1" ), context, results, seed ); -} - -/** - * Create key-value caches of limited size - * @returns {function(string, object)} Returns the Object data after storing it on itself with - * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) - * deleting the oldest entry - */ -function createCache() { - var keys = []; - - function cache( key, value ) { - // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) - if ( keys.push( key + " " ) > Expr.cacheLength ) { - // Only keep the most recent entries - delete cache[ keys.shift() ]; - } - return (cache[ key + " " ] = value); - } - return cache; -} - -/** - * Mark a function for special use by Sizzle - * @param {Function} fn The function to mark - */ -function markFunction( fn ) { - fn[ expando ] = true; - return fn; -} - -/** - * Support testing using an element - * @param {Function} fn Passed the created div and expects a boolean result - */ -function assert( fn ) { - var div = document.createElement("div"); - - try { - return !!fn( div ); - } catch (e) { - return false; - } finally { - // Remove from its parent by default - if ( div.parentNode ) { - div.parentNode.removeChild( div ); - } - // release memory in IE - div = null; - } -} - -/** - * Adds the same handler for all of the specified attrs - * @param {String} attrs Pipe-separated list of attributes - * @param {Function} handler The method that will be applied - */ -function addHandle( attrs, handler ) { - var arr = attrs.split("|"), - i = arr.length; - - while ( i-- ) { - Expr.attrHandle[ arr[i] ] = handler; - } -} - -/** - * Checks document order of two siblings - * @param {Element} a - * @param {Element} b - * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b - */ -function siblingCheck( a, b ) { - var cur = b && a, - diff = cur && a.nodeType === 1 && b.nodeType === 1 && - ( ~b.sourceIndex || MAX_NEGATIVE ) - - ( ~a.sourceIndex || MAX_NEGATIVE ); - - // Use IE sourceIndex if available on both nodes - if ( diff ) { - return diff; - } - - // Check if b follows a - if ( cur ) { - while ( (cur = cur.nextSibling) ) { - if ( cur === b ) { - return -1; - } - } - } - - return a ? 1 : -1; -} - -/** - * Returns a function to use in pseudos for input types - * @param {String} type - */ -function createInputPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === type; - }; -} - -/** - * Returns a function to use in pseudos for buttons - * @param {String} type - */ -function createButtonPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && elem.type === type; - }; -} - -/** - * Returns a function to use in pseudos for positionals - * @param {Function} fn - */ -function createPositionalPseudo( fn ) { - return markFunction(function( argument ) { - argument = +argument; - return markFunction(function( seed, matches ) { - var j, - matchIndexes = fn( [], seed.length, argument ), - i = matchIndexes.length; - - // Match elements found at the specified indexes - while ( i-- ) { - if ( seed[ (j = matchIndexes[i]) ] ) { - seed[j] = !(matches[j] = seed[j]); - } - } - }); - }); -} - -/** - * Checks a node for validity as a Sizzle context - * @param {Element|Object=} context - * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value - */ -function testContext( context ) { - return context && typeof context.getElementsByTagName !== "undefined" && context; -} - -// Expose support vars for convenience -support = Sizzle.support = {}; - -/** - * Detects XML nodes - * @param {Element|Object} elem An element or a document - * @returns {Boolean} True iff elem is a non-HTML XML node - */ -isXML = Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = elem && (elem.ownerDocument || elem).documentElement; - return documentElement ? documentElement.nodeName !== "HTML" : false; -}; - -/** - * Sets document-related variables once based on the current document - * @param {Element|Object} [doc] An element or document object to use to set the document - * @returns {Object} Returns the current document - */ -setDocument = Sizzle.setDocument = function( node ) { - var hasCompare, parent, - doc = node ? node.ownerDocument || node : preferredDoc; - - // Return early if doc is invalid or already selected - if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { - return document; - } - - // Update global variables - document = doc; - docElem = document.documentElement; - documentIsHTML = !isXML( document ); - - // Support: IE 9-11, Edge - // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) - if ( (parent = document.defaultView) && parent.top !== parent ) { - // Support: IE 11 - if ( parent.addEventListener ) { - parent.addEventListener( "unload", unloadHandler, false ); - - // Support: IE 9 - 10 only - } else if ( parent.attachEvent ) { - parent.attachEvent( "onunload", unloadHandler ); - } - } - - /* Attributes - ---------------------------------------------------------------------- */ - - // Support: IE<8 - // Verify that getAttribute really returns attributes and not properties - // (excepting IE8 booleans) - support.attributes = assert(function( div ) { - div.className = "i"; - return !div.getAttribute("className"); - }); - - /* getElement(s)By* - ---------------------------------------------------------------------- */ - - // Check if getElementsByTagName("*") returns only elements - support.getElementsByTagName = assert(function( div ) { - div.appendChild( document.createComment("") ); - return !div.getElementsByTagName("*").length; - }); - - // Support: IE<9 - support.getElementsByClassName = rnative.test( document.getElementsByClassName ); - - // Support: IE<10 - // Check if getElementById returns elements by name - // The broken getElementById methods don't pick up programatically-set names, - // so use a roundabout getElementsByName test - support.getById = assert(function( div ) { - docElem.appendChild( div ).id = expando; - return !document.getElementsByName || !document.getElementsByName( expando ).length; - }); - - // ID find and filter - if ( support.getById ) { - Expr.find["ID"] = function( id, context ) { - if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { - var m = context.getElementById( id ); - return m ? [ m ] : []; - } - }; - Expr.filter["ID"] = function( id ) { - var attrId = id.replace( runescape, funescape ); - return function( elem ) { - return elem.getAttribute("id") === attrId; - }; - }; - } else { - // Support: IE6/7 - // getElementById is not reliable as a find shortcut - delete Expr.find["ID"]; - - Expr.filter["ID"] = function( id ) { - var attrId = id.replace( runescape, funescape ); - return function( elem ) { - var node = typeof elem.getAttributeNode !== "undefined" && - elem.getAttributeNode("id"); - return node && node.value === attrId; - }; - }; - } - - // Tag - Expr.find["TAG"] = support.getElementsByTagName ? - function( tag, context ) { - if ( typeof context.getElementsByTagName !== "undefined" ) { - return context.getElementsByTagName( tag ); - - // DocumentFragment nodes don't have gEBTN - } else if ( support.qsa ) { - return context.querySelectorAll( tag ); - } - } : - - function( tag, context ) { - var elem, - tmp = [], - i = 0, - // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too - results = context.getElementsByTagName( tag ); - - // Filter out possible comments - if ( tag === "*" ) { - while ( (elem = results[i++]) ) { - if ( elem.nodeType === 1 ) { - tmp.push( elem ); - } - } - - return tmp; - } - return results; - }; - - // Class - Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { - if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { - return context.getElementsByClassName( className ); - } - }; - - /* QSA/matchesSelector - ---------------------------------------------------------------------- */ - - // QSA and matchesSelector support - - // matchesSelector(:active) reports false when true (IE9/Opera 11.5) - rbuggyMatches = []; - - // qSa(:focus) reports false when true (Chrome 21) - // We allow this because of a bug in IE8/9 that throws an error - // whenever `document.activeElement` is accessed on an iframe - // So, we allow :focus to pass through QSA all the time to avoid the IE error - // See http://bugs.jquery.com/ticket/13378 - rbuggyQSA = []; - - if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { - // Build QSA regex - // Regex strategy adopted from Diego Perini - assert(function( div ) { - // Select is set to empty string on purpose - // This is to test IE's treatment of not explicitly - // setting a boolean content attribute, - // since its presence should be enough - // http://bugs.jquery.com/ticket/12359 - docElem.appendChild( div ).innerHTML = "" + - ""; - - // Support: IE8, Opera 11-12.16 - // Nothing should be selected when empty strings follow ^= or $= or *= - // The test attribute must be unknown in Opera but "safe" for WinRT - // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section - if ( div.querySelectorAll("[msallowcapture^='']").length ) { - rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); - } - - // Support: IE8 - // Boolean attributes and "value" are not treated correctly - if ( !div.querySelectorAll("[selected]").length ) { - rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); - } - - // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ - if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { - rbuggyQSA.push("~="); - } - - // Webkit/Opera - :checked should return selected option elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - // IE8 throws error here and will not see later tests - if ( !div.querySelectorAll(":checked").length ) { - rbuggyQSA.push(":checked"); - } - - // Support: Safari 8+, iOS 8+ - // https://bugs.webkit.org/show_bug.cgi?id=136851 - // In-page `selector#id sibing-combinator selector` fails - if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { - rbuggyQSA.push(".#.+[+~]"); - } - }); - - assert(function( div ) { - // Support: Windows 8 Native Apps - // The type and name attributes are restricted during .innerHTML assignment - var input = document.createElement("input"); - input.setAttribute( "type", "hidden" ); - div.appendChild( input ).setAttribute( "name", "D" ); - - // Support: IE8 - // Enforce case-sensitivity of name attribute - if ( div.querySelectorAll("[name=d]").length ) { - rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); - } - - // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) - // IE8 throws error here and will not see later tests - if ( !div.querySelectorAll(":enabled").length ) { - rbuggyQSA.push( ":enabled", ":disabled" ); - } - - // Opera 10-11 does not throw on post-comma invalid pseudos - div.querySelectorAll("*,:x"); - rbuggyQSA.push(",.*:"); - }); - } - - if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || - docElem.webkitMatchesSelector || - docElem.mozMatchesSelector || - docElem.oMatchesSelector || - docElem.msMatchesSelector) )) ) { - - assert(function( div ) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9) - support.disconnectedMatch = matches.call( div, "div" ); - - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call( div, "[s!='']:x" ); - rbuggyMatches.push( "!=", pseudos ); - }); - } - - rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); - rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); - - /* Contains - ---------------------------------------------------------------------- */ - hasCompare = rnative.test( docElem.compareDocumentPosition ); - - // Element contains another - // Purposefully self-exclusive - // As in, an element does not contain itself - contains = hasCompare || rnative.test( docElem.contains ) ? - function( a, b ) { - var adown = a.nodeType === 9 ? a.documentElement : a, - bup = b && b.parentNode; - return a === bup || !!( bup && bup.nodeType === 1 && ( - adown.contains ? - adown.contains( bup ) : - a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 - )); - } : - function( a, b ) { - if ( b ) { - while ( (b = b.parentNode) ) { - if ( b === a ) { - return true; - } - } - } - return false; - }; - - /* Sorting - ---------------------------------------------------------------------- */ - - // Document order sorting - sortOrder = hasCompare ? - function( a, b ) { - - // Flag for duplicate removal - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - // Sort on method existence if only one input has compareDocumentPosition - var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; - if ( compare ) { - return compare; - } - - // Calculate position if both inputs belong to the same document - compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? - a.compareDocumentPosition( b ) : - - // Otherwise we know they are disconnected - 1; - - // Disconnected nodes - if ( compare & 1 || - (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { - - // Choose the first element that is related to our preferred document - if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { - return -1; - } - if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { - return 1; - } - - // Maintain original order - return sortInput ? - ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : - 0; - } - - return compare & 4 ? -1 : 1; - } : - function( a, b ) { - // Exit early if the nodes are identical - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - var cur, - i = 0, - aup = a.parentNode, - bup = b.parentNode, - ap = [ a ], - bp = [ b ]; - - // Parentless nodes are either documents or disconnected - if ( !aup || !bup ) { - return a === document ? -1 : - b === document ? 1 : - aup ? -1 : - bup ? 1 : - sortInput ? - ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : - 0; - - // If the nodes are siblings, we can do a quick check - } else if ( aup === bup ) { - return siblingCheck( a, b ); - } - - // Otherwise we need full lists of their ancestors for comparison - cur = a; - while ( (cur = cur.parentNode) ) { - ap.unshift( cur ); - } - cur = b; - while ( (cur = cur.parentNode) ) { - bp.unshift( cur ); - } - - // Walk down the tree looking for a discrepancy - while ( ap[i] === bp[i] ) { - i++; - } - - return i ? - // Do a sibling check if the nodes have a common ancestor - siblingCheck( ap[i], bp[i] ) : - - // Otherwise nodes in our document sort first - ap[i] === preferredDoc ? -1 : - bp[i] === preferredDoc ? 1 : - 0; - }; - - return document; -}; - -Sizzle.matches = function( expr, elements ) { - return Sizzle( expr, null, null, elements ); -}; - -Sizzle.matchesSelector = function( elem, expr ) { - // Set document vars if needed - if ( ( elem.ownerDocument || elem ) !== document ) { - setDocument( elem ); - } - - // Make sure that attribute selectors are quoted - expr = expr.replace( rattributeQuotes, "='$1']" ); - - if ( support.matchesSelector && documentIsHTML && - !compilerCache[ expr + " " ] && - ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && - ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { - - try { - var ret = matches.call( elem, expr ); - - // IE 9's matchesSelector returns false on disconnected nodes - if ( ret || support.disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9 - elem.document && elem.document.nodeType !== 11 ) { - return ret; - } - } catch (e) {} - } - - return Sizzle( expr, document, null, [ elem ] ).length > 0; -}; - -Sizzle.contains = function( context, elem ) { - // Set document vars if needed - if ( ( context.ownerDocument || context ) !== document ) { - setDocument( context ); - } - return contains( context, elem ); -}; - -Sizzle.attr = function( elem, name ) { - // Set document vars if needed - if ( ( elem.ownerDocument || elem ) !== document ) { - setDocument( elem ); - } - - var fn = Expr.attrHandle[ name.toLowerCase() ], - // Don't get fooled by Object.prototype properties (jQuery #13807) - val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? - fn( elem, name, !documentIsHTML ) : - undefined; - - return val !== undefined ? - val : - support.attributes || !documentIsHTML ? - elem.getAttribute( name ) : - (val = elem.getAttributeNode(name)) && val.specified ? - val.value : - null; -}; - -Sizzle.error = function( msg ) { - throw new Error( "Syntax error, unrecognized expression: " + msg ); -}; - -/** - * Document sorting and removing duplicates - * @param {ArrayLike} results - */ -Sizzle.uniqueSort = function( results ) { - var elem, - duplicates = [], - j = 0, - i = 0; - - // Unless we *know* we can detect duplicates, assume their presence - hasDuplicate = !support.detectDuplicates; - sortInput = !support.sortStable && results.slice( 0 ); - results.sort( sortOrder ); - - if ( hasDuplicate ) { - while ( (elem = results[i++]) ) { - if ( elem === results[ i ] ) { - j = duplicates.push( i ); - } - } - while ( j-- ) { - results.splice( duplicates[ j ], 1 ); - } - } - - // Clear input after sorting to release objects - // See https://github.com/jquery/sizzle/pull/225 - sortInput = null; - - return results; -}; - -/** - * Utility function for retrieving the text value of an array of DOM nodes - * @param {Array|Element} elem - */ -getText = Sizzle.getText = function( elem ) { - var node, - ret = "", - i = 0, - nodeType = elem.nodeType; - - if ( !nodeType ) { - // If no nodeType, this is expected to be an array - while ( (node = elem[i++]) ) { - // Do not traverse comment nodes - ret += getText( node ); - } - } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { - // Use textContent for elements - // innerText usage removed for consistency of new lines (jQuery #11153) - if ( typeof elem.textContent === "string" ) { - return elem.textContent; - } else { - // Traverse its children - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - ret += getText( elem ); - } - } - } else if ( nodeType === 3 || nodeType === 4 ) { - return elem.nodeValue; - } - // Do not include comment or processing instruction nodes - - return ret; -}; - -Expr = Sizzle.selectors = { - - // Can be adjusted by the user - cacheLength: 50, - - createPseudo: markFunction, - - match: matchExpr, - - attrHandle: {}, - - find: {}, - - relative: { - ">": { dir: "parentNode", first: true }, - " ": { dir: "parentNode" }, - "+": { dir: "previousSibling", first: true }, - "~": { dir: "previousSibling" } - }, - - preFilter: { - "ATTR": function( match ) { - match[1] = match[1].replace( runescape, funescape ); - - // Move the given value to match[3] whether quoted or unquoted - match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); - - if ( match[2] === "~=" ) { - match[3] = " " + match[3] + " "; - } - - return match.slice( 0, 4 ); - }, - - "CHILD": function( match ) { - /* matches from matchExpr["CHILD"] - 1 type (only|nth|...) - 2 what (child|of-type) - 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) - 4 xn-component of xn+y argument ([+-]?\d*n|) - 5 sign of xn-component - 6 x of xn-component - 7 sign of y-component - 8 y of y-component - */ - match[1] = match[1].toLowerCase(); - - if ( match[1].slice( 0, 3 ) === "nth" ) { - // nth-* requires argument - if ( !match[3] ) { - Sizzle.error( match[0] ); - } - - // numeric x and y parameters for Expr.filter.CHILD - // remember that false/true cast respectively to 0/1 - match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); - match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); - - // other types prohibit arguments - } else if ( match[3] ) { - Sizzle.error( match[0] ); - } - - return match; - }, - - "PSEUDO": function( match ) { - var excess, - unquoted = !match[6] && match[2]; - - if ( matchExpr["CHILD"].test( match[0] ) ) { - return null; - } - - // Accept quoted arguments as-is - if ( match[3] ) { - match[2] = match[4] || match[5] || ""; - - // Strip excess characters from unquoted arguments - } else if ( unquoted && rpseudo.test( unquoted ) && - // Get excess from tokenize (recursively) - (excess = tokenize( unquoted, true )) && - // advance to the next closing parenthesis - (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { - - // excess is a negative index - match[0] = match[0].slice( 0, excess ); - match[2] = unquoted.slice( 0, excess ); - } - - // Return only captures needed by the pseudo filter method (type and argument) - return match.slice( 0, 3 ); - } - }, - - filter: { - - "TAG": function( nodeNameSelector ) { - var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); - return nodeNameSelector === "*" ? - function() { return true; } : - function( elem ) { - return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; - }; - }, - - "CLASS": function( className ) { - var pattern = classCache[ className + " " ]; - - return pattern || - (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && - classCache( className, function( elem ) { - return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); - }); - }, - - "ATTR": function( name, operator, check ) { - return function( elem ) { - var result = Sizzle.attr( elem, name ); - - if ( result == null ) { - return operator === "!="; - } - if ( !operator ) { - return true; - } - - result += ""; - - return operator === "=" ? result === check : - operator === "!=" ? result !== check : - operator === "^=" ? check && result.indexOf( check ) === 0 : - operator === "*=" ? check && result.indexOf( check ) > -1 : - operator === "$=" ? check && result.slice( -check.length ) === check : - operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : - operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : - false; - }; - }, - - "CHILD": function( type, what, argument, first, last ) { - var simple = type.slice( 0, 3 ) !== "nth", - forward = type.slice( -4 ) !== "last", - ofType = what === "of-type"; - - return first === 1 && last === 0 ? - - // Shortcut for :nth-*(n) - function( elem ) { - return !!elem.parentNode; - } : - - function( elem, context, xml ) { - var cache, uniqueCache, outerCache, node, nodeIndex, start, - dir = simple !== forward ? "nextSibling" : "previousSibling", - parent = elem.parentNode, - name = ofType && elem.nodeName.toLowerCase(), - useCache = !xml && !ofType, - diff = false; - - if ( parent ) { - - // :(first|last|only)-(child|of-type) - if ( simple ) { - while ( dir ) { - node = elem; - while ( (node = node[ dir ]) ) { - if ( ofType ? - node.nodeName.toLowerCase() === name : - node.nodeType === 1 ) { - - return false; - } - } - // Reverse direction for :only-* (if we haven't yet done so) - start = dir = type === "only" && !start && "nextSibling"; - } - return true; - } - - start = [ forward ? parent.firstChild : parent.lastChild ]; - - // non-xml :nth-child(...) stores cache data on `parent` - if ( forward && useCache ) { - - // Seek `elem` from a previously-cached index - - // ...in a gzip-friendly way - node = parent; - outerCache = node[ expando ] || (node[ expando ] = {}); - - // Support: IE <9 only - // Defend against cloned attroperties (jQuery gh-1709) - uniqueCache = outerCache[ node.uniqueID ] || - (outerCache[ node.uniqueID ] = {}); - - cache = uniqueCache[ type ] || []; - nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; - diff = nodeIndex && cache[ 2 ]; - node = nodeIndex && parent.childNodes[ nodeIndex ]; - - while ( (node = ++nodeIndex && node && node[ dir ] || - - // Fallback to seeking `elem` from the start - (diff = nodeIndex = 0) || start.pop()) ) { - - // When found, cache indexes on `parent` and break - if ( node.nodeType === 1 && ++diff && node === elem ) { - uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; - break; - } - } - - } else { - // Use previously-cached element index if available - if ( useCache ) { - // ...in a gzip-friendly way - node = elem; - outerCache = node[ expando ] || (node[ expando ] = {}); - - // Support: IE <9 only - // Defend against cloned attroperties (jQuery gh-1709) - uniqueCache = outerCache[ node.uniqueID ] || - (outerCache[ node.uniqueID ] = {}); - - cache = uniqueCache[ type ] || []; - nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; - diff = nodeIndex; - } - - // xml :nth-child(...) - // or :nth-last-child(...) or :nth(-last)?-of-type(...) - if ( diff === false ) { - // Use the same loop as above to seek `elem` from the start - while ( (node = ++nodeIndex && node && node[ dir ] || - (diff = nodeIndex = 0) || start.pop()) ) { - - if ( ( ofType ? - node.nodeName.toLowerCase() === name : - node.nodeType === 1 ) && - ++diff ) { - - // Cache the index of each encountered element - if ( useCache ) { - outerCache = node[ expando ] || (node[ expando ] = {}); - - // Support: IE <9 only - // Defend against cloned attroperties (jQuery gh-1709) - uniqueCache = outerCache[ node.uniqueID ] || - (outerCache[ node.uniqueID ] = {}); - - uniqueCache[ type ] = [ dirruns, diff ]; - } - - if ( node === elem ) { - break; - } - } - } - } - } - - // Incorporate the offset, then check against cycle size - diff -= last; - return diff === first || ( diff % first === 0 && diff / first >= 0 ); - } - }; - }, - - "PSEUDO": function( pseudo, argument ) { - // pseudo-class names are case-insensitive - // http://www.w3.org/TR/selectors/#pseudo-classes - // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters - // Remember that setFilters inherits from pseudos - var args, - fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || - Sizzle.error( "unsupported pseudo: " + pseudo ); - - // The user may use createPseudo to indicate that - // arguments are needed to create the filter function - // just as Sizzle does - if ( fn[ expando ] ) { - return fn( argument ); - } - - // But maintain support for old signatures - if ( fn.length > 1 ) { - args = [ pseudo, pseudo, "", argument ]; - return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? - markFunction(function( seed, matches ) { - var idx, - matched = fn( seed, argument ), - i = matched.length; - while ( i-- ) { - idx = indexOf( seed, matched[i] ); - seed[ idx ] = !( matches[ idx ] = matched[i] ); - } - }) : - function( elem ) { - return fn( elem, 0, args ); - }; - } - - return fn; - } - }, - - pseudos: { - // Potentially complex pseudos - "not": markFunction(function( selector ) { - // Trim the selector passed to compile - // to avoid treating leading and trailing - // spaces as combinators - var input = [], - results = [], - matcher = compile( selector.replace( rtrim, "$1" ) ); - - return matcher[ expando ] ? - markFunction(function( seed, matches, context, xml ) { - var elem, - unmatched = matcher( seed, null, xml, [] ), - i = seed.length; - - // Match elements unmatched by `matcher` - while ( i-- ) { - if ( (elem = unmatched[i]) ) { - seed[i] = !(matches[i] = elem); - } - } - }) : - function( elem, context, xml ) { - input[0] = elem; - matcher( input, null, xml, results ); - // Don't keep the element (issue #299) - input[0] = null; - return !results.pop(); - }; - }), - - "has": markFunction(function( selector ) { - return function( elem ) { - return Sizzle( selector, elem ).length > 0; - }; - }), - - "contains": markFunction(function( text ) { - text = text.replace( runescape, funescape ); - return function( elem ) { - return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; - }; - }), - - // "Whether an element is represented by a :lang() selector - // is based solely on the element's language value - // being equal to the identifier C, - // or beginning with the identifier C immediately followed by "-". - // The matching of C against the element's language value is performed case-insensitively. - // The identifier C does not have to be a valid language name." - // http://www.w3.org/TR/selectors/#lang-pseudo - "lang": markFunction( function( lang ) { - // lang value must be a valid identifier - if ( !ridentifier.test(lang || "") ) { - Sizzle.error( "unsupported lang: " + lang ); - } - lang = lang.replace( runescape, funescape ).toLowerCase(); - return function( elem ) { - var elemLang; - do { - if ( (elemLang = documentIsHTML ? - elem.lang : - elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { - - elemLang = elemLang.toLowerCase(); - return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; - } - } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); - return false; - }; - }), - - // Miscellaneous - "target": function( elem ) { - var hash = window.location && window.location.hash; - return hash && hash.slice( 1 ) === elem.id; - }, - - "root": function( elem ) { - return elem === docElem; - }, - - "focus": function( elem ) { - return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); - }, - - // Boolean properties - "enabled": function( elem ) { - return elem.disabled === false; - }, - - "disabled": function( elem ) { - return elem.disabled === true; - }, - - "checked": function( elem ) { - // In CSS3, :checked should return both checked and selected elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - var nodeName = elem.nodeName.toLowerCase(); - return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); - }, - - "selected": function( elem ) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if ( elem.parentNode ) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - // Contents - "empty": function( elem ) { - // http://www.w3.org/TR/selectors/#empty-pseudo - // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), - // but not by others (comment: 8; processing instruction: 7; etc.) - // nodeType < 6 works because attributes (2) do not appear as children - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - if ( elem.nodeType < 6 ) { - return false; - } - } - return true; - }, - - "parent": function( elem ) { - return !Expr.pseudos["empty"]( elem ); - }, - - // Element/input types - "header": function( elem ) { - return rheader.test( elem.nodeName ); - }, - - "input": function( elem ) { - return rinputs.test( elem.nodeName ); - }, - - "button": function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === "button" || name === "button"; - }, - - "text": function( elem ) { - var attr; - return elem.nodeName.toLowerCase() === "input" && - elem.type === "text" && - - // Support: IE<8 - // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" - ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); - }, - - // Position-in-collection - "first": createPositionalPseudo(function() { - return [ 0 ]; - }), - - "last": createPositionalPseudo(function( matchIndexes, length ) { - return [ length - 1 ]; - }), - - "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { - return [ argument < 0 ? argument + length : argument ]; - }), - - "even": createPositionalPseudo(function( matchIndexes, length ) { - var i = 0; - for ( ; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "odd": createPositionalPseudo(function( matchIndexes, length ) { - var i = 1; - for ( ; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { - var i = argument < 0 ? argument + length : argument; - for ( ; --i >= 0; ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { - var i = argument < 0 ? argument + length : argument; - for ( ; ++i < length; ) { - matchIndexes.push( i ); - } - return matchIndexes; - }) - } -}; - -Expr.pseudos["nth"] = Expr.pseudos["eq"]; - -// Add button/input type pseudos -for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { - Expr.pseudos[ i ] = createInputPseudo( i ); -} -for ( i in { submit: true, reset: true } ) { - Expr.pseudos[ i ] = createButtonPseudo( i ); -} - -// Easy API for creating new setFilters -function setFilters() {} -setFilters.prototype = Expr.filters = Expr.pseudos; -Expr.setFilters = new setFilters(); - -tokenize = Sizzle.tokenize = function( selector, parseOnly ) { - var matched, match, tokens, type, - soFar, groups, preFilters, - cached = tokenCache[ selector + " " ]; - - if ( cached ) { - return parseOnly ? 0 : cached.slice( 0 ); - } - - soFar = selector; - groups = []; - preFilters = Expr.preFilter; - - while ( soFar ) { - - // Comma and first run - if ( !matched || (match = rcomma.exec( soFar )) ) { - if ( match ) { - // Don't consume trailing commas as valid - soFar = soFar.slice( match[0].length ) || soFar; - } - groups.push( (tokens = []) ); - } - - matched = false; - - // Combinators - if ( (match = rcombinators.exec( soFar )) ) { - matched = match.shift(); - tokens.push({ - value: matched, - // Cast descendant combinators to space - type: match[0].replace( rtrim, " " ) - }); - soFar = soFar.slice( matched.length ); - } - - // Filters - for ( type in Expr.filter ) { - if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || - (match = preFilters[ type ]( match ))) ) { - matched = match.shift(); - tokens.push({ - value: matched, - type: type, - matches: match - }); - soFar = soFar.slice( matched.length ); - } - } - - if ( !matched ) { - break; - } - } - - // Return the length of the invalid excess - // if we're just parsing - // Otherwise, throw an error or return tokens - return parseOnly ? - soFar.length : - soFar ? - Sizzle.error( selector ) : - // Cache the tokens - tokenCache( selector, groups ).slice( 0 ); -}; - -function toSelector( tokens ) { - var i = 0, - len = tokens.length, - selector = ""; - for ( ; i < len; i++ ) { - selector += tokens[i].value; - } - return selector; -} - -function addCombinator( matcher, combinator, base ) { - var dir = combinator.dir, - checkNonElements = base && dir === "parentNode", - doneName = done++; - - return combinator.first ? - // Check against closest ancestor/preceding element - function( elem, context, xml ) { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - return matcher( elem, context, xml ); - } - } - } : - - // Check against all ancestor/preceding elements - function( elem, context, xml ) { - var oldCache, uniqueCache, outerCache, - newCache = [ dirruns, doneName ]; - - // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching - if ( xml ) { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - if ( matcher( elem, context, xml ) ) { - return true; - } - } - } - } else { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - outerCache = elem[ expando ] || (elem[ expando ] = {}); - - // Support: IE <9 only - // Defend against cloned attroperties (jQuery gh-1709) - uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); - - if ( (oldCache = uniqueCache[ dir ]) && - oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { - - // Assign to newCache so results back-propagate to previous elements - return (newCache[ 2 ] = oldCache[ 2 ]); - } else { - // Reuse newcache so results back-propagate to previous elements - uniqueCache[ dir ] = newCache; - - // A match means we're done; a fail means we have to keep checking - if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { - return true; - } - } - } - } - } - }; -} - -function elementMatcher( matchers ) { - return matchers.length > 1 ? - function( elem, context, xml ) { - var i = matchers.length; - while ( i-- ) { - if ( !matchers[i]( elem, context, xml ) ) { - return false; - } - } - return true; - } : - matchers[0]; -} - -function multipleContexts( selector, contexts, results ) { - var i = 0, - len = contexts.length; - for ( ; i < len; i++ ) { - Sizzle( selector, contexts[i], results ); - } - return results; -} - -function condense( unmatched, map, filter, context, xml ) { - var elem, - newUnmatched = [], - i = 0, - len = unmatched.length, - mapped = map != null; - - for ( ; i < len; i++ ) { - if ( (elem = unmatched[i]) ) { - if ( !filter || filter( elem, context, xml ) ) { - newUnmatched.push( elem ); - if ( mapped ) { - map.push( i ); - } - } - } - } - - return newUnmatched; -} - -function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { - if ( postFilter && !postFilter[ expando ] ) { - postFilter = setMatcher( postFilter ); - } - if ( postFinder && !postFinder[ expando ] ) { - postFinder = setMatcher( postFinder, postSelector ); - } - return markFunction(function( seed, results, context, xml ) { - var temp, i, elem, - preMap = [], - postMap = [], - preexisting = results.length, - - // Get initial elements from seed or context - elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), - - // Prefilter to get matcher input, preserving a map for seed-results synchronization - matcherIn = preFilter && ( seed || !selector ) ? - condense( elems, preMap, preFilter, context, xml ) : - elems, - - matcherOut = matcher ? - // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, - postFinder || ( seed ? preFilter : preexisting || postFilter ) ? - - // ...intermediate processing is necessary - [] : - - // ...otherwise use results directly - results : - matcherIn; - - // Find primary matches - if ( matcher ) { - matcher( matcherIn, matcherOut, context, xml ); - } - - // Apply postFilter - if ( postFilter ) { - temp = condense( matcherOut, postMap ); - postFilter( temp, [], context, xml ); - - // Un-match failing elements by moving them back to matcherIn - i = temp.length; - while ( i-- ) { - if ( (elem = temp[i]) ) { - matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); - } - } - } - - if ( seed ) { - if ( postFinder || preFilter ) { - if ( postFinder ) { - // Get the final matcherOut by condensing this intermediate into postFinder contexts - temp = []; - i = matcherOut.length; - while ( i-- ) { - if ( (elem = matcherOut[i]) ) { - // Restore matcherIn since elem is not yet a final match - temp.push( (matcherIn[i] = elem) ); - } - } - postFinder( null, (matcherOut = []), temp, xml ); - } - - // Move matched elements from seed to results to keep them synchronized - i = matcherOut.length; - while ( i-- ) { - if ( (elem = matcherOut[i]) && - (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { - - seed[temp] = !(results[temp] = elem); - } - } - } - - // Add elements to results, through postFinder if defined - } else { - matcherOut = condense( - matcherOut === results ? - matcherOut.splice( preexisting, matcherOut.length ) : - matcherOut - ); - if ( postFinder ) { - postFinder( null, results, matcherOut, xml ); - } else { - push.apply( results, matcherOut ); - } - } - }); -} - -function matcherFromTokens( tokens ) { - var checkContext, matcher, j, - len = tokens.length, - leadingRelative = Expr.relative[ tokens[0].type ], - implicitRelative = leadingRelative || Expr.relative[" "], - i = leadingRelative ? 1 : 0, - - // The foundational matcher ensures that elements are reachable from top-level context(s) - matchContext = addCombinator( function( elem ) { - return elem === checkContext; - }, implicitRelative, true ), - matchAnyContext = addCombinator( function( elem ) { - return indexOf( checkContext, elem ) > -1; - }, implicitRelative, true ), - matchers = [ function( elem, context, xml ) { - var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( - (checkContext = context).nodeType ? - matchContext( elem, context, xml ) : - matchAnyContext( elem, context, xml ) ); - // Avoid hanging onto element (issue #299) - checkContext = null; - return ret; - } ]; - - for ( ; i < len; i++ ) { - if ( (matcher = Expr.relative[ tokens[i].type ]) ) { - matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; - } else { - matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); - - // Return special upon seeing a positional matcher - if ( matcher[ expando ] ) { - // Find the next relative operator (if any) for proper handling - j = ++i; - for ( ; j < len; j++ ) { - if ( Expr.relative[ tokens[j].type ] ) { - break; - } - } - return setMatcher( - i > 1 && elementMatcher( matchers ), - i > 1 && toSelector( - // If the preceding token was a descendant combinator, insert an implicit any-element `*` - tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) - ).replace( rtrim, "$1" ), - matcher, - i < j && matcherFromTokens( tokens.slice( i, j ) ), - j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), - j < len && toSelector( tokens ) - ); - } - matchers.push( matcher ); - } - } - - return elementMatcher( matchers ); -} - -function matcherFromGroupMatchers( elementMatchers, setMatchers ) { - var bySet = setMatchers.length > 0, - byElement = elementMatchers.length > 0, - superMatcher = function( seed, context, xml, results, outermost ) { - var elem, j, matcher, - matchedCount = 0, - i = "0", - unmatched = seed && [], - setMatched = [], - contextBackup = outermostContext, - // We must always have either seed elements or outermost context - elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), - // Use integer dirruns iff this is the outermost matcher - dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), - len = elems.length; - - if ( outermost ) { - outermostContext = context === document || context || outermost; - } - - // Add elements passing elementMatchers directly to results - // Support: IE<9, Safari - // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id - for ( ; i !== len && (elem = elems[i]) != null; i++ ) { - if ( byElement && elem ) { - j = 0; - if ( !context && elem.ownerDocument !== document ) { - setDocument( elem ); - xml = !documentIsHTML; - } - while ( (matcher = elementMatchers[j++]) ) { - if ( matcher( elem, context || document, xml) ) { - results.push( elem ); - break; - } - } - if ( outermost ) { - dirruns = dirrunsUnique; - } - } - - // Track unmatched elements for set filters - if ( bySet ) { - // They will have gone through all possible matchers - if ( (elem = !matcher && elem) ) { - matchedCount--; - } - - // Lengthen the array for every element, matched or not - if ( seed ) { - unmatched.push( elem ); - } - } - } - - // `i` is now the count of elements visited above, and adding it to `matchedCount` - // makes the latter nonnegative. - matchedCount += i; - - // Apply set filters to unmatched elements - // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` - // equals `i`), unless we didn't visit _any_ elements in the above loop because we have - // no element matchers and no seed. - // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that - // case, which will result in a "00" `matchedCount` that differs from `i` but is also - // numerically zero. - if ( bySet && i !== matchedCount ) { - j = 0; - while ( (matcher = setMatchers[j++]) ) { - matcher( unmatched, setMatched, context, xml ); - } - - if ( seed ) { - // Reintegrate element matches to eliminate the need for sorting - if ( matchedCount > 0 ) { - while ( i-- ) { - if ( !(unmatched[i] || setMatched[i]) ) { - setMatched[i] = pop.call( results ); - } - } - } - - // Discard index placeholder values to get only actual matches - setMatched = condense( setMatched ); - } - - // Add matches to results - push.apply( results, setMatched ); - - // Seedless set matches succeeding multiple successful matchers stipulate sorting - if ( outermost && !seed && setMatched.length > 0 && - ( matchedCount + setMatchers.length ) > 1 ) { - - Sizzle.uniqueSort( results ); - } - } - - // Override manipulation of globals by nested matchers - if ( outermost ) { - dirruns = dirrunsUnique; - outermostContext = contextBackup; - } - - return unmatched; - }; - - return bySet ? - markFunction( superMatcher ) : - superMatcher; -} - -compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { - var i, - setMatchers = [], - elementMatchers = [], - cached = compilerCache[ selector + " " ]; - - if ( !cached ) { - // Generate a function of recursive functions that can be used to check each element - if ( !match ) { - match = tokenize( selector ); - } - i = match.length; - while ( i-- ) { - cached = matcherFromTokens( match[i] ); - if ( cached[ expando ] ) { - setMatchers.push( cached ); - } else { - elementMatchers.push( cached ); - } - } - - // Cache the compiled function - cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); - - // Save selector and tokenization - cached.selector = selector; - } - return cached; -}; - -/** - * A low-level selection function that works with Sizzle's compiled - * selector functions - * @param {String|Function} selector A selector or a pre-compiled - * selector function built with Sizzle.compile - * @param {Element} context - * @param {Array} [results] - * @param {Array} [seed] A set of elements to match against - */ -select = Sizzle.select = function( selector, context, results, seed ) { - var i, tokens, token, type, find, - compiled = typeof selector === "function" && selector, - match = !seed && tokenize( (selector = compiled.selector || selector) ); - - results = results || []; - - // Try to minimize operations if there is only one selector in the list and no seed - // (the latter of which guarantees us context) - if ( match.length === 1 ) { - - // Reduce context if the leading compound selector is an ID - tokens = match[0] = match[0].slice( 0 ); - if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && - support.getById && context.nodeType === 9 && documentIsHTML && - Expr.relative[ tokens[1].type ] ) { - - context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; - if ( !context ) { - return results; - - // Precompiled matchers will still verify ancestry, so step up a level - } else if ( compiled ) { - context = context.parentNode; - } - - selector = selector.slice( tokens.shift().value.length ); - } - - // Fetch a seed set for right-to-left matching - i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; - while ( i-- ) { - token = tokens[i]; - - // Abort if we hit a combinator - if ( Expr.relative[ (type = token.type) ] ) { - break; - } - if ( (find = Expr.find[ type ]) ) { - // Search, expanding context for leading sibling combinators - if ( (seed = find( - token.matches[0].replace( runescape, funescape ), - rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context - )) ) { - - // If seed is empty or no tokens remain, we can return early - tokens.splice( i, 1 ); - selector = seed.length && toSelector( tokens ); - if ( !selector ) { - push.apply( results, seed ); - return results; - } - - break; - } - } - } - } - - // Compile and execute a filtering function if one is not provided - // Provide `match` to avoid retokenization if we modified the selector above - ( compiled || compile( selector, match ) )( - seed, - context, - !documentIsHTML, - results, - !context || rsibling.test( selector ) && testContext( context.parentNode ) || context - ); - return results; -}; - -// One-time assignments - -// Sort stability -support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; - -// Support: Chrome 14-35+ -// Always assume duplicates if they aren't passed to the comparison function -support.detectDuplicates = !!hasDuplicate; - -// Initialize against the default document -setDocument(); - -// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) -// Detached nodes confoundingly follow *each other* -support.sortDetached = assert(function( div1 ) { - // Should return 1, but returns 4 (following) - return div1.compareDocumentPosition( document.createElement("div") ) & 1; -}); - -// Support: IE<8 -// Prevent attribute/property "interpolation" -// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx -if ( !assert(function( div ) { - div.innerHTML = ""; - return div.firstChild.getAttribute("href") === "#" ; -}) ) { - addHandle( "type|href|height|width", function( elem, name, isXML ) { - if ( !isXML ) { - return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); - } - }); -} - -// Support: IE<9 -// Use defaultValue in place of getAttribute("value") -if ( !support.attributes || !assert(function( div ) { - div.innerHTML = ""; - div.firstChild.setAttribute( "value", "" ); - return div.firstChild.getAttribute( "value" ) === ""; -}) ) { - addHandle( "value", function( elem, name, isXML ) { - if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { - return elem.defaultValue; - } - }); -} - -// Support: IE<9 -// Use getAttributeNode to fetch booleans when getAttribute lies -if ( !assert(function( div ) { - return div.getAttribute("disabled") == null; -}) ) { - addHandle( booleans, function( elem, name, isXML ) { - var val; - if ( !isXML ) { - return elem[ name ] === true ? name.toLowerCase() : - (val = elem.getAttributeNode( name )) && val.specified ? - val.value : - null; - } - }); -} - -return Sizzle; - -})( window ); - - - -jQuery.find = Sizzle; -jQuery.expr = Sizzle.selectors; -jQuery.expr[ ":" ] = jQuery.expr.pseudos; -jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; -jQuery.text = Sizzle.getText; -jQuery.isXMLDoc = Sizzle.isXML; -jQuery.contains = Sizzle.contains; - - - -var dir = function( elem, dir, until ) { - var matched = [], - truncate = until !== undefined; - - while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { - if ( elem.nodeType === 1 ) { - if ( truncate && jQuery( elem ).is( until ) ) { - break; - } - matched.push( elem ); - } - } - return matched; -}; - - -var siblings = function( n, elem ) { - var matched = []; - - for ( ; n; n = n.nextSibling ) { - if ( n.nodeType === 1 && n !== elem ) { - matched.push( n ); - } - } - - return matched; -}; - - -var rneedsContext = jQuery.expr.match.needsContext; - -var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ ); - - - -var risSimple = /^.[^:#\[\.,]*$/; - -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, not ) { - if ( jQuery.isFunction( qualifier ) ) { - return jQuery.grep( elements, function( elem, i ) { - /* jshint -W018 */ - return !!qualifier.call( elem, i, elem ) !== not; - } ); - - } - - if ( qualifier.nodeType ) { - return jQuery.grep( elements, function( elem ) { - return ( elem === qualifier ) !== not; - } ); - - } - - if ( typeof qualifier === "string" ) { - if ( risSimple.test( qualifier ) ) { - return jQuery.filter( qualifier, elements, not ); - } - - qualifier = jQuery.filter( qualifier, elements ); - } - - return jQuery.grep( elements, function( elem ) { - return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not; - } ); -} - -jQuery.filter = function( expr, elems, not ) { - var elem = elems[ 0 ]; - - if ( not ) { - expr = ":not(" + expr + ")"; - } - - return elems.length === 1 && elem.nodeType === 1 ? - jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : - jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { - return elem.nodeType === 1; - } ) ); -}; - -jQuery.fn.extend( { - find: function( selector ) { - var i, - ret = [], - self = this, - len = self.length; - - if ( typeof selector !== "string" ) { - return this.pushStack( jQuery( selector ).filter( function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( self[ i ], this ) ) { - return true; - } - } - } ) ); - } - - for ( i = 0; i < len; i++ ) { - jQuery.find( selector, self[ i ], ret ); - } - - // Needed because $( selector, context ) becomes $( context ).find( selector ) - ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); - ret.selector = this.selector ? this.selector + " " + selector : selector; - return ret; - }, - filter: function( selector ) { - return this.pushStack( winnow( this, selector || [], false ) ); - }, - not: function( selector ) { - return this.pushStack( winnow( this, selector || [], true ) ); - }, - is: function( selector ) { - return !!winnow( - this, - - // If this is a positional/relative selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - typeof selector === "string" && rneedsContext.test( selector ) ? - jQuery( selector ) : - selector || [], - false - ).length; - } -} ); - - -// Initialize a jQuery object - - -// A central reference to the root jQuery(document) -var rootjQuery, - - // A simple way to check for HTML strings - // Prioritize #id over to avoid XSS via location.hash (#9521) - // Strict HTML recognition (#11290: must start with <) - rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, - - init = jQuery.fn.init = function( selector, context, root ) { - var match, elem; - - // HANDLE: $(""), $(null), $(undefined), $(false) - if ( !selector ) { - return this; - } - - // init accepts an alternate rootjQuery - // so migrate can support jQuery.sub (gh-2101) - root = root || rootjQuery; - - // Handle HTML strings - if ( typeof selector === "string" ) { - if ( selector.charAt( 0 ) === "<" && - selector.charAt( selector.length - 1 ) === ">" && - selector.length >= 3 ) { - - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [ null, selector, null ]; - - } else { - match = rquickExpr.exec( selector ); - } - - // Match html or make sure no context is specified for #id - if ( match && ( match[ 1 ] || !context ) ) { - - // HANDLE: $(html) -> $(array) - if ( match[ 1 ] ) { - context = context instanceof jQuery ? context[ 0 ] : context; - - // scripts is true for back-compat - // Intentionally let the error be thrown if parseHTML is not present - jQuery.merge( this, jQuery.parseHTML( - match[ 1 ], - context && context.nodeType ? context.ownerDocument || context : document, - true - ) ); - - // HANDLE: $(html, props) - if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { - for ( match in context ) { - - // Properties of context are called as methods if possible - if ( jQuery.isFunction( this[ match ] ) ) { - this[ match ]( context[ match ] ); - - // ...and otherwise set as attributes - } else { - this.attr( match, context[ match ] ); - } - } - } - - return this; - - // HANDLE: $(#id) - } else { - elem = document.getElementById( match[ 2 ] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id !== match[ 2 ] ) { - return rootjQuery.find( selector ); - } - - // Otherwise, we inject the element directly into the jQuery object - this.length = 1; - this[ 0 ] = elem; - } - - this.context = document; - this.selector = selector; - return this; - } - - // HANDLE: $(expr, $(...)) - } else if ( !context || context.jquery ) { - return ( context || root ).find( selector ); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return this.constructor( context ).find( selector ); - } - - // HANDLE: $(DOMElement) - } else if ( selector.nodeType ) { - this.context = this[ 0 ] = selector; - this.length = 1; - return this; - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) { - return typeof root.ready !== "undefined" ? - root.ready( selector ) : - - // Execute immediately if ready is not present - selector( jQuery ); - } - - if ( selector.selector !== undefined ) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray( selector, this ); - }; - -// Give the init function the jQuery prototype for later instantiation -init.prototype = jQuery.fn; - -// Initialize central reference -rootjQuery = jQuery( document ); - - -var rparentsprev = /^(?:parents|prev(?:Until|All))/, - - // methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; - -jQuery.fn.extend( { - has: function( target ) { - var i, - targets = jQuery( target, this ), - len = targets.length; - - return this.filter( function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( this, targets[ i ] ) ) { - return true; - } - } - } ); - }, - - closest: function( selectors, context ) { - var cur, - i = 0, - l = this.length, - matched = [], - pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? - jQuery( selectors, context || this.context ) : - 0; - - for ( ; i < l; i++ ) { - for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { - - // Always skip document fragments - if ( cur.nodeType < 11 && ( pos ? - pos.index( cur ) > -1 : - - // Don't pass non-elements to Sizzle - cur.nodeType === 1 && - jQuery.find.matchesSelector( cur, selectors ) ) ) { - - matched.push( cur ); - break; - } - } - } - - return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); - }, - - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { - - // No argument, return index in parent - if ( !elem ) { - return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; - } - - // index in selector - if ( typeof elem === "string" ) { - return jQuery.inArray( this[ 0 ], jQuery( elem ) ); - } - - // Locate the position of the desired element - return jQuery.inArray( - - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[ 0 ] : elem, this ); - }, - - add: function( selector, context ) { - return this.pushStack( - jQuery.uniqueSort( - jQuery.merge( this.get(), jQuery( selector, context ) ) - ) - ); - }, - - addBack: function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter( selector ) - ); - } -} ); - -function sibling( cur, dir ) { - do { - cur = cur[ dir ]; - } while ( cur && cur.nodeType !== 1 ); - - return cur; -} - -jQuery.each( { - parent: function( elem ) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function( elem ) { - return dir( elem, "parentNode" ); - }, - parentsUntil: function( elem, i, until ) { - return dir( elem, "parentNode", until ); - }, - next: function( elem ) { - return sibling( elem, "nextSibling" ); - }, - prev: function( elem ) { - return sibling( elem, "previousSibling" ); - }, - nextAll: function( elem ) { - return dir( elem, "nextSibling" ); - }, - prevAll: function( elem ) { - return dir( elem, "previousSibling" ); - }, - nextUntil: function( elem, i, until ) { - return dir( elem, "nextSibling", until ); - }, - prevUntil: function( elem, i, until ) { - return dir( elem, "previousSibling", until ); - }, - siblings: function( elem ) { - return siblings( ( elem.parentNode || {} ).firstChild, elem ); - }, - children: function( elem ) { - return siblings( elem.firstChild ); - }, - contents: function( elem ) { - return jQuery.nodeName( elem, "iframe" ) ? - elem.contentDocument || elem.contentWindow.document : - jQuery.merge( [], elem.childNodes ); - } -}, function( name, fn ) { - jQuery.fn[ name ] = function( until, selector ) { - var ret = jQuery.map( this, fn, until ); - - if ( name.slice( -5 ) !== "Until" ) { - selector = until; - } - - if ( selector && typeof selector === "string" ) { - ret = jQuery.filter( selector, ret ); - } - - if ( this.length > 1 ) { - - // Remove duplicates - if ( !guaranteedUnique[ name ] ) { - ret = jQuery.uniqueSort( ret ); - } - - // Reverse order for parents* and prev-derivatives - if ( rparentsprev.test( name ) ) { - ret = ret.reverse(); - } - } - - return this.pushStack( ret ); - }; -} ); -var rnotwhite = ( /\S+/g ); - - - -// Convert String-formatted options into Object-formatted ones -function createOptions( options ) { - var object = {}; - jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { - object[ flag ] = true; - } ); - return object; -} - -/* - * Create a callback list using the following parameters: - * - * options: an optional list of space-separated options that will change how - * the callback list behaves or a more traditional option object - * - * By default a callback list will act like an event callback list and can be - * "fired" multiple times. - * - * Possible options: - * - * once: will ensure the callback list can only be fired once (like a Deferred) - * - * memory: will keep track of previous values and will call any callback added - * after the list has been fired right away with the latest "memorized" - * values (like a Deferred) - * - * unique: will ensure a callback can only be added once (no duplicate in the list) - * - * stopOnFalse: interrupt callings when a callback returns false - * - */ -jQuery.Callbacks = function( options ) { - - // Convert options from String-formatted to Object-formatted if needed - // (we check in cache first) - options = typeof options === "string" ? - createOptions( options ) : - jQuery.extend( {}, options ); - - var // Flag to know if list is currently firing - firing, - - // Last fire value for non-forgettable lists - memory, - - // Flag to know if list was already fired - fired, - - // Flag to prevent firing - locked, - - // Actual callback list - list = [], - - // Queue of execution data for repeatable lists - queue = [], - - // Index of currently firing callback (modified by add/remove as needed) - firingIndex = -1, - - // Fire callbacks - fire = function() { - - // Enforce single-firing - locked = options.once; - - // Execute callbacks for all pending executions, - // respecting firingIndex overrides and runtime changes - fired = firing = true; - for ( ; queue.length; firingIndex = -1 ) { - memory = queue.shift(); - while ( ++firingIndex < list.length ) { - - // Run callback and check for early termination - if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && - options.stopOnFalse ) { - - // Jump to end and forget the data so .add doesn't re-fire - firingIndex = list.length; - memory = false; - } - } - } - - // Forget the data if we're done with it - if ( !options.memory ) { - memory = false; - } - - firing = false; - - // Clean up if we're done firing for good - if ( locked ) { - - // Keep an empty list if we have data for future add calls - if ( memory ) { - list = []; - - // Otherwise, this object is spent - } else { - list = ""; - } - } - }, - - // Actual Callbacks object - self = { - - // Add a callback or a collection of callbacks to the list - add: function() { - if ( list ) { - - // If we have memory from a past run, we should fire after adding - if ( memory && !firing ) { - firingIndex = list.length - 1; - queue.push( memory ); - } - - ( function add( args ) { - jQuery.each( args, function( _, arg ) { - if ( jQuery.isFunction( arg ) ) { - if ( !options.unique || !self.has( arg ) ) { - list.push( arg ); - } - } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { - - // Inspect recursively - add( arg ); - } - } ); - } )( arguments ); - - if ( memory && !firing ) { - fire(); - } - } - return this; - }, - - // Remove a callback from the list - remove: function() { - jQuery.each( arguments, function( _, arg ) { - var index; - while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { - list.splice( index, 1 ); - - // Handle firing indexes - if ( index <= firingIndex ) { - firingIndex--; - } - } - } ); - return this; - }, - - // Check if a given callback is in the list. - // If no argument is given, return whether or not list has callbacks attached. - has: function( fn ) { - return fn ? - jQuery.inArray( fn, list ) > -1 : - list.length > 0; - }, - - // Remove all callbacks from the list - empty: function() { - if ( list ) { - list = []; - } - return this; - }, - - // Disable .fire and .add - // Abort any current/pending executions - // Clear all callbacks and values - disable: function() { - locked = queue = []; - list = memory = ""; - return this; - }, - disabled: function() { - return !list; - }, - - // Disable .fire - // Also disable .add unless we have memory (since it would have no effect) - // Abort any pending executions - lock: function() { - locked = true; - if ( !memory ) { - self.disable(); - } - return this; - }, - locked: function() { - return !!locked; - }, - - // Call all callbacks with the given context and arguments - fireWith: function( context, args ) { - if ( !locked ) { - args = args || []; - args = [ context, args.slice ? args.slice() : args ]; - queue.push( args ); - if ( !firing ) { - fire(); - } - } - return this; - }, - - // Call all the callbacks with the given arguments - fire: function() { - self.fireWith( this, arguments ); - return this; - }, - - // To know if the callbacks have already been called at least once - fired: function() { - return !!fired; - } - }; - - return self; -}; - - -jQuery.extend( { - - Deferred: function( func ) { - var tuples = [ - - // action, add listener, listener list, final state - [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ], - [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ], - [ "notify", "progress", jQuery.Callbacks( "memory" ) ] - ], - state = "pending", - promise = { - state: function() { - return state; - }, - always: function() { - deferred.done( arguments ).fail( arguments ); - return this; - }, - then: function( /* fnDone, fnFail, fnProgress */ ) { - var fns = arguments; - return jQuery.Deferred( function( newDefer ) { - jQuery.each( tuples, function( i, tuple ) { - var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; - - // deferred[ done | fail | progress ] for forwarding actions to newDefer - deferred[ tuple[ 1 ] ]( function() { - var returned = fn && fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise() - .progress( newDefer.notify ) - .done( newDefer.resolve ) - .fail( newDefer.reject ); - } else { - newDefer[ tuple[ 0 ] + "With" ]( - this === promise ? newDefer.promise() : this, - fn ? [ returned ] : arguments - ); - } - } ); - } ); - fns = null; - } ).promise(); - }, - - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj ) { - return obj != null ? jQuery.extend( obj, promise ) : promise; - } - }, - deferred = {}; - - // Keep pipe for back-compat - promise.pipe = promise.then; - - // Add list-specific methods - jQuery.each( tuples, function( i, tuple ) { - var list = tuple[ 2 ], - stateString = tuple[ 3 ]; - - // promise[ done | fail | progress ] = list.add - promise[ tuple[ 1 ] ] = list.add; - - // Handle state - if ( stateString ) { - list.add( function() { - - // state = [ resolved | rejected ] - state = stateString; - - // [ reject_list | resolve_list ].disable; progress_list.lock - }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); - } - - // deferred[ resolve | reject | notify ] - deferred[ tuple[ 0 ] ] = function() { - deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments ); - return this; - }; - deferred[ tuple[ 0 ] + "With" ] = list.fireWith; - } ); - - // Make the deferred a promise - promise.promise( deferred ); - - // Call given func if any - if ( func ) { - func.call( deferred, deferred ); - } - - // All done! - return deferred; - }, - - // Deferred helper - when: function( subordinate /* , ..., subordinateN */ ) { - var i = 0, - resolveValues = slice.call( arguments ), - length = resolveValues.length, - - // the count of uncompleted subordinates - remaining = length !== 1 || - ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, - - // the master Deferred. - // If resolveValues consist of only a single Deferred, just use that. - deferred = remaining === 1 ? subordinate : jQuery.Deferred(), - - // Update function for both resolve and progress values - updateFunc = function( i, contexts, values ) { - return function( value ) { - contexts[ i ] = this; - values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; - if ( values === progressValues ) { - deferred.notifyWith( contexts, values ); - - } else if ( !( --remaining ) ) { - deferred.resolveWith( contexts, values ); - } - }; - }, - - progressValues, progressContexts, resolveContexts; - - // add listeners to Deferred subordinates; treat others as resolved - if ( length > 1 ) { - progressValues = new Array( length ); - progressContexts = new Array( length ); - resolveContexts = new Array( length ); - for ( ; i < length; i++ ) { - if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { - resolveValues[ i ].promise() - .progress( updateFunc( i, progressContexts, progressValues ) ) - .done( updateFunc( i, resolveContexts, resolveValues ) ) - .fail( deferred.reject ); - } else { - --remaining; - } - } - } - - // if we're not waiting on anything, resolve the master - if ( !remaining ) { - deferred.resolveWith( resolveContexts, resolveValues ); - } - - return deferred.promise(); - } -} ); - - -// The deferred used on DOM ready -var readyList; - -jQuery.fn.ready = function( fn ) { - - // Add the callback - jQuery.ready.promise().done( fn ); - - return this; -}; - -jQuery.extend( { - - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - - // Hold (or release) the ready event - holdReady: function( hold ) { - if ( hold ) { - jQuery.readyWait++; - } else { - jQuery.ready( true ); - } - }, - - // Handle when the DOM is ready - ready: function( wait ) { - - // Abort if there are pending holds or we're already ready - if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { - return; - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - - // If there are functions bound, to execute - readyList.resolveWith( document, [ jQuery ] ); - - // Trigger any bound ready events - if ( jQuery.fn.triggerHandler ) { - jQuery( document ).triggerHandler( "ready" ); - jQuery( document ).off( "ready" ); - } - } -} ); - -/** - * Clean-up method for dom ready events - */ -function detach() { - if ( document.addEventListener ) { - document.removeEventListener( "DOMContentLoaded", completed ); - window.removeEventListener( "load", completed ); - - } else { - document.detachEvent( "onreadystatechange", completed ); - window.detachEvent( "onload", completed ); - } -} - -/** - * The ready event handler and self cleanup method - */ -function completed() { - - // readyState === "complete" is good enough for us to call the dom ready in oldIE - if ( document.addEventListener || - window.event.type === "load" || - document.readyState === "complete" ) { - - detach(); - jQuery.ready(); - } -} - -jQuery.ready.promise = function( obj ) { - if ( !readyList ) { - - readyList = jQuery.Deferred(); - - // Catch cases where $(document).ready() is called - // after the browser event has already occurred. - // Support: IE6-10 - // Older IE sometimes signals "interactive" too soon - if ( document.readyState === "complete" || - ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { - - // Handle it asynchronously to allow scripts the opportunity to delay ready - window.setTimeout( jQuery.ready ); - - // Standards-based browsers support DOMContentLoaded - } else if ( document.addEventListener ) { - - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", completed ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", completed ); - - // If IE event model is used - } else { - - // Ensure firing before onload, maybe late but safe also for iframes - document.attachEvent( "onreadystatechange", completed ); - - // A fallback to window.onload, that will always work - window.attachEvent( "onload", completed ); - - // If IE and not a frame - // continually check to see if the document is ready - var top = false; - - try { - top = window.frameElement == null && document.documentElement; - } catch ( e ) {} - - if ( top && top.doScroll ) { - ( function doScrollCheck() { - if ( !jQuery.isReady ) { - - try { - - // Use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - top.doScroll( "left" ); - } catch ( e ) { - return window.setTimeout( doScrollCheck, 50 ); - } - - // detach all dom ready events - detach(); - - // and execute any waiting functions - jQuery.ready(); - } - } )(); - } - } - } - return readyList.promise( obj ); -}; - -// Kick off the DOM ready check even if the user does not -jQuery.ready.promise(); - - - - -// Support: IE<9 -// Iteration over object's inherited properties before its own -var i; -for ( i in jQuery( support ) ) { - break; -} -support.ownFirst = i === "0"; - -// Note: most support tests are defined in their respective modules. -// false until the test is run -support.inlineBlockNeedsLayout = false; - -// Execute ASAP in case we need to set body.style.zoom -jQuery( function() { - - // Minified: var a,b,c,d - var val, div, body, container; - - body = document.getElementsByTagName( "body" )[ 0 ]; - if ( !body || !body.style ) { - - // Return for frameset docs that don't have a body - return; - } - - // Setup - div = document.createElement( "div" ); - container = document.createElement( "div" ); - container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px"; - body.appendChild( container ).appendChild( div ); - - if ( typeof div.style.zoom !== "undefined" ) { - - // Support: IE<8 - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1"; - - support.inlineBlockNeedsLayout = val = div.offsetWidth === 3; - if ( val ) { - - // Prevent IE 6 from affecting layout for positioned elements #11048 - // Prevent IE from shrinking the body in IE 7 mode #12869 - // Support: IE<8 - body.style.zoom = 1; - } - } - - body.removeChild( container ); -} ); - - -( function() { - var div = document.createElement( "div" ); - - // Support: IE<9 - support.deleteExpando = true; - try { - delete div.test; - } catch ( e ) { - support.deleteExpando = false; - } - - // Null elements to avoid leaks in IE. - div = null; -} )(); -var acceptData = function( elem ) { - var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ], - nodeType = +elem.nodeType || 1; - - // Do not set data on non-element DOM nodes because it will not be cleared (#8335). - return nodeType !== 1 && nodeType !== 9 ? - false : - - // Nodes accept data unless otherwise specified; rejection can be conditional - !noData || noData !== true && elem.getAttribute( "classid" ) === noData; -}; - - - - -var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, - rmultiDash = /([A-Z])/g; - -function dataAttr( elem, key, data ) { - - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - - var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); - - data = elem.getAttribute( name ); - - if ( typeof data === "string" ) { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - - // Only convert to a number if it doesn't change the string - +data + "" === data ? +data : - rbrace.test( data ) ? jQuery.parseJSON( data ) : - data; - } catch ( e ) {} - - // Make sure we set the data so it isn't changed later - jQuery.data( elem, key, data ); - - } else { - data = undefined; - } - } - - return data; -} - -// checks a cache object for emptiness -function isEmptyDataObject( obj ) { - var name; - for ( name in obj ) { - - // if the public data object is empty, the private is still empty - if ( name === "data" && jQuery.isEmptyObject( obj[ name ] ) ) { - continue; - } - if ( name !== "toJSON" ) { - return false; - } - } - - return true; -} - -function internalData( elem, name, data, pvt /* Internal Use Only */ ) { - if ( !acceptData( elem ) ) { - return; - } - - var ret, thisCache, - internalKey = jQuery.expando, - - // We have to handle DOM nodes and JS objects differently because IE6-7 - // can't GC object references properly across the DOM-JS boundary - isNode = elem.nodeType, - - // Only DOM nodes need the global jQuery cache; JS object data is - // attached directly to the object so GC can occur automatically - cache = isNode ? jQuery.cache : elem, - - // Only defining an ID for JS objects if its cache already exists allows - // the code to shortcut on the same path as a DOM node with no cache - id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; - - // Avoid doing any more work than we need to when trying to get data on an - // object that has no data at all - if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) && - data === undefined && typeof name === "string" ) { - return; - } - - if ( !id ) { - - // Only DOM nodes need a new unique ID for each element since their data - // ends up in the global cache - if ( isNode ) { - id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++; - } else { - id = internalKey; - } - } - - if ( !cache[ id ] ) { - - // Avoid exposing jQuery metadata on plain JS objects when the object - // is serialized using JSON.stringify - cache[ id ] = isNode ? {} : { toJSON: jQuery.noop }; - } - - // An object can be passed to jQuery.data instead of a key/value pair; this gets - // shallow copied over onto the existing cache - if ( typeof name === "object" || typeof name === "function" ) { - if ( pvt ) { - cache[ id ] = jQuery.extend( cache[ id ], name ); - } else { - cache[ id ].data = jQuery.extend( cache[ id ].data, name ); - } - } - - thisCache = cache[ id ]; - - // jQuery data() is stored in a separate object inside the object's internal data - // cache in order to avoid key collisions between internal data and user-defined - // data. - if ( !pvt ) { - if ( !thisCache.data ) { - thisCache.data = {}; - } - - thisCache = thisCache.data; - } - - if ( data !== undefined ) { - thisCache[ jQuery.camelCase( name ) ] = data; - } - - // Check for both converted-to-camel and non-converted data property names - // If a data property was specified - if ( typeof name === "string" ) { - - // First Try to find as-is property data - ret = thisCache[ name ]; - - // Test for null|undefined property data - if ( ret == null ) { - - // Try to find the camelCased property - ret = thisCache[ jQuery.camelCase( name ) ]; - } - } else { - ret = thisCache; - } - - return ret; -} - -function internalRemoveData( elem, name, pvt ) { - if ( !acceptData( elem ) ) { - return; - } - - var thisCache, i, - isNode = elem.nodeType, - - // See jQuery.data for more information - cache = isNode ? jQuery.cache : elem, - id = isNode ? elem[ jQuery.expando ] : jQuery.expando; - - // If there is already no cache entry for this object, there is no - // purpose in continuing - if ( !cache[ id ] ) { - return; - } - - if ( name ) { - - thisCache = pvt ? cache[ id ] : cache[ id ].data; - - if ( thisCache ) { - - // Support array or space separated string names for data keys - if ( !jQuery.isArray( name ) ) { - - // try the string as a key before any manipulation - if ( name in thisCache ) { - name = [ name ]; - } else { - - // split the camel cased version by spaces unless a key with the spaces exists - name = jQuery.camelCase( name ); - if ( name in thisCache ) { - name = [ name ]; - } else { - name = name.split( " " ); - } - } - } else { - - // If "name" is an array of keys... - // When data is initially created, via ("key", "val") signature, - // keys will be converted to camelCase. - // Since there is no way to tell _how_ a key was added, remove - // both plain key and camelCase key. #12786 - // This will only penalize the array argument path. - name = name.concat( jQuery.map( name, jQuery.camelCase ) ); - } - - i = name.length; - while ( i-- ) { - delete thisCache[ name[ i ] ]; - } - - // If there is no data left in the cache, we want to continue - // and let the cache object itself get destroyed - if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) { - return; - } - } - } - - // See jQuery.data for more information - if ( !pvt ) { - delete cache[ id ].data; - - // Don't destroy the parent cache unless the internal data object - // had been the only thing left in it - if ( !isEmptyDataObject( cache[ id ] ) ) { - return; - } - } - - // Destroy the cache - if ( isNode ) { - jQuery.cleanData( [ elem ], true ); - - // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) - /* jshint eqeqeq: false */ - } else if ( support.deleteExpando || cache != cache.window ) { - /* jshint eqeqeq: true */ - delete cache[ id ]; - - // When all else fails, undefined - } else { - cache[ id ] = undefined; - } -} - -jQuery.extend( { - cache: {}, - - // The following elements (space-suffixed to avoid Object.prototype collisions) - // throw uncatchable exceptions if you attempt to set expando properties - noData: { - "applet ": true, - "embed ": true, - - // ...but Flash objects (which have this classid) *can* handle expandos - "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" - }, - - hasData: function( elem ) { - elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ]; - return !!elem && !isEmptyDataObject( elem ); - }, - - data: function( elem, name, data ) { - return internalData( elem, name, data ); - }, - - removeData: function( elem, name ) { - return internalRemoveData( elem, name ); - }, - - // For internal use only. - _data: function( elem, name, data ) { - return internalData( elem, name, data, true ); - }, - - _removeData: function( elem, name ) { - return internalRemoveData( elem, name, true ); - } -} ); - -jQuery.fn.extend( { - data: function( key, value ) { - var i, name, data, - elem = this[ 0 ], - attrs = elem && elem.attributes; - - // Special expections of .data basically thwart jQuery.access, - // so implement the relevant behavior ourselves - - // Gets all values - if ( key === undefined ) { - if ( this.length ) { - data = jQuery.data( elem ); - - if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { - i = attrs.length; - while ( i-- ) { - - // Support: IE11+ - // The attrs elements can be null (#14894) - if ( attrs[ i ] ) { - name = attrs[ i ].name; - if ( name.indexOf( "data-" ) === 0 ) { - name = jQuery.camelCase( name.slice( 5 ) ); - dataAttr( elem, name, data[ name ] ); - } - } - } - jQuery._data( elem, "parsedAttrs", true ); - } - } - - return data; - } - - // Sets multiple values - if ( typeof key === "object" ) { - return this.each( function() { - jQuery.data( this, key ); - } ); - } - - return arguments.length > 1 ? - - // Sets one value - this.each( function() { - jQuery.data( this, key, value ); - } ) : - - // Gets one value - // Try to fetch any internally stored data first - elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined; - }, - - removeData: function( key ) { - return this.each( function() { - jQuery.removeData( this, key ); - } ); - } -} ); - - -jQuery.extend( { - queue: function( elem, type, data ) { - var queue; - - if ( elem ) { - type = ( type || "fx" ) + "queue"; - queue = jQuery._data( elem, type ); - - // Speed up dequeue by getting out quickly if this is just a lookup - if ( data ) { - if ( !queue || jQuery.isArray( data ) ) { - queue = jQuery._data( elem, type, jQuery.makeArray( data ) ); - } else { - queue.push( data ); - } - } - return queue || []; - } - }, - - dequeue: function( elem, type ) { - type = type || "fx"; - - var queue = jQuery.queue( elem, type ), - startLength = queue.length, - fn = queue.shift(), - hooks = jQuery._queueHooks( elem, type ), - next = function() { - jQuery.dequeue( elem, type ); - }; - - // If the fx queue is dequeued, always remove the progress sentinel - if ( fn === "inprogress" ) { - fn = queue.shift(); - startLength--; - } - - if ( fn ) { - - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if ( type === "fx" ) { - queue.unshift( "inprogress" ); - } - - // clear up the last queue stop function - delete hooks.stop; - fn.call( elem, next, hooks ); - } - - if ( !startLength && hooks ) { - hooks.empty.fire(); - } - }, - - // not intended for public consumption - generates a queueHooks object, - // or returns the current one - _queueHooks: function( elem, type ) { - var key = type + "queueHooks"; - return jQuery._data( elem, key ) || jQuery._data( elem, key, { - empty: jQuery.Callbacks( "once memory" ).add( function() { - jQuery._removeData( elem, type + "queue" ); - jQuery._removeData( elem, key ); - } ) - } ); - } -} ); - -jQuery.fn.extend( { - queue: function( type, data ) { - var setter = 2; - - if ( typeof type !== "string" ) { - data = type; - type = "fx"; - setter--; - } - - if ( arguments.length < setter ) { - return jQuery.queue( this[ 0 ], type ); - } - - return data === undefined ? - this : - this.each( function() { - var queue = jQuery.queue( this, type, data ); - - // ensure a hooks for this queue - jQuery._queueHooks( this, type ); - - if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - } ); - }, - dequeue: function( type ) { - return this.each( function() { - jQuery.dequeue( this, type ); - } ); - }, - clearQueue: function( type ) { - return this.queue( type || "fx", [] ); - }, - - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function( type, obj ) { - var tmp, - count = 1, - defer = jQuery.Deferred(), - elements = this, - i = this.length, - resolve = function() { - if ( !( --count ) ) { - defer.resolveWith( elements, [ elements ] ); - } - }; - - if ( typeof type !== "string" ) { - obj = type; - type = undefined; - } - type = type || "fx"; - - while ( i-- ) { - tmp = jQuery._data( elements[ i ], type + "queueHooks" ); - if ( tmp && tmp.empty ) { - count++; - tmp.empty.add( resolve ); - } - } - resolve(); - return defer.promise( obj ); - } -} ); - - -( function() { - var shrinkWrapBlocksVal; - - support.shrinkWrapBlocks = function() { - if ( shrinkWrapBlocksVal != null ) { - return shrinkWrapBlocksVal; - } - - // Will be changed later if needed. - shrinkWrapBlocksVal = false; - - // Minified: var b,c,d - var div, body, container; - - body = document.getElementsByTagName( "body" )[ 0 ]; - if ( !body || !body.style ) { - - // Test fired too early or in an unsupported environment, exit. - return; - } - - // Setup - div = document.createElement( "div" ); - container = document.createElement( "div" ); - container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px"; - body.appendChild( container ).appendChild( div ); - - // Support: IE6 - // Check if elements with layout shrink-wrap their children - if ( typeof div.style.zoom !== "undefined" ) { - - // Reset CSS: box-sizing; display; margin; border - div.style.cssText = - - // Support: Firefox<29, Android 2.3 - // Vendor-prefix box-sizing - "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" + - "box-sizing:content-box;display:block;margin:0;border:0;" + - "padding:1px;width:1px;zoom:1"; - div.appendChild( document.createElement( "div" ) ).style.width = "5px"; - shrinkWrapBlocksVal = div.offsetWidth !== 3; - } - - body.removeChild( container ); - - return shrinkWrapBlocksVal; - }; - -} )(); -var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; - -var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); - - -var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; - -var isHidden = function( elem, el ) { - - // isHidden might be called from jQuery#filter function; - // in that case, element will be second argument - elem = el || elem; - return jQuery.css( elem, "display" ) === "none" || - !jQuery.contains( elem.ownerDocument, elem ); - }; - - - -function adjustCSS( elem, prop, valueParts, tween ) { - var adjusted, - scale = 1, - maxIterations = 20, - currentValue = tween ? - function() { return tween.cur(); } : - function() { return jQuery.css( elem, prop, "" ); }, - initial = currentValue(), - unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), - - // Starting value computation is required for potential unit mismatches - initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && - rcssNum.exec( jQuery.css( elem, prop ) ); - - if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { - - // Trust units reported by jQuery.css - unit = unit || initialInUnit[ 3 ]; - - // Make sure we update the tween properties later on - valueParts = valueParts || []; - - // Iteratively approximate from a nonzero starting point - initialInUnit = +initial || 1; - - do { - - // If previous iteration zeroed out, double until we get *something*. - // Use string for doubling so we don't accidentally see scale as unchanged below - scale = scale || ".5"; - - // Adjust and apply - initialInUnit = initialInUnit / scale; - jQuery.style( elem, prop, initialInUnit + unit ); - - // Update scale, tolerating zero or NaN from tween.cur() - // Break the loop if scale is unchanged or perfect, or if we've just had enough. - } while ( - scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations - ); - } - - if ( valueParts ) { - initialInUnit = +initialInUnit || +initial || 0; - - // Apply relative offset (+=/-=) if specified - adjusted = valueParts[ 1 ] ? - initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : - +valueParts[ 2 ]; - if ( tween ) { - tween.unit = unit; - tween.start = initialInUnit; - tween.end = adjusted; - } - } - return adjusted; -} - - -// Multifunctional method to get and set values of a collection -// The value/s can optionally be executed if it's a function -var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { - var i = 0, - length = elems.length, - bulk = key == null; - - // Sets many values - if ( jQuery.type( key ) === "object" ) { - chainable = true; - for ( i in key ) { - access( elems, fn, i, key[ i ], true, emptyGet, raw ); - } - - // Sets one value - } else if ( value !== undefined ) { - chainable = true; - - if ( !jQuery.isFunction( value ) ) { - raw = true; - } - - if ( bulk ) { - - // Bulk operations run against the entire set - if ( raw ) { - fn.call( elems, value ); - fn = null; - - // ...except when executing function values - } else { - bulk = fn; - fn = function( elem, key, value ) { - return bulk.call( jQuery( elem ), value ); - }; - } - } - - if ( fn ) { - for ( ; i < length; i++ ) { - fn( - elems[ i ], - key, - raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) ) - ); - } - } - } - - return chainable ? - elems : - - // Gets - bulk ? - fn.call( elems ) : - length ? fn( elems[ 0 ], key ) : emptyGet; -}; -var rcheckableType = ( /^(?:checkbox|radio)$/i ); - -var rtagName = ( /<([\w:-]+)/ ); - -var rscriptType = ( /^$|\/(?:java|ecma)script/i ); - -var rleadingWhitespace = ( /^\s+/ ); - -var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" + - "details|dialog|figcaption|figure|footer|header|hgroup|main|" + - "mark|meter|nav|output|picture|progress|section|summary|template|time|video"; - - - -function createSafeFragment( document ) { - var list = nodeNames.split( "|" ), - safeFrag = document.createDocumentFragment(); - - if ( safeFrag.createElement ) { - while ( list.length ) { - safeFrag.createElement( - list.pop() - ); - } - } - return safeFrag; -} - - -( function() { - var div = document.createElement( "div" ), - fragment = document.createDocumentFragment(), - input = document.createElement( "input" ); - - // Setup - div.innerHTML = "
    a"; - - // IE strips leading whitespace when .innerHTML is used - support.leadingWhitespace = div.firstChild.nodeType === 3; - - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - support.tbody = !div.getElementsByTagName( "tbody" ).length; - - // Make sure that link elements get serialized correctly by innerHTML - // This requires a wrapper element in IE - support.htmlSerialize = !!div.getElementsByTagName( "link" ).length; - - // Makes sure cloning an html5 element does not cause problems - // Where outerHTML is undefined, this still works - support.html5Clone = - document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav>"; - - // Check if a disconnected checkbox will retain its checked - // value of true after appended to the DOM (IE6/7) - input.type = "checkbox"; - input.checked = true; - fragment.appendChild( input ); - support.appendChecked = input.checked; - - // Make sure textarea (and checkbox) defaultValue is properly cloned - // Support: IE6-IE11+ - div.innerHTML = ""; - support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; - - // #11217 - WebKit loses check when the name is after the checked attribute - fragment.appendChild( div ); - - // Support: Windows Web Apps (WWA) - // `name` and `type` must use .setAttribute for WWA (#14901) - input = document.createElement( "input" ); - input.setAttribute( "type", "radio" ); - input.setAttribute( "checked", "checked" ); - input.setAttribute( "name", "t" ); - - div.appendChild( input ); - - // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 - // old WebKit doesn't clone checked state correctly in fragments - support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; - - // Support: IE<9 - // Cloned elements keep attachEvent handlers, we use addEventListener on IE9+ - support.noCloneEvent = !!div.addEventListener; - - // Support: IE<9 - // Since attributes and properties are the same in IE, - // cleanData must set properties to undefined rather than use removeAttribute - div[ jQuery.expando ] = 1; - support.attributes = !div.getAttribute( jQuery.expando ); -} )(); - - -// We have to close these tags to support XHTML (#13200) -var wrapMap = { - option: [ 1, "" ], - legend: [ 1, "
    ", "
    " ], - area: [ 1, "", "" ], - - // Support: IE8 - param: [ 1, "", "" ], - thead: [ 1, "", "
    " ], - tr: [ 2, "", "
    " ], - col: [ 2, "", "
    " ], - td: [ 3, "", "
    " ], - - // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, - // unless wrapped in a div with non-breaking characters in front of it. - _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X
    ", "
    " ] -}; - -// Support: IE8-IE9 -wrapMap.optgroup = wrapMap.option; - -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; -wrapMap.th = wrapMap.td; - - -function getAll( context, tag ) { - var elems, elem, - i = 0, - found = typeof context.getElementsByTagName !== "undefined" ? - context.getElementsByTagName( tag || "*" ) : - typeof context.querySelectorAll !== "undefined" ? - context.querySelectorAll( tag || "*" ) : - undefined; - - if ( !found ) { - for ( found = [], elems = context.childNodes || context; - ( elem = elems[ i ] ) != null; - i++ - ) { - if ( !tag || jQuery.nodeName( elem, tag ) ) { - found.push( elem ); - } else { - jQuery.merge( found, getAll( elem, tag ) ); - } - } - } - - return tag === undefined || tag && jQuery.nodeName( context, tag ) ? - jQuery.merge( [ context ], found ) : - found; -} - - -// Mark scripts as having already been evaluated -function setGlobalEval( elems, refElements ) { - var elem, - i = 0; - for ( ; ( elem = elems[ i ] ) != null; i++ ) { - jQuery._data( - elem, - "globalEval", - !refElements || jQuery._data( refElements[ i ], "globalEval" ) - ); - } -} - - -var rhtml = /<|&#?\w+;/, - rtbody = / from table fragments - if ( !support.tbody ) { - - // String was a , *may* have spurious - elem = tag === "table" && !rtbody.test( elem ) ? - tmp.firstChild : - - // String was a bare or - wrap[ 1 ] === "
    " && !rtbody.test( elem ) ? - tmp : - 0; - - j = elem && elem.childNodes.length; - while ( j-- ) { - if ( jQuery.nodeName( ( tbody = elem.childNodes[ j ] ), "tbody" ) && - !tbody.childNodes.length ) { - - elem.removeChild( tbody ); - } - } - } - - jQuery.merge( nodes, tmp.childNodes ); - - // Fix #12392 for WebKit and IE > 9 - tmp.textContent = ""; - - // Fix #12392 for oldIE - while ( tmp.firstChild ) { - tmp.removeChild( tmp.firstChild ); - } - - // Remember the top-level container for proper cleanup - tmp = safe.lastChild; - } - } - } - - // Fix #11356: Clear elements from fragment - if ( tmp ) { - safe.removeChild( tmp ); - } - - // Reset defaultChecked for any radios and checkboxes - // about to be appended to the DOM in IE 6/7 (#8060) - if ( !support.appendChecked ) { - jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); - } - - i = 0; - while ( ( elem = nodes[ i++ ] ) ) { - - // Skip elements already in the context collection (trac-4087) - if ( selection && jQuery.inArray( elem, selection ) > -1 ) { - if ( ignored ) { - ignored.push( elem ); - } - - continue; - } - - contains = jQuery.contains( elem.ownerDocument, elem ); - - // Append to fragment - tmp = getAll( safe.appendChild( elem ), "script" ); - - // Preserve script evaluation history - if ( contains ) { - setGlobalEval( tmp ); - } - - // Capture executables - if ( scripts ) { - j = 0; - while ( ( elem = tmp[ j++ ] ) ) { - if ( rscriptType.test( elem.type || "" ) ) { - scripts.push( elem ); - } - } - } - } - - tmp = null; - - return safe; -} - - -( function() { - var i, eventName, - div = document.createElement( "div" ); - - // Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events) - for ( i in { submit: true, change: true, focusin: true } ) { - eventName = "on" + i; - - if ( !( support[ i ] = eventName in window ) ) { - - // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) - div.setAttribute( eventName, "t" ); - support[ i ] = div.attributes[ eventName ].expando === false; - } - } - - // Null elements to avoid leaks in IE. - div = null; -} )(); - - -var rformElems = /^(?:input|select|textarea)$/i, - rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, - rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - rtypenamespace = /^([^.]*)(?:\.(.+)|)/; - -function returnTrue() { - return true; -} - -function returnFalse() { - return false; -} - -// Support: IE9 -// See #13393 for more info -function safeActiveElement() { - try { - return document.activeElement; - } catch ( err ) { } -} - -function on( elem, types, selector, data, fn, one ) { - var origFn, type; - - // Types can be a map of types/handlers - if ( typeof types === "object" ) { - - // ( types-Object, selector, data ) - if ( typeof selector !== "string" ) { - - // ( types-Object, data ) - data = data || selector; - selector = undefined; - } - for ( type in types ) { - on( elem, type, selector, data, types[ type ], one ); - } - return elem; - } - - if ( data == null && fn == null ) { - - // ( types, fn ) - fn = selector; - data = selector = undefined; - } else if ( fn == null ) { - if ( typeof selector === "string" ) { - - // ( types, selector, fn ) - fn = data; - data = undefined; - } else { - - // ( types, data, fn ) - fn = data; - data = selector; - selector = undefined; - } - } - if ( fn === false ) { - fn = returnFalse; - } else if ( !fn ) { - return elem; - } - - if ( one === 1 ) { - origFn = fn; - fn = function( event ) { - - // Can use an empty set, since event contains the info - jQuery().off( event ); - return origFn.apply( this, arguments ); - }; - - // Use same guid so caller can remove using origFn - fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); - } - return elem.each( function() { - jQuery.event.add( this, types, fn, data, selector ); - } ); -} - -/* - * Helper functions for managing events -- not part of the public interface. - * Props to Dean Edwards' addEvent library for many of the ideas. - */ -jQuery.event = { - - global: {}, - - add: function( elem, types, handler, data, selector ) { - var tmp, events, t, handleObjIn, - special, eventHandle, handleObj, - handlers, type, namespaces, origType, - elemData = jQuery._data( elem ); - - // Don't attach events to noData or text/comment nodes (but allow plain objects) - if ( !elemData ) { - return; - } - - // Caller can pass in an object of custom data in lieu of the handler - if ( handler.handler ) { - handleObjIn = handler; - handler = handleObjIn.handler; - selector = handleObjIn.selector; - } - - // Make sure that the handler has a unique ID, used to find/remove it later - if ( !handler.guid ) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure and main handler, if this is the first - if ( !( events = elemData.events ) ) { - events = elemData.events = {}; - } - if ( !( eventHandle = elemData.handle ) ) { - eventHandle = elemData.handle = function( e ) { - - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== "undefined" && - ( !e || jQuery.event.triggered !== e.type ) ? - jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : - undefined; - }; - - // Add elem as a property of the handle fn to prevent a memory leak - // with IE non-native events - eventHandle.elem = elem; - } - - // Handle multiple events separated by a space - types = ( types || "" ).match( rnotwhite ) || [ "" ]; - t = types.length; - while ( t-- ) { - tmp = rtypenamespace.exec( types[ t ] ) || []; - type = origType = tmp[ 1 ]; - namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); - - // There *must* be a type, no attaching namespace-only handlers - if ( !type ) { - continue; - } - - // If event changes its type, use the special event handlers for the changed type - special = jQuery.event.special[ type ] || {}; - - // If selector defined, determine special event api type, otherwise given type - type = ( selector ? special.delegateType : special.bindType ) || type; - - // Update special based on newly reset type - special = jQuery.event.special[ type ] || {}; - - // handleObj is passed to all event handlers - handleObj = jQuery.extend( { - type: type, - origType: origType, - data: data, - handler: handler, - guid: handler.guid, - selector: selector, - needsContext: selector && jQuery.expr.match.needsContext.test( selector ), - namespace: namespaces.join( "." ) - }, handleObjIn ); - - // Init the event handler queue if we're the first - if ( !( handlers = events[ type ] ) ) { - handlers = events[ type ] = []; - handlers.delegateCount = 0; - - // Only use addEventListener/attachEvent if the special events handler returns false - if ( !special.setup || - special.setup.call( elem, data, namespaces, eventHandle ) === false ) { - - // Bind the global event handler to the element - if ( elem.addEventListener ) { - elem.addEventListener( type, eventHandle, false ); - - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, eventHandle ); - } - } - } - - if ( special.add ) { - special.add.call( elem, handleObj ); - - if ( !handleObj.handler.guid ) { - handleObj.handler.guid = handler.guid; - } - } - - // Add to the element's handler list, delegates in front - if ( selector ) { - handlers.splice( handlers.delegateCount++, 0, handleObj ); - } else { - handlers.push( handleObj ); - } - - // Keep track of which events have ever been used, for event optimization - jQuery.event.global[ type ] = true; - } - - // Nullify elem to prevent memory leaks in IE - elem = null; - }, - - // Detach an event or set of events from an element - remove: function( elem, types, handler, selector, mappedTypes ) { - var j, handleObj, tmp, - origCount, t, events, - special, handlers, type, - namespaces, origType, - elemData = jQuery.hasData( elem ) && jQuery._data( elem ); - - if ( !elemData || !( events = elemData.events ) ) { - return; - } - - // Once for each type.namespace in types; type may be omitted - types = ( types || "" ).match( rnotwhite ) || [ "" ]; - t = types.length; - while ( t-- ) { - tmp = rtypenamespace.exec( types[ t ] ) || []; - type = origType = tmp[ 1 ]; - namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); - - // Unbind all events (on this namespace, if provided) for the element - if ( !type ) { - for ( type in events ) { - jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); - } - continue; - } - - special = jQuery.event.special[ type ] || {}; - type = ( selector ? special.delegateType : special.bindType ) || type; - handlers = events[ type ] || []; - tmp = tmp[ 2 ] && - new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); - - // Remove matching events - origCount = j = handlers.length; - while ( j-- ) { - handleObj = handlers[ j ]; - - if ( ( mappedTypes || origType === handleObj.origType ) && - ( !handler || handler.guid === handleObj.guid ) && - ( !tmp || tmp.test( handleObj.namespace ) ) && - ( !selector || selector === handleObj.selector || - selector === "**" && handleObj.selector ) ) { - handlers.splice( j, 1 ); - - if ( handleObj.selector ) { - handlers.delegateCount--; - } - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } - } - } - - // Remove generic event handler if we removed something and no more handlers exist - // (avoids potential for endless recursion during removal of special event handlers) - if ( origCount && !handlers.length ) { - if ( !special.teardown || - special.teardown.call( elem, namespaces, elemData.handle ) === false ) { - - jQuery.removeEvent( elem, type, elemData.handle ); - } - - delete events[ type ]; - } - } - - // Remove the expando if it's no longer used - if ( jQuery.isEmptyObject( events ) ) { - delete elemData.handle; - - // removeData also checks for emptiness and clears the expando if empty - // so use it instead of delete - jQuery._removeData( elem, "events" ); - } - }, - - trigger: function( event, data, elem, onlyHandlers ) { - var handle, ontype, cur, - bubbleType, special, tmp, i, - eventPath = [ elem || document ], - type = hasOwn.call( event, "type" ) ? event.type : event, - namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; - - cur = tmp = elem = elem || document; - - // Don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } - - // focus/blur morphs to focusin/out; ensure we're not firing them right now - if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { - return; - } - - if ( type.indexOf( "." ) > -1 ) { - - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split( "." ); - type = namespaces.shift(); - namespaces.sort(); - } - ontype = type.indexOf( ":" ) < 0 && "on" + type; - - // Caller can pass in a jQuery.Event object, Object, or just an event type string - event = event[ jQuery.expando ] ? - event : - new jQuery.Event( type, typeof event === "object" && event ); - - // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) - event.isTrigger = onlyHandlers ? 2 : 3; - event.namespace = namespaces.join( "." ); - event.rnamespace = event.namespace ? - new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : - null; - - // Clean up the event in case it is being reused - event.result = undefined; - if ( !event.target ) { - event.target = elem; - } - - // Clone any incoming data and prepend the event, creating the handler arg list - data = data == null ? - [ event ] : - jQuery.makeArray( data, [ event ] ); - - // Allow special events to draw outside the lines - special = jQuery.event.special[ type ] || {}; - if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { - return; - } - - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { - - bubbleType = special.delegateType || type; - if ( !rfocusMorph.test( bubbleType + type ) ) { - cur = cur.parentNode; - } - for ( ; cur; cur = cur.parentNode ) { - eventPath.push( cur ); - tmp = cur; - } - - // Only add window if we got to document (e.g., not plain obj or detached DOM) - if ( tmp === ( elem.ownerDocument || document ) ) { - eventPath.push( tmp.defaultView || tmp.parentWindow || window ); - } - } - - // Fire handlers on the event path - i = 0; - while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { - - event.type = i > 1 ? - bubbleType : - special.bindType || type; - - // jQuery handler - handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && - jQuery._data( cur, "handle" ); - - if ( handle ) { - handle.apply( cur, data ); - } - - // Native handler - handle = ontype && cur[ ontype ]; - if ( handle && handle.apply && acceptData( cur ) ) { - event.result = handle.apply( cur, data ); - if ( event.result === false ) { - event.preventDefault(); - } - } - } - event.type = type; - - // If nobody prevented the default action, do it now - if ( !onlyHandlers && !event.isDefaultPrevented() ) { - - if ( - ( !special._default || - special._default.apply( eventPath.pop(), data ) === false - ) && acceptData( elem ) - ) { - - // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction() check here because IE6/7 fails that test. - // Don't do default actions on window, that's where global variables be (#6170) - if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { - - // Don't re-trigger an onFOO event when we call its FOO() method - tmp = elem[ ontype ]; - - if ( tmp ) { - elem[ ontype ] = null; - } - - // Prevent re-triggering of the same event, since we already bubbled it above - jQuery.event.triggered = type; - try { - elem[ type ](); - } catch ( e ) { - - // IE<9 dies on focus/blur to hidden element (#1486,#12518) - // only reproducible on winXP IE8 native, not IE9 in IE8 mode - } - jQuery.event.triggered = undefined; - - if ( tmp ) { - elem[ ontype ] = tmp; - } - } - } - } - - return event.result; - }, - - dispatch: function( event ) { - - // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix( event ); - - var i, j, ret, matched, handleObj, - handlerQueue = [], - args = slice.call( arguments ), - handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [], - special = jQuery.event.special[ event.type ] || {}; - - // Use the fix-ed jQuery.Event rather than the (read-only) native event - args[ 0 ] = event; - event.delegateTarget = this; - - // Call the preDispatch hook for the mapped type, and let it bail if desired - if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { - return; - } - - // Determine handlers - handlerQueue = jQuery.event.handlers.call( this, event, handlers ); - - // Run delegates first; they may want to stop propagation beneath us - i = 0; - while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { - event.currentTarget = matched.elem; - - j = 0; - while ( ( handleObj = matched.handlers[ j++ ] ) && - !event.isImmediatePropagationStopped() ) { - - // Triggered event must either 1) have no namespace, or 2) have namespace(s) - // a subset or equal to those in the bound event (both can have no namespace). - if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { - - event.handleObj = handleObj; - event.data = handleObj.data; - - ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || - handleObj.handler ).apply( matched.elem, args ); - - if ( ret !== undefined ) { - if ( ( event.result = ret ) === false ) { - event.preventDefault(); - event.stopPropagation(); - } - } - } - } - } - - // Call the postDispatch hook for the mapped type - if ( special.postDispatch ) { - special.postDispatch.call( this, event ); - } - - return event.result; - }, - - handlers: function( event, handlers ) { - var i, matches, sel, handleObj, - handlerQueue = [], - delegateCount = handlers.delegateCount, - cur = event.target; - - // Support (at least): Chrome, IE9 - // Find delegate handlers - // Black-hole SVG instance trees (#13180) - // - // Support: Firefox<=42+ - // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343) - if ( delegateCount && cur.nodeType && - ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) { - - /* jshint eqeqeq: false */ - for ( ; cur != this; cur = cur.parentNode || this ) { - /* jshint eqeqeq: true */ - - // Don't check non-elements (#13208) - // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) - if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) { - matches = []; - for ( i = 0; i < delegateCount; i++ ) { - handleObj = handlers[ i ]; - - // Don't conflict with Object.prototype properties (#13203) - sel = handleObj.selector + " "; - - if ( matches[ sel ] === undefined ) { - matches[ sel ] = handleObj.needsContext ? - jQuery( sel, this ).index( cur ) > -1 : - jQuery.find( sel, this, null, [ cur ] ).length; - } - if ( matches[ sel ] ) { - matches.push( handleObj ); - } - } - if ( matches.length ) { - handlerQueue.push( { elem: cur, handlers: matches } ); - } - } - } - } - - // Add the remaining (directly-bound) handlers - if ( delegateCount < handlers.length ) { - handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } ); - } - - return handlerQueue; - }, - - fix: function( event ) { - if ( event[ jQuery.expando ] ) { - return event; - } - - // Create a writable copy of the event object and normalize some properties - var i, prop, copy, - type = event.type, - originalEvent = event, - fixHook = this.fixHooks[ type ]; - - if ( !fixHook ) { - this.fixHooks[ type ] = fixHook = - rmouseEvent.test( type ) ? this.mouseHooks : - rkeyEvent.test( type ) ? this.keyHooks : - {}; - } - copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; - - event = new jQuery.Event( originalEvent ); - - i = copy.length; - while ( i-- ) { - prop = copy[ i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Support: IE<9 - // Fix target property (#1925) - if ( !event.target ) { - event.target = originalEvent.srcElement || document; - } - - // Support: Safari 6-8+ - // Target should not be a text node (#504, #13143) - if ( event.target.nodeType === 3 ) { - event.target = event.target.parentNode; - } - - // Support: IE<9 - // For mouse/key events, metaKey==false if it's undefined (#3368, #11328) - event.metaKey = !!event.metaKey; - - return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; - }, - - // Includes some event props shared by KeyEvent and MouseEvent - props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " + - "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ), - - fixHooks: {}, - - keyHooks: { - props: "char charCode key keyCode".split( " " ), - filter: function( event, original ) { - - // Add which for key events - if ( event.which == null ) { - event.which = original.charCode != null ? original.charCode : original.keyCode; - } - - return event; - } - }, - - mouseHooks: { - props: ( "button buttons clientX clientY fromElement offsetX offsetY " + - "pageX pageY screenX screenY toElement" ).split( " " ), - filter: function( event, original ) { - var body, eventDoc, doc, - button = original.button, - fromElement = original.fromElement; - - // Calculate pageX/Y if missing and clientX/Y available - if ( event.pageX == null && original.clientX != null ) { - eventDoc = event.target.ownerDocument || document; - doc = eventDoc.documentElement; - body = eventDoc.body; - - event.pageX = original.clientX + - ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); - event.pageY = original.clientY + - ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - - ( doc && doc.clientTop || body && body.clientTop || 0 ); - } - - // Add relatedTarget, if necessary - if ( !event.relatedTarget && fromElement ) { - event.relatedTarget = fromElement === event.target ? - original.toElement : - fromElement; - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if ( !event.which && button !== undefined ) { - event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); - } - - return event; - } - }, - - special: { - load: { - - // Prevent triggered image.load events from bubbling to window.load - noBubble: true - }, - focus: { - - // Fire native event if possible so blur/focus sequence is correct - trigger: function() { - if ( this !== safeActiveElement() && this.focus ) { - try { - this.focus(); - return false; - } catch ( e ) { - - // Support: IE<9 - // If we error on focus to hidden element (#1486, #12518), - // let .trigger() run the handlers - } - } - }, - delegateType: "focusin" - }, - blur: { - trigger: function() { - if ( this === safeActiveElement() && this.blur ) { - this.blur(); - return false; - } - }, - delegateType: "focusout" - }, - click: { - - // For checkbox, fire native event so checked state will be right - trigger: function() { - if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { - this.click(); - return false; - } - }, - - // For cross-browser consistency, don't fire native .click() on links - _default: function( event ) { - return jQuery.nodeName( event.target, "a" ); - } - }, - - beforeunload: { - postDispatch: function( event ) { - - // Support: Firefox 20+ - // Firefox doesn't alert if the returnValue field is not set. - if ( event.result !== undefined && event.originalEvent ) { - event.originalEvent.returnValue = event.result; - } - } - } - }, - - // Piggyback on a donor event to simulate a different one - simulate: function( type, elem, event ) { - var e = jQuery.extend( - new jQuery.Event(), - event, - { - type: type, - isSimulated: true - - // Previously, `originalEvent: {}` was set here, so stopPropagation call - // would not be triggered on donor event, since in our own - // jQuery.event.stopPropagation function we had a check for existence of - // originalEvent.stopPropagation method, so, consequently it would be a noop. - // - // Guard for simulated events was moved to jQuery.event.stopPropagation function - // since `originalEvent` should point to the original event for the - // constancy with other events and for more focused logic - } - ); - - jQuery.event.trigger( e, null, elem ); - - if ( e.isDefaultPrevented() ) { - event.preventDefault(); - } - } -}; - -jQuery.removeEvent = document.removeEventListener ? - function( elem, type, handle ) { - - // This "if" is needed for plain objects - if ( elem.removeEventListener ) { - elem.removeEventListener( type, handle ); - } - } : - function( elem, type, handle ) { - var name = "on" + type; - - if ( elem.detachEvent ) { - - // #8545, #7054, preventing memory leaks for custom events in IE6-8 - // detachEvent needed property on element, by name of that event, - // to properly expose it to GC - if ( typeof elem[ name ] === "undefined" ) { - elem[ name ] = null; - } - - elem.detachEvent( name, handle ); - } - }; - -jQuery.Event = function( src, props ) { - - // Allow instantiation without the 'new' keyword - if ( !( this instanceof jQuery.Event ) ) { - return new jQuery.Event( src, props ); - } - - // Event object - if ( src && src.type ) { - this.originalEvent = src; - this.type = src.type; - - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = src.defaultPrevented || - src.defaultPrevented === undefined && - - // Support: IE < 9, Android < 4.0 - src.returnValue === false ? - returnTrue : - returnFalse; - - // Event type - } else { - this.type = src; - } - - // Put explicitly provided properties onto the event object - if ( props ) { - jQuery.extend( this, props ); - } - - // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || jQuery.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; -}; - -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html -jQuery.Event.prototype = { - constructor: jQuery.Event, - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse, - - preventDefault: function() { - var e = this.originalEvent; - - this.isDefaultPrevented = returnTrue; - if ( !e ) { - return; - } - - // If preventDefault exists, run it on the original event - if ( e.preventDefault ) { - e.preventDefault(); - - // Support: IE - // Otherwise set the returnValue property of the original event to false - } else { - e.returnValue = false; - } - }, - stopPropagation: function() { - var e = this.originalEvent; - - this.isPropagationStopped = returnTrue; - - if ( !e || this.isSimulated ) { - return; - } - - // If stopPropagation exists, run it on the original event - if ( e.stopPropagation ) { - e.stopPropagation(); - } - - // Support: IE - // Set the cancelBubble property of the original event to true - e.cancelBubble = true; - }, - stopImmediatePropagation: function() { - var e = this.originalEvent; - - this.isImmediatePropagationStopped = returnTrue; - - if ( e && e.stopImmediatePropagation ) { - e.stopImmediatePropagation(); - } - - this.stopPropagation(); - } -}; - -// Create mouseenter/leave events using mouseover/out and event-time checks -// so that event delegation works in jQuery. -// Do the same for pointerenter/pointerleave and pointerover/pointerout -// -// Support: Safari 7 only -// Safari sends mouseenter too often; see: -// https://code.google.com/p/chromium/issues/detail?id=470258 -// for the description of the bug (it existed in older Chrome versions as well). -jQuery.each( { - mouseenter: "mouseover", - mouseleave: "mouseout", - pointerenter: "pointerover", - pointerleave: "pointerout" -}, function( orig, fix ) { - jQuery.event.special[ orig ] = { - delegateType: fix, - bindType: fix, - - handle: function( event ) { - var ret, - target = this, - related = event.relatedTarget, - handleObj = event.handleObj; - - // For mouseenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { - event.type = handleObj.origType; - ret = handleObj.handler.apply( this, arguments ); - event.type = fix; - } - return ret; - } - }; -} ); - -// IE submit delegation -if ( !support.submit ) { - - jQuery.event.special.submit = { - setup: function() { - - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Lazy-add a submit handler when a descendant form may potentially be submitted - jQuery.event.add( this, "click._submit keypress._submit", function( e ) { - - // Node name check avoids a VML-related crash in IE (#9807) - var elem = e.target, - form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? - - // Support: IE <=8 - // We use jQuery.prop instead of elem.form - // to allow fixing the IE8 delegated submit issue (gh-2332) - // by 3rd party polyfills/workarounds. - jQuery.prop( elem, "form" ) : - undefined; - - if ( form && !jQuery._data( form, "submit" ) ) { - jQuery.event.add( form, "submit._submit", function( event ) { - event._submitBubble = true; - } ); - jQuery._data( form, "submit", true ); - } - } ); - - // return undefined since we don't need an event listener - }, - - postDispatch: function( event ) { - - // If form was submitted by the user, bubble the event up the tree - if ( event._submitBubble ) { - delete event._submitBubble; - if ( this.parentNode && !event.isTrigger ) { - jQuery.event.simulate( "submit", this.parentNode, event ); - } - } - }, - - teardown: function() { - - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Remove delegated handlers; cleanData eventually reaps submit handlers attached above - jQuery.event.remove( this, "._submit" ); - } - }; -} - -// IE change delegation and checkbox/radio fix -if ( !support.change ) { - - jQuery.event.special.change = { - - setup: function() { - - if ( rformElems.test( this.nodeName ) ) { - - // IE doesn't fire change on a check/radio until blur; trigger it on click - // after a propertychange. Eat the blur-change in special.change.handle. - // This still fires onchange a second time for check/radio after blur. - if ( this.type === "checkbox" || this.type === "radio" ) { - jQuery.event.add( this, "propertychange._change", function( event ) { - if ( event.originalEvent.propertyName === "checked" ) { - this._justChanged = true; - } - } ); - jQuery.event.add( this, "click._change", function( event ) { - if ( this._justChanged && !event.isTrigger ) { - this._justChanged = false; - } - - // Allow triggered, simulated change events (#11500) - jQuery.event.simulate( "change", this, event ); - } ); - } - return false; - } - - // Delegated event; lazy-add a change handler on descendant inputs - jQuery.event.add( this, "beforeactivate._change", function( e ) { - var elem = e.target; - - if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) { - jQuery.event.add( elem, "change._change", function( event ) { - if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { - jQuery.event.simulate( "change", this.parentNode, event ); - } - } ); - jQuery._data( elem, "change", true ); - } - } ); - }, - - handle: function( event ) { - var elem = event.target; - - // Swallow native change events from checkbox/radio, we already triggered them above - if ( this !== elem || event.isSimulated || event.isTrigger || - ( elem.type !== "radio" && elem.type !== "checkbox" ) ) { - - return event.handleObj.handler.apply( this, arguments ); - } - }, - - teardown: function() { - jQuery.event.remove( this, "._change" ); - - return !rformElems.test( this.nodeName ); - } - }; -} - -// Support: Firefox -// Firefox doesn't have focus(in | out) events -// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 -// -// Support: Chrome, Safari -// focus(in | out) events fire after focus & blur events, -// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order -// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857 -if ( !support.focusin ) { - jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { - - // Attach a single capturing handler on the document while someone wants focusin/focusout - var handler = function( event ) { - jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); - }; - - jQuery.event.special[ fix ] = { - setup: function() { - var doc = this.ownerDocument || this, - attaches = jQuery._data( doc, fix ); - - if ( !attaches ) { - doc.addEventListener( orig, handler, true ); - } - jQuery._data( doc, fix, ( attaches || 0 ) + 1 ); - }, - teardown: function() { - var doc = this.ownerDocument || this, - attaches = jQuery._data( doc, fix ) - 1; - - if ( !attaches ) { - doc.removeEventListener( orig, handler, true ); - jQuery._removeData( doc, fix ); - } else { - jQuery._data( doc, fix, attaches ); - } - } - }; - } ); -} - -jQuery.fn.extend( { - - on: function( types, selector, data, fn ) { - return on( this, types, selector, data, fn ); - }, - one: function( types, selector, data, fn ) { - return on( this, types, selector, data, fn, 1 ); - }, - off: function( types, selector, fn ) { - var handleObj, type; - if ( types && types.preventDefault && types.handleObj ) { - - // ( event ) dispatched jQuery.Event - handleObj = types.handleObj; - jQuery( types.delegateTarget ).off( - handleObj.namespace ? - handleObj.origType + "." + handleObj.namespace : - handleObj.origType, - handleObj.selector, - handleObj.handler - ); - return this; - } - if ( typeof types === "object" ) { - - // ( types-object [, selector] ) - for ( type in types ) { - this.off( type, selector, types[ type ] ); - } - return this; - } - if ( selector === false || typeof selector === "function" ) { - - // ( types [, fn] ) - fn = selector; - selector = undefined; - } - if ( fn === false ) { - fn = returnFalse; - } - return this.each( function() { - jQuery.event.remove( this, types, fn, selector ); - } ); - }, - - trigger: function( type, data ) { - return this.each( function() { - jQuery.event.trigger( type, data, this ); - } ); - }, - triggerHandler: function( type, data ) { - var elem = this[ 0 ]; - if ( elem ) { - return jQuery.event.trigger( type, data, elem, true ); - } - } -} ); - - -var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, - rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ), - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, - - // Support: IE 10-11, Edge 10240+ - // In IE/Edge using regex groups here causes severe slowdowns. - // See https://connect.microsoft.com/IE/feedback/details/1736512/ - rnoInnerhtml = /\s*$/g, - safeFragment = createSafeFragment( document ), - fragmentDiv = safeFragment.appendChild( document.createElement( "div" ) ); - -// Support: IE<8 -// Manipulating tables requires a tbody -function manipulationTarget( elem, content ) { - return jQuery.nodeName( elem, "table" ) && - jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? - - elem.getElementsByTagName( "tbody" )[ 0 ] || - elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) : - elem; -} - -// Replace/restore the type attribute of script elements for safe DOM manipulation -function disableScript( elem ) { - elem.type = ( jQuery.find.attr( elem, "type" ) !== null ) + "/" + elem.type; - return elem; -} -function restoreScript( elem ) { - var match = rscriptTypeMasked.exec( elem.type ); - if ( match ) { - elem.type = match[ 1 ]; - } else { - elem.removeAttribute( "type" ); - } - return elem; -} - -function cloneCopyEvent( src, dest ) { - if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { - return; - } - - var type, i, l, - oldData = jQuery._data( src ), - curData = jQuery._data( dest, oldData ), - events = oldData.events; - - if ( events ) { - delete curData.handle; - curData.events = {}; - - for ( type in events ) { - for ( i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type, events[ type ][ i ] ); - } - } - } - - // make the cloned public data object a copy from the original - if ( curData.data ) { - curData.data = jQuery.extend( {}, curData.data ); - } -} - -function fixCloneNodeIssues( src, dest ) { - var nodeName, e, data; - - // We do not need to do anything for non-Elements - if ( dest.nodeType !== 1 ) { - return; - } - - nodeName = dest.nodeName.toLowerCase(); - - // IE6-8 copies events bound via attachEvent when using cloneNode. - if ( !support.noCloneEvent && dest[ jQuery.expando ] ) { - data = jQuery._data( dest ); - - for ( e in data.events ) { - jQuery.removeEvent( dest, e, data.handle ); - } - - // Event data gets referenced instead of copied if the expando gets copied too - dest.removeAttribute( jQuery.expando ); - } - - // IE blanks contents when cloning scripts, and tries to evaluate newly-set text - if ( nodeName === "script" && dest.text !== src.text ) { - disableScript( dest ).text = src.text; - restoreScript( dest ); - - // IE6-10 improperly clones children of object elements using classid. - // IE10 throws NoModificationAllowedError if parent is null, #12132. - } else if ( nodeName === "object" ) { - if ( dest.parentNode ) { - dest.outerHTML = src.outerHTML; - } - - // This path appears unavoidable for IE9. When cloning an object - // element in IE9, the outerHTML strategy above is not sufficient. - // If the src has innerHTML and the destination does not, - // copy the src.innerHTML into the dest.innerHTML. #10324 - if ( support.html5Clone && ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) ) { - dest.innerHTML = src.innerHTML; - } - - } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { - - // IE6-8 fails to persist the checked state of a cloned checkbox - // or radio button. Worse, IE6-7 fail to give the cloned element - // a checked appearance if the defaultChecked value isn't also set - - dest.defaultChecked = dest.checked = src.checked; - - // IE6-7 get confused and end up setting the value of a cloned - // checkbox/radio button to an empty string instead of "on" - if ( dest.value !== src.value ) { - dest.value = src.value; - } - - // IE6-8 fails to return the selected option to the default selected - // state when cloning options - } else if ( nodeName === "option" ) { - dest.defaultSelected = dest.selected = src.defaultSelected; - - // IE6-8 fails to set the defaultValue to the correct value when - // cloning other types of input fields - } else if ( nodeName === "input" || nodeName === "textarea" ) { - dest.defaultValue = src.defaultValue; - } -} - -function domManip( collection, args, callback, ignored ) { - - // Flatten any nested arrays - args = concat.apply( [], args ); - - var first, node, hasScripts, - scripts, doc, fragment, - i = 0, - l = collection.length, - iNoClone = l - 1, - value = args[ 0 ], - isFunction = jQuery.isFunction( value ); - - // We can't cloneNode fragments that contain checked, in WebKit - if ( isFunction || - ( l > 1 && typeof value === "string" && - !support.checkClone && rchecked.test( value ) ) ) { - return collection.each( function( index ) { - var self = collection.eq( index ); - if ( isFunction ) { - args[ 0 ] = value.call( this, index, self.html() ); - } - domManip( self, args, callback, ignored ); - } ); - } - - if ( l ) { - fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); - first = fragment.firstChild; - - if ( fragment.childNodes.length === 1 ) { - fragment = first; - } - - // Require either new content or an interest in ignored elements to invoke the callback - if ( first || ignored ) { - scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); - hasScripts = scripts.length; - - // Use the original fragment for the last item - // instead of the first because it can end up - // being emptied incorrectly in certain situations (#8070). - for ( ; i < l; i++ ) { - node = fragment; - - if ( i !== iNoClone ) { - node = jQuery.clone( node, true, true ); - - // Keep references to cloned scripts for later restoration - if ( hasScripts ) { - - // Support: Android<4.1, PhantomJS<2 - // push.apply(_, arraylike) throws on ancient WebKit - jQuery.merge( scripts, getAll( node, "script" ) ); - } - } - - callback.call( collection[ i ], node, i ); - } - - if ( hasScripts ) { - doc = scripts[ scripts.length - 1 ].ownerDocument; - - // Reenable scripts - jQuery.map( scripts, restoreScript ); - - // Evaluate executable scripts on first document insertion - for ( i = 0; i < hasScripts; i++ ) { - node = scripts[ i ]; - if ( rscriptType.test( node.type || "" ) && - !jQuery._data( node, "globalEval" ) && - jQuery.contains( doc, node ) ) { - - if ( node.src ) { - - // Optional AJAX dependency, but won't run scripts if not present - if ( jQuery._evalUrl ) { - jQuery._evalUrl( node.src ); - } - } else { - jQuery.globalEval( - ( node.text || node.textContent || node.innerHTML || "" ) - .replace( rcleanScript, "" ) - ); - } - } - } - } - - // Fix #11809: Avoid leaking memory - fragment = first = null; - } - } - - return collection; -} - -function remove( elem, selector, keepData ) { - var node, - elems = selector ? jQuery.filter( selector, elem ) : elem, - i = 0; - - for ( ; ( node = elems[ i ] ) != null; i++ ) { - - if ( !keepData && node.nodeType === 1 ) { - jQuery.cleanData( getAll( node ) ); - } - - if ( node.parentNode ) { - if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { - setGlobalEval( getAll( node, "script" ) ); - } - node.parentNode.removeChild( node ); - } - } - - return elem; -} - -jQuery.extend( { - htmlPrefilter: function( html ) { - return html.replace( rxhtmlTag, "<$1>" ); - }, - - clone: function( elem, dataAndEvents, deepDataAndEvents ) { - var destElements, node, clone, i, srcElements, - inPage = jQuery.contains( elem.ownerDocument, elem ); - - if ( support.html5Clone || jQuery.isXMLDoc( elem ) || - !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { - - clone = elem.cloneNode( true ); - - // IE<=8 does not properly clone detached, unknown element nodes - } else { - fragmentDiv.innerHTML = elem.outerHTML; - fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); - } - - if ( ( !support.noCloneEvent || !support.noCloneChecked ) && - ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) { - - // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 - destElements = getAll( clone ); - srcElements = getAll( elem ); - - // Fix all IE cloning issues - for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) { - - // Ensure that the destination node is not null; Fixes #9587 - if ( destElements[ i ] ) { - fixCloneNodeIssues( node, destElements[ i ] ); - } - } - } - - // Copy the events from the original to the clone - if ( dataAndEvents ) { - if ( deepDataAndEvents ) { - srcElements = srcElements || getAll( elem ); - destElements = destElements || getAll( clone ); - - for ( i = 0; ( node = srcElements[ i ] ) != null; i++ ) { - cloneCopyEvent( node, destElements[ i ] ); - } - } else { - cloneCopyEvent( elem, clone ); - } - } - - // Preserve script evaluation history - destElements = getAll( clone, "script" ); - if ( destElements.length > 0 ) { - setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); - } - - destElements = srcElements = node = null; - - // Return the cloned set - return clone; - }, - - cleanData: function( elems, /* internal */ forceAcceptData ) { - var elem, type, id, data, - i = 0, - internalKey = jQuery.expando, - cache = jQuery.cache, - attributes = support.attributes, - special = jQuery.event.special; - - for ( ; ( elem = elems[ i ] ) != null; i++ ) { - if ( forceAcceptData || acceptData( elem ) ) { - - id = elem[ internalKey ]; - data = id && cache[ id ]; - - if ( data ) { - if ( data.events ) { - for ( type in data.events ) { - if ( special[ type ] ) { - jQuery.event.remove( elem, type ); - - // This is a shortcut to avoid jQuery.event.remove's overhead - } else { - jQuery.removeEvent( elem, type, data.handle ); - } - } - } - - // Remove cache only if it was not already removed by jQuery.event.remove - if ( cache[ id ] ) { - - delete cache[ id ]; - - // Support: IE<9 - // IE does not allow us to delete expando properties from nodes - // IE creates expando attributes along with the property - // IE does not have a removeAttribute function on Document nodes - if ( !attributes && typeof elem.removeAttribute !== "undefined" ) { - elem.removeAttribute( internalKey ); - - // Webkit & Blink performance suffers when deleting properties - // from DOM nodes, so set to undefined instead - // https://code.google.com/p/chromium/issues/detail?id=378607 - } else { - elem[ internalKey ] = undefined; - } - - deletedIds.push( id ); - } - } - } - } - } -} ); - -jQuery.fn.extend( { - - // Keep domManip exposed until 3.0 (gh-2225) - domManip: domManip, - - detach: function( selector ) { - return remove( this, selector, true ); - }, - - remove: function( selector ) { - return remove( this, selector ); - }, - - text: function( value ) { - return access( this, function( value ) { - return value === undefined ? - jQuery.text( this ) : - this.empty().append( - ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value ) - ); - }, null, value, arguments.length ); - }, - - append: function() { - return domManip( this, arguments, function( elem ) { - if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { - var target = manipulationTarget( this, elem ); - target.appendChild( elem ); - } - } ); - }, - - prepend: function() { - return domManip( this, arguments, function( elem ) { - if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { - var target = manipulationTarget( this, elem ); - target.insertBefore( elem, target.firstChild ); - } - } ); - }, - - before: function() { - return domManip( this, arguments, function( elem ) { - if ( this.parentNode ) { - this.parentNode.insertBefore( elem, this ); - } - } ); - }, - - after: function() { - return domManip( this, arguments, function( elem ) { - if ( this.parentNode ) { - this.parentNode.insertBefore( elem, this.nextSibling ); - } - } ); - }, - - empty: function() { - var elem, - i = 0; - - for ( ; ( elem = this[ i ] ) != null; i++ ) { - - // Remove element nodes and prevent memory leaks - if ( elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem, false ) ); - } - - // Remove any remaining nodes - while ( elem.firstChild ) { - elem.removeChild( elem.firstChild ); - } - - // If this is a select, ensure that it displays empty (#12336) - // Support: IE<9 - if ( elem.options && jQuery.nodeName( elem, "select" ) ) { - elem.options.length = 0; - } - } - - return this; - }, - - clone: function( dataAndEvents, deepDataAndEvents ) { - dataAndEvents = dataAndEvents == null ? false : dataAndEvents; - deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; - - return this.map( function() { - return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); - } ); - }, - - html: function( value ) { - return access( this, function( value ) { - var elem = this[ 0 ] || {}, - i = 0, - l = this.length; - - if ( value === undefined ) { - return elem.nodeType === 1 ? - elem.innerHTML.replace( rinlinejQuery, "" ) : - undefined; - } - - // See if we can take a shortcut and just use innerHTML - if ( typeof value === "string" && !rnoInnerhtml.test( value ) && - ( support.htmlSerialize || !rnoshimcache.test( value ) ) && - ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && - !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { - - value = jQuery.htmlPrefilter( value ); - - try { - for ( ; i < l; i++ ) { - - // Remove element nodes and prevent memory leaks - elem = this[ i ] || {}; - if ( elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem, false ) ); - elem.innerHTML = value; - } - } - - elem = 0; - - // If using innerHTML throws an exception, use the fallback method - } catch ( e ) {} - } - - if ( elem ) { - this.empty().append( value ); - } - }, null, value, arguments.length ); - }, - - replaceWith: function() { - var ignored = []; - - // Make the changes, replacing each non-ignored context element with the new content - return domManip( this, arguments, function( elem ) { - var parent = this.parentNode; - - if ( jQuery.inArray( this, ignored ) < 0 ) { - jQuery.cleanData( getAll( this ) ); - if ( parent ) { - parent.replaceChild( elem, this ); - } - } - - // Force callback invocation - }, ignored ); - } -} ); - -jQuery.each( { - appendTo: "append", - prependTo: "prepend", - insertBefore: "before", - insertAfter: "after", - replaceAll: "replaceWith" -}, function( name, original ) { - jQuery.fn[ name ] = function( selector ) { - var elems, - i = 0, - ret = [], - insert = jQuery( selector ), - last = insert.length - 1; - - for ( ; i <= last; i++ ) { - elems = i === last ? this : this.clone( true ); - jQuery( insert[ i ] )[ original ]( elems ); - - // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() - push.apply( ret, elems.get() ); - } - - return this.pushStack( ret ); - }; -} ); - - -var iframe, - elemdisplay = { - - // Support: Firefox - // We have to pre-define these values for FF (#10227) - HTML: "block", - BODY: "block" - }; - -/** - * Retrieve the actual display of a element - * @param {String} name nodeName of the element - * @param {Object} doc Document object - */ - -// Called only from within defaultDisplay -function actualDisplay( name, doc ) { - var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), - - display = jQuery.css( elem[ 0 ], "display" ); - - // We don't have any data stored on the element, - // so use "detach" method as fast way to get rid of the element - elem.detach(); - - return display; -} - -/** - * Try to determine the default display value of an element - * @param {String} nodeName - */ -function defaultDisplay( nodeName ) { - var doc = document, - display = elemdisplay[ nodeName ]; - - if ( !display ) { - display = actualDisplay( nodeName, doc ); - - // If the simple way fails, read from inside an iframe - if ( display === "none" || !display ) { - - // Use the already-created iframe if possible - iframe = ( iframe || jQuery( "' - ,'' - ,''].join('')) - - //编辑器不兼容ie8以下 - if(device.ie && device.ie < 8){ - return textArea.removeClass('layui-hide').addClass(SHOW); - } - - haveBuild[0] && (haveBuild.remove()); - - setIframe.call(that, editor, textArea[0], set) - textArea.addClass('layui-hide').after(editor); - - return that.index; - }; - - //获得编辑器中内容 - Edit.prototype.getContent = function(index){ - var iframeWin = getWin(index); - if(!iframeWin[0]) return; - return toLower(iframeWin[0].document.body.innerHTML); - }; - - //获得编辑器中纯文本内容 - Edit.prototype.getText = function(index){ - var iframeWin = getWin(index); - if(!iframeWin[0]) return; - return $(iframeWin[0].document.body).text(); - }; - /** - * 设置编辑器内容 - * @param {[type]} index 编辑器索引 - * @param {[type]} content 要设置的内容 - * @param {[type]} flag 是否追加模式 - */ - Edit.prototype.setContent = function(index, content, flag){ - var iframeWin = getWin(index); - if(!iframeWin[0]) return; - if(flag){ - $(iframeWin[0].document.body).append(content) - }else{ - $(iframeWin[0].document.body).html(content) - }; - layedit.sync(index) - }; - //将编辑器内容同步到textarea(一般用于异步提交时) - Edit.prototype.sync = function(index){ - var iframeWin = getWin(index); - if(!iframeWin[0]) return; - var textarea = $('#'+iframeWin[1].attr('textarea')); - textarea.val(toLower(iframeWin[0].document.body.innerHTML)); - }; - - //获取编辑器选中内容 - Edit.prototype.getSelection = function(index){ - var iframeWin = getWin(index); - if(!iframeWin[0]) return; - var range = Range(iframeWin[0].document); - return document.selection ? range.text : range.toString(); - }; - - //iframe初始化 - var setIframe = function(editor, textArea, set){ - var that = this, iframe = editor.find('iframe'); - - iframe.css({ - height: set.height - }).on('load', function(){ - var conts = iframe.contents() - ,iframeWin = iframe.prop('contentWindow') - ,head = conts.find('head') - ,style = $([''].join('')) - ,body = conts.find('body'); - - head.append(style); - body.attr('contenteditable', 'true').css({ - 'min-height': set.height - }).html(textArea.value||''); - - hotkey.apply(that, [iframeWin, iframe, textArea, set]); //快捷键处理 - toolActive.call(that, iframeWin, editor, set); //触发工具 - - }); - } - - //获得iframe窗口对象 - ,getWin = function(index){ - var iframe = $('#LAY_layedit_'+ index) - ,iframeWin = iframe.prop('contentWindow'); - return [iframeWin, iframe]; - } - - //IE8下将标签处理成小写 - ,toLower = function(html){ - if(device.ie == 8){ - html = html.replace(/<.+>/g, function(str){ - return str.toLowerCase(); - }); - } - return html; - } - - //快捷键处理 - ,hotkey = function(iframeWin, iframe, textArea, set){ - var iframeDOM = iframeWin.document, body = $(iframeDOM.body); - body.on('keydown', function(e){ - var keycode = e.keyCode; - //处理回车 - if(keycode === 13){ - var range = Range(iframeDOM); - var container = getContainer(range) - ,parentNode = container.parentNode; - - if(parentNode.tagName.toLowerCase() === 'pre'){ - if(e.shiftKey) return - layer.msg('请暂时用shift+enter'); - return false; - } - iframeDOM.execCommand('formatBlock', false, '

    '); - } - }); - - //给textarea同步内容 - $(textArea).parents('form').on('submit', function(){ - var html = body.html(); - //IE8下将标签处理成小写 - if(device.ie == 8){ - html = html.replace(/<.+>/g, function(str){ - return str.toLowerCase(); - }); - } - textArea.value = html; - }); - - //处理粘贴 - body.on('paste', function(e){ - iframeDOM.execCommand('formatBlock', false, '

    '); - setTimeout(function(){ - filter.call(iframeWin, body); - textArea.value = body.html(); - }, 100); - }); - } - - //标签过滤 - ,filter = function(body){ - var iframeWin = this - ,iframeDOM = iframeWin.document; - - //清除影响版面的css属性 - body.find('*[style]').each(function(){ - var textAlign = this.style.textAlign; - this.removeAttribute('style'); - $(this).css({ - 'text-align': textAlign || '' - }) - }); - - //修饰表格 - body.find('table').addClass('layui-table'); - - //移除不安全的标签 - body.find('script,link').remove(); - } - - //Range对象兼容性处理 - ,Range = function(iframeDOM){ - return iframeDOM.selection - ? iframeDOM.selection.createRange() - : iframeDOM.getSelection().getRangeAt(0); - } - - //当前Range对象的endContainer兼容性处理 - ,getContainer = function(range){ - return range.endContainer || range.parentElement().childNodes[0] - } - - //在选区插入内联元素 - ,insertInline = function(tagName, attr, range){ - var iframeDOM = this.document - ,elem = document.createElement(tagName) - for(var key in attr){ - elem.setAttribute(key, attr[key]); - } - elem.removeAttribute('text'); - - if(iframeDOM.selection){ //IE - var text = range.text || attr.text; - if(tagName === 'a' && !text) return; - if(text){ - elem.innerHTML = text; - } - range.pasteHTML($(elem).prop('outerHTML')); - range.select(); - } else { //非IE - var text = range.toString() || attr.text; - if(tagName === 'a' && !text) return; - if(text){ - elem.innerHTML = text; - } - range.deleteContents(); - range.insertNode(elem); - } - } - - //工具选中 - ,toolCheck = function(tools, othis){ - var iframeDOM = this.document - ,CHECK = 'layedit-tool-active' - ,container = getContainer(Range(iframeDOM)) - ,item = function(type){ - return tools.find('.layedit-tool-'+type) - } - - if(othis){ - othis[othis.hasClass(CHECK) ? 'removeClass' : 'addClass'](CHECK); - } - - tools.find('>i').removeClass(CHECK); - item('unlink').addClass(ABLED); - - $(container).parents().each(function(){ - var tagName = this.tagName.toLowerCase() - ,textAlign = this.style.textAlign; - - //文字 - if(tagName === 'b' || tagName === 'strong'){ - item('b').addClass(CHECK) - } - if(tagName === 'i' || tagName === 'em'){ - item('i').addClass(CHECK) - } - if(tagName === 'u'){ - item('u').addClass(CHECK) - } - if(tagName === 'strike'){ - item('d').addClass(CHECK) - } - - //对齐 - if(tagName === 'p'){ - if(textAlign === 'center'){ - item('center').addClass(CHECK); - } else if(textAlign === 'right'){ - item('right').addClass(CHECK); - } else { - item('left').addClass(CHECK); - } - } - - //超链接 - if(tagName === 'a'){ - item('link').addClass(CHECK); - item('unlink').removeClass(ABLED); - } - }); - } - - //触发工具 - ,toolActive = function(iframeWin, editor, set){ - var iframeDOM = iframeWin.document - ,body = $(iframeDOM.body) - ,toolEvent = { - //超链接 - link: function(range){ - var container = getContainer(range) - ,parentNode = $(container).parent(); - - link.call(body, { - href: parentNode.attr('href') - ,target: parentNode.attr('target') - }, function(field){ - var parent = parentNode[0]; - if(parent.tagName === 'A'){ - parent.href = field.url; - } else { - insertInline.call(iframeWin, 'a', { - target: field.target - ,href: field.url - ,text: field.url - }, range); - } - }); - } - //清除超链接 - ,unlink: function(range){ - iframeDOM.execCommand('unlink'); - } - //表情 - ,face: function(range){ - face.call(this, function(img){ - insertInline.call(iframeWin, 'img', { - src: img.src - ,alt: img.alt - }, range); - }); - } - //图片 - ,image: function(range){ - var that = this; - layui.use('upload', function(upload){ - var uploadImage = set.uploadImage || {}; - upload.render({ - url: uploadImage.url - ,method: uploadImage.type - ,elem: $(that).find('input')[0] - ,done: function(res){ - if(res.code == 0){ - res.data = res.data || {}; - insertInline.call(iframeWin, 'img', { - src: res.data.src - ,alt: res.data.title - }, range); - } else { - layer.msg(res.msg||'上传失败'); - } - } - }); - }); - } - //插入代码 - ,code: function(range){ - code.call(body, function(pre){ - insertInline.call(iframeWin, 'pre', { - text: pre.code - ,'lay-lang': pre.lang - }, range); - }); - } - //帮助 - ,help: function(){ - layer.open({ - type: 2 - ,title: '帮助' - ,area: ['600px', '380px'] - ,shadeClose: true - ,shade: 0.1 - ,skin: 'layui-layer-msg' - ,content: ['', 'no'] - }); - } - } - ,tools = editor.find('.layui-layedit-tool') - - ,click = function(){ - var othis = $(this) - ,events = othis.attr('layedit-event') - ,command = othis.attr('lay-command'); - - if(othis.hasClass(ABLED)) return; - - body.focus(); - - var range = Range(iframeDOM) - ,container = range.commonAncestorContainer - - if(command){ - iframeDOM.execCommand(command); - if(/justifyLeft|justifyCenter|justifyRight/.test(command)){ - iframeDOM.execCommand('formatBlock', false, '

    '); - } - setTimeout(function(){ - body.focus(); - }, 10); - } else { - toolEvent[events] && toolEvent[events].call(this, range); - } - toolCheck.call(iframeWin, tools, othis); - } - - ,isClick = /image/ - - tools.find('>i').on('mousedown', function(){ - var othis = $(this) - ,events = othis.attr('layedit-event'); - if(isClick.test(events)) return; - click.call(this) - }).on('click', function(){ - var othis = $(this) - ,events = othis.attr('layedit-event'); - if(!isClick.test(events)) return; - click.call(this) - }); - - //触发内容区域 - body.on('click', function(){ - toolCheck.call(iframeWin, tools); - layer.close(face.index); - }); - } - - //超链接面板 - ,link = function(options, callback){ - var body = this, index = layer.open({ - type: 1 - ,id: 'LAY_layedit_link' - ,area: '350px' - ,shade: 0.05 - ,shadeClose: true - ,moveType: 1 - ,title: '超链接' - ,skin: 'layui-layer-msg' - ,content: ['

      ' - ,'
    • ' - ,'' - ,'
      ' - ,'' - ,'
      ' - ,'
    • ' - ,'
    • ' - ,'' - ,'
      ' - ,'' - ,'' - ,'
      ' - ,'
    • ' - ,'
    • ' - ,'' - ,'' - ,'
    • ' - ,'
    '].join('') - ,success: function(layero, index){ - var eventFilter = 'submit(layedit-link-yes)'; - form.render('radio'); - layero.find('.layui-btn-primary').on('click', function(){ - layer.close(index); - body.focus(); - }); - form.on(eventFilter, function(data){ - layer.close(link.index); - callback && callback(data.field); - }); - } - }); - link.index = index; - } - - //表情面板 - ,face = function(callback){ - //表情库 - var faces = function(){ - var alt = ["[微笑]", "[嘻嘻]", "[哈哈]", "[可爱]", "[可怜]", "[挖鼻]", "[吃惊]", "[害羞]", "[挤眼]", "[闭嘴]", "[鄙视]", "[爱你]", "[泪]", "[偷笑]", "[亲亲]", "[生病]", "[太开心]", "[白眼]", "[右哼哼]", "[左哼哼]", "[嘘]", "[衰]", "[委屈]", "[吐]", "[哈欠]", "[抱抱]", "[怒]", "[疑问]", "[馋嘴]", "[拜拜]", "[思考]", "[汗]", "[困]", "[睡]", "[钱]", "[失望]", "[酷]", "[色]", "[哼]", "[鼓掌]", "[晕]", "[悲伤]", "[抓狂]", "[黑线]", "[阴险]", "[怒骂]", "[互粉]", "[心]", "[伤心]", "[猪头]", "[熊猫]", "[兔子]", "[ok]", "[耶]", "[good]", "[NO]", "[赞]", "[来]", "[弱]", "[草泥马]", "[神马]", "[囧]", "[浮云]", "[给力]", "[围观]", "[威武]", "[奥特曼]", "[礼物]", "[钟]", "[话筒]", "[蜡烛]", "[蛋糕]"], arr = {}; - layui.each(alt, function(index, item){ - arr[item] = layui.cache.dir + 'images/face/'+ index + '.gif'; - }); - return arr; - }(); - face.hide = face.hide || function(e){ - if($(e.target).attr('layedit-event') !== 'face'){ - layer.close(face.index); - } - } - return face.index = layer.tips(function(){ - var content = []; - layui.each(faces, function(key, item){ - content.push('
  • '+ key +'
  • '); - }); - return '
      ' + content.join('') + '
    '; - }(), this, { - tips: 1 - ,time: 0 - ,skin: 'layui-box layui-util-face' - ,maxWidth: 500 - ,success: function(layero, index){ - layero.css({ - marginTop: -4 - ,marginLeft: -10 - }).find('.layui-clear>li').on('click', function(){ - callback && callback({ - src: faces[this.title] - ,alt: this.title - }); - layer.close(index); - }); - $(document).off('click', face.hide).on('click', face.hide); - } - }); - } - - //插入代码面板 - ,code = function(callback){ - var body = this, index = layer.open({ - type: 1 - ,id: 'LAY_layedit_code' - ,area: '550px' - ,shade: 0.05 - ,shadeClose: true - ,moveType: 1 - ,title: '插入代码' - ,skin: 'layui-layer-msg' - ,content: ['
      ' - ,'
    • ' - ,'' - ,'
      ' - ,'' - ,'
      ' - ,'
    • ' - ,'
    • ' - ,'' - ,'
      ' - ,'' - ,'
      ' - ,'
    • ' - ,'
    • ' - ,'' - ,'' - ,'
    • ' - ,'
    '].join('') - ,success: function(layero, index){ - var eventFilter = 'submit(layedit-code-yes)'; - form.render('select'); - layero.find('.layui-btn-primary').on('click', function(){ - layer.close(index); - body.focus(); - }); - form.on(eventFilter, function(data){ - layer.close(code.index); - callback && callback(data.field); - }); - } - }); - code.index = index; - } - - //全部工具 - ,tools = { - html: '' - ,strong: '' - ,italic: '' - ,underline: '' - ,del: '' - - ,'|': '' - - ,left: '' - ,center: '' - ,right: '' - ,link: '' - ,unlink: '' - ,face: '' - ,image: '' - ,code: '' - - ,help: '' - } - - ,edit = new Edit(); - - exports(MOD_NAME, edit); -}); +/** layui-v2.5.7 MIT License */ + ;layui.define(["layer","form"],function(t){"use strict";var e=layui.$,i=layui.layer,a=layui.form,l=(layui.hint(),layui.device()),n="layedit",o="layui-show",r="layui-disabled",c=function(){var t=this;t.index=0,t.config={tool:["strong","italic","underline","del","|","left","center","right","|","link","unlink","face","image"],hideTool:[],height:280}};c.prototype.set=function(t){var i=this;return e.extend(!0,i.config,t),i},c.prototype.on=function(t,e){return layui.onevent(n,t,e)},c.prototype.build=function(t,i){i=i||{};var a=this,n=a.config,r="layui-layedit",c=e("string"==typeof t?"#"+t:t),u="LAY_layedit_"+ ++a.index,d=c.next("."+r),y=e.extend({},n,i),f=function(){var t=[],e={};return layui.each(y.hideTool,function(t,i){e[i]=!0}),layui.each(y.tool,function(i,a){C[a]&&!e[a]&&t.push(C[a])}),t.join("")}(),m=e(['
    ','
    '+f+"
    ",'
    ','',"
    ","
    "].join(""));return l.ie&&l.ie<8?c.removeClass("layui-hide").addClass(o):(d[0]&&d.remove(),s.call(a,m,c[0],y),c.addClass("layui-hide").after(m),a.index)},c.prototype.getContent=function(t){var e=u(t);if(e[0])return d(e[0].document.body.innerHTML)},c.prototype.getText=function(t){var i=u(t);if(i[0])return e(i[0].document.body).text()},c.prototype.setContent=function(t,i,a){var l=u(t);l[0]&&(a?e(l[0].document.body).append(i):e(l[0].document.body).html(i),layedit.sync(t))},c.prototype.sync=function(t){var i=u(t);if(i[0]){var a=e("#"+i[1].attr("textarea"));a.val(d(i[0].document.body.innerHTML))}},c.prototype.getSelection=function(t){var e=u(t);if(e[0]){var i=m(e[0].document);return document.selection?i.text:i.toString()}};var s=function(t,i,a){var l=this,n=t.find("iframe");n.css({height:a.height}).on("load",function(){var o=n.contents(),r=n.prop("contentWindow"),c=o.find("head"),s=e([""].join("")),u=o.find("body");c.append(s),u.attr("contenteditable","true").css({"min-height":a.height}).html(i.value||""),y.apply(l,[r,n,i,a]),g.call(l,r,t,a)})},u=function(t){var i=e("#LAY_layedit_"+t),a=i.prop("contentWindow");return[a,i]},d=function(t){return 8==l.ie&&(t=t.replace(/<.+>/g,function(t){return t.toLowerCase()})),t},y=function(t,a,n,o){var r=t.document,c=e(r.body);c.on("keydown",function(t){var e=t.keyCode;if(13===e){var a=m(r),l=p(a),n=l.parentNode;if("pre"===n.tagName.toLowerCase()){if(t.shiftKey)return;return i.msg("请暂时用shift+enter"),!1}r.execCommand("formatBlock",!1,"

    ")}}),e(n).parents("form").on("submit",function(){var t=c.html();8==l.ie&&(t=t.replace(/<.+>/g,function(t){return t.toLowerCase()})),n.value=t}),c.on("paste",function(e){r.execCommand("formatBlock",!1,"

    "),setTimeout(function(){f.call(t,c),n.value=c.html()},100)})},f=function(t){var i=this;i.document;t.find("*[style]").each(function(){var t=this.style.textAlign;this.removeAttribute("style"),e(this).css({"text-align":t||""})}),t.find("table").addClass("layui-table"),t.find("script,link").remove()},m=function(t){return t.selection?t.selection.createRange():t.getSelection().getRangeAt(0)},p=function(t){return t.endContainer||t.parentElement().childNodes[0]},v=function(t,i,a){var l=this.document,n=document.createElement(t);for(var o in i)n.setAttribute(o,i[o]);if(n.removeAttribute("text"),l.selection){var r=a.text||i.text;if("a"===t&&!r)return;r&&(n.innerHTML=r),a.pasteHTML(e(n).prop("outerHTML")),a.select()}else{var r=a.toString()||i.text;if("a"===t&&!r)return;r&&(n.innerHTML=r),a.deleteContents(),a.insertNode(n)}},h=function(t,i){var a=this.document,l="layedit-tool-active",n=p(m(a)),o=function(e){return t.find(".layedit-tool-"+e)};i&&i[i.hasClass(l)?"removeClass":"addClass"](l),t.find(">i").removeClass(l),o("unlink").addClass(r),e(n).parents().each(function(){var t=this.tagName.toLowerCase(),e=this.style.textAlign;"b"!==t&&"strong"!==t||o("b").addClass(l),"i"!==t&&"em"!==t||o("i").addClass(l),"u"===t&&o("u").addClass(l),"strike"===t&&o("d").addClass(l),"p"===t&&("center"===e?o("center").addClass(l):"right"===e?o("right").addClass(l):o("left").addClass(l)),"a"===t&&(o("link").addClass(l),o("unlink").removeClass(r))})},g=function(t,a,l){var n=t.document,o=e(n.body),c={link:function(i){var a=p(i),l=e(a).parent();b.call(o,{href:l.attr("href"),target:l.attr("target")},function(e){var a=l[0];"A"===a.tagName?a.href=e.url:v.call(t,"a",{target:e.target,href:e.url,text:e.url},i)})},unlink:function(t){n.execCommand("unlink")},face:function(e){x.call(this,function(i){v.call(t,"img",{src:i.src,alt:i.alt},e)})},image:function(a){var n=this;layui.use("upload",function(o){var r=l.uploadImage||{};o.render({url:r.url,method:r.type,elem:e(n).find("input")[0],done:function(e){0==e.code?(e.data=e.data||{},v.call(t,"img",{src:e.data.src,alt:e.data.title},a)):i.msg(e.msg||"上传失败")}})})},code:function(e){k.call(o,function(i){v.call(t,"pre",{text:i.code,"lay-lang":i.lang},e)})},help:function(){i.open({type:2,title:"帮助",area:["600px","380px"],shadeClose:!0,shade:.1,skin:"layui-layer-msg",content:["http://www.layui.com/about/layedit/help.html","no"]})}},s=a.find(".layui-layedit-tool"),u=function(){var i=e(this),a=i.attr("layedit-event"),l=i.attr("lay-command");if(!i.hasClass(r)){o.focus();var u=m(n);u.commonAncestorContainer;l?(n.execCommand(l),/justifyLeft|justifyCenter|justifyRight/.test(l)&&n.execCommand("formatBlock",!1,"

    "),setTimeout(function(){o.focus()},10)):c[a]&&c[a].call(this,u),h.call(t,s,i)}},d=/image/;s.find(">i").on("mousedown",function(){var t=e(this),i=t.attr("layedit-event");d.test(i)||u.call(this)}).on("click",function(){var t=e(this),i=t.attr("layedit-event");d.test(i)&&u.call(this)}),o.on("click",function(){h.call(t,s),i.close(x.index)})},b=function(t,e){var l=this,n=i.open({type:1,id:"LAY_layedit_link",area:"350px",shade:.05,shadeClose:!0,moveType:1,title:"超链接",skin:"layui-layer-msg",content:['

      ','
    • ','','
      ','',"
      ","
    • ",'
    • ','','
      ','",'","
      ","
    • ",'
    • ','','',"
    • ","
    "].join(""),success:function(t,n){var o="submit(layedit-link-yes)";a.render("radio"),t.find(".layui-btn-primary").on("click",function(){i.close(n),l.focus()}),a.on(o,function(t){i.close(b.index),e&&e(t.field)})}});b.index=n},x=function(t){var a=function(){var t=["[微笑]","[嘻嘻]","[哈哈]","[可爱]","[可怜]","[挖鼻]","[吃惊]","[害羞]","[挤眼]","[闭嘴]","[鄙视]","[爱你]","[泪]","[偷笑]","[亲亲]","[生病]","[太开心]","[白眼]","[右哼哼]","[左哼哼]","[嘘]","[衰]","[委屈]","[吐]","[哈欠]","[抱抱]","[怒]","[疑问]","[馋嘴]","[拜拜]","[思考]","[汗]","[困]","[睡]","[钱]","[失望]","[酷]","[色]","[哼]","[鼓掌]","[晕]","[悲伤]","[抓狂]","[黑线]","[阴险]","[怒骂]","[互粉]","[心]","[伤心]","[猪头]","[熊猫]","[兔子]","[ok]","[耶]","[good]","[NO]","[赞]","[来]","[弱]","[草泥马]","[神马]","[囧]","[浮云]","[给力]","[围观]","[威武]","[奥特曼]","[礼物]","[钟]","[话筒]","[蜡烛]","[蛋糕]"],e={};return layui.each(t,function(t,i){e[i]=layui.cache.dir+"images/face/"+t+".gif"}),e}();return x.hide=x.hide||function(t){"face"!==e(t.target).attr("layedit-event")&&i.close(x.index)},x.index=i.tips(function(){var t=[];return layui.each(a,function(e,i){t.push('
  • '+e+'
  • ')}),'
      '+t.join("")+"
    "}(),this,{tips:1,time:0,skin:"layui-box layui-util-face",maxWidth:500,success:function(l,n){l.css({marginTop:-4,marginLeft:-10}).find(".layui-clear>li").on("click",function(){t&&t({src:a[this.title],alt:this.title}),i.close(n)}),e(document).off("click",x.hide).on("click",x.hide)}})},k=function(t){var e=this,l=i.open({type:1,id:"LAY_layedit_code",area:"550px",shade:.05,shadeClose:!0,moveType:1,title:"插入代码",skin:"layui-layer-msg",content:['
      ','
    • ','','
      ','","
      ","
    • ",'
    • ','','
      ','',"
      ","
    • ",'
    • ','','',"
    • ","
    "].join(""),success:function(l,n){var o="submit(layedit-code-yes)";a.render("select"),l.find(".layui-btn-primary").on("click",function(){i.close(n),e.focus()}),a.on(o,function(e){i.close(k.index),t&&t(e.field)})}});k.index=l},C={html:'',strong:'',italic:'',underline:'',del:'',"|":'',left:'',center:'',right:'',link:'',unlink:'',face:'',image:'',code:'',help:''},w=new c;t(n,w)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/layer.js b/IoTGateway/wwwroot/layui/lay/modules/layer.js index 830fbf5..12172b9 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/layer.js +++ b/IoTGateway/wwwroot/layui/lay/modules/layer.js @@ -1,1311 +1,2 @@ -/** - - @Name:layer - Web 弹出层组件 - @License:MIT - - */ - -;!function(window, undefined){ -"use strict"; - -var isLayui = window.layui && layui.define, $, win, ready = { - getPath: function(){ - var jsPath = document.currentScript ? document.currentScript.src : function(){ - var js = document.scripts - ,last = js.length - 1 - ,src; - for(var i = last; i > 0; i--){ - if(js[i].readyState === 'interactive'){ - src = js[i].src; - break; - } - } - return src || js[last].src; - }(); - return jsPath.substring(0, jsPath.lastIndexOf('/') + 1); - }(), - - config: {}, end: {}, minIndex: 0, minLeft: [], - btn: ['确定', '取消'], - - //五种原始层模式 - type: ['dialog', 'page', 'iframe', 'loading', 'tips'], - - //获取节点的style属性值 - getStyle: function(node, name){ - var style = node.currentStyle ? node.currentStyle : window.getComputedStyle(node, null); - return style[style.getPropertyValue ? 'getPropertyValue' : 'getAttribute'](name); - }, - - //载入 CSS 依赖 - link: function(href, fn, cssname){ - - //未设置路径,则不主动加载css - if(!layer.path) return; - - var head = document.getElementsByTagName("head")[0], link = document.createElement('link'); - if(typeof fn === 'string') cssname = fn; - var app = (cssname || href).replace(/\.|\//g, ''); - var id = 'layuicss-'+ app, timeout = 0; - - link.rel = 'stylesheet'; - link.href = layer.path + href; - link.id = id; - - if(!document.getElementById(id)){ - head.appendChild(link); - } - - if(typeof fn !== 'function') return; - - //轮询css是否加载完毕 - (function poll() { - if(++timeout > 8 * 1000 / 100){ - return window.console && console.error('layer.css: Invalid'); - }; - parseInt(ready.getStyle(document.getElementById(id), 'width')) === 1989 ? fn() : setTimeout(poll, 100); - }()); - } -}; - -//默认内置方法。 -var layer = { - v: '3.3.0', - ie: function(){ //ie版本 - var agent = navigator.userAgent.toLowerCase(); - return (!!window.ActiveXObject || "ActiveXObject" in window) ? ( - (agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识 - ) : false; - }(), - index: (window.layer && window.layer.v) ? 100000 : 0, - path: ready.getPath, - config: function(options, fn){ - options = options || {}; - layer.cache = ready.config = $.extend({}, ready.config, options); - layer.path = ready.config.path || layer.path; - typeof options.extend === 'string' && (options.extend = [options.extend]); - - if(ready.config.path) layer.ready(); - - if(!options.extend) return this; - - isLayui - ? layui.addcss('modules/layer/' + options.extend) - : ready.link('theme/' + options.extend); - - return this; - }, - - //主体CSS等待事件 - ready: function(callback){ - var cssname = 'layer', ver = '' - ,path = (isLayui ? 'modules/layer/' : 'theme/') + 'default/layer.css?v='+ layer.v + ver; - isLayui ? layui.addcss(path, callback, cssname) : ready.link(path, callback, cssname); - return this; - }, - - //各种快捷引用 - alert: function(content, options, yes){ - var type = typeof options === 'function'; - if(type) yes = options; - return layer.open($.extend({ - content: content, - yes: yes - }, type ? {} : options)); - }, - - confirm: function(content, options, yes, cancel){ - var type = typeof options === 'function'; - if(type){ - cancel = yes; - yes = options; - } - return layer.open($.extend({ - content: content, - btn: ready.btn, - yes: yes, - btn2: cancel - }, type ? {} : options)); - }, - - msg: function(content, options, end){ //最常用提示层 - var type = typeof options === 'function', rskin = ready.config.skin; - var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '')||'layui-layer-msg'; - var anim = doms.anim.length - 1; - if(type) end = options; - return layer.open($.extend({ - content: content, - time: 3000, - shade: false, - skin: skin, - title: false, - closeBtn: false, - btn: false, - resize: false, - end: end - }, (type && !ready.config.skin) ? { - skin: skin + ' layui-layer-hui', - anim: anim - } : function(){ - options = options || {}; - if(options.icon === -1 || options.icon === undefined && !ready.config.skin){ - options.skin = skin + ' ' + (options.skin||'layui-layer-hui'); - } - return options; - }())); - }, - - load: function(icon, options){ - return layer.open($.extend({ - type: 3, - icon: icon || 0, - resize: false, - shade: 0.01 - }, options)); - }, - - tips: function(content, follow, options){ - return layer.open($.extend({ - type: 4, - content: [content, follow], - closeBtn: false, - time: 3000, - shade: false, - resize: false, - fixed: false, - maxWidth: 260 - }, options)); - } -}; - -var Class = function(setings){ - var that = this, creat = function(){ - layer.ready(function(){ - that.creat(); - }); - }; - that.index = ++layer.index; - that.config.maxWidth = $(win).width() - 15*2; //初始最大宽度:当前屏幕宽,左右留 15px 边距 - that.config = $.extend({}, that.config, ready.config, setings); - document.body ? creat() : setTimeout(function(){ - creat(); - }, 30); -}; - -Class.pt = Class.prototype; - -//缓存常用字符 -var doms = ['layui-layer', '.layui-layer-title', '.layui-layer-main', '.layui-layer-dialog', 'layui-layer-iframe', 'layui-layer-content', 'layui-layer-btn', 'layui-layer-close']; -doms.anim = ['layer-anim-00', 'layer-anim-01', 'layer-anim-02', 'layer-anim-03', 'layer-anim-04', 'layer-anim-05', 'layer-anim-06']; - -//默认配置 -Class.pt.config = { - type: 0, - shade: 0.3, - fixed: true, - move: doms[1], - title: '信息', - offset: 'auto', - area: 'auto', - closeBtn: 1, - time: 0, //0表示不自动关闭 - zIndex: 19891014, - maxWidth: 360, - anim: 0, - isOutAnim: true, - icon: -1, - moveType: 1, - resize: true, - scrollbar: true, //是否允许浏览器滚动条 - tips: 2 -}; - -//容器 -Class.pt.vessel = function(conType, callback){ - var that = this, times = that.index, config = that.config; - var zIndex = config.zIndex + times, titype = typeof config.title === 'object'; - var ismax = config.maxmin && (config.type === 1 || config.type === 2); - var titleHTML = (config.title ? '
    ' - + (titype ? config.title[0] : config.title) - + '
    ' : ''); - - config.zIndex = zIndex; - callback([ - //遮罩 - config.shade ? ('
    ') : '', - - //主体 - '
    ' - + (conType && config.type != 2 ? '' : titleHTML) - + '
    ' - + (config.type == 0 && config.icon !== -1 ? '' : '') - + (config.type == 1 && conType ? '' : (config.content||'')) - + '
    ' - + ''+ function(){ - var closebtn = ismax ? '' : ''; - config.closeBtn && (closebtn += ''); - return closebtn; - }() + '' - + (config.btn ? function(){ - var button = ''; - typeof config.btn === 'string' && (config.btn = [config.btn]); - for(var i = 0, len = config.btn.length; i < len; i++){ - button += ''+ config.btn[i] +'' - } - return '
    '+ button +'
    ' - }() : '') - + (config.resize ? '' : '') - + '
    ' - ], titleHTML, $('
    ')); - return that; -}; - -//创建骨架 -Class.pt.creat = function(){ - var that = this - ,config = that.config - ,times = that.index, nodeIndex - ,content = config.content - ,conType = typeof content === 'object' - ,body = $('body'); - - if(config.id && $('#'+config.id)[0]) return; - - if(typeof config.area === 'string'){ - config.area = config.area === 'auto' ? ['', ''] : [config.area, '']; - } - - //anim兼容旧版shift - if(config.shift){ - config.anim = config.shift; - } - - if(layer.ie == 6){ - config.fixed = false; - } - - switch(config.type){ - case 0: - config.btn = ('btn' in config) ? config.btn : ready.btn[0]; - layer.closeAll('dialog'); - break; - case 2: - var content = config.content = conType ? config.content : [config.content||'', 'auto']; - config.content = ''; - break; - case 3: - delete config.title; - delete config.closeBtn; - config.icon === -1 && (config.icon === 0); - layer.closeAll('loading'); - break; - case 4: - conType || (config.content = [config.content, 'body']); - config.follow = config.content[1]; - config.content = config.content[0] + ''; - delete config.title; - config.tips = typeof config.tips === 'object' ? config.tips : [config.tips, true]; - config.tipsMore || layer.closeAll('tips'); - break; - } - - //建立容器 - that.vessel(conType, function(html, titleHTML, moveElem){ - body.append(html[0]); - conType ? function(){ - (config.type == 2 || config.type == 4) ? function(){ - $('body').append(html[1]); - }() : function(){ - if(!content.parents('.'+doms[0])[0]){ - content.data('display', content.css('display')).show().addClass('layui-layer-wrap').wrap(html[1]); - $('#'+ doms[0] + times).find('.'+doms[5]).before(titleHTML); - } - }(); - }() : body.append(html[1]); - $('.layui-layer-move')[0] || body.append(ready.moveElem = moveElem); - that.layero = $('#'+ doms[0] + times); - config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times); - }).auto(times); - - //遮罩 - $('#layui-layer-shade'+ that.index).css({ - 'background-color': config.shade[1] || '#000' - ,'opacity': config.shade[0]||config.shade - }); - - config.type == 2 && layer.ie == 6 && that.layero.find('iframe').attr('src', content[0]); - - //坐标自适应浏览器窗口尺寸 - config.type == 4 ? that.tips() : that.offset(); - if(config.fixed){ - win.on('resize', function(){ - that.offset(); - (/^\d+%$/.test(config.area[0]) || /^\d+%$/.test(config.area[1])) && that.auto(times); - config.type == 4 && that.tips(); - }); - } - - config.time <= 0 || setTimeout(function(){ - layer.close(that.index) - }, config.time); - that.move().callback(); - - //为兼容jQuery3.0的css动画影响元素尺寸计算 - if(doms.anim[config.anim]){ - var animClass = 'layer-anim '+ doms.anim[config.anim]; - that.layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ - $(this).removeClass(animClass); - }); - }; - - //记录关闭动画 - if(config.isOutAnim){ - that.layero.data('isOutAnim', true); - } -}; - -//自适应 -Class.pt.auto = function(index){ - var that = this, config = that.config, layero = $('#'+ doms[0] + index); - - if(config.area[0] === '' && config.maxWidth > 0){ - //为了修复IE7下一个让人难以理解的bug - if(layer.ie && layer.ie < 8 && config.btn){ - layero.width(layero.innerWidth()); - } - layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth); - } - - var area = [layero.innerWidth(), layero.innerHeight()] - ,titHeight = layero.find(doms[1]).outerHeight() || 0 - ,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0 - ,setHeight = function(elem){ - elem = layero.find(elem); - elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding-top'))|0)); - }; - - switch(config.type){ - case 2: - setHeight('iframe'); - break; - default: - if(config.area[1] === ''){ - if(config.maxHeight > 0 && layero.outerHeight() > config.maxHeight){ - area[1] = config.maxHeight; - setHeight('.'+doms[5]); - } else if(config.fixed && area[1] >= win.height()){ - area[1] = win.height(); - setHeight('.'+doms[5]); - } - } else { - setHeight('.'+doms[5]); - } - break; - }; - - return that; -}; - -//计算坐标 -Class.pt.offset = function(){ - var that = this, config = that.config, layero = that.layero; - var area = [layero.outerWidth(), layero.outerHeight()]; - var type = typeof config.offset === 'object'; - that.offsetTop = (win.height() - area[1])/2; - that.offsetLeft = (win.width() - area[0])/2; - - if(type){ - that.offsetTop = config.offset[0]; - that.offsetLeft = config.offset[1]||that.offsetLeft; - } else if(config.offset !== 'auto'){ - - if(config.offset === 't'){ //上 - that.offsetTop = 0; - } else if(config.offset === 'r'){ //右 - that.offsetLeft = win.width() - area[0]; - } else if(config.offset === 'b'){ //下 - that.offsetTop = win.height() - area[1]; - } else if(config.offset === 'l'){ //左 - that.offsetLeft = 0; - } else if(config.offset === 'lt'){ //左上角 - that.offsetTop = 0; - that.offsetLeft = 0; - } else if(config.offset === 'lb'){ //左下角 - that.offsetTop = win.height() - area[1]; - that.offsetLeft = 0; - } else if(config.offset === 'rt'){ //右上角 - that.offsetTop = 0; - that.offsetLeft = win.width() - area[0]; - } else if(config.offset === 'rb'){ //右下角 - that.offsetTop = win.height() - area[1]; - that.offsetLeft = win.width() - area[0]; - } else { - that.offsetTop = config.offset; - } - - } - - if(!config.fixed){ - that.offsetTop = /%$/.test(that.offsetTop) ? - win.height()*parseFloat(that.offsetTop)/100 - : parseFloat(that.offsetTop); - that.offsetLeft = /%$/.test(that.offsetLeft) ? - win.width()*parseFloat(that.offsetLeft)/100 - : parseFloat(that.offsetLeft); - that.offsetTop += win.scrollTop(); - that.offsetLeft += win.scrollLeft(); - } - - if(layero.attr('minLeft')){ - that.offsetTop = win.height() - (layero.find(doms[1]).outerHeight() || 0); - that.offsetLeft = layero.css('left'); - } - - layero.css({top: that.offsetTop, left: that.offsetLeft}); -}; - -//Tips -Class.pt.tips = function(){ - var that = this, config = that.config, layero = that.layero; - var layArea = [layero.outerWidth(), layero.outerHeight()], follow = $(config.follow); - if(!follow[0]) follow = $('body'); - var goal = { - width: follow.outerWidth(), - height: follow.outerHeight(), - top: follow.offset().top, - left: follow.offset().left - }, tipsG = layero.find('.layui-layer-TipsG'); - - var guide = config.tips[0]; - config.tips[1] || tipsG.remove(); - - goal.autoLeft = function(){ - if(goal.left + layArea[0] - win.width() > 0){ - goal.tipLeft = goal.left + goal.width - layArea[0]; - tipsG.css({right: 12, left: 'auto'}); - } else { - goal.tipLeft = goal.left; - }; - }; - - //辨别tips的方位 - goal.where = [function(){ //上 - goal.autoLeft(); - goal.tipTop = goal.top - layArea[1] - 10; - tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]); - }, function(){ //右 - goal.tipLeft = goal.left + goal.width + 10; - goal.tipTop = goal.top; - tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]); - }, function(){ //下 - goal.autoLeft(); - goal.tipTop = goal.top + goal.height + 10; - tipsG.removeClass('layui-layer-TipsT').addClass('layui-layer-TipsB').css('border-right-color', config.tips[1]); - }, function(){ //左 - goal.tipLeft = goal.left - layArea[0] - 10; - goal.tipTop = goal.top; - tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]); - }]; - goal.where[guide-1](); - - /* 8*2为小三角形占据的空间 */ - if(guide === 1){ - goal.top - (win.scrollTop() + layArea[1] + 8*2) < 0 && goal.where[2](); - } else if(guide === 2){ - win.width() - (goal.left + goal.width + layArea[0] + 8*2) > 0 || goal.where[3]() - } else if(guide === 3){ - (goal.top - win.scrollTop() + goal.height + layArea[1] + 8*2) - win.height() > 0 && goal.where[0](); - } else if(guide === 4){ - layArea[0] + 8*2 - goal.left > 0 && goal.where[1]() - } - - layero.find('.'+doms[5]).css({ - 'background-color': config.tips[1], - 'padding-right': (config.closeBtn ? '30px' : '') - }); - layero.css({ - left: goal.tipLeft - (config.fixed ? win.scrollLeft() : 0), - top: goal.tipTop - (config.fixed ? win.scrollTop() : 0) - }); -} - -//拖拽层 -Class.pt.move = function(){ - var that = this - ,config = that.config - ,_DOC = $(document) - ,layero = that.layero - ,moveElem = layero.find(config.move) - ,resizeElem = layero.find('.layui-layer-resize') - ,dict = {}; - - if(config.move){ - moveElem.css('cursor', 'move'); - } - - moveElem.on('mousedown', function(e){ - e.preventDefault(); - if(config.move){ - dict.moveStart = true; - dict.offset = [ - e.clientX - parseFloat(layero.css('left')) - ,e.clientY - parseFloat(layero.css('top')) - ]; - ready.moveElem.css('cursor', 'move').show(); - } - }); - - resizeElem.on('mousedown', function(e){ - e.preventDefault(); - dict.resizeStart = true; - dict.offset = [e.clientX, e.clientY]; - dict.area = [ - layero.outerWidth() - ,layero.outerHeight() - ]; - ready.moveElem.css('cursor', 'se-resize').show(); - }); - - _DOC.on('mousemove', function(e){ - - //拖拽移动 - if(dict.moveStart){ - var X = e.clientX - dict.offset[0] - ,Y = e.clientY - dict.offset[1] - ,fixed = layero.css('position') === 'fixed'; - - e.preventDefault(); - - dict.stX = fixed ? 0 : win.scrollLeft(); - dict.stY = fixed ? 0 : win.scrollTop(); - - //控制元素不被拖出窗口外 - if(!config.moveOut){ - var setRig = win.width() - layero.outerWidth() + dict.stX - ,setBot = win.height() - layero.outerHeight() + dict.stY; - X < dict.stX && (X = dict.stX); - X > setRig && (X = setRig); - Y < dict.stY && (Y = dict.stY); - Y > setBot && (Y = setBot); - } - - layero.css({ - left: X - ,top: Y - }); - } - - //Resize - if(config.resize && dict.resizeStart){ - var X = e.clientX - dict.offset[0] - ,Y = e.clientY - dict.offset[1]; - - e.preventDefault(); - - layer.style(that.index, { - width: dict.area[0] + X - ,height: dict.area[1] + Y - }) - dict.isResize = true; - config.resizing && config.resizing(layero); - } - }).on('mouseup', function(e){ - if(dict.moveStart){ - delete dict.moveStart; - ready.moveElem.hide(); - config.moveEnd && config.moveEnd(layero); - } - if(dict.resizeStart){ - delete dict.resizeStart; - ready.moveElem.hide(); - } - }); - - return that; -}; - -Class.pt.callback = function(){ - var that = this, layero = that.layero, config = that.config; - that.openLayer(); - if(config.success){ - if(config.type == 2){ - layero.find('iframe').on('load', function(){ - config.success(layero, that.index); - }); - } else { - config.success(layero, that.index); - } - } - layer.ie == 6 && that.IE6(layero); - - //按钮 - layero.find('.'+ doms[6]).children('a').on('click', function(){ - var index = $(this).index(); - if(index === 0){ - if(config.yes){ - config.yes(that.index, layero) - } else if(config['btn1']){ - config['btn1'](that.index, layero) - } else { - layer.close(that.index); - } - } else { - var close = config['btn'+(index+1)] && config['btn'+(index+1)](that.index, layero); - close === false || layer.close(that.index); - } - }); - - //取消 - function cancel(){ - var close = config.cancel && config.cancel(that.index, layero); - close === false || layer.close(that.index); - } - - //右上角关闭回调 - layero.find('.'+ doms[7]).on('click', cancel); - - //点遮罩关闭 - if(config.shadeClose){ - $('#layui-layer-shade'+ that.index).on('click', function(){ - layer.close(that.index); - }); - } - - //最小化 - layero.find('.layui-layer-min').on('click', function(){ - var min = config.min && config.min(layero); - min === false || layer.min(that.index, config); - }); - - //全屏/还原 - layero.find('.layui-layer-max').on('click', function(){ - if($(this).hasClass('layui-layer-maxmin')){ - layer.restore(that.index); - config.restore && config.restore(layero); - } else { - layer.full(that.index, config); - setTimeout(function(){ - config.full && config.full(layero); - }, 100); - } - }); - - config.end && (ready.end[that.index] = config.end); -}; - -//for ie6 恢复select -ready.reselect = function(){ - $.each($('select'), function(index , value){ - var sthis = $(this); - if(!sthis.parents('.'+doms[0])[0]){ - (sthis.attr('layer') == 1 && $('.'+doms[0]).length < 1) && sthis.removeAttr('layer').show(); - } - sthis = null; - }); -}; - -Class.pt.IE6 = function(layero){ - //隐藏select - $('select').each(function(index , value){ - var sthis = $(this); - if(!sthis.parents('.'+doms[0])[0]){ - sthis.css('display') === 'none' || sthis.attr({'layer' : '1'}).hide(); - } - sthis = null; - }); -}; - -//需依赖原型的对外方法 -Class.pt.openLayer = function(){ - var that = this; - - //置顶当前窗口 - layer.zIndex = that.config.zIndex; - layer.setTop = function(layero){ - var setZindex = function(){ - layer.zIndex++; - layero.css('z-index', layer.zIndex + 1); - }; - layer.zIndex = parseInt(layero[0].style.zIndex); - layero.on('mousedown', setZindex); - return layer.zIndex; - }; -}; - -ready.record = function(layero){ - var area = [ - layero.width(), - layero.height(), - layero.position().top, - layero.position().left + parseFloat(layero.css('margin-left')) - ]; - layero.find('.layui-layer-max').addClass('layui-layer-maxmin'); - layero.attr({area: area}); -}; - -ready.rescollbar = function(index){ - if(doms.html.attr('layer-full') == index){ - if(doms.html[0].style.removeProperty){ - doms.html[0].style.removeProperty('overflow'); - } else { - doms.html[0].style.removeAttribute('overflow'); - } - doms.html.removeAttr('layer-full'); - } -}; - -/** 内置成员 */ - -window.layer = layer; - -//获取子iframe的DOM -layer.getChildFrame = function(selector, index){ - index = index || $('.'+doms[4]).attr('times'); - return $('#'+ doms[0] + index).find('iframe').contents().find(selector); -}; - -//得到当前iframe层的索引,子iframe时使用 -layer.getFrameIndex = function(name){ - return $('#'+ name).parents('.'+doms[4]).attr('times'); -}; - -//iframe层自适应宽高 -layer.iframeAuto = function(index){ - if(!index) return; - var heg = layer.getChildFrame('html', index).outerHeight(); - var layero = $('#'+ doms[0] + index); - var titHeight = layero.find(doms[1]).outerHeight() || 0; - var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0; - layero.css({height: heg + titHeight + btnHeight}); - layero.find('iframe').css({height: heg}); -}; - -//重置iframe url -layer.iframeSrc = function(index, url){ - $('#'+ doms[0] + index).find('iframe').attr('src', url); -}; - -//设定层的样式 -layer.style = function(index, options, limit){ - var layero = $('#'+ doms[0] + index) - ,contElem = layero.find('.layui-layer-content') - ,type = layero.attr('type') - ,titHeight = layero.find(doms[1]).outerHeight() || 0 - ,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0 - ,minLeft = layero.attr('minLeft'); - - if(type === ready.type[3] || type === ready.type[4]){ - return; - } - - if(!limit){ - if(parseFloat(options.width) <= 260){ - options.width = 260; - }; - - if(parseFloat(options.height) - titHeight - btnHeight <= 64){ - options.height = 64 + titHeight + btnHeight; - }; - } - - layero.css(options); - btnHeight = layero.find('.'+doms[6]).outerHeight(); - - if(type === ready.type[2]){ - layero.find('iframe').css({ - height: parseFloat(options.height) - titHeight - btnHeight - }); - } else { - contElem.css({ - height: parseFloat(options.height) - titHeight - btnHeight - - parseFloat(contElem.css('padding-top')) - - parseFloat(contElem.css('padding-bottom')) - }) - } -}; - -//最小化 -layer.min = function(index, options){ - var layero = $('#'+ doms[0] + index) - ,titHeight = layero.find(doms[1]).outerHeight() || 0 - ,left = layero.attr('minLeft') || (181*ready.minIndex)+'px' - ,position = layero.css('position'); - - ready.record(layero); - - if(ready.minLeft[0]){ - left = ready.minLeft[0]; - ready.minLeft.shift(); - } - - layero.attr('position', position); - - layer.style(index, { - width: 180 - ,height: titHeight - ,left: left - ,top: win.height() - titHeight - ,position: 'fixed' - ,overflow: 'hidden' - }, true); - - layero.find('.layui-layer-min').hide(); - layero.attr('type') === 'page' && layero.find(doms[4]).hide(); - ready.rescollbar(index); - - if(!layero.attr('minLeft')){ - ready.minIndex++; - } - layero.attr('minLeft', left); -}; - -//还原 -layer.restore = function(index){ - var layero = $('#'+ doms[0] + index), area = layero.attr('area').split(','); - var type = layero.attr('type'); - layer.style(index, { - width: parseFloat(area[0]), - height: parseFloat(area[1]), - top: parseFloat(area[2]), - left: parseFloat(area[3]), - position: layero.attr('position'), - overflow: 'visible' - }, true); - layero.find('.layui-layer-max').removeClass('layui-layer-maxmin'); - layero.find('.layui-layer-min').show(); - layero.attr('type') === 'page' && layero.find(doms[4]).show(); - ready.rescollbar(index); -}; - -//全屏 -layer.full = function(index){ - var layero = $('#'+ doms[0] + index), timer; - ready.record(layero); - if(!doms.html.attr('layer-full')){ - doms.html.css('overflow','hidden').attr('layer-full', index); - } - clearTimeout(timer); - timer = setTimeout(function(){ - var isfix = layero.css('position') === 'fixed'; - layer.style(index, { - top: isfix ? 0 : win.scrollTop(), - left: isfix ? 0 : win.scrollLeft(), - width: win.width(), - height: win.height() - }, true); - layero.find('.layui-layer-min').hide(); - }, 100); -}; - -//改变title -layer.title = function(name, index){ - var title = $('#'+ doms[0] + (index||layer.index)).find(doms[1]); - title.html(name); -}; - -//关闭layer总方法 -layer.close = function(index){ - layer.ready(function(){ - var layero = $('#'+ doms[0] + index), type = layero.attr('type'), closeAnim = 'layer-anim-close'; - if(!layero[0]) return; - var WRAP = 'layui-layer-wrap', remove = function(){ - if(type === ready.type[1] && layero.attr('conType') === 'object'){ - layero.children(':not(.'+ doms[5] +')').remove(); - var wrap = layero.find('.'+WRAP); - for(var i = 0; i < 2; i++){ - wrap.unwrap(); - } - wrap.css('display', wrap.data('display')).removeClass(WRAP); - } else { - //低版本IE 回收 iframe - if(type === ready.type[2]){ - try { - var iframe = $('#'+doms[4]+index)[0]; - iframe.contentWindow.document.write(''); - iframe.contentWindow.close(); - layero.find('.'+doms[5])[0].removeChild(iframe); - } catch(e){} - } - layero[0].innerHTML = ''; - layero.remove(); - } - typeof ready.end[index] === 'function' && ready.end[index](); - delete ready.end[index]; - }; - - if(layero.data('isOutAnim')){ - layero.addClass('layer-anim '+ closeAnim); - } - - $('#layui-layer-moves, #layui-layer-shade' + index).remove(); - layer.ie == 6 && ready.reselect(); - ready.rescollbar(index); - if(layero.attr('minLeft')){ - ready.minIndex--; - ready.minLeft.push(layero.attr('minLeft')); - } - - if((layer.ie && layer.ie < 10) || !layero.data('isOutAnim')){ - remove() - } else { - setTimeout(function(){ - remove(); - }, 200); - } - }); -}; - -//关闭所有层 -layer.closeAll = function(type){ - layer.ready(function(){ - $.each($('.'+doms[0]), function(){ - var othis = $(this); - var is = type ? (othis.attr('type') === type) : 1; - is && layer.close(othis.attr('times')); - is = null; - }); - }); -}; - -/** - - 拓展模块,layui开始合并在一起 - - */ - -var cache = layer.cache||{}, skin = function(type){ - return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : ''); -}; - -//仿系统prompt -layer.prompt = function(options, yes){ - var style = ''; - options = options || {}; - - if(typeof options === 'function') yes = options; - - if(options.area){ - var area = options.area; - style = 'style="width: '+ area[0] +'; height: '+ area[1] + ';"'; - delete options.area; - } - var prompt, content = options.formType == 2 ? '' : function(){ - return ''; - }(); - - var success = options.success; - delete options.success; - - return layer.open($.extend({ - type: 1 - ,btn: ['确定','取消'] - ,content: content - ,skin: 'layui-layer-prompt' + skin('prompt') - ,maxWidth: win.width() - ,success: function(layero){ - prompt = layero.find('.layui-layer-input'); - prompt.val(options.value || '').focus(); - typeof success === 'function' && success(layero); - } - ,resize: false - ,yes: function(index){ - var value = prompt.val(); - if(value === ''){ - prompt.focus(); - } else if(value.length > (options.maxlength||500)) { - layer.tips('最多输入'+ (options.maxlength || 500) +'个字数', prompt, {tips: 1}); - } else { - yes && yes(value, index, prompt); - } - } - }, options)); -}; - -//tab层 -layer.tab = function(options){ - options = options || {}; - - var tab = options.tab || {} - ,THIS = 'layui-this' - ,success = options.success; - - delete options.success; - - return layer.open($.extend({ - type: 1, - skin: 'layui-layer-tab' + skin('tab'), - resize: false, - title: function(){ - var len = tab.length, ii = 1, str = ''; - if(len > 0){ - str = ''+ tab[0].title +''; - for(; ii < len; ii++){ - str += ''+ tab[ii].title +''; - } - } - return str; - }(), - content: '
      '+ function(){ - var len = tab.length, ii = 1, str = ''; - if(len > 0){ - str = '
    • '+ (tab[0].content || 'no content') +'
    • '; - for(; ii < len; ii++){ - str += '
    • '+ (tab[ii].content || 'no content') +'
    • '; - } - } - return str; - }() +'
    ', - success: function(layero){ - var btn = layero.find('.layui-layer-title').children(); - var main = layero.find('.layui-layer-tabmain').children(); - btn.on('mousedown', function(e){ - e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; - var othis = $(this), index = othis.index(); - othis.addClass(THIS).siblings().removeClass(THIS); - main.eq(index).show().siblings().hide(); - typeof options.change === 'function' && options.change(index); - }); - typeof success === 'function' && success(layero); - } - }, options)); -}; - -//相册层 -layer.photos = function(options, loop, key){ - var dict = {}; - options = options || {}; - if(!options.photos) return; - var type = options.photos.constructor === Object; - var photos = type ? options.photos : {}, data = photos.data || []; - var start = photos.start || 0; - dict.imgIndex = (start|0) + 1; - - options.img = options.img || 'img'; - - var success = options.success; - delete options.success; - - if(!type){ //页面直接获取 - var parent = $(options.photos), pushData = function(){ - data = []; - parent.find(options.img).each(function(index){ - var othis = $(this); - othis.attr('layer-index', index); - data.push({ - alt: othis.attr('alt'), - pid: othis.attr('layer-pid'), - src: othis.attr('layer-src') || othis.attr('src'), - thumb: othis.attr('src') - }); - }) - }; - - pushData(); - - if (data.length === 0) return; - - loop || parent.on('click', options.img, function(){ - var othis = $(this), index = othis.attr('layer-index'); - layer.photos($.extend(options, { - photos: { - start: index, - data: data, - tab: options.tab - }, - full: options.full - }), true); - pushData(); - }) - - //不直接弹出 - if(!loop) return; - - } else if (data.length === 0){ - return layer.msg('没有图片'); - } - - //上一张 - dict.imgprev = function(key){ - dict.imgIndex--; - if(dict.imgIndex < 1){ - dict.imgIndex = data.length; - } - dict.tabimg(key); - }; - - //下一张 - dict.imgnext = function(key,errorMsg){ - dict.imgIndex++; - if(dict.imgIndex > data.length){ - dict.imgIndex = 1; - if (errorMsg) {return}; - } - dict.tabimg(key) - }; - - //方向键 - dict.keyup = function(event){ - if(!dict.end){ - var code = event.keyCode; - event.preventDefault(); - if(code === 37){ - dict.imgprev(true); - } else if(code === 39) { - dict.imgnext(true); - } else if(code === 27) { - layer.close(dict.index); - } - } - } - - //切换 - dict.tabimg = function(key){ - if(data.length <= 1) return; - photos.start = dict.imgIndex - 1; - layer.close(dict.index); - return layer.photos(options, true, key); - setTimeout(function(){ - layer.photos(options, true, key); - }, 200); - } - - //一些动作 - dict.event = function(){ - dict.bigimg.hover(function(){ - dict.imgsee.show(); - }, function(){ - dict.imgsee.hide(); - }); - - dict.bigimg.find('.layui-layer-imgprev').on('click', function(event){ - event.preventDefault(); - dict.imgprev(); - }); - - dict.bigimg.find('.layui-layer-imgnext').on('click', function(event){ - event.preventDefault(); - dict.imgnext(); - }); - - $(document).on('keyup', dict.keyup); - }; - - //图片预加载 - function loadImage(url, callback, error) { - var img = new Image(); - img.src = url; - if(img.complete){ - return callback(img); - } - img.onload = function(){ - img.onload = null; - callback(img); - }; - img.onerror = function(e){ - img.onerror = null; - error(e); - }; - }; - - dict.loadi = layer.load(1, { - shade: 'shade' in options ? false : 0.9, - scrollbar: false - }); - - loadImage(data[start].src, function(img){ - layer.close(dict.loadi); - dict.index = layer.open($.extend({ - type: 1, - id: 'layui-layer-photos', - area: function(){ - var imgarea = [img.width, img.height]; - var winarea = [$(window).width() - 100, $(window).height() - 100]; - - //如果 实际图片的宽或者高比 屏幕大(那么进行缩放) - if(!options.full && (imgarea[0]>winarea[0]||imgarea[1]>winarea[1])){ - var wh = [imgarea[0]/winarea[0],imgarea[1]/winarea[1]];//取宽度缩放比例、高度缩放比例 - if(wh[0] > wh[1]){//取缩放比例最大的进行缩放 - imgarea[0] = imgarea[0]/wh[0]; - imgarea[1] = imgarea[1]/wh[0]; - } else if(wh[0] < wh[1]){ - imgarea[0] = imgarea[0]/wh[1]; - imgarea[1] = imgarea[1]/wh[1]; - } - } - - return [imgarea[0]+'px', imgarea[1]+'px']; - }(), - title: false, - shade: 0.9, - shadeClose: true, - closeBtn: false, - move: '.layui-layer-phimg img', - moveType: 1, - scrollbar: false, - moveOut: true, - //anim: Math.random()*5|0, - isOutAnim: false, - skin: 'layui-layer-photos' + skin('photos'), - content: '
    ' - +''+ (data[start].alt||'') +'' - +'
    ' - +(data.length > 1 ? '' : '') - +'
    '+ (data[start].alt||'') +''+ dict.imgIndex +'/'+ data.length +'
    ' - +'
    ' - +'
    ', - success: function(layero, index){ - dict.bigimg = layero.find('.layui-layer-phimg'); - dict.imgsee = layero.find('.layui-layer-imguide,.layui-layer-imgbar'); - dict.event(layero); - options.tab && options.tab(data[start], layero); - typeof success === 'function' && success(layero); - }, end: function(){ - dict.end = true; - $(document).off('keyup', dict.keyup); - } - }, options)); - }, function(){ - layer.close(dict.loadi); - layer.msg('当前图片地址异常
    是否继续查看下一张?', { - time: 30000, - btn: ['下一张', '不看了'], - yes: function(){ - data.length > 1 && dict.imgnext(true,true); - } - }); - }); -}; - -//主入口 -ready.run = function(_$){ - $ = _$; - win = $(window); - doms.html = $('html'); - layer.open = function(deliver){ - var o = new Class(deliver); - return o.index; - }; -}; - -//加载方式 -window.layui && layui.define ? ( - layer.ready() - ,layui.define('jquery', function(exports){ //layui加载 - layer.path = layui.cache.dir; - ready.run(layui.$); - - //暴露模块 - window.layer = layer; - exports('layer', layer); - }) -) : ( - (typeof define === 'function' && define.amd) ? define(['jquery'], function(){ //requirejs加载 - ready.run(window.jQuery); - return layer; - }) : function(){ //普通script标签加载 - ready.run(window.jQuery); - layer.ready(); - }() -); - -}(window); +/** layui-v2.5.7 MIT License */ + ;!function(e,t){"use strict";var i,n,a=e.layui&&layui.define,o={getPath:function(){var e=document.currentScript?document.currentScript.src:function(){for(var e,t=document.scripts,i=t.length-1,n=i;n>0;n--)if("interactive"===t[n].readyState){e=t[n].src;break}return e||t[i].src}();return e.substring(0,e.lastIndexOf("/")+1)}(),config:{},end:{},minIndex:0,minLeft:[],btn:["确定","取消"],type:["dialog","page","iframe","loading","tips"],getStyle:function(t,i){var n=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return n[n.getPropertyValue?"getPropertyValue":"getAttribute"](i)},link:function(t,i,n){if(r.path){var a=document.getElementsByTagName("head")[0],s=document.createElement("link");"string"==typeof i&&(n=i);var l=(n||t).replace(/\.|\//g,""),f="layuicss-"+l,c=0;s.rel="stylesheet",s.href=r.path+t,s.id=f,document.getElementById(f)||a.appendChild(s),"function"==typeof i&&!function u(){return++c>80?e.console&&console.error("layer.css: Invalid"):void(1989===parseInt(o.getStyle(document.getElementById(f),"width"))?i():setTimeout(u,100))}()}}},r={v:"3.1.1",ie:function(){var t=navigator.userAgent.toLowerCase();return!!(e.ActiveXObject||"ActiveXObject"in e)&&((t.match(/msie\s(\d+)/)||[])[1]||"11")}(),index:e.layer&&e.layer.v?1e5:0,path:o.getPath,config:function(e,t){return e=e||{},r.cache=o.config=i.extend({},o.config,e),r.path=o.config.path||r.path,"string"==typeof e.extend&&(e.extend=[e.extend]),o.config.path&&r.ready(),e.extend?(a?layui.addcss("modules/layer/"+e.extend):o.link("theme/"+e.extend),this):this},ready:function(e){var t="layer",i="",n=(a?"modules/layer/":"theme/")+"default/layer.css?v="+r.v+i;return a?layui.addcss(n,e,t):o.link(n,e,t),this},alert:function(e,t,n){var a="function"==typeof t;return a&&(n=t),r.open(i.extend({content:e,yes:n},a?{}:t))},confirm:function(e,t,n,a){var s="function"==typeof t;return s&&(a=n,n=t),r.open(i.extend({content:e,btn:o.btn,yes:n,btn2:a},s?{}:t))},msg:function(e,n,a){var s="function"==typeof n,f=o.config.skin,c=(f?f+" "+f+"-msg":"")||"layui-layer-msg",u=l.anim.length-1;return s&&(a=n),r.open(i.extend({content:e,time:3e3,shade:!1,skin:c,title:!1,closeBtn:!1,btn:!1,resize:!1,end:a},s&&!o.config.skin?{skin:c+" layui-layer-hui",anim:u}:function(){return n=n||{},(n.icon===-1||n.icon===t&&!o.config.skin)&&(n.skin=c+" "+(n.skin||"layui-layer-hui")),n}()))},load:function(e,t){return r.open(i.extend({type:3,icon:e||0,resize:!1,shade:.01},t))},tips:function(e,t,n){return r.open(i.extend({type:4,content:[e,t],closeBtn:!1,time:3e3,shade:!1,resize:!1,fixed:!1,maxWidth:210},n))}},s=function(e){var t=this;t.index=++r.index,t.config=i.extend({},t.config,o.config,e),document.body?t.creat():setTimeout(function(){t.creat()},30)};s.pt=s.prototype;var l=["layui-layer",".layui-layer-title",".layui-layer-main",".layui-layer-dialog","layui-layer-iframe","layui-layer-content","layui-layer-btn","layui-layer-close"];l.anim=["layer-anim-00","layer-anim-01","layer-anim-02","layer-anim-03","layer-anim-04","layer-anim-05","layer-anim-06"],s.pt.config={type:0,shade:.3,fixed:!0,move:l[1],title:"信息",offset:"auto",area:"auto",closeBtn:1,time:0,zIndex:19891014,maxWidth:360,anim:0,isOutAnim:!0,icon:-1,moveType:1,resize:!0,scrollbar:!0,tips:2},s.pt.vessel=function(e,t){var n=this,a=n.index,r=n.config,s=r.zIndex+a,f="object"==typeof r.title,c=r.maxmin&&(1===r.type||2===r.type),u=r.title?'
    '+(f?r.title[0]:r.title)+"
    ":"";return r.zIndex=s,t([r.shade?'
    ':"",'
    '+(e&&2!=r.type?"":u)+'
    '+(0==r.type&&r.icon!==-1?'':"")+(1==r.type&&e?"":r.content||"")+'
    '+function(){var e=c?'':"";return r.closeBtn&&(e+=''),e}()+""+(r.btn?function(){var e="";"string"==typeof r.btn&&(r.btn=[r.btn]);for(var t=0,i=r.btn.length;t'+r.btn[t]+"";return'
    '+e+"
    "}():"")+(r.resize?'':"")+"
    "],u,i('
    ')),n},s.pt.creat=function(){var e=this,t=e.config,a=e.index,s=t.content,f="object"==typeof s,c=i("body");if(!t.id||!i("#"+t.id)[0]){switch("string"==typeof t.area&&(t.area="auto"===t.area?["",""]:[t.area,""]),t.shift&&(t.anim=t.shift),6==r.ie&&(t.fixed=!1),t.type){case 0:t.btn="btn"in t?t.btn:o.btn[0],r.closeAll("dialog");break;case 2:var s=t.content=f?t.content:[t.content||"","auto"];t.content='';break;case 3:delete t.title,delete t.closeBtn,t.icon===-1&&0===t.icon,r.closeAll("loading");break;case 4:f||(t.content=[t.content,"body"]),t.follow=t.content[1],t.content=t.content[0]+'',delete t.title,t.tips="object"==typeof t.tips?t.tips:[t.tips,!0],t.tipsMore||r.closeAll("tips")}if(e.vessel(f,function(n,r,u){c.append(n[0]),f?function(){2==t.type||4==t.type?function(){i("body").append(n[1])}():function(){s.parents("."+l[0])[0]||(s.data("display",s.css("display")).show().addClass("layui-layer-wrap").wrap(n[1]),i("#"+l[0]+a).find("."+l[5]).before(r))}()}():c.append(n[1]),i(".layui-layer-move")[0]||c.append(o.moveElem=u),e.layero=i("#"+l[0]+a),t.scrollbar||l.html.css("overflow","hidden").attr("layer-full",a)}).auto(a),i("#layui-layer-shade"+e.index).css({"background-color":t.shade[1]||"#000",opacity:t.shade[0]||t.shade}),2==t.type&&6==r.ie&&e.layero.find("iframe").attr("src",s[0]),4==t.type?e.tips():e.offset(),t.fixed&&n.on("resize",function(){e.offset(),(/^\d+%$/.test(t.area[0])||/^\d+%$/.test(t.area[1]))&&e.auto(a),4==t.type&&e.tips()}),t.time<=0||setTimeout(function(){r.close(e.index)},t.time),e.move().callback(),l.anim[t.anim]){var u="layer-anim "+l.anim[t.anim];e.layero.addClass(u).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",function(){i(this).removeClass(u)})}t.isOutAnim&&e.layero.data("isOutAnim",!0)}},s.pt.auto=function(e){var t=this,a=t.config,o=i("#"+l[0]+e);""===a.area[0]&&a.maxWidth>0&&(r.ie&&r.ie<8&&a.btn&&o.width(o.innerWidth()),o.outerWidth()>a.maxWidth&&o.width(a.maxWidth));var s=[o.innerWidth(),o.innerHeight()],f=o.find(l[1]).outerHeight()||0,c=o.find("."+l[6]).outerHeight()||0,u=function(e){e=o.find(e),e.height(s[1]-f-c-2*(0|parseFloat(e.css("padding-top"))))};switch(a.type){case 2:u("iframe");break;default:""===a.area[1]?a.maxHeight>0&&o.outerHeight()>a.maxHeight?(s[1]=a.maxHeight,u("."+l[5])):a.fixed&&s[1]>=n.height()&&(s[1]=n.height(),u("."+l[5])):u("."+l[5])}return t},s.pt.offset=function(){var e=this,t=e.config,i=e.layero,a=[i.outerWidth(),i.outerHeight()],o="object"==typeof t.offset;e.offsetTop=(n.height()-a[1])/2,e.offsetLeft=(n.width()-a[0])/2,o?(e.offsetTop=t.offset[0],e.offsetLeft=t.offset[1]||e.offsetLeft):"auto"!==t.offset&&("t"===t.offset?e.offsetTop=0:"r"===t.offset?e.offsetLeft=n.width()-a[0]:"b"===t.offset?e.offsetTop=n.height()-a[1]:"l"===t.offset?e.offsetLeft=0:"lt"===t.offset?(e.offsetTop=0,e.offsetLeft=0):"lb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=0):"rt"===t.offset?(e.offsetTop=0,e.offsetLeft=n.width()-a[0]):"rb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=n.width()-a[0]):e.offsetTop=t.offset),t.fixed||(e.offsetTop=/%$/.test(e.offsetTop)?n.height()*parseFloat(e.offsetTop)/100:parseFloat(e.offsetTop),e.offsetLeft=/%$/.test(e.offsetLeft)?n.width()*parseFloat(e.offsetLeft)/100:parseFloat(e.offsetLeft),e.offsetTop+=n.scrollTop(),e.offsetLeft+=n.scrollLeft()),i.attr("minLeft")&&(e.offsetTop=n.height()-(i.find(l[1]).outerHeight()||0),e.offsetLeft=i.css("left")),i.css({top:e.offsetTop,left:e.offsetLeft})},s.pt.tips=function(){var e=this,t=e.config,a=e.layero,o=[a.outerWidth(),a.outerHeight()],r=i(t.follow);r[0]||(r=i("body"));var s={width:r.outerWidth(),height:r.outerHeight(),top:r.offset().top,left:r.offset().left},f=a.find(".layui-layer-TipsG"),c=t.tips[0];t.tips[1]||f.remove(),s.autoLeft=function(){s.left+o[0]-n.width()>0?(s.tipLeft=s.left+s.width-o[0],f.css({right:12,left:"auto"})):s.tipLeft=s.left},s.where=[function(){s.autoLeft(),s.tipTop=s.top-o[1]-10,f.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left+s.width+10,s.tipTop=s.top,f.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color",t.tips[1])},function(){s.autoLeft(),s.tipTop=s.top+s.height+10,f.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left-o[0]-10,s.tipTop=s.top,f.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color",t.tips[1])}],s.where[c-1](),1===c?s.top-(n.scrollTop()+o[1]+16)<0&&s.where[2]():2===c?n.width()-(s.left+s.width+o[0]+16)>0||s.where[3]():3===c?s.top-n.scrollTop()+s.height+o[1]+16-n.height()>0&&s.where[0]():4===c&&o[0]+16-s.left>0&&s.where[1](),a.find("."+l[5]).css({"background-color":t.tips[1],"padding-right":t.closeBtn?"30px":""}),a.css({left:s.tipLeft-(t.fixed?n.scrollLeft():0),top:s.tipTop-(t.fixed?n.scrollTop():0)})},s.pt.move=function(){var e=this,t=e.config,a=i(document),s=e.layero,l=s.find(t.move),f=s.find(".layui-layer-resize"),c={};return t.move&&l.css("cursor","move"),l.on("mousedown",function(e){e.preventDefault(),t.move&&(c.moveStart=!0,c.offset=[e.clientX-parseFloat(s.css("left")),e.clientY-parseFloat(s.css("top"))],o.moveElem.css("cursor","move").show())}),f.on("mousedown",function(e){e.preventDefault(),c.resizeStart=!0,c.offset=[e.clientX,e.clientY],c.area=[s.outerWidth(),s.outerHeight()],o.moveElem.css("cursor","se-resize").show()}),a.on("mousemove",function(i){if(c.moveStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1],l="fixed"===s.css("position");if(i.preventDefault(),c.stX=l?0:n.scrollLeft(),c.stY=l?0:n.scrollTop(),!t.moveOut){var f=n.width()-s.outerWidth()+c.stX,u=n.height()-s.outerHeight()+c.stY;af&&(a=f),ou&&(o=u)}s.css({left:a,top:o})}if(t.resize&&c.resizeStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1];i.preventDefault(),r.style(e.index,{width:c.area[0]+a,height:c.area[1]+o}),c.isResize=!0,t.resizing&&t.resizing(s)}}).on("mouseup",function(e){c.moveStart&&(delete c.moveStart,o.moveElem.hide(),t.moveEnd&&t.moveEnd(s)),c.resizeStart&&(delete c.resizeStart,o.moveElem.hide())}),e},s.pt.callback=function(){function e(){var e=a.cancel&&a.cancel(t.index,n);e===!1||r.close(t.index)}var t=this,n=t.layero,a=t.config;t.openLayer(),a.success&&(2==a.type?n.find("iframe").on("load",function(){a.success(n,t.index)}):a.success(n,t.index)),6==r.ie&&t.IE6(n),n.find("."+l[6]).children("a").on("click",function(){var e=i(this).index();if(0===e)a.yes?a.yes(t.index,n):a.btn1?a.btn1(t.index,n):r.close(t.index);else{var o=a["btn"+(e+1)]&&a["btn"+(e+1)](t.index,n);o===!1||r.close(t.index)}}),n.find("."+l[7]).on("click",e),a.shadeClose&&i("#layui-layer-shade"+t.index).on("click",function(){r.close(t.index)}),n.find(".layui-layer-min").on("click",function(){var e=a.min&&a.min(n);e===!1||r.min(t.index,a)}),n.find(".layui-layer-max").on("click",function(){i(this).hasClass("layui-layer-maxmin")?(r.restore(t.index),a.restore&&a.restore(n)):(r.full(t.index,a),setTimeout(function(){a.full&&a.full(n)},100))}),a.end&&(o.end[t.index]=a.end)},o.reselect=function(){i.each(i("select"),function(e,t){var n=i(this);n.parents("."+l[0])[0]||1==n.attr("layer")&&i("."+l[0]).length<1&&n.removeAttr("layer").show(),n=null})},s.pt.IE6=function(e){i("select").each(function(e,t){var n=i(this);n.parents("."+l[0])[0]||"none"===n.css("display")||n.attr({layer:"1"}).hide(),n=null})},s.pt.openLayer=function(){var e=this;r.zIndex=e.config.zIndex,r.setTop=function(e){var t=function(){r.zIndex++,e.css("z-index",r.zIndex+1)};return r.zIndex=parseInt(e[0].style.zIndex),e.on("mousedown",t),r.zIndex}},o.record=function(e){var t=[e.width(),e.height(),e.position().top,e.position().left+parseFloat(e.css("margin-left"))];e.find(".layui-layer-max").addClass("layui-layer-maxmin"),e.attr({area:t})},o.rescollbar=function(e){l.html.attr("layer-full")==e&&(l.html[0].style.removeProperty?l.html[0].style.removeProperty("overflow"):l.html[0].style.removeAttribute("overflow"),l.html.removeAttr("layer-full"))},e.layer=r,r.getChildFrame=function(e,t){return t=t||i("."+l[4]).attr("times"),i("#"+l[0]+t).find("iframe").contents().find(e)},r.getFrameIndex=function(e){return i("#"+e).parents("."+l[4]).attr("times")},r.iframeAuto=function(e){if(e){var t=r.getChildFrame("html",e).outerHeight(),n=i("#"+l[0]+e),a=n.find(l[1]).outerHeight()||0,o=n.find("."+l[6]).outerHeight()||0;n.css({height:t+a+o}),n.find("iframe").css({height:t})}},r.iframeSrc=function(e,t){i("#"+l[0]+e).find("iframe").attr("src",t)},r.style=function(e,t,n){var a=i("#"+l[0]+e),r=a.find(".layui-layer-content"),s=a.attr("type"),f=a.find(l[1]).outerHeight()||0,c=a.find("."+l[6]).outerHeight()||0;a.attr("minLeft");s!==o.type[3]&&s!==o.type[4]&&(n||(parseFloat(t.width)<=260&&(t.width=260),parseFloat(t.height)-f-c<=64&&(t.height=64+f+c)),a.css(t),c=a.find("."+l[6]).outerHeight(),s===o.type[2]?a.find("iframe").css({height:parseFloat(t.height)-f-c}):r.css({height:parseFloat(t.height)-f-c-parseFloat(r.css("padding-top"))-parseFloat(r.css("padding-bottom"))}))},r.min=function(e,t){var a=i("#"+l[0]+e),s=a.find(l[1]).outerHeight()||0,f=a.attr("minLeft")||181*o.minIndex+"px",c=a.css("position");o.record(a),o.minLeft[0]&&(f=o.minLeft[0],o.minLeft.shift()),a.attr("position",c),r.style(e,{width:180,height:s,left:f,top:n.height()-s,position:"fixed",overflow:"hidden"},!0),a.find(".layui-layer-min").hide(),"page"===a.attr("type")&&a.find(l[4]).hide(),o.rescollbar(e),a.attr("minLeft")||o.minIndex++,a.attr("minLeft",f)},r.restore=function(e){var t=i("#"+l[0]+e),n=t.attr("area").split(",");t.attr("type");r.style(e,{width:parseFloat(n[0]),height:parseFloat(n[1]),top:parseFloat(n[2]),left:parseFloat(n[3]),position:t.attr("position"),overflow:"visible"},!0),t.find(".layui-layer-max").removeClass("layui-layer-maxmin"),t.find(".layui-layer-min").show(),"page"===t.attr("type")&&t.find(l[4]).show(),o.rescollbar(e)},r.full=function(e){var t,a=i("#"+l[0]+e);o.record(a),l.html.attr("layer-full")||l.html.css("overflow","hidden").attr("layer-full",e),clearTimeout(t),t=setTimeout(function(){var t="fixed"===a.css("position");r.style(e,{top:t?0:n.scrollTop(),left:t?0:n.scrollLeft(),width:n.width(),height:n.height()},!0),a.find(".layui-layer-min").hide()},100)},r.title=function(e,t){var n=i("#"+l[0]+(t||r.index)).find(l[1]);n.html(e)},r.close=function(e){var t=i("#"+l[0]+e),n=t.attr("type"),a="layer-anim-close";if(t[0]){var s="layui-layer-wrap",f=function(){if(n===o.type[1]&&"object"===t.attr("conType")){t.children(":not(."+l[5]+")").remove();for(var a=t.find("."+s),r=0;r<2;r++)a.unwrap();a.css("display",a.data("display")).removeClass(s)}else{if(n===o.type[2])try{var f=i("#"+l[4]+e)[0];f.contentWindow.document.write(""),f.contentWindow.close(),t.find("."+l[5])[0].removeChild(f)}catch(c){}t[0].innerHTML="",t.remove()}"function"==typeof o.end[e]&&o.end[e](),delete o.end[e]};t.data("isOutAnim")&&t.addClass("layer-anim "+a),i("#layui-layer-moves, #layui-layer-shade"+e).remove(),6==r.ie&&o.reselect(),o.rescollbar(e),t.attr("minLeft")&&(o.minIndex--,o.minLeft.push(t.attr("minLeft"))),r.ie&&r.ie<10||!t.data("isOutAnim")?f():setTimeout(function(){f()},200)}},r.closeAll=function(e){i.each(i("."+l[0]),function(){var t=i(this),n=e?t.attr("type")===e:1;n&&r.close(t.attr("times")),n=null})};var f=r.cache||{},c=function(e){return f.skin?" "+f.skin+" "+f.skin+"-"+e:""};r.prompt=function(e,t){var a="";if(e=e||{},"function"==typeof e&&(t=e),e.area){var o=e.area;a='style="width: '+o[0]+"; height: "+o[1]+';"',delete e.area}var s,l=2==e.formType?'":function(){return''}(),f=e.success;return delete e.success,r.open(i.extend({type:1,btn:["确定","取消"],content:l,skin:"layui-layer-prompt"+c("prompt"),maxWidth:n.width(),success:function(t){s=t.find(".layui-layer-input"),s.val(e.value||"").focus(),"function"==typeof f&&f(t)},resize:!1,yes:function(i){var n=s.val();""===n?s.focus():n.length>(e.maxlength||500)?r.tips("最多输入"+(e.maxlength||500)+"个字数",s,{tips:1}):t&&t(n,i,s)}},e))},r.tab=function(e){e=e||{};var t=e.tab||{},n="layui-this",a=e.success;return delete e.success,r.open(i.extend({type:1,skin:"layui-layer-tab"+c("tab"),resize:!1,title:function(){var e=t.length,i=1,a="";if(e>0)for(a=''+t[0].title+"";i"+t[i].title+"";return a}(),content:'
      '+function(){var e=t.length,i=1,a="";if(e>0)for(a='
    • '+(t[0].content||"no content")+"
    • ";i'+(t[i].content||"no content")+"";return a}()+"
    ",success:function(t){var o=t.find(".layui-layer-title").children(),r=t.find(".layui-layer-tabmain").children();o.on("mousedown",function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0;var a=i(this),o=a.index();a.addClass(n).siblings().removeClass(n),r.eq(o).show().siblings().hide(),"function"==typeof e.change&&e.change(o)}),"function"==typeof a&&a(t)}},e))},r.photos=function(t,n,a){function o(e,t,i){var n=new Image;return n.src=e,n.complete?t(n):(n.onload=function(){n.onload=null,t(n)},void(n.onerror=function(e){n.onerror=null,i(e)}))}var s={};if(t=t||{},t.photos){var l=t.photos.constructor===Object,f=l?t.photos:{},u=f.data||[],d=f.start||0;s.imgIndex=(0|d)+1,t.img=t.img||"img";var y=t.success;if(delete t.success,l){if(0===u.length)return r.msg("没有图片")}else{var p=i(t.photos),h=function(){u=[],p.find(t.img).each(function(e){var t=i(this);t.attr("layer-index",e),u.push({alt:t.attr("alt"),pid:t.attr("layer-pid"),src:t.attr("layer-src")||t.attr("src"),thumb:t.attr("src")})})};if(h(),0===u.length)return;if(n||p.on("click",t.img,function(){var e=i(this),n=e.attr("layer-index");r.photos(i.extend(t,{photos:{start:n,data:u,tab:t.tab},full:t.full}),!0),h()}),!n)return}s.imgprev=function(e){s.imgIndex--,s.imgIndex<1&&(s.imgIndex=u.length),s.tabimg(e)},s.imgnext=function(e,t){s.imgIndex++,s.imgIndex>u.length&&(s.imgIndex=1,t)||s.tabimg(e)},s.keyup=function(e){if(!s.end){var t=e.keyCode;e.preventDefault(),37===t?s.imgprev(!0):39===t?s.imgnext(!0):27===t&&r.close(s.index)}},s.tabimg=function(e){if(!(u.length<=1))return f.start=s.imgIndex-1,r.close(s.index),r.photos(t,!0,e)},s.event=function(){s.bigimg.hover(function(){s.imgsee.show()},function(){s.imgsee.hide()}),s.bigimg.find(".layui-layer-imgprev").on("click",function(e){e.preventDefault(),s.imgprev()}),s.bigimg.find(".layui-layer-imgnext").on("click",function(e){e.preventDefault(),s.imgnext()}),i(document).on("keyup",s.keyup)},s.loadi=r.load(1,{shade:!("shade"in t)&&.9,scrollbar:!1}),o(u[d].src,function(n){r.close(s.loadi),s.index=r.open(i.extend({type:1,id:"layui-layer-photos",area:function(){var a=[n.width,n.height],o=[i(e).width()-100,i(e).height()-100];if(!t.full&&(a[0]>o[0]||a[1]>o[1])){var r=[a[0]/o[0],a[1]/o[1]];r[0]>r[1]?(a[0]=a[0]/r[0],a[1]=a[1]/r[0]):r[0]'+(u[d].alt||
    '+(u.length>1?'':"")+'
    '+(u[d].alt||"")+""+s.imgIndex+"/"+u.length+"
    ",success:function(e,i){s.bigimg=e.find(".layui-layer-phimg"),s.imgsee=e.find(".layui-layer-imguide,.layui-layer-imgbar"),s.event(e),t.tab&&t.tab(u[d],e),"function"==typeof y&&y(e)},end:function(){s.end=!0,i(document).off("keyup",s.keyup)}},t))},function(){r.close(s.loadi),r.msg("当前图片地址异常
    是否继续查看下一张?",{time:3e4,btn:["下一张","不看了"],yes:function(){u.length>1&&s.imgnext(!0,!0)}})})}},o.run=function(t){i=t,n=i(e),l.html=i("html"),r.open=function(e){var t=new s(e);return t.index}},e.layui&&layui.define?(r.ready(),layui.define("jquery",function(t){r.path=layui.cache.dir,o.run(layui.$),e.layer=r,t("layer",r)})):"function"==typeof define&&define.amd?define(["jquery"],function(){return o.run(e.jQuery),r}):function(){o.run(e.jQuery),r.ready()}()}(window); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/layim.js b/IoTGateway/wwwroot/layui/lay/modules/layim.js new file mode 100644 index 0000000..74aa620 --- /dev/null +++ b/IoTGateway/wwwroot/layui/lay/modules/layim.js @@ -0,0 +1,3 @@ +/** layui-v2.4.5 MIT License By https://www.layui.com */ + ;layui.define(["layer","laytpl","upload"],function(i){var a="3.8.0",e=layui.$,t=layui.layer,n=layui.laytpl,l=layui.device(),s="layui-show",o="layim-this",d=20,r={},c=function(){this.v=a,e("body").on("click","*[layim-event]",function(i){var a=e(this),t=a.attr("layim-event");ti[t]?ti[t].call(this,a,i):""})};c.prototype.config=function(i){var a=[];if(layui.each(Array(5),function(i){a.push(layui.cache.dir+"css/modules/layim/skin/"+(i+1)+".jpg")}),i=i||{},i.skin=i.skin||[],layui.each(i.skin,function(i,e){a.unshift(e)}),i.skin=a,i=e.extend({isfriend:!0,isgroup:!0,voice:"default.mp3"},i),window.JSON&&window.JSON.parse)return H(i),this},c.prototype.on=function(i,a){return"function"==typeof a&&(r[i]?r[i].push(a):r[i]=[a]),this},c.prototype.cache=function(){return j},c.prototype.chat=function(i){if(window.JSON&&window.JSON.parse)return z(i),this},c.prototype.setChatMin=function(){return N(),this},c.prototype.setChatStatus=function(i){var a=_();if(a){var e=a.elem.find(".layim-chat-status");return e.html(i),this}},c.prototype.getMessage=function(i){return K(i),this},c.prototype.notice=function(i){return J(i),this},c.prototype.add=function(i){return M(i),this},c.prototype.setFriendGroup=function(i){return M(i,"setGroup"),this},c.prototype.msgbox=function(i){return V(i),this},c.prototype.addList=function(i){return P(i),this},c.prototype.removeList=function(i){return W(i),this},c.prototype.setFriendStatus=function(i,a){var t=e(".layim-friend"+i);t["online"===a?"removeClass":"addClass"]("layim-list-gray")},c.prototype.content=function(i){return layui.data.content(i)};var u=function(i){var a={friend:"该分组下暂无好友",group:"暂无群组",history:"暂无历史会话"};return i=i||{},i.item=i.item||"d."+i.type,["{{# var length = 0; layui.each("+i.item+", function(i, data){ length++; }}",'
  • {{ data.username||data.groupname||data.name||"佚名" }}

    {{ data.remark||data.sign||"" }}

    new
  • ',"{{# }); if(length === 0){ }}",'
  • '+(a[i.type]||"暂无数据")+"
  • ","{{# } }}"].join("")},y=['
    ','
    ','
    {{ d.mine.username }}
    ','
    ','{{# if(d.mine.status === "online"){ }}','','{{# } else if(d.mine.status === "hide") { }}','',"{{# } }}",'
      ','
    • 在线
    • ','
    • 隐身
    • ',"
    ","
    ",'',"
    ",'
      ','
    • ','
    • ','
    • ',"
    ",'
      ','{{# layui.each(d.friend, function(index, item){ var spread = d.local["spread"+index]; }}',"
    • ",'
      {{# if(spread === "true"){ }}{{# } else { }}{{# } }}{{ item.groupname||"未命名分组"+index }}( {{ (item.list||[]).length }})
      ','
        ',u({type:"friend",item:"item.list",index:"index"}),"
      ","
    • ","{{# }); if(d.friend.length === 0){ }}",'
      • 暂无联系人
      ',"{{# } }}","
    ",'
      ',"
    • ",'
        ',u({type:"group"}),"
      ","
    • ","
    ",'
      ',"
    • ",'
        ',u({type:"history"}),"
      ","
    • ","
    ",'
      ',"
    • ",'',"
    • ","
    ",'
      ','',"{{# if(d.base.msgbox){ }}",'
    • ',"{{# } }}","{{# if(d.base.find){ }}",'
    • ',"{{# } }}",'
    • ',"{{# if(!d.base.copyright){ }}",'
    • ',"{{# } }}","
    ",'',"
    "].join(""),m=['
      ',"{{# layui.each(d.skin, function(index, item){ }}",'
    • ',"{{# }); }}",'
    • 简约
    • ',"
    "].join(""),f=['
    ','
    ','
    ','{{ d.data.name||"佚名" }} {{d.data.temporary ? "临时会话" : ""}} {{# if(d.data.type==="group"){ }} {{# } }}','

    ',"
    ","
    ",'
    ',"
      ","
      ",'","
      "].join(""),p=['
      ','

      {{ d.data.name||"" }}

      ','
      ','{{# if(d.data.type === "friend" && d.type === "setGroup"){ }}',"

      选择分组

      ",'{{# } if(d.data.type === "friend"){ }}','","{{# } }}",'{{# if(d.data.type === "group"){ }}',"

      请输入验证信息

      ",'{{# } if(d.type !== "setGroup"){ }}','',"{{# } }}","
      ","
      "].join(""),h=['
    • ','
      ',"{{# if(d.mine){ }}",'{{ layui.data.date(d.timestamp) }}{{ d.username||"佚名" }}',"{{# } else { }}",'{{ d.username||"佚名" }}{{ layui.data.date(d.timestamp) }}',"{{# } }}","
      ",'
      {{ layui.data.content(d.content||" ") }}
      ',"
    • "].join(""),v='
    • {{ d.data.name||"佚名" }}{{# if(!d.base.brief){ }}{{# } }}
    • ',g=function(i){return i<10?"0"+(0|i):i};layui.data.date=function(i){var a=new Date(i||new Date);return a.getFullYear()+"-"+g(a.getMonth()+1)+"-"+g(a.getDate())+" "+g(a.getHours())+":"+g(a.getMinutes())+":"+g(a.getSeconds())},layui.data.content=function(i){var a=function(i){return new RegExp("\\n*\\["+(i||"")+"(code|pre|div|span|p|table|thead|th|tbody|tr|td|ul|li|ol|li|dl|dt|dd|h2|h3|h4|h5)([\\s\\S]*?)\\]\\n*","g")};return i=(i||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""").replace(/@(\S+)(\s+?|$)/g,'@$1$2').replace(/face\[([^\s\[\]]+?)\]/g,function(i){var a=i.replace(/^face/g,"");return''+a+''}).replace(/img\[([^\s]+?)\]/g,function(i){return''}).replace(/file\([\s\S]+?\)\[[\s\S]*?\]/g,function(i){var a=(i.match(/file\(([\s\S]+?)\)\[/)||[])[1],e=(i.match(/\)\[([\s\S]*?)\]/)||[])[1];return a?''+(e||a)+"":i}).replace(/audio\[([^\s]+?)\]/g,function(i){return'

      音频消息

      '}).replace(/video\[([^\s]+?)\]/g,function(i){return'
      '}).replace(/a\([\s\S]+?\)\[[\s\S]*?\]/g,function(i){var a=(i.match(/a\(([\s\S]+?)\)\[/)||[])[1],e=(i.match(/\)\[([\s\S]*?)\]/)||[])[1];return a?''+(e||a)+"":i}).replace(a(),"<$1 $2>").replace(a("/"),"").replace(/\n/g,"
      ")};var x,b,w,k,C,S=function(i,a,n){return i=i||{},e.ajax({url:i.url,type:i.type||"get",data:i.data,dataType:i.dataType||"json",cache:!1,success:function(i){0==i.code?a&&a(i.data||{}):t.msg(i.msg||(n||"Error")+": LAYIM_NOT_GET_DATA",{time:5e3})},error:function(i,a){window.console&&console.log&&console.error("LAYIM_DATE_ERROR:"+a)}})},j={message:{},chat:[]},H=function(i){var a=i.init||{};return mine=a.mine||{},local=layui.data("layim")[mine.id]||{},obj={base:i,local:local,mine:mine,history:local.history||{}},create=function(a){var t=a.mine||{},l=layui.data("layim")[t.id]||{},s={base:i,local:l,mine:t,friend:a.friend||[],group:a.group||[],history:l.history||{}};j=e.extend(j,s),L(n(y).render(s)),(l.close||i.min)&&T(),layui.each(r.ready,function(i,a){a&&a(s)})},j=e.extend(j,obj),i.brief?layui.each(r.ready,function(i,a){a&&a(obj)}):void(a.url?S(a,create,"INIT"):create(a))},L=function(i){return t.open({type:1,area:["260px","520px"],skin:"layui-box layui-layim",title:"​",offset:"rb",id:"layui-layim",shade:!1,anim:2,resize:!1,content:i,success:function(i){x=i,R(i),j.base.right&&i.css("margin-left","-"+j.base.right),b&&t.close(b.attr("times"));var a=[],n=i.find(".layim-list-history");n.find("li").each(function(){a.push(e(this).prop("outerHTML"))}),a.length>0&&(a.reverse(),n.html(a.join(""))),A(),ti.sign()},cancel:function(i){T();var a=layui.data("layim")[j.mine.id]||{};return a.close=!0,layui.data("layim",{key:j.mine.id,value:a}),!1}})},A=function(){x.on("contextmenu",function(i){return i.cancelBubble=!0,i.returnValue=!1,!1});var i=function(){t.closeAll("tips")};x.find(".layim-list-history").on("contextmenu","li",function(a){var n=e(this),l='
      • 移除该会话
      • 清空全部会话列表
      ';n.hasClass("layim-null")||(t.tips(l,this,{tips:1,time:0,anim:5,fixed:!0,skin:"layui-box layui-layim-contextmenu",success:function(i){var a=function(i){ii(i)};i.off("mousedown",a).on("mousedown",a)}}),e(document).off("mousedown",i).on("mousedown",i),e(window).off("resize",i).on("resize",i))})},T=function(i){return b&&t.close(b.attr("times")),x&&x.hide(),j.mine=j.mine||{},t.open({type:1,title:!1,id:"layui-layim-close",skin:"layui-box layui-layim-min layui-layim-close",shade:!1,closeBtn:!1,anim:2,offset:"rb",resize:!1,content:''+(i||j.base.title||"我的LayIM")+"",move:"#layui-layim-close img",success:function(i,a){b=i,j.base.right&&i.css("margin-left","-"+j.base.right),i.on("click",function(){t.close(a),x.show();var i=layui.data("layim")[j.mine.id]||{};delete i.close,layui.data("layim",{key:j.mine.id,value:i})})}})},z=function(i){i=i||{};var a=e("#layui-layim-chat"),l={data:i,base:j.base,local:j.local};if(!i.id)return t.msg("非法用户");if(a[0]){var s=w.find(".layim-chat-list"),o=s.find(".layim-chatlist-"+i.type+i.id),d=w.find(".layui-layer-max").hasClass("layui-layer-maxmin"),c=a.children(".layim-chat-box");return"none"===w.css("display")&&w.show(),k&&t.close(k.attr("times")),1!==s.find("li").length||o[0]||(d||w.css("width",800),s.css({height:w.height()}).show(),c.css("margin-left","200px")),o[0]||(s.append(n(v).render(l)),c.append(n(f).render(l)),I(i),E()),O(s.find(".layim-chatlist-"+i.type+i.id)),o[0]||U(),$(i),Q(),C}l.first=!0;var u=C=t.open({type:1,area:"600px",skin:"layui-box layui-layim-chat",id:"layui-layim-chat",title:"​",shade:!1,maxmin:!0,offset:i.offset||"auto",anim:i.anim||0,closeBtn:!j.base.brief&&1,content:n('
        '+v+'
      '+f+"
      ").render(l),success:function(a){w=a,a.css({"min-width":"500px","min-height":"420px"}),I(i),"function"==typeof i.success&&i.success(a),Q(),R(a),$(i),U(),q(),layui.each(r.chatChange,function(i,a){a&&a(_())}),a.on("dblclick",".layui-layim-photos",function(){var i=this.src;t.close(z.photosIndex),t.photos({photos:{data:[{alt:"大图模式",src:i}]},shade:.01,closeBtn:2,anim:0,resize:!1,success:function(i,a){z.photosIndex=a}})})},full:function(i){t.style(u,{width:"100%",height:"100%"},!0),E()},resizing:E,restore:E,min:function(){return N(),!1},end:function(){t.closeAll("tips"),w=null}});return u},I=function(i){e(".layim-"+i.type+i.id).each(function(){e(this).hasClass("layim-list-gray")&&layui.layim.setFriendStatus(i.id,"offline")})},E=function(){var i=w.find(".layim-chat-list"),a=w.find(".layim-chat-main"),e=w.height();i.css({height:e}),a.css({height:e-20-80-158})},N=function(i){var a=i||_().data,n=layui.layim.cache().base;w&&!i&&w.hide(),t.close(N.index),N.index=t.open({type:1,title:!1,skin:"layui-box layui-layim-min",shade:!1,closeBtn:!1,anim:a.anim||2,offset:"b",move:"#layui-layim-min",resize:!1,area:["182px","50px"],content:''+a.name+"",success:function(a,l){i||(k=a),n.minRight&&t.style(l,{left:e(window).width()-a.outerWidth()-parseFloat(n.minRight)}),a.find(".layui-layer-content span").on("click",function(){t.close(l),i?layui.each(j.chat,function(i,a){z(a)}):w.show(),i&&(j.chat=[],Z())}),a.find(".layui-layer-content img").on("click",function(i){ii(i)})}})},M=function(i,a){return i=i||{},t.close(M.index),M.index=t.open({type:1,area:"430px",title:{friend:"添加好友",group:"加入群组"}[i.type]||"",shade:!1,resize:!1,btn:a?["确认","取消"]:["发送申请","关闭"],content:n(p).render({data:{name:i.username||i.groupname,avatar:i.avatar,group:i.group||parent.layui.layim.cache().friend||[],type:i.type},type:a}),yes:function(e,t){var n=t.find("#LAY_layimGroup"),l=t.find("#LAY_layimRemark");a?i.submit&&i.submit(n.val(),e):i.submit&&i.submit(n.val(),l.val(),e)}})},O=function(i,a){i=i||e(".layim-chat-list ."+o);var n=i.index()===-1?0:i.index(),l=".layim-chat",d=w.find(l).eq(n),c=w.find(".layui-layer-max").hasClass("layui-layer-maxmin");if(a){i.hasClass(o)&&O(0===n?i.next():i.prev());var u=w.find(l).length;return 1===u?t.close(C):(i.remove(),d.remove(),2===u&&(w.find(".layim-chat-list").hide(),c||w.css("width","600px"),w.find(".layim-chat-box").css("margin-left",0)),!1)}i.addClass(o).siblings().removeClass(o),d.addClass(s).siblings(l).removeClass(s),d.find("textarea").focus(),layui.each(r.chatChange,function(i,a){a&&a(_())}),q()},q=function(){var i=_(),a=j.message[i.data.type+i.data.id];a&&delete j.message[i.data.type+i.data.id]},_=c.prototype.thisChat=function(){if(w){var i=e(".layim-chat-list ."+o).index(),a=w.find(".layim-chat").eq(i),t=JSON.parse(decodeURIComponent(a.find(".layim-chat-tool").data("json")));return{elem:a,data:t,textarea:a.find("textarea")}}},R=function(i){var a=layui.data("layim")[j.mine.id]||{},e=a.skin;i.css({"background-image":e?"url("+e+")":function(){return j.base.initSkin?"url("+(layui.cache.dir+"css/modules/layim/skin/"+j.base.initSkin)+")":"none"}()})},$=function(i){var a=layui.data("layim")[j.mine.id]||{},e={},t=a.history||{},l=t[i.type+i.id];if(x){var s=x.find(".layim-list-history");if(i.historyTime=(new Date).getTime(),t[i.type+i.id]=i,a.history=t,layui.data("layim",{key:j.mine.id,value:a}),!l){e[i.type+i.id]=i;var o=n(u({type:"history",item:"d.data"})).render({data:e});s.prepend(o),s.find(".layim-null").remove()}}},D=function(){var i={username:j.mine?j.mine.username:"访客",avatar:j.mine?j.mine.avatar:layui.cache.dir+"css/pc/layim/skin/logo.jpg",id:j.mine?j.mine.id:null,mine:!0},a=_(),e=a.elem.find(".layim-chat-main ul"),l=j.base.maxLength||3e3;if(i.content=a.textarea.val(),""!==i.content.replace(/\s/g,"")){if(i.content.length>l)return t.msg("内容最长不能超过"+l+"个字符");e.append(n(h).render(i));var s={mine:i,to:a.data},o={username:s.mine.username,avatar:s.mine.avatar,id:s.to.id,type:s.to.type,content:s.mine.content,timestamp:(new Date).getTime(),mine:!0};B(o),layui.each(r.sendMessage,function(i,a){a&&a(s)})}Z(),a.textarea.val("").focus()},J=function(i){if(i=i||{},window.Notification)if("granted"===Notification.permission){new Notification(i.title||"",{body:i.content||"",icon:i.avatar||"http://tp2.sinaimg.cn/5488749285/50/5719808192/1"})}else Notification.requestPermission()},F=function(){if(!(l.ie&&l.ie<9)){var i=document.createElement("audio");i.src=layui.cache.dir+"css/modules/layim/voice/"+j.base.voice,i.play()}},G={},K=function(i){i=i||{};var a=e(".layim-chatlist-"+i.type+i.id),t={},l=a.index();if(i.timestamp=i.timestamp||(new Date).getTime(),i.fromid==j.mine.id&&(i.mine=!0),i.system||B(i),G=JSON.parse(JSON.stringify(i)),j.base.voice&&F(),!w&&i.content||l===-1){if(j.message[i.type+i.id])j.message[i.type+i.id].push(i);else if(j.message[i.type+i.id]=[i],"friend"===i.type){var s;layui.each(j.friend,function(a,e){if(layui.each(e.list,function(a,e){if(e.id==i.id)return e.type="friend",e.name=e.username,j.chat.push(e),s=!0}),s)return!0}),s||(i.name=i.username,i.temporary=!0,j.chat.push(i))}else if("group"===i.type){var o;layui.each(j.group,function(a,e){if(e.id==i.id)return e.type="group",e.name=e.groupname,j.chat.push(e),o=!0}),o||(i.name=i.groupname,j.chat.push(i))}else i.name=i.name||i.username||i.groupname,j.chat.push(i);if("group"===i.type&&layui.each(j.group,function(a,e){if(e.id==i.id)return t.avatar=e.avatar,!0}),!i.system)return j.base.notice&&J({title:"来自 "+i.username+" 的消息",content:i.content,avatar:t.avatar||i.avatar}),N({name:"收到新消息",avatar:t.avatar||i.avatar,anim:6})}if(w){var d=_();d.data.type+d.data.id!==i.type+i.id&&(a.addClass("layui-anim layer-anim-06"),setTimeout(function(){a.removeClass("layui-anim layer-anim-06")},300));var r=w.find(".layim-chat").eq(l),c=r.find(".layim-chat-main ul");i.system?l!==-1&&c.append('
    • '+i.content+"
    • "):""!==i.content.replace(/\s/g,"")&&c.append(n(h).render(i)),Z()}},Y="layui-anim-loop layer-anim-05",V=function(i){var a=x.find(".layim-tool-msgbox");a.find("span").addClass(Y).html(i)},B=function(i){var a=layui.data("layim")[j.mine.id]||{};a.chatlog=a.chatlog||{};var e=a.chatlog[i.type+i.id];if(e){var t;layui.each(e,function(a,e){e.timestamp===i.timestamp&&e.type===i.type&&e.id===i.id&&e.content===i.content&&(t=!0)}),t||i.fromid==j.mine.id||e.push(i),e.length>d&&e.shift()}else a.chatlog[i.type+i.id]=[i];layui.data("layim",{key:j.mine.id,value:a})},U=function(){var i=layui.data("layim")[j.mine.id]||{},a=_(),e=i.chatlog||{},t=a.elem.find(".layim-chat-main ul");layui.each(e[a.data.type+a.data.id],function(i,a){t.append(n(h).render(a))}),Z()},P=function(i){var a,e={},l=x.find(".layim-list-"+i.type);if(j[i.type])if("friend"===i.type)layui.each(j.friend,function(n,l){if(i.groupid==l.id)return layui.each(j.friend[n].list,function(e,t){if(t.id==i.id)return a=!0}),a?t.msg("好友 ["+(i.username||"")+"] 已经存在列表中",{anim:6}):(j.friend[n].list=j.friend[n].list||[],e[j.friend[n].list.length]=i,i.groupIndex=n,j.friend[n].list.push(i),!0)});else if("group"===i.type){if(layui.each(j.group,function(e,t){if(t.id==i.id)return a=!0}),a)return t.msg("您已是 ["+(i.groupname||"")+"] 的群成员",{anim:6});e[j.group.length]=i,j.group.push(i)}if(!a){var s=n(u({type:i.type,item:"d.data",index:"friend"===i.type?"data.groupIndex":null})).render({data:e});if("friend"===i.type){var o=l.find(">li").eq(i.groupIndex);o.find(".layui-layim-list").append(s),o.find(".layim-count").html(j.friend[i.groupIndex].list.length),o.find(".layim-null")[0]&&o.find(".layim-null").remove()}else"group"===i.type&&(l.append(s),l.find(".layim-null")[0]&&l.find(".layim-null").remove())}},W=function(i){var a=x.find(".layim-list-"+i.type);j[i.type]&&("friend"===i.type?layui.each(j.friend,function(e,t){layui.each(t.list,function(t,n){if(i.id==n.id){var l=a.find(">li").eq(e);l.find(".layui-layim-list>li");return l.find(".layui-layim-list>li").eq(t).remove(),j.friend[e].list.splice(t,1),l.find(".layim-count").html(j.friend[e].list.length),0===j.friend[e].list.length&&l.find(".layui-layim-list").html('
    • 该分组下已无好友了
    • '),!0}})}):"group"===i.type&&layui.each(j.group,function(e,t){if(i.id==t.id)return a.find(">li").eq(e).remove(),j.group.splice(e,1),0===j.group.length&&a.html('
    • 暂无群组
    • '),!0}))},Z=function(){var i=_(),a=i.elem.find(".layim-chat-main"),e=a.find("ul"),t=e.find("li").length;if(t>=d){var n=e.find("li").eq(0);e.prev().hasClass("layim-chat-system")||e.before('
      查看更多记录
      '),t>d&&n.remove()}a.scrollTop(a[0].scrollHeight+1e3),a.find("ul li:last").find("img").load(function(){a.scrollTop(a[0].scrollHeight+1e3)})},Q=function(){var i=_(),a=i.textarea;a.focus(),a.off("keydown").on("keydown",function(i){var e=layui.data("layim")[j.mine.id]||{},t=i.keyCode;if("Ctrl+Enter"===e.sendHotKey)return void(i.ctrlKey&&13===t&&D());if(13===t){if(i.ctrlKey)return a.val(a.val()+"\n");if(i.shiftKey)return;i.preventDefault(),D()}})},X=function(){var i=["[微笑]","[嘻嘻]","[哈哈]","[可爱]","[可怜]","[挖鼻]","[吃惊]","[害羞]","[挤眼]","[闭嘴]","[鄙视]","[爱你]","[泪]","[偷笑]","[亲亲]","[生病]","[太开心]","[白眼]","[右哼哼]","[左哼哼]","[嘘]","[衰]","[委屈]","[吐]","[哈欠]","[抱抱]","[怒]","[疑问]","[馋嘴]","[拜拜]","[思考]","[汗]","[困]","[睡]","[钱]","[失望]","[酷]","[色]","[哼]","[鼓掌]","[晕]","[悲伤]","[抓狂]","[黑线]","[阴险]","[怒骂]","[互粉]","[心]","[伤心]","[猪头]","[熊猫]","[兔子]","[ok]","[耶]","[good]","[NO]","[赞]","[来]","[弱]","[草泥马]","[神马]","[囧]","[浮云]","[给力]","[围观]","[威武]","[奥特曼]","[礼物]","[钟]","[话筒]","[蜡烛]","[蛋糕]"],a={};return layui.each(i,function(i,e){a[e]=layui.cache.dir+"images/face/"+i+".gif"}),a}(),ii=layui.stope,ai=function(i,a){var e,t=i.value;i.focus(),document.selection?(e=document.selection.createRange(),document.selection.empty(),e.text=a):(e=[t.substring(0,i.selectionStart),a,t.substr(i.selectionEnd)],i.focus(),i.value=e.join(""))},ei="layui-anim-upbit",ti={status:function(i,a){var t=function(){i.next().hide().removeClass(ei)},n=i.attr("lay-type");if("show"===n)ii(a),i.next().show().addClass(ei),e(document).off("click",t).on("click",t);else{var l=i.parent().prev();i.addClass(o).siblings().removeClass(o),l.html(i.find("cite").html()),l.removeClass("layim-status-"+("online"===n?"hide":"online")).addClass("layim-status-"+n),layui.each(r.online,function(i,a){a&&a(n)})}},sign:function(){var i=x.find(".layui-layim-remark");i.on("change",function(){var i=this.value;layui.each(r.sign,function(a,e){e&&e(i)})}),i.on("keyup",function(i){var a=i.keyCode;13===a&&this.blur()})},tab:function(i){var a,e=".layim-tab-content",t=x.find(".layui-layim-tab>li");"number"==typeof i?(a=i,i=t.eq(a)):a=i.index(),a>2?t.removeClass(o):(ti.tab.index=a,i.addClass(o).siblings().removeClass(o)),x.find(e).eq(a).addClass(s).siblings(e).removeClass(s)},spread:function(i){var a=i.attr("lay-type"),e="true"===a?"false":"true",t=layui.data("layim")[j.mine.id]||{};i.next()["true"===a?"removeClass":"addClass"](s),t["spread"+i.parent().index()]=e,layui.data("layim",{key:j.mine.id,value:t}),i.attr("lay-type",e),i.find(".layui-icon").html("true"===e?"":"")},search:function(i){var a=x.find(".layui-layim-search"),e=x.find("#layui-layim-search"),t=a.find("input"),n=function(i){var a=t.val().replace(/\s/);if(""===a)ti.tab(0|ti.tab.index);else{for(var n=[],l=j.friend||[],s=j.group||[],o="",d=0;d0)for(var u=0;u'+(n[u].username||n[u].groupname||"佚名")+"

      "+(n[u].remark||n[u].sign||"")+"

      ";else o='
    • 无搜索结果
    • ';e.html(o),ti.tab(3)}};!j.base.isfriend&&j.base.isgroup?ti.tab.index=1:j.base.isfriend||j.base.isgroup||(ti.tab.index=2),a.show(),t.focus(),t.off("keyup",n).on("keyup",n)},closeSearch:function(i){i.parent().hide(),ti.tab(0|ti.tab.index)},msgbox:function(){var i=x.find(".layim-tool-msgbox");return t.close(ti.msgbox.index),i.find("span").removeClass(Y).html(""),ti.msgbox.index=t.open({type:2,title:"消息盒子",shade:!1,maxmin:!0,area:["600px","520px"],skin:"layui-box layui-layer-border",resize:!1,content:j.base.msgbox})},find:function(){return t.close(ti.find.index),ti.find.index=t.open({type:2,title:"查找",shade:!1,maxmin:!0,area:["1000px","520px"],skin:"layui-box layui-layer-border",resize:!1,content:j.base.find})},skin:function(){t.open({type:1,title:"更换背景",shade:!1,area:"300px",skin:"layui-box layui-layer-border",id:"layui-layim-skin",zIndex:66666666,resize:!1,content:n(m).render({skin:j.base.skin})})},about:function(){t.alert("版本: "+a+'
      版权所有:layim.layui.com',{title:"关于 LayIM",shade:!1})},setSkin:function(i){var a=i.attr("src"),e=layui.data("layim")[j.mine.id]||{};e.skin=a,a||delete e.skin,layui.data("layim",{key:j.mine.id,value:e});try{x.css({"background-image":a?"url("+a+")":"none"}),w.css({"background-image":a?"url("+a+")":"none"})}catch(t){}layui.each(r.setSkin,function(i,e){var t=(a||"").replace(layui.cache.dir+"css/modules/layim/skin/","");e&&e(t,a)})},chat:function(i){var a=layui.data("layim")[j.mine.id]||{},e=i.data("type"),t=i.data("index"),n=i.attr("data-list")||i.index(),l={};"friend"===e?l=j[e][t].list[n]:"group"===e?l=j[e][n]:"history"===e&&(l=(a.history||{})[t]||{}),l.name=l.name||l.username||l.groupname,"history"!==e&&(l.type=e),z(l)},tabChat:function(i){O(i)},closeChat:function(i,a){O(i.parent(),1),ii(a)},closeThisChat:function(){O(null,1)},groupMembers:function(i,a){var n=i.find(".layui-icon"),l=function(){n.html(""),i.data("down",null),t.close(ti.groupMembers.index)},s=function(i){ii(i)};i.data("down")?l():(n.html(""),i.data("down",!0),ti.groupMembers.index=t.tips('
        ',i,{tips:3,time:0,anim:5,fixed:!0,skin:"layui-box layui-layim-members",success:function(a){var t=j.base.members||{},n=_(),s=a.find(".layim-members-list"),o="",d={},c=w.find(".layui-layer-max").hasClass("layui-layer-maxmin"),u="none"===w.find(".layim-chat-list").css("display");c&&s.css({width:e(window).width()-22-(u||200)}),t.data=e.extend(t.data,{id:n.data.id}),S(t,function(a){layui.each(a.list,function(i,a){o+='
      • '+a.username+"
      • ",d[a.id]=a}),s.html(o),i.find(".layim-chat-members").html(a.members||(a.list||[]).length+"人"),s.find("li").on("click",function(){var i=e(this).data("uid"),a=d[i];z({name:a.username,type:"friend",avatar:a.avatar,id:a.id}),l()}),layui.each(r.members,function(i,e){e&&e(a)})}),a.on("mousedown",function(i){ii(i)})}}),e(document).off("mousedown",l).on("mousedown",l),e(window).off("resize",l).on("resize",l),i.off("mousedown",s).on("mousedown",s))},send:function(){D()},setSend:function(i,a){var t=ti.setSend.box=i.siblings(".layim-menu-box"),n=i.attr("lay-type");if("show"===n)ii(a),t.show().addClass(ei),e(document).off("click",ti.setSendHide).on("click",ti.setSendHide);else{i.addClass(o).siblings().removeClass(o);var l=layui.data("layim")[j.mine.id]||{};l.sendHotKey=n,layui.data("layim",{key:j.mine.id,value:l}),ti.setSendHide(a,i.parent())}},setSendHide:function(i,a){(a||ti.setSend.box).hide().removeClass(ei)},face:function(i,a){var n="",l=_();for(var s in X)n+='
      • ';n='
          '+n+"
        ",ti.face.index=t.tips(n,i,{tips:1,time:0,fixed:!0,skin:"layui-box layui-layim-face",success:function(i){i.find(".layim-face-list>li").on("mousedown",function(i){ii(i)}).on("click",function(){ai(l.textarea[0],"face"+this.title+" "),t.close(ti.face.index); +})}}),e(document).off("mousedown",ti.faceHide).on("mousedown",ti.faceHide),e(window).off("resize",ti.faceHide).on("resize",ti.faceHide),ii(a)},faceHide:function(){t.close(ti.face.index)},image:function(i){var a=i.data("type")||"images",e={images:"uploadImage",file:"uploadFile"},n=_(),l=j.base[e[a]]||{};layui.upload.render({url:l.url||"",method:l.type,elem:i.find("input")[0],accept:a,done:function(i){0==i.code?(i.data=i.data||{},"images"===a?ai(n.textarea[0],"img["+(i.data.src||"")+"]"):"file"===a&&ai(n.textarea[0],"file("+(i.data.src||"")+")["+(i.data.name||"下载文件")+"]"),D()):t.msg(i.msg||"上传失败")}})},media:function(i){var a=i.data("type"),n={audio:"音频",video:"视频"},l=_();t.prompt({title:"请输入网络"+n[a]+"地址",shade:!1,offset:[i.offset().top-e(window).scrollTop()-158+"px",i.offset().left+"px"]},function(i,e){ai(l.textarea[0],a+"["+i+"]"),D(),t.close(e)})},extend:function(i){var a=i.attr("lay-filter"),e=_();layui.each(r["tool("+a+")"],function(a,t){t&&t.call(i,function(i){ai(e.textarea[0],i)},D,e)})},playAudio:function(i){var a=i.data("audio"),e=a||document.createElement("audio"),n=function(){e.pause(),i.removeAttr("status"),i.find("i").html("")};return i.data("error")?t.msg("播放音频源异常"):e.play?void(i.attr("status")?n():(a||(e.src=i.data("src")),e.play(),i.attr("status","pause"),i.data("audio",e),i.find("i").html(""),e.onended=function(){n()},e.onerror=function(){t.msg("播放音频源异常"),i.data("error",!0),n()})):t.msg("您的浏览器不支持audio")},playVideo:function(i){var a=i.data("src"),e=document.createElement("video");return e.play?(t.close(ti.playVideo.index),void(ti.playVideo.index=t.open({type:1,title:"播放视频",area:["460px","300px"],maxmin:!0,shade:!1,content:'
        '}))):t.msg("您的浏览器不支持video")},chatLog:function(i){var a=_();return j.base.chatLog?(t.close(ti.chatLog.index),ti.chatLog.index=t.open({type:2,maxmin:!0,title:"与 "+a.data.name+" 的聊天记录",area:["450px","100%"],shade:!1,offset:"rb",skin:"layui-box",anim:2,id:"layui-layim-chatlog",content:j.base.chatLog+"?id="+a.data.id+"&type="+a.data.type})):t.msg("未开启更多聊天记录")},menuHistory:function(i,a){var n=layui.data("layim")[j.mine.id]||{},l=i.parent(),s=i.data("type"),o=x.find(".layim-list-history"),d='
      • 暂无历史会话
      • ';if("one"===s){var r=n.history;delete r[l.data("index")],n.history=r,layui.data("layim",{key:j.mine.id,value:n}),e("#"+l.data("id")).remove(),0===o.find("li").length&&o.html(d)}else"all"===s&&(delete n.history,layui.data("layim",{key:j.mine.id,value:n}),o.html(d));t.closeAll("tips")}};i("layim",new c)}).addcss("modules/layim/layim.css?v=3.8.0","skinlayimcss"); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/laypage.js b/IoTGateway/wwwroot/layui/lay/modules/laypage.js index 2df27fd..b714f4e 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/laypage.js +++ b/IoTGateway/wwwroot/layui/lay/modules/laypage.js @@ -1,309 +1,2 @@ -/** - - @Name : laypage 分页组件 - @License:MIT - - */ - -layui.define(function(exports){ - "use strict"; - - var doc = document - ,id = 'getElementById' - ,tag = 'getElementsByTagName' - - //字符常量 - ,MOD_NAME = 'laypage', DISABLED = 'layui-disabled' - - //构造器 - ,Class = function(options){ - var that = this; - that.config = options || {}; - that.config.index = ++laypage.index; - that.render(true); - }; - - //判断传入的容器类型 - Class.prototype.type = function(){ - var config = this.config; - if(typeof config.elem === 'object'){ - return config.elem.length === undefined ? 2 : 3; - } - }; - - //分页视图 - Class.prototype.view = function(){ - var that = this - ,config = that.config - ,groups = config.groups = 'groups' in config ? (config.groups|0) : 5; //连续页码个数 - - //排版 - config.layout = typeof config.layout === 'object' - ? config.layout - : ['prev', 'page', 'next']; - - config.count = config.count|0; //数据总数 - config.curr = (config.curr|0) || 1; //当前页 - - //每页条数的选择项 - config.limits = typeof config.limits === 'object' - ? config.limits - : [10, 20, 30, 40, 50]; - config.limit = (config.limit|0) || 10; //默认条数 - - //总页数 - config.pages = Math.ceil(config.count/config.limit) || 1; - - //当前页不能超过总页数 - if(config.curr > config.pages){ - config.curr = config.pages; - } - - //连续分页个数不能低于0且不能大于总页数 - if(groups < 0){ - groups = 1; - } else if (groups > config.pages){ - groups = config.pages; - } - - config.prev = 'prev' in config ? config.prev : '上一页'; //上一页文本 - config.next = 'next' in config ? config.next : '下一页'; //下一页文本 - - //计算当前组 - var index = config.pages > groups - ? Math.ceil( (config.curr + (groups > 1 ? 1 : 0)) / (groups > 0 ? groups : 1) ) - : 1 - - //视图片段 - ,views = { - //上一页 - prev: function(){ - return config.prev - ? ''+ config.prev +'' - : ''; - }() - - //页码 - ,page: function(){ - var pager = []; - - //数据量为0时,不输出页码 - if(config.count < 1){ - return ''; - } - - //首页 - if(index > 1 && config.first !== false && groups !== 0){ - pager.push(''+ (config.first || 1) +''); - } - - //计算当前页码组的起始页 - var halve = Math.floor((groups-1)/2) //页码数等分 - ,start = index > 1 ? config.curr - halve : 1 - ,end = index > 1 ? (function(){ - var max = config.curr + (groups - halve - 1); - return max > config.pages ? config.pages : max; - }()) : groups; - - //防止最后一组出现“不规定”的连续页码数 - if(end - start < groups - 1){ - start = end - groups + 1; - } - - //输出左分割符 - if(config.first !== false && start > 2){ - pager.push('') - } - - //输出连续页码 - for(; start <= end; start++){ - if(start === config.curr){ - //当前页 - pager.push(''+ start +''); - } else { - pager.push(''+ start +''); - } - } - - //输出输出右分隔符 & 末页 - if(config.pages > groups && config.pages > end && config.last !== false){ - if(end + 1 < config.pages){ - pager.push(''); - } - if(groups !== 0){ - pager.push(''+ (config.last || config.pages) +''); - } - } - - return pager.join(''); - }() - - //下一页 - ,next: function(){ - return config.next - ? ''+ config.next +'' - : ''; - }() - - //数据总数 - ,count: '共 '+ config.count +' 条' - - //每页条数 - ,limit: function(){ - var options = [''; - }() - - //刷新当前页 - ,refresh: ['' - ,'' - ,''].join('') - - //跳页区域 - ,skip: function(){ - return ['到第' - ,'' - ,'页' - ,''].join(''); - }() - }; - - return ['
        ' - ,function(){ - var plate = []; - layui.each(config.layout, function(index, item){ - if(views[item]){ - plate.push(views[item]) - } - }); - return plate.join(''); - }() - ,'
        '].join(''); - }; - - //跳页的回调 - Class.prototype.jump = function(elem, isskip){ - if(!elem) return; - var that = this - ,config = that.config - ,childs = elem.children - ,btn = elem[tag]('button')[0] - ,input = elem[tag]('input')[0] - ,select = elem[tag]('select')[0] - ,skip = function(){ - var curr = input.value.replace(/\s|\D/g, '')|0; - if(curr){ - config.curr = curr; - that.render(); - } - }; - - if(isskip) return skip(); - - //页码 - for(var i = 0, len = childs.length; i < len; i++){ - if(childs[i].nodeName.toLowerCase() === 'a'){ - laypage.on(childs[i], 'click', function(){ - var curr = this.getAttribute('data-page')|0; - if(curr < 1 || curr > config.pages) return; - config.curr = curr; - that.render(); - }); - } - } - - //条数 - if(select){ - laypage.on(select, 'change', function(){ - var value = this.value; - if(config.curr*value > config.count){ - config.curr = Math.ceil(config.count/value); - } - config.limit = value; - that.render(); - }); - } - - //确定 - if(btn){ - laypage.on(btn, 'click', function(){ - skip(); - }); - } - }; - - //输入页数字控制 - Class.prototype.skip = function(elem){ - if(!elem) return; - var that = this, input = elem[tag]('input')[0]; - if(!input) return; - laypage.on(input, 'keyup', function(e){ - var value = this.value - ,keyCode = e.keyCode; - if(/^(37|38|39|40)$/.test(keyCode)) return; - if(/\D/.test(value)){ - this.value = value.replace(/\D/, ''); - } - if(keyCode === 13){ - that.jump(elem, true) - } - }); - }; - - //渲染分页 - Class.prototype.render = function(load){ - var that = this - ,config = that.config - ,type = that.type() - ,view = that.view(); - - if(type === 2){ - config.elem && (config.elem.innerHTML = view); - } else if(type === 3){ - config.elem.html(view); - } else { - if(doc[id](config.elem)){ - doc[id](config.elem).innerHTML = view; - } - } - - config.jump && config.jump(config, load); - - var elem = doc[id]('layui-laypage-' + config.index); - that.jump(elem); - - if(config.hash && !load){ - location.hash = '!'+ config.hash +'='+ config.curr; - } - - that.skip(elem); - }; - - //外部接口 - var laypage = { - //分页渲染 - render: function(options){ - var o = new Class(options); - return o.index; - } - ,index: layui.laypage ? (layui.laypage.index + 10000) : 0 - ,on: function(elem, even, fn){ - elem.attachEvent ? elem.attachEvent('on'+ even, function(e){ //for ie - e.target = e.srcElement; - fn.call(elem, e); - }) : elem.addEventListener(even, fn, false); - return this; - } - } - - exports(MOD_NAME, laypage); -}); \ No newline at end of file +/** layui-v2.5.7 MIT License */ + ;layui.define(function(e){"use strict";var t=document,a="getElementById",r="getElementsByTagName",n="laypage",i="layui-disabled",u=function(e){var t=this;t.config=e||{},t.config.index=++p.index,t.render(!0)};u.prototype.type=function(){var e=this.config;if("object"==typeof e.elem)return void 0===e.elem.length?2:3},u.prototype.view=function(){var e=this,t=e.config,a=t.groups="groups"in t?0|t.groups:5;t.layout="object"==typeof t.layout?t.layout:["prev","page","next"],t.count=0|t.count,t.curr=0|t.curr||1,t.limits="object"==typeof t.limits?t.limits:[10,20,30,40,50],t.limit=0|t.limit||10,t.pages=Math.ceil(t.count/t.limit)||1,t.curr>t.pages&&(t.curr=t.pages),a<0?a=1:a>t.pages&&(a=t.pages),t.prev="prev"in t?t.prev:"上一页",t.next="next"in t?t.next:"下一页",t.rpptext="rpptext"in t?t.rpptext:"条/页",t.totaltext="totaltext"in t?t.totaltext:"共",t.recordtext="recordtext"in t?t.recordtext:"条",t.gototext="gototext"in t?t.gototext:"到第",t.pagetext="pagetext"in t?t.pagetext:"页",t.oktext="oktext"in t?t.oktext:"确定";var r=t.pages>a?Math.ceil((t.curr+(a>1?1:0))/(a>0?a:1)):1,n={prev:function(){return t.prev?''+t.prev+"":""}(),page:function(){var e=[];if(t.count<1)return"";r>1&&t.first!==!1&&0!==a&&e.push(''+(t.first||1)+"");var n=Math.floor((a-1)/2),i=r>1?t.curr-n:1,u=r>1?function(){var e=t.curr+(a-n-1);return e>t.pages?t.pages:e}():a;for(u-i2&&e.push('');i<=u;i++)i===t.curr?e.push('"+i+""):e.push(''+i+"");return t.pages>a&&t.pages>u&&t.last!==!1&&(u+1…'),0!==a&&e.push(''+(t.last||t.pages)+"")),e.join("")}(),next:function(){return t.next?''+t.next+"":""}(),count:''+t.totaltext+" "+t.count+" "+t.recordtext+"",limit:function(){var e=['"}(),refresh:['','',""].join(""),skip:function(){return[''+t.gototext,'',t.pagetext+'",""].join("")}()};return['
        ',function(){var e=[];return layui.each(t.layout,function(t,a){n[a]&&e.push(n[a])}),e.join("")}(),"
        "].join("")},u.prototype.jump=function(e,t){if(e){var a=this,n=a.config,i=e.children,u=e[r]("button")[0],l=e[r]("input")[0],s=e[r]("select")[0],o=function(){var e=0|l.value.replace(/\s|\D/g,"");e&&(n.curr=e,a.render())};if(t)return o();for(var c=0,g=i.length;cn.pages||(n.curr=e,a.render())});s&&p.on(s,"change",function(){var e=this.value;n.curr*e>n.count&&(n.curr=Math.ceil(n.count/e)),n.limit=e,a.render()}),u&&p.on(u,"click",function(){o()})}},u.prototype.skip=function(e){if(e){var t=this,a=e[r]("input")[0];a&&p.on(a,"keyup",function(a){var r=this.value,n=a.keyCode;/^(37|38|39|40)$/.test(n)||(/\D/.test(r)&&(this.value=r.replace(/\D/,"")),13===n&&t.jump(e,!0))})}},u.prototype.render=function(e){var r=this,n=r.config,i=r.type(),u=r.view();2===i?n.elem&&(n.elem.innerHTML=u):3===i?n.elem.html(u):t[a](n.elem)&&(t[a](n.elem).innerHTML=u),n.jump&&n.jump(n,e);var p=t[a]("layui-laypage-"+n.index);r.jump(p),n.hash&&!e&&(location.hash="!"+n.hash+"="+n.curr),r.skip(p)};var p={render:function(e){var t=new u(e);return t.index},index:layui.laypage?layui.laypage.index+1e4:0,on:function(e,t,a){return e.attachEvent?e.attachEvent("on"+t,function(t){t.target=t.srcElement,a.call(e,t)}):e.addEventListener(t,a,!1),this}};e(n,p)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/laytpl.js b/IoTGateway/wwwroot/layui/lay/modules/laytpl.js index 8e6adbc..c9aa844 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/laytpl.js +++ b/IoTGateway/wwwroot/layui/lay/modules/laytpl.js @@ -1,122 +1,2 @@ -/** - - @Name : laytpl 模板引擎 - @License:MIT - - */ - -layui.define(function(exports){ - - "use strict"; - - var config = { - open: '{{', - close: '}}' - }; - - var tool = { - exp: function(str){ - return new RegExp(str, 'g'); - }, - //匹配满足规则内容 - query: function(type, _, __){ - var types = [ - '#([\\s\\S])+?', //js语句 - '([^{#}])*?' //普通字段 - ][type || 0]; - return exp((_||'') + config.open + types + config.close + (__||'')); - }, - escape: function(html){ - return String(html||'').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') - .replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); - }, - error: function(e, tplog){ - var error = 'Laytpl Error: '; - typeof console === 'object' && console.error(error + e + '\n'+ (tplog || '')); - return error + e; - } - }; - - var exp = tool.exp, Tpl = function(tpl){ - this.tpl = tpl; - }; - - Tpl.pt = Tpl.prototype; - - window.errors = 0; - - //编译模版 - Tpl.pt.parse = function(tpl, data){ - var that = this, tplog = tpl; - var jss = exp('^'+config.open+'#', ''), jsse = exp(config.close+'$', ''); - - tpl = tpl.replace(/\s+|\r|\t|\n/g, ' ') - .replace(exp(config.open+'#'), config.open+'# ') - .replace(exp(config.close+'}'), '} '+config.close).replace(/\\/g, '\\\\') - - //不匹配指定区域的内容 - .replace(exp(config.open + '!(.+?)!' + config.close), function(str){ - str = str.replace(exp('^'+ config.open + '!'), '') - .replace(exp('!'+ config.close), '') - .replace(exp(config.open + '|' + config.close), function(tag){ - return tag.replace(/(.)/g, '\\$1') - }); - return str - }) - - //匹配JS规则内容 - .replace(/(?="|')/g, '\\').replace(tool.query(), function(str){ - str = str.replace(jss, '').replace(jsse, ''); - return '";' + str.replace(/\\/g, '') + ';view+="'; - }) - - //匹配普通字段 - .replace(tool.query(1), function(str){ - var start = '"+('; - if(str.replace(/\s/g, '') === config.open+config.close){ - return ''; - } - str = str.replace(exp(config.open+'|'+config.close), ''); - if(/^=/.test(str)){ - str = str.replace(/^=/, ''); - start = '"+_escape_('; - } - return start + str.replace(/\\/g, '') + ')+"'; - }); - - tpl = '"use strict";var view = "' + tpl + '";return view;'; - - try{ - that.cache = tpl = new Function('d, _escape_', tpl); - return tpl(data, tool.escape); - } catch(e){ - delete that.cache; - return tool.error(e, tplog); - } - }; - - Tpl.pt.render = function(data, callback){ - var that = this, tpl; - if(!data) return tool.error('no data'); - tpl = that.cache ? that.cache(data, tool.escape) : that.parse(that.tpl, data); - if(!callback) return tpl; - callback(tpl); - }; - - var laytpl = function(tpl){ - if(typeof tpl !== 'string') return tool.error('Template not found'); - return new Tpl(tpl); - }; - - laytpl.config = function(options){ - options = options || {}; - for(var i in options){ - config[i] = options[i]; - } - }; - - laytpl.v = '1.2.0'; - - exports('laytpl', laytpl); - -}); \ No newline at end of file +/** layui-v2.5.7 MIT License */ + ;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/mobile.js b/IoTGateway/wwwroot/layui/lay/modules/mobile.js index 7306fb6..9f902ce 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/mobile.js +++ b/IoTGateway/wwwroot/layui/lay/modules/mobile.js @@ -1,29 +1,2 @@ -/** - - @Name:layui 移动模块入口 | 构建后则为移动模块集合 - @License:MIT - - */ - - -if(!layui['layui.mobile']){ - layui.config({ - base: layui.cache.dir + 'lay/modules/mobile/' - }).extend({ - 'layer-mobile': 'layer-mobile' - ,'zepto': 'zepto' - ,'upload-mobile': 'upload-mobile' - ,'layim-mobile': 'layim-mobile' - }); -} - -layui.define([ - 'layer-mobile' - ,'zepto' - ,'layim-mobile' -], function(exports){ - exports('mobile', { - layer: layui['layer-mobile'] //弹层 - ,layim: layui['layim-mobile'] //WebIM - }); -}); \ No newline at end of file +/** layui-v2.5.7 MIT License */ + ;layui.define(function(i){i("layui.mobile",layui.v)});layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)});layui.define(function(e){"use strict";var t=(window,document),i="querySelectorAll",n="getElementsByClassName",a=function(e){return t[i](e)},s={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},l={extend:function(e){var t=JSON.parse(JSON.stringify(s));for(var i in e)t[i]=e[i];return t},timer:{},end:{}};l.touch=function(e,t){e.addEventListener("click",function(e){t.call(this,e)},!1)};var o=0,r=["layui-m-layer"],d=function(e){var t=this;t.config=l.extend(e),t.view()};d.prototype.view=function(){var e=this,i=e.config,s=t.createElement("div");e.id=s.id=r[0]+o,s.setAttribute("class",r[0]+" "+r[0]+(i.type||0)),s.setAttribute("index",o);var l=function(){var e="object"==typeof i.title;return i.title?'

        '+(e?i.title[0]:i.title)+"

        ":""}(),d=function(){"string"==typeof i.btn&&(i.btn=[i.btn]);var e,t=(i.btn||[]).length;return 0!==t&&i.btn?(e=''+i.btn[0]+"",2===t&&(e=''+i.btn[1]+""+e),'
        '+e+"
        "):""}();if(i.fixed||(i.top=i.hasOwnProperty("top")?i.top:100,i.style=i.style||"",i.style+=" top:"+(t.body.scrollTop+i.top)+"px"),2===i.type&&(i.content='

        '+(i.content||"")+"

        "),i.skin&&(i.anim="up"),"msg"===i.skin&&(i.shade=!1),s.innerHTML=(i.shade?"
        ':"")+'
        "+l+'
        '+i.content+"
        "+d+"
        ",!i.type||2===i.type){var y=t[n](r[0]+i.type),u=y.length;u>=1&&c.close(y[0].getAttribute("index"))}document.body.appendChild(s);var m=e.elem=a("#"+e.id)[0];i.success&&i.success(m),e.index=o++,e.action(i,m)},d.prototype.action=function(e,t){var i=this;e.time&&(l.timer[i.index]=setTimeout(function(){c.close(i.index)},1e3*e.time));var a=function(){var t=this.getAttribute("type");0==t?(e.no&&e.no(),c.close(i.index)):e.yes?e.yes(i.index):c.close(i.index)};if(e.btn)for(var s=t[n]("layui-m-layerbtn")[0].children,o=s.length,r=0;r0&&e-1 in t)}function s(t){return A.call(t,function(t){return null!=t})}function u(t){return t.length>0?T.fn.concat.apply([],t):t}function c(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function l(t){return t in F?F[t]:F[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function f(t,e){return"number"!=typeof e||k[c(t)]?e:e+"px"}function h(t){var e,n;return $[t]||(e=L.createElement(t),L.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),$[t]=n),$[t]}function p(t){return"children"in t?D.call(t.children):T.map(t.childNodes,function(t){if(1==t.nodeType)return t})}function d(t,e){var n,r=t?t.length:0;for(n=0;n]*>/,R=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,z=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Z=/^(?:body|html)$/i,q=/([A-Z])/g,H=["val","css","html","text","data","width","height","offset"],I=["after","prepend","before","append"],V=L.createElement("table"),_=L.createElement("tr"),B={tr:L.createElement("tbody"),tbody:V,thead:V,tfoot:V,td:_,th:_,"*":L.createElement("div")},U=/complete|loaded|interactive/,X=/^[\w-]*$/,J={},W=J.toString,Y={},G=L.createElement("div"),K={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},Q=Array.isArray||function(t){return t instanceof Array};return Y.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var r,i=t.parentNode,o=!i;return o&&(i=G).appendChild(t),r=~Y.qsa(i,e).indexOf(t),o&&G.removeChild(t),r},C=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},N=function(t){return A.call(t,function(e,n){return t.indexOf(e)==n})},Y.fragment=function(t,e,n){var r,i,a;return R.test(t)&&(r=T(L.createElement(RegExp.$1))),r||(t.replace&&(t=t.replace(z,"<$1>")),e===E&&(e=M.test(t)&&RegExp.$1),e in B||(e="*"),a=B[e],a.innerHTML=""+t,r=T.each(D.call(a.childNodes),function(){a.removeChild(this)})),o(n)&&(i=T(r),T.each(n,function(t,e){H.indexOf(t)>-1?i[t](e):i.attr(t,e)})),r},Y.Z=function(t,e){return new d(t,e)},Y.isZ=function(t){return t instanceof Y.Z},Y.init=function(t,n){var r;if(!t)return Y.Z();if("string"==typeof t)if(t=t.trim(),"<"==t[0]&&M.test(t))r=Y.fragment(t,RegExp.$1,n),t=null;else{if(n!==E)return T(n).find(t);r=Y.qsa(L,t)}else{if(e(t))return T(L).ready(t);if(Y.isZ(t))return t;if(Q(t))r=s(t);else if(i(t))r=[t],t=null;else if(M.test(t))r=Y.fragment(t.trim(),RegExp.$1,n),t=null;else{if(n!==E)return T(n).find(t);r=Y.qsa(L,t)}}return Y.Z(r,t)},T=function(t,e){return Y.init(t,e)},T.extend=function(t){var e,n=D.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){m(t,n,e)}),t},Y.qsa=function(t,e){var n,r="#"==e[0],i=!r&&"."==e[0],o=r||i?e.slice(1):e,a=X.test(o);return t.getElementById&&a&&r?(n=t.getElementById(o))?[n]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:D.call(a&&!r&&t.getElementsByClassName?i?t.getElementsByClassName(o):t.getElementsByTagName(e):t.querySelectorAll(e))},T.contains=L.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},T.type=t,T.isFunction=e,T.isWindow=n,T.isArray=Q,T.isPlainObject=o,T.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},T.isNumeric=function(t){var e=Number(t),n=typeof t;return null!=t&&"boolean"!=n&&("string"!=n||t.length)&&!isNaN(e)&&isFinite(e)||!1},T.inArray=function(t,e,n){return O.indexOf.call(e,t,n)},T.camelCase=C,T.trim=function(t){return null==t?"":String.prototype.trim.call(t)},T.uuid=0,T.support={},T.expr={},T.noop=function(){},T.map=function(t,e){var n,r,i,o=[];if(a(t))for(r=0;r=0?t:t+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return O.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return e(t)?this.not(this.not(t)):T(A.call(this,function(e){return Y.matches(e,t)}))},add:function(t,e){return T(N(this.concat(T(t,e))))},is:function(t){return this.length>0&&Y.matches(this[0],t)},not:function(t){var n=[];if(e(t)&&t.call!==E)this.each(function(e){t.call(this,e)||n.push(this)});else{var r="string"==typeof t?this.filter(t):a(t)&&e(t.item)?D.call(t):T(t);this.forEach(function(t){r.indexOf(t)<0&&n.push(t)})}return T(n)},has:function(t){return this.filter(function(){return i(t)?T.contains(this,t):T(this).find(t).size()})},eq:function(t){return t===-1?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!i(t)?t:T(t)},last:function(){var t=this[this.length-1];return t&&!i(t)?t:T(t)},find:function(t){var e,n=this;return e=t?"object"==typeof t?T(t).filter(function(){var t=this;return O.some.call(n,function(e){return T.contains(e,t)})}):1==this.length?T(Y.qsa(this[0],t)):this.map(function(){return Y.qsa(this,t)}):T()},closest:function(t,e){var n=[],i="object"==typeof t&&T(t);return this.each(function(o,a){for(;a&&!(i?i.indexOf(a)>=0:Y.matches(a,t));)a=a!==e&&!r(a)&&a.parentNode;a&&n.indexOf(a)<0&&n.push(a)}),T(n)},parents:function(t){for(var e=[],n=this;n.length>0;)n=T.map(n,function(t){if((t=t.parentNode)&&!r(t)&&e.indexOf(t)<0)return e.push(t),t});return v(e,t)},parent:function(t){return v(N(this.pluck("parentNode")),t)},children:function(t){return v(this.map(function(){return p(this)}),t)},contents:function(){return this.map(function(){return this.contentDocument||D.call(this.childNodes)})},siblings:function(t){return v(this.map(function(t,e){return A.call(p(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return T.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=h(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var n=e(t);if(this[0]&&!n)var r=T(t).get(0),i=r.parentNode||this.length>1;return this.each(function(e){T(this).wrapAll(n?t.call(this,e):i?r.cloneNode(!0):r)})},wrapAll:function(t){if(this[0]){T(this[0]).before(t=T(t));for(var e;(e=t.children()).length;)t=e.first();T(t).append(this)}return this},wrapInner:function(t){var n=e(t);return this.each(function(e){var r=T(this),i=r.contents(),o=n?t.call(this,e):t;i.length?i.wrapAll(o):r.append(o)})},unwrap:function(){return this.parent().each(function(){T(this).replaceWith(T(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(t){return this.each(function(){var e=T(this);(t===E?"none"==e.css("display"):t)?e.show():e.hide()})},prev:function(t){return T(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return T(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var n=this.innerHTML;T(this).empty().append(g(this,t,e,n))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=g(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(t,e){var n;return"string"!=typeof t||1 in arguments?this.each(function(n){if(1===this.nodeType)if(i(t))for(j in t)y(this,j,t[j]);else y(this,t,g(this,e,n,this.getAttribute(t)))}):0 in this&&1==this[0].nodeType&&null!=(n=this[0].getAttribute(t))?n:E},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){y(this,t)},this)})},prop:function(t,e){return t=K[t]||t,1 in arguments?this.each(function(n){this[t]=g(this,e,n,this[t])}):this[0]&&this[0][t]},removeProp:function(t){return t=K[t]||t,this.each(function(){delete this[t]})},data:function(t,e){var n="data-"+t.replace(q,"-$1").toLowerCase(),r=1 in arguments?this.attr(n,e):this.attr(n);return null!==r?b(r):E},val:function(t){return 0 in arguments?(null==t&&(t=""),this.each(function(e){this.value=g(this,t,e,this.value)})):this[0]&&(this[0].multiple?T(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(t){if(t)return this.each(function(e){var n=T(this),r=g(this,t,e,n.offset()),i=n.offsetParent().offset(),o={top:r.top-i.top,left:r.left-i.left};"static"==n.css("position")&&(o.position="relative"),n.css(o)});if(!this.length)return null;if(L.documentElement!==this[0]&&!T.contains(L.documentElement,this[0]))return{top:0,left:0};var e=this[0].getBoundingClientRect();return{left:e.left+window.pageXOffset,top:e.top+window.pageYOffset,width:Math.round(e.width),height:Math.round(e.height)}},css:function(e,n){if(arguments.length<2){var r=this[0];if("string"==typeof e){if(!r)return;return r.style[C(e)]||getComputedStyle(r,"").getPropertyValue(e)}if(Q(e)){if(!r)return;var i={},o=getComputedStyle(r,"");return T.each(e,function(t,e){i[e]=r.style[C(e)]||o.getPropertyValue(e)}),i}}var a="";if("string"==t(e))n||0===n?a=c(e)+":"+f(e,n):this.each(function(){this.style.removeProperty(c(e))});else for(j in e)e[j]||0===e[j]?a+=c(j)+":"+f(j,e[j])+";":this.each(function(){this.style.removeProperty(c(j))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(T(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return!!t&&O.some.call(this,function(t){return this.test(x(t))},l(t))},addClass:function(t){return t?this.each(function(e){if("className"in this){S=[];var n=x(this),r=g(this,t,e,n);r.split(/\s+/g).forEach(function(t){T(this).hasClass(t)||S.push(t)},this),S.length&&x(this,n+(n?" ":"")+S.join(" "))}}):this},removeClass:function(t){return this.each(function(e){if("className"in this){if(t===E)return x(this,"");S=x(this),g(this,t,e,S).split(/\s+/g).forEach(function(t){S=S.replace(l(t)," ")}),x(this,S.trim())}})},toggleClass:function(t,e){return t?this.each(function(n){var r=T(this),i=g(this,t,n,x(this));i.split(/\s+/g).forEach(function(t){(e===E?!r.hasClass(t):e)?r.addClass(t):r.removeClass(t)})}):this},scrollTop:function(t){if(this.length){var e="scrollTop"in this[0];return t===E?e?this[0].scrollTop:this[0].pageYOffset:this.each(e?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var e="scrollLeft"in this[0];return t===E?e?this[0].scrollLeft:this[0].pageXOffset:this.each(e?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),r=Z.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(T(t).css("margin-top"))||0,n.left-=parseFloat(T(t).css("margin-left"))||0,r.top+=parseFloat(T(e[0]).css("border-top-width"))||0,r.left+=parseFloat(T(e[0]).css("border-left-width"))||0,{top:n.top-r.top,left:n.left-r.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||L.body;t&&!Z.test(t.nodeName)&&"static"==T(t).css("position");)t=t.offsetParent;return t})}},T.fn.detach=T.fn.remove,["width","height"].forEach(function(t){var e=t.replace(/./,function(t){return t[0].toUpperCase()});T.fn[t]=function(i){var o,a=this[0];return i===E?n(a)?a["inner"+e]:r(a)?a.documentElement["scroll"+e]:(o=this.offset())&&o[t]:this.each(function(e){a=T(this),a.css(t,g(this,i,e,a[t]()))})}}),I.forEach(function(e,n){var r=n%2;T.fn[e]=function(){var e,i,o=T.map(arguments,function(n){var r=[];return e=t(n),"array"==e?(n.forEach(function(t){return t.nodeType!==E?r.push(t):T.zepto.isZ(t)?r=r.concat(t.get()):void(r=r.concat(Y.fragment(t)))}),r):"object"==e||null==n?n:Y.fragment(n)}),a=this.length>1;return o.length<1?this:this.each(function(t,e){i=r?e:e.parentNode,e=0==n?e.nextSibling:1==n?e.firstChild:2==n?e:null;var s=T.contains(L.documentElement,i);o.forEach(function(t){if(a)t=t.cloneNode(!0);else if(!i)return T(t).remove();i.insertBefore(t,e),s&&w(t,function(t){if(!(null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src)){var e=t.ownerDocument?t.ownerDocument.defaultView:window;e.eval.call(e,t.innerHTML)}})})})},T.fn[r?e+"To":"insert"+(n?"Before":"After")]=function(t){return T(t)[e](this),this}}),Y.Z.prototype=d.prototype=T.fn,Y.uniq=N,Y.deserializeValue=b,T.zepto=Y,T}();!function(t){function e(t){return t._zid||(t._zid=h++)}function n(t,n,o,a){if(n=r(n),n.ns)var s=i(n.ns);return(v[e(t)]||[]).filter(function(t){return t&&(!n.e||t.e==n.e)&&(!n.ns||s.test(t.ns))&&(!o||e(t.fn)===e(o))&&(!a||t.sel==a)})}function r(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function i(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function o(t,e){return t.del&&!y&&t.e in x||!!e}function a(t){return b[t]||y&&x[t]||t}function s(n,i,s,u,l,h,p){var d=e(n),m=v[d]||(v[d]=[]);i.split(/\s/).forEach(function(e){if("ready"==e)return t(document).ready(s);var i=r(e);i.fn=s,i.sel=l,i.e in b&&(s=function(e){var n=e.relatedTarget;if(!n||n!==this&&!t.contains(this,n))return i.fn.apply(this,arguments)}),i.del=h;var d=h||s;i.proxy=function(t){if(t=c(t),!t.isImmediatePropagationStopped()){t.data=u;var e=d.apply(n,t._args==f?[t]:[t].concat(t._args));return e===!1&&(t.preventDefault(),t.stopPropagation()),e}},i.i=m.length,m.push(i),"addEventListener"in n&&n.addEventListener(a(i.e),i.proxy,o(i,p))})}function u(t,r,i,s,u){var c=e(t);(r||"").split(/\s/).forEach(function(e){n(t,e,i,s).forEach(function(e){delete v[c][e.i],"removeEventListener"in t&&t.removeEventListener(a(e.e),e.proxy,o(e,u))})})}function c(e,n){return!n&&e.isDefaultPrevented||(n||(n=e),t.each(T,function(t,r){var i=n[t];e[t]=function(){return this[r]=w,i&&i.apply(n,arguments)},e[r]=E}),e.timeStamp||(e.timeStamp=Date.now()),(n.defaultPrevented!==f?n.defaultPrevented:"returnValue"in n?n.returnValue===!1:n.getPreventDefault&&n.getPreventDefault())&&(e.isDefaultPrevented=w)),e}function l(t){var e,n={originalEvent:t};for(e in t)j.test(e)||t[e]===f||(n[e]=t[e]);return c(n,t)}var f,h=1,p=Array.prototype.slice,d=t.isFunction,m=function(t){return"string"==typeof t},v={},g={},y="onfocusin"in window,x={focus:"focusin",blur:"focusout"},b={mouseenter:"mouseover",mouseleave:"mouseout"};g.click=g.mousedown=g.mouseup=g.mousemove="MouseEvents",t.event={add:s,remove:u},t.proxy=function(n,r){var i=2 in arguments&&p.call(arguments,2);if(d(n)){var o=function(){return n.apply(r,i?i.concat(p.call(arguments)):arguments)};return o._zid=e(n),o}if(m(r))return i?(i.unshift(n[r],n),t.proxy.apply(null,i)):t.proxy(n[r],n);throw new TypeError("expected function")},t.fn.bind=function(t,e,n){return this.on(t,e,n)},t.fn.unbind=function(t,e){return this.off(t,e)},t.fn.one=function(t,e,n,r){return this.on(t,e,n,r,1)};var w=function(){return!0},E=function(){return!1},j=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,T={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};t.fn.delegate=function(t,e,n){return this.on(e,t,n)},t.fn.undelegate=function(t,e,n){return this.off(e,t,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.on=function(e,n,r,i,o){var a,c,h=this;return e&&!m(e)?(t.each(e,function(t,e){h.on(t,n,r,e,o)}),h):(m(n)||d(i)||i===!1||(i=r,r=n,n=f),i!==f&&r!==!1||(i=r,r=f),i===!1&&(i=E),h.each(function(f,h){o&&(a=function(t){return u(h,t.type,i),i.apply(this,arguments)}),n&&(c=function(e){var r,o=t(e.target).closest(n,h).get(0);if(o&&o!==h)return r=t.extend(l(e),{currentTarget:o,liveFired:h}),(a||i).apply(o,[r].concat(p.call(arguments,1)))}),s(h,e,i,r,n,c||a)}))},t.fn.off=function(e,n,r){var i=this;return e&&!m(e)?(t.each(e,function(t,e){i.off(t,n,e)}),i):(m(n)||d(r)||r===!1||(r=n,n=f),r===!1&&(r=E),i.each(function(){u(this,e,r,n)}))},t.fn.trigger=function(e,n){return e=m(e)||t.isPlainObject(e)?t.Event(e):c(e),e._args=n,this.each(function(){e.type in x&&"function"==typeof this[e.type]?this[e.type]():"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,n)})},t.fn.triggerHandler=function(e,r){var i,o;return this.each(function(a,s){i=l(m(e)?t.Event(e):e),i._args=r,i.target=s,t.each(n(s,e.type||e),function(t,e){if(o=e.proxy(i),i.isImmediatePropagationStopped())return!1})}),o},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(e){t.fn[e]=function(t){return 0 in arguments?this.bind(e,t):this.trigger(e)}}),t.Event=function(t,e){m(t)||(e=t,t=e.type);var n=document.createEvent(g[t]||"Events"),r=!0;if(e)for(var i in e)"bubbles"==i?r=!!e[i]:n[i]=e[i];return n.initEvent(t,r,!0),c(n)}}(e),function(t){function e(e,n,r){var i=t.Event(n);return t(e).trigger(i,r),!i.isDefaultPrevented()}function n(t,n,r,i){if(t.global)return e(n||x,r,i)}function r(e){e.global&&0===t.active++&&n(e,null,"ajaxStart")}function i(e){e.global&&!--t.active&&n(e,null,"ajaxStop")}function o(t,e){var r=e.context;return e.beforeSend.call(r,t,e)!==!1&&n(e,r,"ajaxBeforeSend",[t,e])!==!1&&void n(e,r,"ajaxSend",[t,e])}function a(t,e,r,i){var o=r.context,a="success";r.success.call(o,t,a,e),i&&i.resolveWith(o,[t,a,e]),n(r,o,"ajaxSuccess",[e,r,t]),u(a,e,r)}function s(t,e,r,i,o){var a=i.context;i.error.call(a,r,e,t),o&&o.rejectWith(a,[r,e,t]),n(i,a,"ajaxError",[r,i,t||e]),u(e,r,i)}function u(t,e,r){var o=r.context;r.complete.call(o,e,t),n(r,o,"ajaxComplete",[e,r]),i(r)}function c(t,e,n){if(n.dataFilter==l)return t;var r=n.context;return n.dataFilter.call(r,t,e)}function l(){}function f(t){return t&&(t=t.split(";",2)[0]),t&&(t==T?"html":t==j?"json":w.test(t)?"script":E.test(t)&&"xml")||"text"}function h(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function p(e){e.processData&&e.data&&"string"!=t.type(e.data)&&(e.data=t.param(e.data,e.traditional)),!e.data||e.type&&"GET"!=e.type.toUpperCase()&&"jsonp"!=e.dataType||(e.url=h(e.url,e.data),e.data=void 0)}function d(e,n,r,i){return t.isFunction(n)&&(i=r,r=n,n=void 0),t.isFunction(r)||(i=r,r=void 0),{url:e,data:n,success:r,dataType:i}}function m(e,n,r,i){var o,a=t.isArray(n),s=t.isPlainObject(n);t.each(n,function(n,u){o=t.type(u),i&&(n=r?i:i+"["+(s||"object"==o||"array"==o?n:"")+"]"),!i&&a?e.add(u.name,u.value):"array"==o||!r&&"object"==o?m(e,u,r,n):e.add(n,u)})}var v,g,y=+new Date,x=window.document,b=/)<[^<]*)*<\/script>/gi,w=/^(?:text|application)\/javascript/i,E=/^(?:text|application)\/xml/i,j="application/json",T="text/html",S=/^\s*$/,C=x.createElement("a");C.href=window.location.href,t.active=0,t.ajaxJSONP=function(e,n){if(!("type"in e))return t.ajax(e);var r,i,u=e.jsonpCallback,c=(t.isFunction(u)?u():u)||"Zepto"+y++,l=x.createElement("script"),f=window[c],h=function(e){t(l).triggerHandler("error",e||"abort")},p={abort:h};return n&&n.promise(p),t(l).on("load error",function(o,u){clearTimeout(i),t(l).off().remove(),"error"!=o.type&&r?a(r[0],p,e,n):s(null,u||"error",p,e,n),window[c]=f,r&&t.isFunction(f)&&f(r[0]),f=r=void 0}),o(p,e)===!1?(h("abort"),p):(window[c]=function(){r=arguments},l.src=e.url.replace(/\?(.+)=\?/,"?$1="+c),x.head.appendChild(l),e.timeout>0&&(i=setTimeout(function(){h("timeout")},e.timeout)),p)},t.ajaxSettings={type:"GET",beforeSend:l,success:l,error:l,complete:l,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:j,xml:"application/xml, text/xml",html:T,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:l},t.ajax=function(e){var n,i,u=t.extend({},e||{}),d=t.Deferred&&t.Deferred();for(v in t.ajaxSettings)void 0===u[v]&&(u[v]=t.ajaxSettings[v]);r(u),u.crossDomain||(n=x.createElement("a"),n.href=u.url,n.href=n.href,u.crossDomain=C.protocol+"//"+C.host!=n.protocol+"//"+n.host),u.url||(u.url=window.location.toString()),(i=u.url.indexOf("#"))>-1&&(u.url=u.url.slice(0,i)),p(u);var m=u.dataType,y=/\?.+=\?/.test(u.url);if(y&&(m="jsonp"),u.cache!==!1&&(e&&e.cache===!0||"script"!=m&&"jsonp"!=m)||(u.url=h(u.url,"_="+Date.now())),"jsonp"==m)return y||(u.url=h(u.url,u.jsonp?u.jsonp+"=?":u.jsonp===!1?"":"callback=?")),t.ajaxJSONP(u,d);var b,w=u.accepts[m],E={},j=function(t,e){E[t.toLowerCase()]=[t,e]},T=/^([\w-]+:)\/\//.test(u.url)?RegExp.$1:window.location.protocol,N=u.xhr(),O=N.setRequestHeader;if(d&&d.promise(N),u.crossDomain||j("X-Requested-With","XMLHttpRequest"),j("Accept",w||"*/*"),(w=u.mimeType||w)&&(w.indexOf(",")>-1&&(w=w.split(",",2)[0]),N.overrideMimeType&&N.overrideMimeType(w)),(u.contentType||u.contentType!==!1&&u.data&&"GET"!=u.type.toUpperCase())&&j("Content-Type",u.contentType||"application/x-www-form-urlencoded"),u.headers)for(g in u.headers)j(g,u.headers[g]);if(N.setRequestHeader=j,N.onreadystatechange=function(){if(4==N.readyState){N.onreadystatechange=l,clearTimeout(b);var e,n=!1;if(N.status>=200&&N.status<300||304==N.status||0==N.status&&"file:"==T){if(m=m||f(u.mimeType||N.getResponseHeader("content-type")),"arraybuffer"==N.responseType||"blob"==N.responseType)e=N.response;else{e=N.responseText;try{e=c(e,m,u),"script"==m?(0,eval)(e):"xml"==m?e=N.responseXML:"json"==m&&(e=S.test(e)?null:t.parseJSON(e))}catch(r){n=r}if(n)return s(n,"parsererror",N,u,d)}a(e,N,u,d)}else s(N.statusText||null,N.status?"error":"abort",N,u,d)}},o(N,u)===!1)return N.abort(),s(null,"abort",N,u,d),N;var P=!("async"in u)||u.async;if(N.open(u.type,u.url,P,u.username,u.password),u.xhrFields)for(g in u.xhrFields)N[g]=u.xhrFields[g];for(g in E)O.apply(N,E[g]);return u.timeout>0&&(b=setTimeout(function(){N.onreadystatechange=l,N.abort(),s(null,"timeout",N,u,d)},u.timeout)),N.send(u.data?u.data:null),N},t.get=function(){return t.ajax(d.apply(null,arguments))},t.post=function(){var e=d.apply(null,arguments);return e.type="POST",t.ajax(e)},t.getJSON=function(){var e=d.apply(null,arguments);return e.dataType="json",t.ajax(e)},t.fn.load=function(e,n,r){if(!this.length)return this;var i,o=this,a=e.split(/\s/),s=d(e,n,r),u=s.success;return a.length>1&&(s.url=a[0],i=a[1]),s.success=function(e){o.html(i?t("
        ").html(e.replace(b,"")).find(i):e),u&&u.apply(o,arguments)},t.ajax(s),this};var N=encodeURIComponent;t.param=function(e,n){var r=[];return r.add=function(e,n){t.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(N(e)+"="+N(n))},m(r,e,n),r.join("&").replace(/%20/g,"+")}}(e),function(t){t.fn.serializeArray=function(){var e,n,r=[],i=function(t){return t.forEach?t.forEach(i):void r.push({name:e,value:t})};return this[0]&&t.each(this[0].elements,function(r,o){n=o.type,e=o.name,e&&"fieldset"!=o.nodeName.toLowerCase()&&!o.disabled&&"submit"!=n&&"reset"!=n&&"button"!=n&&"file"!=n&&("radio"!=n&&"checkbox"!=n||o.checked)&&i(t(o).val())}),r},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(e),function(){try{getComputedStyle(void 0)}catch(t){var e=getComputedStyle;window.getComputedStyle=function(t,n){try{return e(t,n)}catch(r){return null}}}}(),t("zepto",e)});layui.define(function(i){i("layim-mobile",layui.v)});layui["layui.mobile"]||layui.config({base:layui.cache.dir+"lay/modules/mobile/"}).extend({"layer-mobile":"layer-mobile",zepto:"zepto","upload-mobile":"upload-mobile","layim-mobile":"layim-mobile"}),layui.define(["layer-mobile","zepto","layim-mobile"],function(l){l("mobile",{layer:layui["layer-mobile"],layim:layui["layim-mobile"]})}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/rate.js b/IoTGateway/wwwroot/layui/lay/modules/rate.js index 550d79c..5e42ec8 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/rate.js +++ b/IoTGateway/wwwroot/layui/lay/modules/rate.js @@ -1,218 +1,2 @@ -/** - - @Title: rate 评分评星组件 - @License:MIT - - */ - -layui.define('jquery',function(exports){ - "use strict"; - var $ = layui.jquery - - //外部接口 - ,rate = { - config: {} - ,index: layui.rate ? (layui.rate.index + 10000) : 0 - - //设置全局项 - ,set: function(options){ - var that = this; - that.config = $.extend({}, that.config, options); - return that; - } - - //事件 - ,on: function(events, callback){ - return layui.onevent.call(this, MOD_NAME, events, callback); - } - } - - //操作当前实例 - ,thisRate = function(){ - var that = this - ,options = that.config; - - return { - setvalue: function(value){ - that.setvalue.call(that, value); - } - ,config: options - } - } - - //字符常量 - ,MOD_NAME = 'rate',ELEM_VIEW = 'layui-rate', ICON_RATE = 'layui-icon-rate', ICON_RATE_SOLID = 'layui-icon-rate-solid', ICON_RATE_HALF = 'layui-icon-rate-half' - - ,ICON_SOLID_HALF = 'layui-icon-rate-solid layui-icon-rate-half', ICON_SOLID_RATE = 'layui-icon-rate-solid layui-icon-rate', ICON_HALF_RATE = 'layui-icon-rate layui-icon-rate-half' - - //构造器 - ,Class = function(options){ - var that = this; - that.index = ++rate.index; - that.config = $.extend({}, that.config, rate.config, options); - that.render(); - }; - - //默认配置 - Class.prototype.config = { - length: 5 //初始长度 - ,text: false //是否显示评分等级 - ,readonly: false //是否只读 - ,half: false //是否可以半星 - ,value: 0 //星星选中个数 - ,theme: '' - }; - - //评分渲染 - Class.prototype.render = function(){ - var that = this - ,options = that.config - ,style = options.theme ? ('style="color: '+ options.theme + ';"') : ''; - - options.elem = $(options.elem); - - //最大值不能大于总长度 - if(options.value > options.length){ - options.value = options.length; - } - - //如果没有选择半星的属性,却给了小数的数值,统一向上或向下取整 - if(parseInt(options.value) !== options.value){ - if(!options.half){ - options.value = (Math.ceil(options.value) - options.value) < 0.5 ? Math.ceil(options.value): Math.floor(options.value) - } - } - - //组件模板 - var temp = '
          '; - for(var i = 1;i <= options.length;i++){ - var item = '
        • '; - - if(options.half){ - if(parseInt(options.value) !== options.value){ - if(i == Math.ceil(options.value)){ - temp = temp + '
        • '; - }else{ - temp = temp + item - } - }else{ - temp = temp + item - } - }else{ - temp = temp +item; - } - } - temp += '
        ' + (options.text ? (''+ options.value + '星') : '') + ''; - - //开始插入替代元素 - var othis = options.elem - ,hasRender = othis.next('.' + ELEM_VIEW); - - //生成替代元素 - hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender - - that.elemTemp = $(temp); - - options.span = that.elemTemp.next('span'); - - options.setText && options.setText(options.value); - - othis.html(that.elemTemp); - - othis.addClass("layui-inline"); - - //如果不是只读,那么进行触控事件 - if(!options.readonly) that.action(); - - }; - - //评分重置 - Class.prototype.setvalue = function(value){ - var that = this - ,options = that.config ; - - options.value = value ; - that.render(); - }; - - //li触控事件 - Class.prototype.action = function(){ - var that = this - ,options = that.config - ,_ul = that.elemTemp - ,wide = _ul.find("i").width(); - - _ul.children("li").each(function(index){ - var ind = index + 1 - ,othis = $(this); - - //点击 - othis.on('click', function(e){ - //将当前点击li的索引值赋给value - options.value = ind; - if(options.half){ - //获取鼠标在li上的位置 - var x = e.pageX - $(this).offset().left; - if(x <= wide / 2){ - options.value = options.value - 0.5; - } - } - - if(options.text) _ul.next("span").text(options.value + "星"); - - options.choose && options.choose(options.value); - options.setText && options.setText(options.value); - }); - - //移入 - othis.on('mousemove', function(e){ - _ul.find("i").each(function(){ - $(this).addClass(ICON_RATE).removeClass(ICON_SOLID_HALF) - }); - _ul.find("i:lt(" + ind + ")").each(function(){ - $(this).addClass(ICON_RATE_SOLID).removeClass(ICON_HALF_RATE) - }); - // 如果设置可选半星,那么判断鼠标相对li的位置 - if(options.half){ - var x = e.pageX - $(this).offset().left; - if(x <= wide / 2){ - othis.children("i").addClass(ICON_RATE_HALF).removeClass(ICON_RATE_SOLID) - } - } - }) - - //移出 - othis.on('mouseleave', function(){ - _ul.find("i").each(function(){ - $(this).addClass(ICON_RATE).removeClass(ICON_SOLID_HALF) - }); - _ul.find("i:lt(" + Math.floor(options.value) + ")").each(function(){ - $(this).addClass(ICON_RATE_SOLID).removeClass(ICON_HALF_RATE) - }); - //如果设置可选半星,根据分数判断是否有半星 - if(options.half){ - if(parseInt(options.value) !== options.value){ - _ul.children("li:eq(" + Math.floor(options.value) + ")").children("i").addClass(ICON_RATE_HALF).removeClass(ICON_SOLID_RATE) - } - } - }) - - }) - }; - - //事件处理 - Class.prototype.events = function(){ - var that = this - ,options = that.config; - }; - - //核心入口 - rate.render = function(options){ - var inst = new Class(options); - return thisRate.call(inst); - }; - - exports(MOD_NAME, rate); -}) \ No newline at end of file +/** layui-v2.5.7 MIT License */ + ;layui.define("jquery",function(e){"use strict";var a=layui.jquery,l={config:{},index:layui.rate?layui.rate.index+1e4:0,set:function(e){var l=this;return l.config=a.extend({},l.config,e),l},on:function(e,a){return layui.onevent.call(this,n,e,a)}},i=function(){var e=this,a=e.config;return{setvalue:function(a){e.setvalue.call(e,a)},config:a}},n="rate",t="layui-rate",o="layui-icon-rate",u="layui-icon-rate-solid",s="layui-icon-rate-half",r="layui-icon-rate-solid layui-icon-rate-half",c="layui-icon-rate-solid layui-icon-rate",f="layui-icon-rate layui-icon-rate-half",v=function(e){var i=this;i.index=++l.index,i.config=a.extend({},i.config,l.config,e),i.render()};v.prototype.config={length:5,text:!1,readonly:!1,half:!1,value:0,theme:""},v.prototype.render=function(){var e=this,l=e.config,i=l.theme?'style="color: '+l.theme+';"':"";l.elem=a(l.elem),l.value>l.length&&(l.value=l.length),parseInt(l.value)!==l.value&&(l.half||(l.value=Math.ceil(l.value)-l.value<.5?Math.ceil(l.value):Math.floor(l.value)));for(var n='
          ",s=1;s<=l.length;s++){var r='
        • ";l.half&&parseInt(l.value)!==l.value&&s==Math.ceil(l.value)?n=n+'
        • ":n+=r}n+="
        "+(l.text?''+l.value+"星":"")+"";var c=l.elem,f=c.next("."+t);f[0]&&f.remove(),e.elemTemp=a(n),l.span=e.elemTemp.next("span"),l.setText&&l.setText(l.value),c.html(e.elemTemp),c.addClass("layui-inline"),l.readonly||e.action()},v.prototype.setvalue=function(e){var a=this,l=a.config;l.value=e,a.render()},v.prototype.action=function(){var e=this,l=e.config,i=e.elemTemp,n=i.find("i").width();i.children("li").each(function(e){var t=e+1,v=a(this);v.on("click",function(e){if(l.value=t,l.half){var o=e.pageX-a(this).offset().left;o<=n/2&&(l.value=l.value-.5)}l.text&&i.next("span").text(l.value+"星"),l.choose&&l.choose(l.value),l.setText&&l.setText(l.value)}),v.on("mousemove",function(e){if(i.find("i").each(function(){a(this).addClass(o).removeClass(r)}),i.find("i:lt("+t+")").each(function(){a(this).addClass(u).removeClass(f)}),l.half){var c=e.pageX-a(this).offset().left;c<=n/2&&v.children("i").addClass(s).removeClass(u)}}),v.on("mouseleave",function(){i.find("i").each(function(){a(this).addClass(o).removeClass(r)}),i.find("i:lt("+Math.floor(l.value)+")").each(function(){a(this).addClass(u).removeClass(f)}),l.half&&parseInt(l.value)!==l.value&&i.children("li:eq("+Math.floor(l.value)+")").children("i").addClass(s).removeClass(c)})})},v.prototype.events=function(){var e=this;e.config},l.render=function(e){var a=new v(e);return i.call(a)},e(n,l)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/slider.js b/IoTGateway/wwwroot/layui/lay/modules/slider.js index e449632..1acef19 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/slider.js +++ b/IoTGateway/wwwroot/layui/lay/modules/slider.js @@ -1,383 +1,2 @@ -/** - - @Title: slider 滑块组件 - @License:MIT - - */ - -layui.define('jquery', function(exports){ - "use strict"; - var $ = layui.jquery - - //外部接口 - ,slider = { - config: {} - ,index: layui.slider ? (layui.slider.index + 10000) : 0 - - //设置全局项 - ,set: function(options){ - var that = this; - that.config = $.extend({}, that.config, options); - return that; - } - - //事件 - ,on: function(events, callback){ - return layui.onevent.call(this, MOD_NAME, events, callback); - } - } - - //操作当前实例 - ,thisSlider = function(){ - var that = this - ,options = that.config; - - return { - setValue: function(value, index){ //设置值 - options.value = value; - return that.slide('set', value, index || 0); - } - ,config: options - } - } - - //字符常量 - ,MOD_NAME = 'slider', DISABLED = 'layui-disabled', ELEM_VIEW = 'layui-slider', SLIDER_BAR = 'layui-slider-bar', SLIDER_WRAP = 'layui-slider-wrap', SLIDER_WRAP_BTN = 'layui-slider-wrap-btn', SLIDER_TIPS = 'layui-slider-tips', SLIDER_INPUT = 'layui-slider-input', SLIDER_INPUT_TXT = 'layui-slider-input-txt', SLIDER_INPUT_BTN = 'layui-slider-input-btn', ELEM_HOVER = 'layui-slider-hover' - - //构造器 - ,Class = function(options){ - var that = this; - that.index = ++slider.index; - that.config = $.extend({}, that.config, slider.config, options); - that.render(); - }; - - //默认配置 - Class.prototype.config = { - type: 'default' //滑块类型,垂直:vertical - ,min: 0 //最小值 - ,max: 100 //最大值,默认100 - ,value: 0 //初始值,默认为0 - ,step: 1 //间隔值 - ,showstep: false //间隔点开启 - ,tips: true //文字提示,开启 - ,input: false //输入框,关闭 - ,range: false //范围选择,与输入框不能同时开启,默认关闭 - ,height: 200 //配合 type:"vertical" 使用,默认200px - ,disabled: false //滑块禁用,默认关闭 - ,theme: '#009688' //主题颜色 - }; - - //滑块渲染 - Class.prototype.render = function(){ - var that = this - ,options = that.config; - - //间隔值不能小于 1 - if(options.step < 1) options.step = 1; - - //最大值不能小于最小值 - if(options.max < options.min) options.max = options.min + options.step; - - - - //判断是否开启双滑块 - if(options.range){ - options.value = typeof(options.value) == 'object' ? options.value : [options.min, options.value]; - var minValue = Math.min(options.value[0], options.value[1]) - ,maxValue = Math.max(options.value[0], options.value[1]); - options.value[0] = minValue > options.min ? minValue : options.min; - options.value[1] = maxValue > options.min ? maxValue : options.min; - options.value[0] = options.value[0] > options.max ? options.max : options.value[0]; - options.value[1] = options.value[1] > options.max ? options.max : options.value[1]; - - var scaleFir = Math.floor((options.value[0] - options.min) / (options.max - options.min) * 100) - ,scaleSec = Math.floor((options.value[1] - options.min) / (options.max - options.min) * 100) - ,scale = scaleSec - scaleFir + '%'; - scaleFir = scaleFir + '%'; - scaleSec = scaleSec + '%'; - } else { - //如果初始值是一个数组,则获取数组的最小值 - if(typeof options.value == 'object'){ - options.value = Math.min.apply(null, options.value); - } - - //初始值不能小于最小值且不能大于最大值 - if(options.value < options.min) options.value = options.min; - if(options.value > options.max) options.value = options.max; - - var scale = Math.floor((options.value - options.min) / (options.max - options.min) * 100) + '%'; - }; - - - //如果禁用,颜色为统一的灰色 - var theme = options.disabled ? '#c2c2c2' : options.theme; - - //滑块 - var temp = '
        '+ (options.tips ? '
        ' : '') + - '
        ' + - '
        '+ (options.range ? '
        ' : '') +'
        '; - - var othis = $(options.elem) - ,hasRender = othis.next('.' + ELEM_VIEW); - //生成替代元素 - hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender - that.elemTemp = $(temp); - - //把数据缓存到滑块上 - if(options.range){ - that.elemTemp.find('.' + SLIDER_WRAP).eq(0).data('value', options.value[0]); - that.elemTemp.find('.' + SLIDER_WRAP).eq(1).data('value', options.value[1]); - }else{ - that.elemTemp.find('.' + SLIDER_WRAP).data('value', options.value); - }; - - //插入替代元素 - othis.html(that.elemTemp); - - //垂直滑块 - if(options.type === 'vertical'){ - that.elemTemp.height(options.height + 'px'); - }; - - //显示间断点 - if(options.showstep){ - var number = (options.max - options.min) / options.step, item = ''; - for(var i = 1; i < number + 1; i++) { - var step = i * 100 / number; - if(step < 100){ - item += '
        ' - } - }; - that.elemTemp.append(item); - }; - - //插入输入框 - if(options.input && !options.range){ - var elemInput = $('
        '); - othis.css("position","relative"); - othis.append(elemInput); - othis.find('.' + SLIDER_INPUT_TXT).children('input').val(options.value); - if(options.type === 'vertical'){ - elemInput.css({ - left: 0 - ,top: -48 - }); - } else { - that.elemTemp.css("margin-right", elemInput.outerWidth() + 15); - } - }; - - //给未禁止的滑块滑动事件 - if(!options.disabled){ - that.slide(); - }else{ - that.elemTemp.addClass(DISABLED); - that.elemTemp.find('.' + SLIDER_WRAP_BTN).addClass(DISABLED); - }; - - //划过滑块显示数值 - that.elemTemp.find('.' + SLIDER_WRAP_BTN).on('mouseover', function(){ - var sliderWidth = options.type === 'vertical' ? options.height : that.elemTemp[0].offsetWidth - ,sliderWrap = that.elemTemp.find('.' + SLIDER_WRAP) - ,tipsLeft = options.type === 'vertical' ? (sliderWidth - $(this).parent()[0].offsetTop - sliderWrap.height()) : $(this).parent()[0].offsetLeft - ,left = tipsLeft / sliderWidth * 100 - ,value = $(this).parent().data('value') - ,tipsTxt = options.setTips ? options.setTips(value) : value; - that.elemTemp.find('.' + SLIDER_TIPS).html(tipsTxt); - if(options.type === 'vertical'){ - that.elemTemp.find('.' + SLIDER_TIPS).css({"bottom":left + '%', "margin-bottom":"20px", "display":"inline-block"}); - }else{ - that.elemTemp.find('.' + SLIDER_TIPS).css({"left":left + '%', "display":"inline-block"}); - }; - }).on('mouseout', function(){ - that.elemTemp.find('.' + SLIDER_TIPS).css("display", "none"); - }); - }; - - //滑块滑动 - Class.prototype.slide = function(setValue, value, i){ - var that = this - ,options = that.config - ,sliderAct = that.elemTemp - ,sliderWidth = function(){ - return options.type === 'vertical' ? options.height : sliderAct[0].offsetWidth - } - ,sliderWrap = sliderAct.find('.' + SLIDER_WRAP) - ,sliderTxt = sliderAct.next('.' + SLIDER_INPUT) - ,inputValue = sliderTxt.children('.' + SLIDER_INPUT_TXT).children('input').val() - ,step = 100 / ((options.max - options.min) / Math.ceil(options.step)) - ,change = function(offsetValue, index){ - if(Math.ceil(offsetValue) * step > 100){ - offsetValue = Math.ceil(offsetValue) * step - }else{ - offsetValue = Math.round(offsetValue) * step - }; - offsetValue = offsetValue > 100 ? 100: offsetValue; - sliderWrap.eq(index).css((options.type === 'vertical' ?'bottom':'left'), offsetValue + '%'); - var firLeft = valueTo(sliderWrap[0].offsetLeft) - ,secLeft = options.range ? valueTo(sliderWrap[1].offsetLeft) : 0; - if(options.type === 'vertical'){ - sliderAct.find('.' + SLIDER_TIPS).css({"bottom":offsetValue + '%', "margin-bottom":"20px"}); - firLeft = valueTo(sliderWidth() - sliderWrap[0].offsetTop - sliderWrap.height()); - secLeft = options.range ? valueTo(sliderWidth() - sliderWrap[1].offsetTop - sliderWrap.height()) : 0; - }else{ - sliderAct.find('.' + SLIDER_TIPS).css("left",offsetValue + '%'); - }; - firLeft = firLeft > 100 ? 100: firLeft; - secLeft = secLeft > 100 ? 100: secLeft; - var minLeft = Math.min(firLeft, secLeft) - ,wrapWidth = Math.abs(firLeft - secLeft); - if(options.type === 'vertical'){ - sliderAct.find('.' + SLIDER_BAR).css({"height":wrapWidth + '%', "bottom":minLeft + '%'}); - }else{ - sliderAct.find('.' + SLIDER_BAR).css({"width":wrapWidth + '%', "left":minLeft + '%'}); - }; - var selfValue = options.min + Math.round((options.max - options.min) * offsetValue / 100); - inputValue = selfValue; - sliderTxt.children('.' + SLIDER_INPUT_TXT).children('input').val(inputValue); - sliderWrap.eq(index).data('value', selfValue); - sliderAct.find('.' + SLIDER_TIPS).html(options.setTips ? options.setTips(selfValue) : selfValue); - - //如果开启范围选择,则返回数组值 - if(options.range){ - var arrValue = [ - sliderWrap.eq(0).data('value') - ,sliderWrap.eq(1).data('value') - ]; - if(arrValue[0] > arrValue[1]) arrValue.reverse(); //如果前面的圆点超过了后面的圆点值,则调换顺序 - } - - //回调 - options.change && options.change(options.range ? arrValue : selfValue); - } - ,valueTo = function(value){ - var oldLeft = value / sliderWidth() * 100 / step - ,left = Math.round(oldLeft) * step; - if(value == sliderWidth()){ - left = Math.ceil(oldLeft) * step; - }; - return left; - } - - //拖拽元素 - ,elemMove = $(['
        sliderWidth())left = sliderWidth(); - var reaLeft = left / sliderWidth() * 100 / step; - change(reaLeft, index); - othis.addClass(ELEM_HOVER); - sliderAct.find('.' + SLIDER_TIPS).show(); - e.preventDefault(); - }; - - var up = function(){ - othis.removeClass(ELEM_HOVER); - sliderAct.find('.' + SLIDER_TIPS).hide(); - }; - - createMoveElem(move, up) - }); - }); - - //点击滑块 - sliderAct.on('click', function(e){ - var main = $('.' + SLIDER_WRAP_BTN); - if(!main.is(event.target) && main.has(event.target).length === 0 && main.length){ - var left = options.type === 'vertical' ? (sliderWidth() - e.clientY + $(this).offset().top):(e.clientX - $(this).offset().left), index; - if(left < 0)left = 0; - if(left > sliderWidth())left = sliderWidth(); - var reaLeft = left / sliderWidth() * 100 / step; - if(options.range){ - if(options.type === 'vertical'){ - index = Math.abs(left - parseInt($(sliderWrap[0]).css('bottom'))) > Math.abs(left - parseInt($(sliderWrap[1]).css('bottom'))) ? 1 : 0; - }else{ - index = Math.abs(left - sliderWrap[0].offsetLeft) > Math.abs(left - sliderWrap[1].offsetLeft) ? 1 : 0; - } - }else{ - index = 0; - }; - change(reaLeft, index); - e.preventDefault(); - } - }); - - //点击加减输入框 - sliderTxt.children('.' + SLIDER_INPUT_BTN).children('i').each(function(index){ - $(this).on('click', function(){ - inputValue = sliderTxt.children('.' + SLIDER_INPUT_TXT).children('input').val(); - if(index == 1){ //减 - inputValue = inputValue - options.step < options.min - ? options.min - : Number(inputValue) - options.step; - }else{ - inputValue = Number(inputValue) + options.step > options.max - ? options.max - : Number(inputValue) + options.step; - }; - var inputScale = (inputValue - options.min) / (options.max - options.min) * 100 / step; - change(inputScale, 0); - }); - }); - - //获取输入框值 - var getInputValue = function(){ - var realValue = this.value; - realValue = isNaN(realValue) ? 0 : realValue; - realValue = realValue < options.min ? options.min : realValue; - realValue = realValue > options.max ? options.max : realValue; - this.value = realValue; - var inputScale = (realValue - options.min) / (options.max - options.min) * 100 / step; - change(inputScale, 0); - }; - sliderTxt.children('.' + SLIDER_INPUT_TXT).children('input').on('keydown', function(e){ - if(e.keyCode === 13){ - e.preventDefault(); - getInputValue.call(this); - } - }).on('change', getInputValue); - }; - - //事件处理 - Class.prototype.events = function(){ - var that = this - ,options = that.config; - }; - - //核心入口 - slider.render = function(options){ - var inst = new Class(options); - return thisSlider.call(inst); - }; - - exports(MOD_NAME, slider); -}) \ No newline at end of file +/** layui-v2.5.7 MIT License */ + ;layui.define("jquery",function(e){"use strict";var i=layui.jquery,t={config:{},index:layui.slider?layui.slider.index+1e4:0,set:function(e){var t=this;return t.config=i.extend({},t.config,e),t},on:function(e,i){return layui.onevent.call(this,n,e,i)}},a=function(){var e=this,i=e.config;return{setValue:function(t,a){return i.value=t,e.slide("set",t,a||0)},config:i}},n="slider",l="layui-disabled",s="layui-slider",r="layui-slider-bar",o="layui-slider-wrap",u="layui-slider-wrap-btn",d="layui-slider-tips",v="layui-slider-input",c="layui-slider-input-txt",p="layui-slider-input-btn",m="layui-slider-hover",f=function(e){var a=this;a.index=++t.index,a.config=i.extend({},a.config,t.config,e),a.render()};f.prototype.config={type:"default",min:0,max:100,value:0,step:1,showstep:!1,tips:!0,input:!1,range:!1,height:200,disabled:!1,theme:"#009688"},f.prototype.render=function(){var e=this,t=e.config;if(t.step<1&&(t.step=1),t.maxt.min?a:t.min,t.value[1]=n>t.min?n:t.min,t.value[0]=t.value[0]>t.max?t.max:t.value[0],t.value[1]=t.value[1]>t.max?t.max:t.value[1];var r=Math.floor((t.value[0]-t.min)/(t.max-t.min)*100),v=Math.floor((t.value[1]-t.min)/(t.max-t.min)*100),p=v-r+"%";r+="%",v+="%"}else{"object"==typeof t.value&&(t.value=Math.min.apply(null,t.value)),t.valuet.max&&(t.value=t.max);var p=Math.floor((t.value-t.min)/(t.max-t.min)*100)+"%"}var m=t.disabled?"#c2c2c2":t.theme,f='
        '+(t.tips?'
        ':"")+'
        '+(t.range?'
        ':"")+"
        ",h=i(t.elem),y=h.next("."+s);if(y[0]&&y.remove(),e.elemTemp=i(f),t.range?(e.elemTemp.find("."+o).eq(0).data("value",t.value[0]),e.elemTemp.find("."+o).eq(1).data("value",t.value[1])):e.elemTemp.find("."+o).data("value",t.value),h.html(e.elemTemp),"vertical"===t.type&&e.elemTemp.height(t.height+"px"),t.showstep){for(var g=(t.max-t.min)/t.step,b="",x=1;x
        ')}e.elemTemp.append(b)}if(t.input&&!t.range){var w=i('
        ');h.css("position","relative"),h.append(w),h.find("."+c).children("input").val(t.value),"vertical"===t.type?w.css({left:0,top:-48}):e.elemTemp.css("margin-right",w.outerWidth()+15)}t.disabled?(e.elemTemp.addClass(l),e.elemTemp.find("."+u).addClass(l)):e.slide(),e.elemTemp.find("."+u).on("mouseover",function(){var a="vertical"===t.type?t.height:e.elemTemp[0].offsetWidth,n=e.elemTemp.find("."+o),l="vertical"===t.type?a-i(this).parent()[0].offsetTop-n.height():i(this).parent()[0].offsetLeft,s=l/a*100,r=i(this).parent().data("value"),u=t.setTips?t.setTips(r):r;e.elemTemp.find("."+d).html(u),"vertical"===t.type?e.elemTemp.find("."+d).css({bottom:s+"%","margin-bottom":"20px",display:"inline-block"}):e.elemTemp.find("."+d).css({left:s+"%",display:"inline-block"})}).on("mouseout",function(){e.elemTemp.find("."+d).css("display","none")})},f.prototype.slide=function(e,t,a){var n=this,l=n.config,s=n.elemTemp,f=function(){return"vertical"===l.type?l.height:s[0].offsetWidth},h=s.find("."+o),y=s.next("."+v),g=y.children("."+c).children("input").val(),b=100/((l.max-l.min)/Math.ceil(l.step)),x=function(e,i){e=Math.ceil(e)*b>100?Math.ceil(e)*b:Math.round(e)*b,e=e>100?100:e,h.eq(i).css("vertical"===l.type?"bottom":"left",e+"%");var t=T(h[0].offsetLeft),a=l.range?T(h[1].offsetLeft):0;"vertical"===l.type?(s.find("."+d).css({bottom:e+"%","margin-bottom":"20px"}),t=T(f()-h[0].offsetTop-h.height()),a=l.range?T(f()-h[1].offsetTop-h.height()):0):s.find("."+d).css("left",e+"%"),t=t>100?100:t,a=a>100?100:a;var n=Math.min(t,a),o=Math.abs(t-a);"vertical"===l.type?s.find("."+r).css({height:o+"%",bottom:n+"%"}):s.find("."+r).css({width:o+"%",left:n+"%"});var u=l.min+Math.round((l.max-l.min)*e/100);if(g=u,y.children("."+c).children("input").val(g),h.eq(i).data("value",u),s.find("."+d).html(l.setTips?l.setTips(u):u),l.range){var v=[h.eq(0).data("value"),h.eq(1).data("value")];v[0]>v[1]&&v.reverse()}l.change&&l.change(l.range?v:u)},T=function(e){var i=e/f()*100/b,t=Math.round(i)*b;return e==f()&&(t=Math.ceil(i)*b),t},w=i(['
        f()&&(r=f());var o=r/f()*100/b;x(o,e),t.addClass(m),s.find("."+d).show(),i.preventDefault()},o=function(){t.removeClass(m),s.find("."+d).hide()};M(r,o)})}),s.on("click",function(e){var t=i("."+u);if(!t.is(event.target)&&0===t.has(event.target).length&&t.length){var a,n="vertical"===l.type?f()-e.clientY+i(this).offset().top:e.clientX-i(this).offset().left;n<0&&(n=0),n>f()&&(n=f());var s=n/f()*100/b;a=l.range?"vertical"===l.type?Math.abs(n-parseInt(i(h[0]).css("bottom")))>Math.abs(n-parseInt(i(h[1]).css("bottom")))?1:0:Math.abs(n-h[0].offsetLeft)>Math.abs(n-h[1].offsetLeft)?1:0:0,x(s,a),e.preventDefault()}}),y.children("."+p).children("i").each(function(e){i(this).on("click",function(){g=y.children("."+c).children("input").val(),g=1==e?g-l.stepl.max?l.max:Number(g)+l.step;var i=(g-l.min)/(l.max-l.min)*100/b;x(i,0)})});var q=function(){var e=this.value;e=isNaN(e)?0:e,e=el.max?l.max:e,this.value=e;var i=(e-l.min)/(l.max-l.min)*100/b;x(i,0)};y.children("."+c).children("input").on("keydown",function(e){13===e.keyCode&&(e.preventDefault(),q.call(this))}).on("change",q)},f.prototype.events=function(){var e=this;e.config},t.render=function(e){var i=new f(e);return a.call(i)},e(n,t)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/table.js b/IoTGateway/wwwroot/layui/lay/modules/table.js index c72fe93..10ab647 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/table.js +++ b/IoTGateway/wwwroot/layui/lay/modules/table.js @@ -1,2025 +1,2 @@ -/** - - @Name:table 表格操作组件 - @License:MIT - - */ - -layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){ - "use strict"; - - var $ = layui.$ - ,laytpl = layui.laytpl - ,laypage = layui.laypage - ,layer = layui.layer - ,form = layui.form - ,util = layui.util - ,hint = layui.hint() - ,device = layui.device() - - //外部接口 - ,table = { - config: { - checkName: 'LAY_CHECKED' //是否选中状态的字段名 - ,indexName: 'LAY_TABLE_INDEX' //初始下标索引名,用于恢复排序 - } //全局配置项 - ,cache: {} //数据缓存 - ,index: layui.table ? (layui.table.index + 10000) : 0 - - //设置全局项 - ,set: function(options){ - var that = this; - that.config = $.extend({}, that.config, options); - return that; - } - - //事件 - ,on: function(events, callback){ - return layui.onevent.call(this, MOD_NAME, events, callback); - } - } - - //操作当前实例 - ,thisTable = function(){ - var that = this - ,options = that.config - ,id = options.id || options.index; - - if(id){ - thisTable.that[id] = that; //记录当前实例对象 - thisTable.config[id] = options; //记录当前实例配置项 - } - - return { - config: options - ,reload: function(options, deep){ - that.reload.call(that, options, deep); - } - ,setColsWidth: function(){ - that.setColsWidth.call(that); - } - ,resize: function(){ //重置表格尺寸/结构 - that.resize.call(that); - } - } - } - - //获取当前实例配置项 - ,getThisTableConfig = function(id){ - var config = thisTable.config[id]; - if(!config) hint.error(id ? ('The table instance with ID \''+ id +'\' not found') : 'ID argument required'); - return config || null; - } - - //解析自定义模板数据 - ,parseTempData = function(item3, content, tplData, text){ //表头数据、原始内容、表体数据、是否只返回文本 - var str = item3.templet ? function(){ - return typeof item3.templet === 'function' - ? item3.templet(tplData) - : laytpl($(item3.templet).html() || String(content)).render(tplData) - }() : content; - return text ? $('
        '+ str +'
        ').text() : str; - } - - //字符常量 - ,MOD_NAME = 'table', ELEM = '.layui-table', THIS = 'layui-this', SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled', NONE = 'layui-none' - - ,ELEM_VIEW = 'layui-table-view', ELEM_TOOL = '.layui-table-tool', ELEM_BOX = '.layui-table-box', ELEM_INIT = '.layui-table-init', ELEM_HEADER = '.layui-table-header', ELEM_BODY = '.layui-table-body', ELEM_MAIN = '.layui-table-main', ELEM_FIXED = '.layui-table-fixed', ELEM_FIXL = '.layui-table-fixed-l', ELEM_FIXR = '.layui-table-fixed-r', ELEM_TOTAL = '.layui-table-total', ELEM_PAGE = '.layui-table-page', ELEM_SORT = '.layui-table-sort', ELEM_EDIT = 'layui-table-edit', ELEM_HOVER = 'layui-table-hover' - - //thead区域模板 - ,TPL_HEADER = function(options){ - var rowCols = '{{#if(item2.colspan){}} colspan="{{item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{item2.rowspan}}"{{#}}}'; - - options = options || {}; - return ['
        ' - ,'' - ,'{{# layui.each(d.data.cols, function(i1, item1){ }}' - ,'' - ,'{{# layui.each(item1, function(i2, item2){ }}' - ,'{{# if(item2.fixed && item2.fixed !== "right"){ left = true; } }}' - ,'{{# if(item2.fixed === "right"){ right = true; } }}' - ,function(){ - if(options.fixed && options.fixed !== 'right'){ - return '{{# if(item2.fixed && item2.fixed !== "right"){ }}'; - } - if(options.fixed === 'right'){ - return '{{# if(item2.fixed === "right"){ }}'; - } - return ''; - }() - ,'{{# var isSort = !(item2.colGroup) && item2.sort; }}' - ,'' - ,(options.fixed ? '{{# }; }}' : '') - ,'{{# }); }}' - ,'' - ,'{{# }); }}' - ,'' - ,'
        ' - ,'
        ' - ,'{{# if(item2.type === "checkbox"){ }}' //复选框 - ,'' - ,'{{# } else { }}' - ,'{{item2.title||""}}' - ,'{{# if(isSort){ }}' - ,'' - ,'{{# } }}' - ,'{{# } }}' - ,'
        ' - ,'
        '].join(''); - } - - //tbody区域模板 - ,TPL_BODY = ['' - ,'' - ,'
        '].join('') - - //主模板 - ,TPL_MAIN = ['
        ' - - ,'{{# if(d.data.toolbar){ }}' - ,'
        ' - ,'
        ' - ,'
        ' - ,'
        ' - ,'{{# } }}' - - ,'
        ' - ,'{{# if(d.data.loading){ }}' - ,'
        ' - ,'' - ,'
        ' - ,'{{# } }}' - - ,'{{# var left, right; }}' - ,'
        ' - ,TPL_HEADER() - ,'
        ' - ,'
        ' - ,TPL_BODY - ,'
        ' - - ,'{{# if(left){ }}' - ,'
        ' - ,'
        ' - ,TPL_HEADER({fixed: true}) - ,'
        ' - ,'
        ' - ,TPL_BODY - ,'
        ' - ,'
        ' - ,'{{# }; }}' - - ,'{{# if(right){ }}' - ,'
        ' - ,'
        ' - ,TPL_HEADER({fixed: 'right'}) - ,'
        ' - ,'
        ' - ,'
        ' - ,TPL_BODY - ,'
        ' - ,'
        ' - ,'{{# }; }}' - ,'
        ' - - ,'{{# if(d.data.totalRow){ }}' - ,'
        ' - ,'' - ,'' - , '
        ' - ,'
        ' - ,'{{# } }}' - - ,'{{# if(d.data.page){ }}' - ,'
        ' - ,'
        ' - ,'
        ' - ,'{{# } }}' - - ,'' - ,'
        '].join('') - - ,_WIN = $(window) - ,_DOC = $(document) - - //构造器 - ,Class = function(options){ - var that = this; - that.index = ++table.index; - that.config = $.extend({}, that.config, table.config, options);; - that.render(); - }; - - //初始默认配置 - Class.prototype.config = { - limit: 10 //每页显示的数量 - ,loading: true //请求数据时,是否显示loading - ,cellMinWidth: 60 //所有单元格默认最小宽度 - ,defaultToolbar: ['filter', 'exports', 'print'] //工具栏右侧图标 - ,autoSort: true //是否前端自动排序。如果否,则需自主排序(通常为服务端处理好排序) - ,text: { - none: '无数据' - } - }; - - //表格渲染 - Class.prototype.render = function(){ - var that = this - ,options = that.config; - - options.elem = $(options.elem); - options.where = options.where || {}; - options.id = options.id || options.elem.attr('id') || that.index; - - //请求参数的自定义格式 - options.request = $.extend({ - pageName: 'page' - ,limitName: 'limit' - }, options.request) - - //响应数据的自定义格式 - options.response = $.extend({ - statusName: 'code' //规定数据状态的字段名称 - ,statusCode: 0 //规定成功的状态码 - ,msgName: 'msg' //规定状态信息的字段名称 - ,dataName: 'data' //规定数据总数的字段名称 - ,totalRowName: 'totalRow' //规定数据统计的字段名称 - ,countName: 'count' - }, options.response); - - //如果 page 传入 laypage 对象 - if(typeof options.page === 'object'){ - options.limit = options.page.limit || options.limit; - options.limits = options.page.limits || options.limits; - that.page = options.page.curr = options.page.curr || 1; - delete options.page.elem; - delete options.page.jump; - } - - if(!options.elem[0]) return that; - - //高度铺满:full-差距值 - if(options.height && /^full-\d+$/.test(options.height)){ - that.fullHeightGap = options.height.split('-')[1]; - options.height = _WIN.height() - that.fullHeightGap; - } - - //初始化一些参数 - that.setInit(); - - //开始插入替代元素 - var othis = options.elem - ,hasRender = othis.next('.' + ELEM_VIEW) - - //主容器 - ,reElem = that.elem = $(laytpl(TPL_MAIN).render({ - VIEW_CLASS: ELEM_VIEW - ,data: options - ,index: that.index //索引 - })); - - options.index = that.index; - that.key = options.id || options.index; - - //生成替代元素 - hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender - othis.after(reElem); - - //各级容器 - that.layTool = reElem.find(ELEM_TOOL); - that.layBox = reElem.find(ELEM_BOX); - that.layHeader = reElem.find(ELEM_HEADER); - that.layMain = reElem.find(ELEM_MAIN); - that.layBody = reElem.find(ELEM_BODY); - that.layFixed = reElem.find(ELEM_FIXED); - that.layFixLeft = reElem.find(ELEM_FIXL); - that.layFixRight = reElem.find(ELEM_FIXR); - that.layTotal = reElem.find(ELEM_TOTAL); - that.layPage = reElem.find(ELEM_PAGE); - - //初始化工具栏 - that.renderToolbar(); - - //让表格平铺 - that.fullSize(); - - //如果多级表头,则填补表头高度 - if(options.cols.length > 1){ - //补全高度 - var th = that.layFixed.find(ELEM_HEADER).find('th'); - th.height(that.layHeader.height() - 1 - parseFloat(th.css('padding-top')) - parseFloat(th.css('padding-bottom'))); - } - - that.pullData(that.page); //请求数据 - that.events(); //事件 - }; - - //根据列类型,定制化参数 - Class.prototype.initOpts = function(item){ - var that = this - ,options = that.config - ,initWidth = { - checkbox: 48 - ,radio: 48 - ,space: 15 - ,numbers: 40 - }; - - //让 type 参数兼容旧版本 - if(item.checkbox) item.type = "checkbox"; - if(item.space) item.type = "space"; - if(!item.type) item.type = "normal"; - - if(item.type !== "normal"){ - item.unresize = true; - item.width = item.width || initWidth[item.type]; - } - }; - - //初始化一些参数 - Class.prototype.setInit = function(type){ - var that = this - ,options = that.config; - - options.clientWidth = options.width || function(){ //获取容器宽度 - //如果父元素宽度为0(一般为隐藏元素),则继续查找上层元素,直到找到真实宽度为止 - var getWidth = function(parent){ - var width, isNone; - parent = parent || options.elem.parent() - width = parent.width(); - try { - isNone = parent.css('display') === 'none'; - } catch(e){} - if(parent[0] && (!width || isNone)) return getWidth(parent.parent()); - return width; - }; - return getWidth(); - }(); - - if(type === 'width') return options.clientWidth; - - //初始化列参数 - layui.each(options.cols, function(i1, item1){ - layui.each(item1, function(i2, item2){ - - //如果列参数为空,则移除 - if(!item2){ - item1.splice(i2, 1); - return; - } - - item2.key = i1 + '-' + i2; - item2.hide = item2.hide || false; - - //设置列的父列索引 - //如果是组合列,则捕获对应的子列 - if(item2.colGroup || item2.colspan > 1){ - var childIndex = 0; - layui.each(options.cols[i1 + 1], function(i22, item22){ - //如果子列已经被标注为{HAS_PARENT},或者子列累计 colspan 数等于父列定义的 colspan,则跳出当前子列循环 - if(item22.HAS_PARENT || (childIndex > 1 && childIndex == item2.colspan)) return; - - item22.HAS_PARENT = true; - item22.parentKey = i1 + '-' + i2; - - childIndex = childIndex + parseInt(item22.colspan > 1 ? item22.colspan : 1); - }); - item2.colGroup = true; //标注是组合列 - } - - //根据列类型,定制化参数 - that.initOpts(item2); - }); - }); - - }; - - //初始工具栏 - Class.prototype.renderToolbar = function(){ - var that = this - ,options = that.config - - //添加工具栏左侧模板 - var leftDefaultTemp = [ - '
        ' - ,'
        ' - ,'
        ' - ].join('') - ,elemToolTemp = that.layTool.find('.layui-table-tool-temp'); - - if(options.toolbar === 'default'){ - elemToolTemp.html(leftDefaultTemp); - } else if(typeof options.toolbar === 'string'){ - var toolbarHtml = $(options.toolbar).html() || ''; - toolbarHtml && elemToolTemp.html( - laytpl(toolbarHtml).render(options) - ); - } - - //添加工具栏右侧面板 - var layout = { - filter: { - title: '筛选列' - ,layEvent: 'LAYTABLE_COLS' - ,icon: 'layui-icon-cols' - } - ,exports: { - title: '导出' - ,layEvent: 'LAYTABLE_EXPORT' - ,icon: 'layui-icon-export' - } - ,print: { - title: '打印' - ,layEvent: 'LAYTABLE_PRINT' - ,icon: 'layui-icon-print' - } - }, iconElem = []; - - if(typeof options.defaultToolbar === 'object'){ - layui.each(options.defaultToolbar, function(i, item){ - var thisItem = typeof item === 'string' ? layout[item] : item; - if(thisItem){ - iconElem.push('
        ' - +'' - +'
        '); - } - }); - } - that.layTool.find('.layui-table-tool-self').html(iconElem.join('')); - } - - //同步表头父列的相关值 - Class.prototype.setParentCol = function(hide, parentKey){ - var that = this - ,options = that.config - - ,parentTh = that.layHeader.find('th[data-key="'+ options.index +'-'+ parentKey +'"]') //获取父列元素 - ,parentColspan = parseInt(parentTh.attr('colspan')) || 0; - - if(parentTh[0]){ - var arrParentKey = parentKey.split('-') - ,getThisCol = options.cols[arrParentKey[0]][arrParentKey[1]]; - - hide ? parentColspan-- : parentColspan++; - - parentTh.attr('colspan', parentColspan); - parentTh[parentColspan < 1 ? 'addClass' : 'removeClass'](HIDE); - - getThisCol.colspan = parentColspan; //同步 colspan 参数 - getThisCol.hide = parentColspan < 1; //同步 hide 参数 - - //递归,继续往上查询是否有父列 - var nextParentKey = parentTh.data('parentkey'); - nextParentKey && that.setParentCol(hide, nextParentKey); - } - }; - - //多级表头补丁 - Class.prototype.setColsPatch = function(){ - var that = this - ,options = that.config - - //同步表头父列的相关值 - layui.each(options.cols, function(i1, item1){ - layui.each(item1, function(i2, item2){ - if(item2.hide){ - that.setParentCol(item2.hide, item2.parentKey); - } - }); - }); - }; - - //动态分配列宽 - Class.prototype.setColsWidth = function(){ - var that = this - ,options = that.config - ,colNums = 0 //列个数 - ,autoColNums = 0 //自动列宽的列个数 - ,autoWidth = 0 //自动列分配的宽度 - ,countWidth = 0 //所有列总宽度和 - ,cntrWidth = that.setInit('width'); - - //统计列个数 - that.eachCols(function(i, item){ - item.hide || colNums++; - }); - - //减去边框差和滚动条宽 - cntrWidth = cntrWidth - function(){ - return (options.skin === 'line' || options.skin === 'nob') ? 2 : colNums + 1; - }() - that.getScrollWidth(that.layMain[0]) - 1; - - //计算自动分配的宽度 - var getAutoWidth = function(back){ - //遍历所有列 - layui.each(options.cols, function(i1, item1){ - layui.each(item1, function(i2, item2){ - var width = 0 - ,minWidth = item2.minWidth || options.cellMinWidth; //最小宽度 - - if(!item2){ - item1.splice(i2, 1); - return; - } - - if(item2.colGroup || item2.hide) return; - - if(!back){ - width = item2.width || 0; - if(/\d+%$/.test(width)){ //列宽为百分比 - width = Math.floor((parseFloat(width) / 100) * cntrWidth); - width < minWidth && (width = minWidth); - } else if(!width){ //列宽未填写 - item2.width = width = 0; - autoColNums++; - } - } else if(autoWidth && autoWidth < minWidth){ - autoColNums--; - width = minWidth; - } - - if(item2.hide) width = 0; - countWidth = countWidth + width; - }); - }); - - //如果未填充满,则将剩余宽度平分 - (cntrWidth > countWidth && autoColNums) && ( - autoWidth = (cntrWidth - countWidth) / autoColNums - ); - } - - getAutoWidth(); - getAutoWidth(true); //重新检测分配的宽度是否低于最小列宽 - - //记录自动列数 - that.autoColNums = autoColNums; - - //设置列宽 - that.eachCols(function(i3, item3){ - var minWidth = item3.minWidth || options.cellMinWidth; - if(item3.colGroup || item3.hide) return; - - //给位分配宽的列平均分配宽 - if(item3.width === 0){ - that.getCssRule(options.index +'-'+ item3.key, function(item){ - item.style.width = Math.floor(autoWidth >= minWidth ? autoWidth : minWidth) + 'px'; - }); - } - - //给设定百分比的列分配列宽 - else if(/\d+%$/.test(item3.width)){ - that.getCssRule(options.index +'-'+ item3.key, function(item){ - item.style.width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth) + 'px'; - }); - } - }); - - //填补 Math.floor 造成的数差 - var patchNums = that.layMain.width() - that.getScrollWidth(that.layMain[0]) - - that.layMain.children('table').outerWidth(); - - if(that.autoColNums && patchNums >= -colNums && patchNums <= colNums){ - var getEndTh = function(th){ - var field; - th = th || that.layHeader.eq(0).find('thead th:last-child') - field = th.data('field'); - if(!field && th.prev()[0]){ - return getEndTh(th.prev()) - } - return th - } - ,th = getEndTh() - ,key = th.data('key'); - - that.getCssRule(key, function(item){ - var width = item.style.width || th.outerWidth(); - item.style.width = (parseFloat(width) + patchNums) + 'px'; - - //二次校验,如果仍然出现横向滚动条(通常是 1px 的误差导致) - if(that.layMain.height() - that.layMain.prop('clientHeight') > 0){ - item.style.width = (parseFloat(item.style.width) - 1) + 'px'; - } - }); - } - - that.loading(!0); - }; - - //重置表格尺寸/结构 - Class.prototype.resize = function(){ - var that = this; - that.fullSize(); //让表格铺满 - that.setColsWidth(); //自适应列宽 - that.scrollPatch(); //滚动条补丁 - }; - - //表格重载 - Class.prototype.reload = function(options, deep){ - var that = this; - - options = options || {}; - delete that.haveInit; - - //如果直接传入数组 data,则移除原来的数组,以免数组发生深度拷贝 - if(options.data && options.data.constructor === Array) delete that.config.data; - - //对参数进行深度或浅扩展 - that.config = $.extend(deep, {}, that.config, options); - - //执行渲染 - that.render(); - }; - - //异常提示 - Class.prototype.errorView = function(html){ - var that = this - ,elemNone = that.layMain.find('.'+ NONE) - ,layNone = $('
        '+ (html || 'Error') +'
        '); - - if(elemNone[0]){ - that.layNone.remove(); - elemNone.remove(); - } - - that.layFixed.addClass(HIDE); - that.layMain.find('tbody').html(''); - - that.layMain.append(that.layNone = layNone); - - table.cache[that.key] = []; //格式化缓存数据 - }; - - //页码 - Class.prototype.page = 1; - - //获得数据 - Class.prototype.pullData = function(curr){ - var that = this - ,options = that.config - ,request = options.request - ,response = options.response - ,sort = function(){ - if(typeof options.initSort === 'object'){ - that.sort(options.initSort.field, options.initSort.type); - } - }; - - that.startTime = new Date().getTime(); //渲染开始时间 - - if(options.url){ //Ajax请求 - var params = {}; - params[request.pageName] = curr; - params[request.limitName] = options.limit; - - //参数 - var data = $.extend(params, options.where); - if(options.contentType && options.contentType.indexOf("application/json") == 0){ //提交 json 格式 - data = JSON.stringify(data); - } - - that.loading(); - - $.ajax({ - type: options.method || 'get' - ,url: options.url - ,contentType: options.contentType - ,data: data - ,dataType: 'json' - ,headers: options.headers || {} - ,success: function(res){ - //如果有数据解析的回调,则获得其返回的数据 - if(typeof options.parseData === 'function'){ - res = options.parseData(res) || res; - } - //检查数据格式是否符合规范 - if(res[response.statusName] != response.statusCode){ - that.renderForm(); - that.errorView( - res[response.msgName] || - ('返回的数据不符合规范,正确的成功状态码应为:"'+ response.statusName +'": '+ response.statusCode) - ); - } else { - that.renderData(res, curr, res[response.countName]), sort(); - options.time = (new Date().getTime() - that.startTime) + ' ms'; //耗时(接口请求+视图渲染) - } - that.setColsWidth(); - typeof options.done === 'function' && options.done(res, curr, res[response.countName]); - } - ,error: function(e, msg){ - that.errorView('数据接口请求异常:'+ msg); - - that.renderForm(); - that.setColsWidth(); - - typeof options.error === 'function' && options.error(e, msg); - } - }); - } else if(options.data && options.data.constructor === Array){ //已知数据 - var res = {} - ,startLimit = curr*options.limit - options.limit - - res[response.dataName] = options.data.concat().splice(startLimit, options.limit); - res[response.countName] = options.data.length; - - //记录合计行数据 - if(typeof options.totalRow === 'object'){ - res[response.totalRowName] = $.extend({}, options.totalRow); - } - - that.renderData(res, curr, res[response.countName]), sort(); - that.setColsWidth(); - typeof options.done === 'function' && options.done(res, curr, res[response.countName]); - } - }; - - //遍历表头 - Class.prototype.eachCols = function(callback){ - var that = this; - table.eachCols(null, callback, that.config.cols); - return that; - }; - - //数据渲染 - Class.prototype.renderData = function(res, curr, count, sort){ - var that = this - ,options = that.config - ,data = res[options.response.dataName] || [] //列表数据 - ,totalRowData = res[options.response.totalRowName] //合计行数据 - ,trs = [] - ,trs_fixed = [] - ,trs_fixed_r = [] - - //渲染视图 - ,render = function(){ //后续性能提升的重点 - var thisCheckedRowIndex; - if(!sort && that.sortKey){ - return that.sort(that.sortKey.field, that.sortKey.sort, true); - } - layui.each(data, function(i1, item1){ - var tds = [], tds_fixed = [], tds_fixed_r = [] - ,numbers = i1 + options.limit*(curr - 1) + 1; //序号 - - if(item1.length === 0) return; - - if(!sort){ - item1[table.config.indexName] = i1; - } - - that.eachCols(function(i3, item3){ - var field = item3.field || i3 - ,key = options.index + '-' + item3.key - ,content = item1[field]; - - if(content === undefined || content === null) content = ''; - if(item3.colGroup) return; - - //td内容 - var td = ['' - ,'
        ' + function(){ - var tplData = $.extend(true, { - LAY_INDEX: numbers - }, item1) - ,checkName = table.config.checkName; - - //渲染不同风格的列 - switch(item3.type){ - case 'checkbox': - return ''; - break; - case 'radio': - if(tplData[checkName]){ - thisCheckedRowIndex = i1; - } - return ''; - break; - case 'numbers': - return numbers; - break; - }; - - //解析工具列模板 - if(item3.toolbar){ - return laytpl($(item3.toolbar).html()||'').render(tplData); - } - return parseTempData(item3, content, tplData); - }() - ,'
        '].join(''); - - tds.push(td); - if(item3.fixed && item3.fixed !== 'right') tds_fixed.push(td); - if(item3.fixed === 'right') tds_fixed_r.push(td); - }); - - trs.push(''+ tds.join('') + ''); - trs_fixed.push(''+ tds_fixed.join('') + ''); - trs_fixed_r.push(''+ tds_fixed_r.join('') + ''); - }); - - that.layBody.scrollTop(0); - that.layMain.find('.'+ NONE).remove(); - that.layMain.find('tbody').html(trs.join('')); - that.layFixLeft.find('tbody').html(trs_fixed.join('')); - that.layFixRight.find('tbody').html(trs_fixed_r.join('')); - - that.renderForm(); - typeof thisCheckedRowIndex === 'number' && that.setThisRowChecked(thisCheckedRowIndex); - that.syncCheckAll(); - - //滚动条补丁 - that.haveInit ? that.scrollPatch() : setTimeout(function(){ - that.scrollPatch(); - }, 50); - that.haveInit = true; - - layer.close(that.tipsIndex); - - //同步表头父列的相关值 - options.HAS_SET_COLS_PATCH || that.setColsPatch(); - options.HAS_SET_COLS_PATCH = true; - }; - - table.cache[that.key] = data; //记录数据 - - //显示隐藏分页栏 - that.layPage[(count == 0 || (data.length === 0 && curr == 1)) ? 'addClass' : 'removeClass'](HIDE); - - //如果无数据 - if(data.length === 0){ - that.renderForm(); - return that.errorView(options.text.none); - } else { - that.layFixed.removeClass(HIDE); - } - - //如果执行初始排序 - if(sort){ - return render(); - } - - //正常初始化数据渲染 - render(); //渲染数据 - that.renderTotal(data, totalRowData); //数据合计 - - //同步分页状态 - if(options.page){ - options.page = $.extend({ - elem: 'layui-table-page' + options.index - ,count: count - ,limit: options.limit - ,limits: options.limits || [10,20,30,40,50,60,70,80,90] - ,groups: 3 - ,layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'] - ,prev: '' - ,next: '' - ,jump: function(obj, first){ - if(!first){ - //分页本身并非需要做以下更新,下面参数的同步,主要是因为其它处理统一用到了它们 - //而并非用的是 options.page 中的参数(以确保分页未开启的情况仍能正常使用) - that.page = obj.curr; //更新页码 - options.limit = obj.limit; //更新每页条数 - - that.pullData(obj.curr); - } - } - }, options.page); - options.page.count = count; //更新总条数 - laypage.render(options.page); - } - }; - - //数据合计行 - Class.prototype.renderTotal = function(data, totalRowData){ - var that = this - ,options = that.config - ,totalNums = {}; - - if(!options.totalRow) return; - - layui.each(data, function(i1, item1){ - if(item1.length === 0) return; - - that.eachCols(function(i3, item3){ - var field = item3.field || i3 - ,content = item1[field]; - - if(item3.totalRow){ - totalNums[field] = (totalNums[field] || 0) + (parseFloat(content) || 0); - } - }); - }); - - that.dataTotal = {}; - - var tds = []; - that.eachCols(function(i3, item3){ - var field = item3.field || i3; - - //td 内容 - var content = function(){ - var text = item3.totalRowText || '' - ,thisTotalNum = parseFloat(totalNums[field]).toFixed(2) - ,tplData = {}; - - tplData[field] = thisTotalNum; - thisTotalNum = parseTempData(item3, thisTotalNum, tplData); - - //如果直接传入了合计行数据,则不输出自动计算的结果 - if(totalRowData){ - return totalRowData[item3.field] || text; - } else { - return item3.totalRow ? (thisTotalNum || text) : text; - } - }() - ,td = ['' - ,'
        ' + function(){ - var totalRow = item3.totalRow || options.totalRow; - //如果 totalRow 参数为字符类型,则解析为自定义模版 - if(typeof totalRow === 'string'){ - return laytpl(totalRow).render($.extend({ - TOTAL_NUMS: content - }, item3)) - } - return content; - }() - ,'
        '].join(''); - - item3.field && (that.dataTotal[field] = content); - tds.push(td); - }); - - that.layTotal.find('tbody').html('' + tds.join('') + ''); - }; - - //找到对应的列元素 - Class.prototype.getColElem = function(parent, key){ - var that = this - ,options = that.config; - return parent.eq(0).find('.laytable-cell-'+ (options.index + '-' + key) + ':eq(0)'); - }; - - //渲染表单 - Class.prototype.renderForm = function(type){ - form.render(type, 'LAY-table-'+ this.index); - }; - - //标记当前行选中状态 - Class.prototype.setThisRowChecked = function(index){ - var that = this - ,options = that.config - ,ELEM_CLICK = 'layui-table-click' - ,tr = that.layBody.find('tr[data-index="'+ index +'"]'); - - tr.addClass(ELEM_CLICK).siblings('tr').removeClass(ELEM_CLICK); - }; - - //数据排序 - Class.prototype.sort = function(th, type, pull, formEvent){ - var that = this - ,field - ,res = {} - ,options = that.config - ,filter = options.elem.attr('lay-filter') - ,data = table.cache[that.key], thisData; - - //字段匹配 - if(typeof th === 'string'){ - field = th; - that.layHeader.find('th').each(function(i, item){ - var othis = $(this) - ,_field = othis.data('field'); - if(_field === th){ - th = othis; - field = _field; - return false; - } - }); - } - - try { - var field = field || th.data('field') - ,key = th.data('key'); - - //如果欲执行的排序已在状态中,则不执行渲染 - if(that.sortKey && !pull){ - if(field === that.sortKey.field && type === that.sortKey.sort){ - return; - } - } - - var elemSort = that.layHeader.find('th .laytable-cell-'+ key).find(ELEM_SORT); - that.layHeader.find('th').find(ELEM_SORT).removeAttr('lay-sort'); //清除其它标题排序状态 - elemSort.attr('lay-sort', type || null); - that.layFixed.find('th') - } catch(e){ - hint.error('Table modules: sort field \''+ field +'\' not matched'); - } - - //记录排序索引和类型 - that.sortKey = { - field: field - ,sort: type - }; - - //默认为前端自动排序。如果否,则需自主排序(通常为服务端处理好排序) - if(options.autoSort){ - if(type === 'asc'){ //升序 - thisData = layui.sort(data, field); - } else if(type === 'desc'){ //降序 - thisData = layui.sort(data, field, true); - } else { //清除排序 - thisData = layui.sort(data, table.config.indexName); - delete that.sortKey; - } - } - - res[options.response.dataName] = thisData || data; - that.renderData(res, that.page, that.count, true); - - if(formEvent){ - layui.event.call(th, MOD_NAME, 'sort('+ filter +')', { - field: field - ,type: type - }); - } - }; - - //请求loading - Class.prototype.loading = function(hide){ - var that = this - ,options = that.config; - if(options.loading){ - if(hide){ - that.layInit && that.layInit.remove(); - delete that.layInit; - that.layBox.find(ELEM_INIT).remove(); - } else { - that.layInit = $(['
        ' - ,'' - ,'
        '].join('')); - that.layBox.append(that.layInit); - } - } - }; - - //同步选中值状态 - Class.prototype.setCheckData = function(index, checked){ - var that = this - ,options = that.config - ,thisData = table.cache[that.key]; - if(!thisData[index]) return; - if(thisData[index].constructor === Array) return; - thisData[index][options.checkName] = checked; - }; - - //同步全选按钮状态 - Class.prototype.syncCheckAll = function(){ - var that = this - ,options = that.config - ,checkAllElem = that.layHeader.find('input[name="layTableCheckbox"]') - ,syncColsCheck = function(checked){ - that.eachCols(function(i, item){ - if(item.type === 'checkbox'){ - item[options.checkName] = checked; - } - }); - return checked; - }; - - if(!checkAllElem[0]) return; - - if(table.checkStatus(that.key).isAll){ - if(!checkAllElem[0].checked){ - checkAllElem.prop('checked', true); - that.renderForm('checkbox'); - } - syncColsCheck(true); - } else { - if(checkAllElem[0].checked){ - checkAllElem.prop('checked', false); - that.renderForm('checkbox'); - } - syncColsCheck(false); - } - }; - - //获取cssRule - Class.prototype.getCssRule = function(key, callback){ - var that = this - ,style = that.elem.find('style')[0] - ,sheet = style.sheet || style.styleSheet || {} - ,rules = sheet.cssRules || sheet.rules; - layui.each(rules, function(i, item){ - if(item.selectorText === ('.laytable-cell-'+ key)){ - return callback(item), true; - } - }); - }; - - //让表格铺满 - Class.prototype.fullSize = function(){ - var that = this - ,options = that.config - ,height = options.height, bodyHeight; - - if(that.fullHeightGap){ - height = _WIN.height() - that.fullHeightGap; - if(height < 135) height = 135; - that.elem.css('height', height); - } - - if(!height) return; - - //减去列头区域的高度 - bodyHeight = parseFloat(height) - (that.layHeader.outerHeight() || 38); //此处的数字常量是为了防止容器处在隐藏区域无法获得高度的问题,暂时只对默认尺寸的表格做支持。 - - //减去工具栏的高度 - if(options.toolbar){ - bodyHeight = bodyHeight - (that.layTool.outerHeight() || 50); - } - - //减去统计朗的高度 - if(options.totalRow){ - bodyHeight = bodyHeight - (that.layTotal.outerHeight() || 40); - } - - //减去分页栏的高度 - if(options.page){ - bodyHeight = bodyHeight - (that.layPage.outerHeight() || 41); - } - - that.layMain.css('height', bodyHeight - 2); - }; - - //获取滚动条宽度 - Class.prototype.getScrollWidth = function(elem){ - var width = 0; - if(elem){ - width = elem.offsetWidth - elem.clientWidth; - } else { - elem = document.createElement('div'); - elem.style.width = '100px'; - elem.style.height = '100px'; - elem.style.overflowY = 'scroll'; - - document.body.appendChild(elem); - width = elem.offsetWidth - elem.clientWidth; - document.body.removeChild(elem); - } - return width; - }; - - //滚动条补丁 - Class.prototype.scrollPatch = function(){ - var that = this - ,layMainTable = that.layMain.children('table') - ,scollWidth = that.layMain.width() - that.layMain.prop('clientWidth') //纵向滚动条宽度 - ,scollHeight = that.layMain.height() - that.layMain.prop('clientHeight') //横向滚动条高度 - ,getScrollWidth = that.getScrollWidth(that.layMain[0]) //获取主容器滚动条宽度,如果有的话 - ,outWidth = layMainTable.outerWidth() - that.layMain.width() //表格内容器的超出宽度 - - //添加补丁 - ,addPatch = function(elem){ - if(scollWidth && scollHeight){ - elem = elem.eq(0); - if(!elem.find('.layui-table-patch')[0]){ - var patchElem = $('
        '); //补丁元素 - patchElem.find('div').css({ - width: scollWidth - }); - elem.find('tr').append(patchElem); - } - } else { - elem.find('.layui-table-patch').remove(); - } - } - - addPatch(that.layHeader); - addPatch(that.layTotal); - - //固定列区域高度 - var mainHeight = that.layMain.height() - ,fixHeight = mainHeight - scollHeight; - that.layFixed.find(ELEM_BODY).css('height', layMainTable.height() >= fixHeight ? fixHeight : 'auto'); - - //表格宽度小于容器宽度时,隐藏固定列 - that.layFixRight[outWidth > 0 ? 'removeClass' : 'addClass'](HIDE); - - //操作栏 - that.layFixRight.css('right', scollWidth - 1); - }; - - //事件处理 - Class.prototype.events = function(){ - var that = this - ,options = that.config - ,_BODY = $('body') - ,dict = {} - ,th = that.layHeader.find('th') - ,resizing - ,ELEM_CELL = '.layui-table-cell' - ,filter = options.elem.attr('lay-filter'); - - //工具栏操作事件 - that.layTool.on('click', '*[lay-event]', function(e){ - var othis = $(this) - ,events = othis.attr('lay-event') - ,openPanel = function(sets){ - var list = $(sets.list) - ,panel = $('
          '); - - panel.html(list); - - //限制最大高度 - if(options.height){ - panel.css('max-height', options.height - (that.layTool.outerHeight() || 50)); - } - - //插入元素 - othis.find('.layui-table-tool-panel')[0] || othis.append(panel); - that.renderForm(); - - panel.on('click', function(e){ - layui.stope(e); - }); - - sets.done && sets.done(panel, list) - }; - - layui.stope(e); - _DOC.trigger('table.tool.panel.remove'); - layer.close(that.tipsIndex); - - switch(events){ - case 'LAYTABLE_COLS': //筛选列 - openPanel({ - list: function(){ - var lis = []; - that.eachCols(function(i, item){ - if(item.field && item.type == 'normal'){ - lis.push('
        • '); - } - }); - return lis.join(''); - }() - ,done: function(){ - form.on('checkbox(LAY_TABLE_TOOL_COLS)', function(obj){ - var othis = $(obj.elem) - ,checked = this.checked - ,key = othis.data('key') - ,parentKey = othis.data('parentkey'); - - layui.each(options.cols, function(i1, item1){ - layui.each(item1, function(i2, item2){ - if(i1+ '-'+ i2 === key){ - var hide = item2.hide; - - //同步勾选列的 hide 值和隐藏样式 - item2.hide = !checked; - that.elem.find('*[data-key="'+ options.index +'-'+ key +'"]') - [checked ? 'removeClass' : 'addClass'](HIDE); - - //根据列的显示隐藏,同步多级表头的父级相关属性值 - if(hide != item2.hide){ - that.setParentCol(!checked, parentKey); - } - - //重新适配尺寸 - that.resize(); - } - }); - }); - }); - } - }); - break; - case 'LAYTABLE_EXPORT': //导出 - if(device.ie){ - layer.tips('导出功能不支持 IE,请用 Chrome 等高级浏览器导出', this, { - tips: 3 - }) - } else { - openPanel({ - list: function(){ - return [ - '
        • 导出到 Csv 文件
        • ' - ,'
        • 导出到 Excel 文件
        • ' - ].join('') - }() - ,done: function(panel, list){ - list.on('click', function(){ - var type = $(this).data('type') - table.exportFile.call(that, options.id, null, type); - }); - } - }); - } - break; - case 'LAYTABLE_PRINT': //打印 - var printWin = window.open('打印窗口', '_blank') - ,style = [''].join('') - ,html = $(that.layHeader.html()); //输出表头 - - html.append(that.layMain.find('table').html()); //输出表体 - html.append(that.layTotal.find('table').html()) //输出合计行 - - html.find('th.layui-table-patch').remove(); //移除补丁 - html.find('.layui-table-col-special').remove(); //移除特殊列 - - printWin.document.write(style + html.prop('outerHTML')); - printWin.document.close(); - printWin.print(); - printWin.close(); - break; - } - - layui.event.call(this, MOD_NAME, 'toolbar('+ filter +')', $.extend({ - event: events - ,config: options - },{})); - }); - - //拖拽调整宽度 - th.on('mousemove', function(e){ - var othis = $(this) - ,oLeft = othis.offset().left - ,pLeft = e.clientX - oLeft; - if(othis.data('unresize') || dict.resizeStart){ - return; - } - dict.allowResize = othis.width() - pLeft <= 10; //是否处于拖拽允许区域 - _BODY.css('cursor', (dict.allowResize ? 'col-resize' : '')); - }).on('mouseleave', function(){ - var othis = $(this); - if(dict.resizeStart) return; - _BODY.css('cursor', ''); - }).on('mousedown', function(e){ - var othis = $(this); - if(dict.allowResize){ - var key = othis.data('key'); - e.preventDefault(); - dict.resizeStart = true; //开始拖拽 - dict.offset = [e.clientX, e.clientY]; //记录初始坐标 - - that.getCssRule(key, function(item){ - var width = item.style.width || othis.outerWidth(); - dict.rule = item; - dict.ruleWidth = parseFloat(width); - dict.minWidth = othis.data('minwidth') || options.cellMinWidth; - }); - } - }); - - //拖拽中 - _DOC.on('mousemove', function(e){ - if(dict.resizeStart){ - e.preventDefault(); - if(dict.rule){ - var setWidth = dict.ruleWidth + e.clientX - dict.offset[0]; - if(setWidth < dict.minWidth) setWidth = dict.minWidth; - dict.rule.style.width = setWidth + 'px'; - layer.close(that.tipsIndex); - } - resizing = 1 - } - }).on('mouseup', function(e){ - if(dict.resizeStart){ - dict = {}; - _BODY.css('cursor', ''); - that.scrollPatch(); - } - if(resizing === 2){ - resizing = null; - } - }); - - //排序 - th.on('click', function(e){ - var othis = $(this) - ,elemSort = othis.find(ELEM_SORT) - ,nowType = elemSort.attr('lay-sort') - ,type; - - if(!elemSort[0] || resizing === 1) return resizing = 2; - - if(nowType === 'asc'){ - type = 'desc'; - } else if(nowType === 'desc'){ - type = null; - } else { - type = 'asc'; - } - that.sort(othis, type, null, true); - }).find(ELEM_SORT+' .layui-edge ').on('click', function(e){ - var othis = $(this) - ,index = othis.index() - ,field = othis.parents('th').eq(0).data('field') - layui.stope(e); - if(index === 0){ - that.sort(field, 'asc', null, true); - } else { - that.sort(field, 'desc', null, true); - } - }); - - //数据行中的事件返回的公共对象成员 - var commonMember = function(sets){ - var othis = $(this) - ,index = othis.parents('tr').eq(0).data('index') - ,tr = that.layBody.find('tr[data-index="'+ index +'"]') - ,data = table.cache[that.key] || []; - - - data = data[index] || {}; - - return $.extend({ - tr: tr //行元素 - ,data: table.clearCacheKey(data) //当前行数据 - ,del: function(){ //删除行数据 - table.cache[that.key][index] = []; - tr.remove(); - that.scrollPatch(); - } - ,update: function(fields){ //修改行数据 - fields = fields || {}; - layui.each(fields, function(key, value){ - if(key in data){ - var templet, td = tr.children('td[data-field="'+ key +'"]'); - data[key] = value; - that.eachCols(function(i, item2){ - if(item2.field == key && item2.templet){ - templet = item2.templet; - } - }); - td.children(ELEM_CELL).html(parseTempData({ - templet: templet - }, value, data)); - td.data('content', value); - } - }); - } - }, sets); - }; - - //复选框选择 - that.elem.on('click', 'input[name="layTableCheckbox"]+', function(){ //替代元素的 click 事件 - var checkbox = $(this).prev() - ,childs = that.layBody.find('input[name="layTableCheckbox"]') - ,index = checkbox.parents('tr').eq(0).data('index') - ,checked = checkbox[0].checked - ,isAll = checkbox.attr('lay-filter') === 'layTableAllChoose'; - - //全选 - if(isAll){ - childs.each(function(i, item){ - item.checked = checked; - that.setCheckData(i, checked); - }); - that.syncCheckAll(); - that.renderForm('checkbox'); - } else { - that.setCheckData(index, checked); - that.syncCheckAll(); - } - - layui.event.call(checkbox[0], MOD_NAME, 'checkbox('+ filter +')', commonMember.call(checkbox[0], { - checked: checked - ,type: isAll ? 'all' : 'one' - })); - }); - - //单选框选择 - that.elem.on('click', 'input[lay-type="layTableRadio"]+', function(){ - var radio = $(this).prev() - ,checked = radio[0].checked - ,thisData = table.cache[that.key] - ,index = radio.parents('tr').eq(0).data('index'); - - //重置数据单选属性 - layui.each(thisData, function(i, item){ - if(index === i){ - item[options.checkName] = true; - } else { - delete item[options.checkName]; - } - }); - that.setThisRowChecked(index); - - layui.event.call(this, MOD_NAME, 'radio('+ filter +')', commonMember.call(this, { - checked: checked - })); - }); - - //行事件 - that.layBody.on('mouseenter', 'tr', function(){ //鼠标移入行 - var othis = $(this) - ,index = othis.index(); - if(othis.data('off')) return; //不触发事件 - that.layBody.find('tr:eq('+ index +')').addClass(ELEM_HOVER) - }).on('mouseleave', 'tr', function(){ //鼠标移出行 - var othis = $(this) - ,index = othis.index(); - if(othis.data('off')) return; //不触发事件 - that.layBody.find('tr:eq('+ index +')').removeClass(ELEM_HOVER) - }).on('click', 'tr', function(){ //单击行 - setRowEvent.call(this, 'row'); - }).on('dblclick', 'tr', function(){ //双击行 - setRowEvent.call(this, 'rowDouble'); - }); - - //创建行单击、双击事件 - var setRowEvent = function(eventType){ - var othis = $(this); - if(othis.data('off')) return; //不触发事件 - layui.event.call(this, - MOD_NAME, eventType + '('+ filter +')' - ,commonMember.call(othis.children('td')[0]) - ); - }; - - //单元格编辑 - that.layBody.on('change', '.'+ELEM_EDIT, function(){ - var othis = $(this) - ,value = this.value - ,field = othis.parent().data('field') - ,index = othis.parents('tr').eq(0).data('index') - ,data = table.cache[that.key][index]; - - data[field] = value; //更新缓存中的值 - - layui.event.call(this, MOD_NAME, 'edit('+ filter +')', commonMember.call(this, { - value: value - ,field: field - })); - }).on('blur', '.'+ELEM_EDIT, function(){ - var templet - ,othis = $(this) - ,thisElem = this - ,field = othis.parent().data('field') - ,index = othis.parents('tr').eq(0).data('index') - ,data = table.cache[that.key][index]; - that.eachCols(function(i, item){ - if(item.field == field && item.templet){ - templet = item.templet; - } - }); - othis.siblings(ELEM_CELL).html(function(value){ - return parseTempData({ - templet: templet - }, value, data); - }(thisElem.value)); - othis.parent().data('content', thisElem.value); - othis.remove(); - }); - - //单元格单击事件 - that.layBody.on('click', 'td', function(e){ - var othis = $(this) - ,field = othis.data('field') - ,editType = othis.data('edit') - ,elemCell = othis.children(ELEM_CELL); - - if(othis.data('off')) return; //不触发事件 - - //显示编辑表单 - if(editType){ - var input = $(''); - input[0].value = othis.data('content') || elemCell.text(); - othis.find('.'+ELEM_EDIT)[0] || othis.append(input); - input.focus(); - layui.stope(e); - return; - } - }).on('mouseenter', 'td', function(){ - gridExpand.call(this) - }).on('mouseleave', 'td', function(){ - gridExpand.call(this, 'hide'); - }); - - //单元格展开图标 - var ELEM_GRID = 'layui-table-grid', ELEM_GRID_DOWN = 'layui-table-grid-down', ELEM_GRID_PANEL = 'layui-table-grid-panel' - ,gridExpand = function(hide){ - var othis = $(this) - ,elemCell = othis.children(ELEM_CELL); - - if(othis.data('off')) return; //不触发事件 - - if(hide){ - othis.find('.layui-table-grid-down').remove(); - } else if(elemCell.prop('scrollWidth') > elemCell.outerWidth()){ - if(elemCell.find('.'+ ELEM_GRID_DOWN)[0]) return; - othis.append('
          '); - } - }; - - //单元格展开事件 - that.layBody.on('click', '.'+ ELEM_GRID_DOWN, function(e){ - var othis = $(this) - ,td = othis.parent() - ,elemCell = td.children(ELEM_CELL); - - that.tipsIndex = layer.tips([ - '
          ' - ,elemCell.html() - ,'
          ' - ,'' - ].join(''), elemCell[0], { - tips: [3, ''] - ,time: -1 - ,anim: -1 - ,maxWidth: (device.ios || device.android) ? 300 : that.elem.width()/2 - ,isOutAnim: false - ,skin: 'layui-table-tips' - ,success: function(layero, index){ - layero.find('.layui-table-tips-c').on('click', function(){ - layer.close(index); - }); - } - }); - - layui.stope(e); - }); - - //行工具条操作事件 - that.layBody.on('click', '*[lay-event]', function(){ - var othis = $(this) - ,index = othis.parents('tr').eq(0).data('index'); - layui.event.call(this, MOD_NAME, 'tool('+ filter +')', commonMember.call(this, { - event: othis.attr('lay-event') - })); - that.setThisRowChecked(index); - }); - - //同步滚动条 - that.layMain.on('scroll', function(){ - var othis = $(this) - ,scrollLeft = othis.scrollLeft() - ,scrollTop = othis.scrollTop(); - - that.layHeader.scrollLeft(scrollLeft); - that.layTotal.scrollLeft(scrollLeft); - that.layFixed.find(ELEM_BODY).scrollTop(scrollTop); - - layer.close(that.tipsIndex); - }); - - //自适应 - _WIN.on('resize', function(){ - that.resize(); - }); - }; - - //一次性事件 - ;(function(){ - //全局点击 - _DOC.on('click', function(){ - _DOC.trigger('table.remove.tool.panel'); - }); - - //工具面板移除事件 - _DOC.on('table.remove.tool.panel', function(){ - $('.layui-table-tool-panel').remove(); - }); - })(); - - //初始化 - table.init = function(filter, settings){ - settings = settings || {}; - var that = this - ,elemTable = filter ? $('table[lay-filter="'+ filter +'"]') : $(ELEM + '[lay-data]') - ,errorTips = 'Table element property lay-data configuration item has a syntax error: '; - - //遍历数据表格 - elemTable.each(function(){ - var othis = $(this), tableData = othis.attr('lay-data'); - - try{ - tableData = new Function('return '+ tableData)(); - } catch(e){ - hint.error(errorTips + tableData, 'error') - } - - var cols = [], options = $.extend({ - elem: this - ,cols: [] - ,data: [] - ,skin: othis.attr('lay-skin') //风格 - ,size: othis.attr('lay-size') //尺寸 - ,even: typeof othis.attr('lay-even') === 'string' //偶数行背景 - }, table.config, settings, tableData); - - filter && othis.hide(); - - //获取表头数据 - othis.find('thead>tr').each(function(i){ - options.cols[i] = []; - $(this).children().each(function(ii){ - var th = $(this), itemData = th.attr('lay-data'); - - try{ - itemData = new Function('return '+ itemData)(); - } catch(e){ - return hint.error(errorTips + itemData) - } - - var row = $.extend({ - title: th.text() - ,colspan: th.attr('colspan') || 0 //列单元格 - ,rowspan: th.attr('rowspan') || 0 //行单元格 - }, itemData); - - if(row.colspan < 2) cols.push(row); - options.cols[i].push(row); - }); - }); - - //获取表体数据 - othis.find('tbody>tr').each(function(i1){ - var tr = $(this), row = {}; - //如果定义了字段名 - tr.children('td').each(function(i2, item2){ - var td = $(this) - ,field = td.data('field'); - if(field){ - return row[field] = td.html(); - } - }); - //如果未定义字段名 - layui.each(cols, function(i3, item3){ - var td = tr.children('td').eq(i3); - row[item3.field] = td.html(); - }); - options.data[i1] = row; - }); - table.render(options); - }); - - return that; - }; - - //记录所有实例 - thisTable.that = {}; //记录所有实例对象 - thisTable.config = {}; //记录所有实例配置项 - - //遍历表头 - table.eachCols = function(id, callback, cols){ - var config = thisTable.config[id] || {} - ,arrs = [], index = 0; - - cols = $.extend(true, [], cols || config.cols); - - //重新整理表头结构 - layui.each(cols, function(i1, item1){ - layui.each(item1, function(i2, item2){ - - //如果是组合列,则捕获对应的子列 - if(item2.colGroup){ - var childIndex = 0; - index++ - item2.CHILD_COLS = []; - - layui.each(cols[i1 + 1], function(i22, item22){ - //如果子列已经被标注为{PARENT_COL_INDEX},或者子列累计 colspan 数等于父列定义的 colspan,则跳出当前子列循环 - if(item22.PARENT_COL_INDEX || (childIndex > 1 && childIndex == item2.colspan)) return; - - item22.PARENT_COL_INDEX = index; - - item2.CHILD_COLS.push(item22); - childIndex = childIndex + parseInt(item22.colspan > 1 ? item22.colspan : 1); - }); - } - - if(item2.PARENT_COL_INDEX) return; //如果是子列,则不进行追加,因为已经存储在父列中 - arrs.push(item2) - }); - }); - - //重新遍历列,如果有子列,则进入递归 - var eachArrs = function(obj){ - layui.each(obj || arrs, function(i, item){ - if(item.CHILD_COLS) return eachArrs(item.CHILD_COLS); - typeof callback === 'function' && callback(i, item); - }); - }; - - eachArrs(); - }; - - //表格选中状态 - table.checkStatus = function(id){ - var nums = 0 - ,invalidNum = 0 - ,arr = [] - ,data = table.cache[id] || []; - //计算全选个数 - layui.each(data, function(i, item){ - if(item.constructor === Array){ - invalidNum++; //无效数据,或已删除的 - return; - } - if(item[table.config.checkName]){ - nums++; - arr.push(table.clearCacheKey(item)); - } - }); - return { - data: arr //选中的数据 - ,isAll: data.length ? (nums === (data.length - invalidNum)) : false //是否全选 - }; - }; - - //获取表格当前页的所有行数据 - table.getData = function(id){ - var arr = [] - ,data = table.cache[id] || []; - layui.each(data, function(i, item){ - if(item.constructor === Array){ - return; - }; - arr.push(table.clearCacheKey(item)); - }); - return arr; - }; - - //表格导出 - table.exportFile = function(id, data, type){ - var that = this; - - data = data || table.clearCacheKey(table.cache[id]); - type = type || 'csv'; - - var config = thisTable.config[id] || {} - ,textType = ({ - csv: 'text/csv' - ,xls: 'application/vnd.ms-excel' - })[type] - ,alink = document.createElement("a"); - - if(device.ie) return hint.error('IE_NOT_SUPPORT_EXPORTS'); - - alink.href = 'data:'+ textType +';charset=utf-8,\ufeff'+ encodeURIComponent(function(){ - var dataTitle = [], dataMain = [], dataTotal = []; - - //表头和表体 - layui.each(data, function(i1, item1){ - var vals = []; - if(typeof id === 'object'){ //如果 id 参数直接为表头数据 - layui.each(id, function(i, item){ - i1 == 0 && dataTitle.push(item || ''); - }); - layui.each(table.clearCacheKey(item1), function(i2, item2){ - vals.push('"'+ (item2 || '') +'"'); - }); - } else { - table.eachCols(id, function(i3, item3){ - if(item3.field && item3.type == 'normal' && !item3.hide){ - var content = item1[item3.field]; - if(content === undefined || content === null) content = ''; - - i1 == 0 && dataTitle.push(item3.title || ''); - vals.push('"'+ parseTempData(item3, content, item1, 'text') + '"'); - } - }); - } - dataMain.push(vals.join(',')); - }); - - //表合计 - layui.each(that.dataTotal, function(key, value){ - dataTotal.push(value); - }); - - return dataTitle.join(',') + '\r\n' + dataMain.join('\r\n') + '\r\n' + dataTotal.join(','); - }()); - - alink.download = (config.title || 'table_'+ (config.index || '')) + '.' + type; - document.body.appendChild(alink); - alink.click(); - document.body.removeChild(alink); - }; - - //重置表格尺寸结构 - table.resize = function(id){ - //如果指定表格唯一 id,则只执行该 id 对应的表格实例 - if(id){ - var config = getThisTableConfig(id); //获取当前实例配置项 - if(!config) return; - - thisTable.that[id].resize(); - - } else { //否则重置所有表格实例尺寸 - layui.each(thisTable.that, function(){ - this.resize(); - }); - } - }; - - //表格重载 - table.reload = function(id, options, deep){ - var config = getThisTableConfig(id); //获取当前实例配置项 - if(!config) return; - - var that = thisTable.that[id]; - that.reload(options, deep); - - return thisTable.call(that); - }; - - //核心入口 - table.render = function(options){ - var inst = new Class(options); - return thisTable.call(inst); - }; - - //清除临时Key - table.clearCacheKey = function(data){ - data = $.extend({}, data); - delete data[table.config.checkName]; - delete data[table.config.indexName]; - return data; - }; - - //自动完成渲染 - table.init(); - - exports(MOD_NAME, table); -}); - - +/** layui-v2.5.7 MIT License */ + ;layui.define(["laytpl","laypage","layer","form","util"],function(e){"use strict";var t=layui.$,i=layui.laytpl,a=layui.laypage,l=layui.layer,n=layui.form,o=(layui.util,layui.hint()),r=layui.device(),d={config:{checkName:"LAY_CHECKED",indexName:"LAY_TABLE_INDEX"},cache:{},index:layui.table?layui.table.index+1e4:0,set:function(e){var i=this;return i.config=t.extend({},i.config,e),i},on:function(e,t){return layui.onevent.call(this,y,e,t)}},c=function(){var e=this,t=e.config,i=t.id||t.index;return i&&(c.that[i]=e,c.config[i]=t),{config:t,reload:function(t){e.reload.call(e,t)},setColsWidth:function(){e.setColsWidth.call(e)},resize:function(){e.resize.call(e)}}},s=function(e){var t=c.config[e];return t||o.error("The ID option was not found in the table instance"),t||null},u=function(e,a,l,n){var o=e.templet?function(){return"function"==typeof e.templet?e.templet(l):i(t(e.templet).html()||String(a)).render(l)}():a;return n?t("
          "+o+"
          ").text():o},y="table",h=".layui-table",f="layui-hide",p="layui-none",v="layui-table-view",m=".layui-table-tool",g=".layui-table-box",b=".layui-table-init",x=".layui-table-header",k=".layui-table-body",C=".layui-table-main",w=".layui-table-fixed",T=".layui-table-fixed-l",A=".layui-table-fixed-r",L=".layui-table-total",N=".layui-table-page",S=".layui-table-sort",R="layui-table-edit",W="layui-table-hover",_=function(e){var t='{{#if(item2.colspan){}} colspan="{{item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{item2.rowspan}}"{{#}}}';return e=e||{},['',"","{{# layui.each(d.data.cols, function(i1, item1){ }}","","{{# layui.each(item1, function(i2, item2){ }}",'{{# if(item2.fixed && item2.fixed !== "right"){ left = true; } }}','{{# if(item2.fixed === "right"){ right = true; } }}',function(){return e.fixed&&"right"!==e.fixed?'{{# if(item2.fixed && item2.fixed !== "right"){ }}':"right"===e.fixed?'{{# if(item2.fixed === "right"){ }}':""}(),"{{# var isSort = !(item2.colGroup) && item2.sort; }}",'",e.fixed?"{{# }; }}":"","{{# }); }}","","{{# }); }}","","
          ','
          ','{{# if(item2.type === "checkbox"){ }}','',"{{# } else { }}",'{{item2.title||""}}',"{{# if(isSort){ }}",'',"{{# } }}","{{# } }}","
          ","
          "].join("")},E=['',"","
          "].join(""),z=['
          ',"{{# if(d.data.toolbar){ }}",'
          ','
          ','
          ',"
          ","{{# } }}",'
          ',"{{# if(d.data.loading){ }}",'
          ','',"
          ","{{# } }}","{{# var left, right; }}",'
          ',_(),"
          ",'
          ',E,"
          ","{{# if(left){ }}",'
          ','
          ',_({fixed:!0}),"
          ",'
          ',E,"
          ","
          ","{{# }; }}","{{# if(right){ }}",'
          ','
          ',_({fixed:"right"}),'
          ',"
          ",'
          ',E,"
          ","
          ","{{# }; }}","
          ","{{# if(d.data.totalRow){ }}",'
          ','','',"
          ","
          ","{{# } }}","{{# if(d.data.page){ }}",'
          ','
          ',"
          ","{{# } }}","","
          "].join(""),H=t(window),j=t(document),F=function(e){var i=this;i.index=++d.index,i.config=t.extend({},i.config,d.config,e),i.render()};F.prototype.config={limit:10,loading:!0,cellMinWidth:60,defaultToolbar:["filter","exports","print"],autoSort:!0,text:{none:"无数据"}},F.prototype.render=function(){var e=this,a=e.config;if(a.elem=t(a.elem),a.where=a.where||{},a.id=a.id||a.elem.attr("id")||e.index,a.request=t.extend({pageName:"page",limitName:"limit"},a.request),a.response=t.extend({statusName:"code",statusCode:0,msgName:"msg",dataName:"data",totalRowName:"totalRow",countName:"count"},a.response),"object"==typeof a.page&&(a.limit=a.page.limit||a.limit,a.limits=a.page.limits||a.limits,e.page=a.page.curr=a.page.curr||1,delete a.page.elem,delete a.page.jump),!a.elem[0])return e;a.height&&/^full-\d+$/.test(a.height)&&(e.fullHeightGap=a.height.split("-")[1],a.height=H.height()-e.fullHeightGap),e.setInit();var l=a.elem,n=l.next("."+v),o=e.elem=t(i(z).render({VIEW_CLASS:v,data:a,index:e.index}));if(a.index=e.index,e.key=a.id||a.index,n[0]&&n.remove(),l.after(o),e.layTool=o.find(m),e.layBox=o.find(g),e.layHeader=o.find(x),e.layMain=o.find(C),e.layBody=o.find(k),e.layFixed=o.find(w),e.layFixLeft=o.find(T),e.layFixRight=o.find(A),e.layTotal=o.find(L),e.layPage=o.find(N),e.renderToolbar(),e.fullSize(),a.cols.length>1){var r=e.layFixed.find(x).find("th");r.height(e.layHeader.height()-1-parseFloat(r.css("padding-top"))-parseFloat(r.css("padding-bottom")))}e.pullData(e.page),e.events()},F.prototype.initOpts=function(e){var t=this,i=(t.config,{checkbox:48,radio:48,space:15,numbers:40});e.checkbox&&(e.type="checkbox"),e.space&&(e.type="space"),e.type||(e.type="normal"),"normal"!==e.type&&(e.unresize=!0,e.width=e.width||i[e.type])},F.prototype.setInit=function(e){var t=this,i=t.config;return i.clientWidth=i.width||function(){var e=function(t){var a,l;t=t||i.elem.parent(),a=t.width();try{l="none"===t.css("display")}catch(n){}return!t[0]||a&&!l?a:e(t.parent())};return e()}(),"width"===e?i.clientWidth:void layui.each(i.cols,function(e,a){layui.each(a,function(l,n){if(!n)return void a.splice(l,1);if(n.key=e+"-"+l,n.hide=n.hide||!1,n.colGroup||n.colspan>1){var o=0;layui.each(i.cols[e+1],function(t,i){i.HAS_PARENT||o>1&&o==n.colspan||(i.HAS_PARENT=!0,i.parentKey=e+"-"+l,o+=parseInt(i.colspan>1?i.colspan:1))}),n.colGroup=!0}t.initOpts(n)})})},F.prototype.renderToolbar=function(){var e=this,a=e.config,l=['
          ','
          ','
          '].join(""),n=e.layTool.find(".layui-table-tool-temp");if("default"===a.toolbar)n.html(l);else if("string"==typeof a.toolbar){var o=t(a.toolbar).html()||"";o&&n.html(i(o).render(a))}var r={filter:{title:"筛选列",layEvent:"LAYTABLE_COLS",icon:"layui-icon-cols"},exports:{title:"导出",layEvent:"LAYTABLE_EXPORT",icon:"layui-icon-export"},print:{title:"打印",layEvent:"LAYTABLE_PRINT",icon:"layui-icon-print"}},d=[];"object"==typeof a.defaultToolbar&&layui.each(a.defaultToolbar,function(e,t){var i="string"==typeof t?r[t]:t;i&&d.push('
          ')}),e.layTool.find(".layui-table-tool-self").html(d.join(""))},F.prototype.setParentCol=function(e,t){var i=this,a=i.config,l=i.layHeader.find('th[data-key="'+a.index+"-"+t+'"]'),n=parseInt(l.attr("colspan"))||0;if(l[0]){var o=t.split("-"),r=a.cols[o[0]][o[1]];e?n--:n++,l.attr("colspan",n),l[n<1?"addClass":"removeClass"](f),r.colspan=n,r.hide=n<1;var d=l.data("parentkey");d&&i.setParentCol(e,d)}},F.prototype.setColsPatch=function(){var e=this,t=e.config;layui.each(t.cols,function(t,i){layui.each(i,function(t,i){i.hide&&e.setParentCol(i.hide,i.parentKey)})})},F.prototype.setColsWidth=function(){var e=this,t=e.config,i=0,a=0,l=0,n=0,o=e.setInit("width");e.eachCols(function(e,t){t.hide||i++}),o=o-function(){return"line"===t.skin||"nob"===t.skin?2:i+1}()-e.getScrollWidth(e.layMain[0])-1;var r=function(e){layui.each(t.cols,function(i,r){layui.each(r,function(i,d){var c=0,s=d.minWidth||t.cellMinWidth;return d?void(d.colGroup||d.hide||(e?l&&ln&&a&&(l=(o-n)/a)};r(),r(!0),e.autoColNums=a,e.eachCols(function(i,a){var n=a.minWidth||t.cellMinWidth;a.colGroup||a.hide||(0===a.width?e.getCssRule(t.index+"-"+a.key,function(e){e.style.width=Math.floor(l>=n?l:n)+"px"}):/\d+%$/.test(a.width)&&e.getCssRule(t.index+"-"+a.key,function(e){e.style.width=Math.floor(parseFloat(a.width)/100*o)+"px"}))});var d=e.layMain.width()-e.getScrollWidth(e.layMain[0])-e.layMain.children("table").outerWidth();if(e.autoColNums&&d>=-i&&d<=i){var c=function(t){var i;return t=t||e.layHeader.eq(0).find("thead th:last-child"),i=t.data("field"),!i&&t.prev()[0]?c(t.prev()):t},s=c(),u=s.data("key");e.getCssRule(u,function(t){var i=t.style.width||s.outerWidth();t.style.width=parseFloat(i)+d+"px",e.layMain.height()-e.layMain.prop("clientHeight")>0&&(t.style.width=parseFloat(t.style.width)-1+"px")})}e.loading(!0)},F.prototype.resize=function(){var e=this;e.fullSize(),e.setColsWidth(),e.scrollPatch()},F.prototype.reload=function(e){var i=this;e=e||{},delete i.haveInit,e.data&&e.data.constructor===Array&&delete i.config.data,i.config=t.extend(!0,{},i.config,e),i.render()},F.prototype.errorView=function(e){var i=this,a=i.layMain.find("."+p),l=t('
          '+(e||"Error")+"
          ");a[0]&&(i.layNone.remove(),a.remove()),i.layFixed.addClass(f),i.layMain.find("tbody").html(""),i.layMain.append(i.layNone=l),d.cache[i.key]=[]},F.prototype.page=1,F.prototype.pullData=function(e){var i=this,a=i.config,l=a.request,n=a.response,o=function(){"object"==typeof a.initSort&&i.sort(a.initSort.field,a.initSort.type)};if(i.startTime=(new Date).getTime(),a.url){var r={};r[l.pageName]=e,r[l.limitName]=a.limit;var d=t.extend(r,a.where);a.contentType&&0==a.contentType.indexOf("application/json")&&(d=JSON.stringify(d)),i.loading(),t.ajax({type:a.method||"get",url:a.url,contentType:a.contentType,data:d,dataType:"json",headers:a.headers||{},success:function(t){"function"==typeof a.parseData&&(t=a.parseData(t)||t),t[n.statusName]!=n.statusCode?(i.renderForm(),i.errorView(t[n.msgName]||'返回的数据不符合规范,正确的成功状态码应为:"'+n.statusName+'": '+n.statusCode)):(i.renderData(t,e,t[n.countName]),o(),a.time=(new Date).getTime()-i.startTime+" ms"),i.setColsWidth(),"function"==typeof a.done&&a.done(t,e,t[n.countName])},error:function(e,t){i.errorView("数据接口请求异常:"+t),i.renderForm(),i.setColsWidth()}})}else if(a.data&&a.data.constructor===Array){var c={},s=e*a.limit-a.limit;c[n.dataName]=a.data.concat().splice(s,a.limit),c[n.countName]=a.data.length,"object"==typeof a.totalRow&&(c[n.totalRowName]=t.extend({},a.totalRow)),i.renderData(c,e,c[n.countName]),o(),i.setColsWidth(),"function"==typeof a.done&&a.done(c,e,c[n.countName])}},F.prototype.eachCols=function(e){var t=this;return d.eachCols(null,e,t.config.cols),t},F.prototype.renderData=function(e,n,o,r){var c=this,s=c.config,y=e[s.response.dataName]||[],h=e[s.response.totalRowName],v=[],m=[],g=[],b=function(){var e;return!r&&c.sortKey?c.sort(c.sortKey.field,c.sortKey.sort,!0):(layui.each(y,function(a,l){var o=[],y=[],h=[],p=a+s.limit*(n-1)+1;0!==l.length&&(r||(l[d.config.indexName]=a),c.eachCols(function(n,r){var c=r.field||n,v=s.index+"-"+r.key,m=l[c];if(void 0!==m&&null!==m||(m=""),!r.colGroup){var g=['','
          '+function(){var n=t.extend(!0,{LAY_INDEX:p},l),o=d.config.checkName;switch(r.type){case"checkbox":return'";case"radio":return n[o]&&(e=a),'';case"numbers":return p}return r.toolbar?i(t(r.toolbar).html()||"").render(n):u(r,m,n)}(),"
          "].join("");o.push(g),r.fixed&&"right"!==r.fixed&&y.push(g),"right"===r.fixed&&h.push(g)}}),v.push(''+o.join("")+""),m.push(''+y.join("")+""),g.push(''+h.join("")+""))}),c.layBody.scrollTop(0),c.layMain.find("."+p).remove(),c.layMain.find("tbody").html(v.join("")),c.layFixLeft.find("tbody").html(m.join("")),c.layFixRight.find("tbody").html(g.join("")),c.renderForm(),"number"==typeof e&&c.setThisRowChecked(e),c.syncCheckAll(),c.haveInit?c.scrollPatch():setTimeout(function(){c.scrollPatch()},50),c.haveInit=!0,l.close(c.tipsIndex),s.HAS_SET_COLS_PATCH||c.setColsPatch(),void(s.HAS_SET_COLS_PATCH=!0))};return d.cache[c.key]=y,c.layPage[0==o||0===y.length&&1==n?"addClass":"removeClass"](f),0===y.length?(c.renderForm(),c.errorView(s.text.none)):(c.layFixed.removeClass(f),r?b():(b(),c.renderTotal(y,h),void(s.page&&(s.page=t.extend({elem:"layui-table-page"+s.index,count:o,limit:s.limit,limits:s.limits||[10,20,30,40,50,60,70,80,90],groups:3,layout:["prev","page","next","skip","count","limit"],prev:'',next:'',jump:function(e,t){t||(c.page=e.curr,s.limit=e.limit,c.pullData(e.curr))}},s.page),s.page.count=o,a.render(s.page)))))},F.prototype.renderTotal=function(e,t){var i=this,a=i.config,l={};if(a.totalRow){layui.each(e,function(e,t){0!==t.length&&i.eachCols(function(e,i){var a=i.field||e,n=t[a];i.totalRow&&(l[a]=(l[a]||0)+(parseFloat(n)||0))})}),i.dataTotal={};var n=[];i.eachCols(function(e,o){var r=o.field||e,d=function(){var e=o.totalRowText||"",i=parseFloat(l[r]).toFixed(2),a={};return a[r]=i,i=u(o,i,a),t?t[o.field]||e:o.totalRow?i||e:e}(),c=['','
          '+d,"
          "].join("");o.field&&(i.dataTotal[r]=d),n.push(c)}),i.layTotal.find("tbody").html(""+n.join("")+"")}},F.prototype.getColElem=function(e,t){var i=this,a=i.config;return e.eq(0).find(".laytable-cell-"+(a.index+"-"+t)+":eq(0)")},F.prototype.renderForm=function(e){n.render(e,"LAY-table-"+this.index)},F.prototype.setThisRowChecked=function(e){var t=this,i=(t.config,"layui-table-click"),a=t.layBody.find('tr[data-index="'+e+'"]');a.addClass(i).siblings("tr").removeClass(i)},F.prototype.sort=function(e,i,a,l){var n,r,c=this,s={},u=c.config,h=u.elem.attr("lay-filter"),f=d.cache[c.key];"string"==typeof e&&c.layHeader.find("th").each(function(i,a){var l=t(this),o=l.data("field");if(o===e)return e=l,n=o,!1});try{var n=n||e.data("field"),p=e.data("key");if(c.sortKey&&!a&&n===c.sortKey.field&&i===c.sortKey.sort)return;var v=c.layHeader.find("th .laytable-cell-"+p).find(S);c.layHeader.find("th").find(S).removeAttr("lay-sort"),v.attr("lay-sort",i||null),c.layFixed.find("th")}catch(m){return o.error("Table modules: Did not match to field")}c.sortKey={field:n,sort:i},u.autoSort&&("asc"===i?r=layui.sort(f,n):"desc"===i?r=layui.sort(f,n,!0):(r=layui.sort(f,d.config.indexName),delete c.sortKey)),s[u.response.dataName]=r||f,c.renderData(s,c.page,c.count,!0),l&&layui.event.call(e,y,"sort("+h+")",{field:n,type:i})},F.prototype.loading=function(e){var i=this,a=i.config;a.loading&&(e?(i.layInit&&i.layInit.remove(),delete i.layInit,i.layBox.find(b).remove()):(i.layInit=t(['
          ','',"
          "].join("")),i.layBox.append(i.layInit)))},F.prototype.setCheckData=function(e,t){var i=this,a=i.config,l=d.cache[i.key];l[e]&&l[e].constructor!==Array&&(l[e][a.checkName]=t)},F.prototype.syncCheckAll=function(){var e=this,t=e.config,i=e.layHeader.find('input[name="layTableCheckbox"]'),a=function(i){return e.eachCols(function(e,a){"checkbox"===a.type&&(a[t.checkName]=i)}),i};i[0]&&(d.checkStatus(e.key).isAll?(i[0].checked||(i.prop("checked",!0),e.renderForm("checkbox")),a(!0)):(i[0].checked&&(i.prop("checked",!1),e.renderForm("checkbox")),a(!1)))},F.prototype.getCssRule=function(e,t){var i=this,a=i.elem.find("style")[0],l=a.sheet||a.styleSheet||{},n=l.cssRules||l.rules;layui.each(n,function(i,a){if(a.selectorText===".laytable-cell-"+e)return t(a),!0})},F.prototype.fullSize=function(){var e,t=this,i=t.config,a=i.height;t.fullHeightGap&&(a=H.height()-t.fullHeightGap,a<135&&(a=135),t.elem.css("height",a)),a&&(e=parseFloat(a)-(t.layHeader.outerHeight()||38),i.toolbar&&(e-=t.layTool.outerHeight()||50),i.totalRow&&(e-=t.layTotal.outerHeight()||40),i.page&&(e-=t.layPage.outerHeight()||41),t.layMain.css("height",e-2))},F.prototype.getScrollWidth=function(e){var t=0;return e?t=e.offsetWidth-e.clientWidth:(e=document.createElement("div"),e.style.width="100px",e.style.height="100px",e.style.overflowY="scroll",document.body.appendChild(e),t=e.offsetWidth-e.clientWidth,document.body.removeChild(e)),t},F.prototype.scrollPatch=function(){var e=this,i=e.layMain.children("table"),a=e.layMain.width()-e.layMain.prop("clientWidth"),l=e.layMain.height()-e.layMain.prop("clientHeight"),n=(e.getScrollWidth(e.layMain[0]),i.outerWidth()-e.layMain.width()),o=function(e){if(a&&l){if(e=e.eq(0),!e.find(".layui-table-patch")[0]){var i=t('
          ');i.find("div").css({width:a}),e.find("tr").append(i)}}else e.find(".layui-table-patch").remove()};o(e.layHeader),o(e.layTotal);var r=e.layMain.height(),d=r-l;e.layFixed.find(k).css("height",i.height()>=d?d:"auto"),e.layFixRight[n>0?"removeClass":"addClass"](f),e.layFixRight.css("right",a-1)},F.prototype.events=function(){var e,i=this,a=i.config,o=t("body"),c={},s=i.layHeader.find("th"),h=".layui-table-cell",p=a.elem.attr("lay-filter");i.layTool.on("click","*[lay-event]",function(e){var o=t(this),c=o.attr("lay-event"),s=function(e){var l=t(e.list),n=t('
            ');n.html(l),a.height&&n.css("max-height",a.height-(i.layTool.outerHeight()||50)),o.find(".layui-table-tool-panel")[0]||o.append(n),i.renderForm(),n.on("click",function(e){layui.stope(e)}),e.done&&e.done(n,l)};switch(layui.stope(e),j.trigger("table.tool.panel.remove"),l.close(i.tipsIndex),c){case"LAYTABLE_COLS":s({list:function(){var e=[];return i.eachCols(function(t,i){i.field&&"normal"==i.type&&e.push('
          • ')}),e.join("")}(),done:function(){n.on("checkbox(LAY_TABLE_TOOL_COLS)",function(e){var l=t(e.elem),n=this.checked,o=l.data("key"),r=l.data("parentkey");layui.each(a.cols,function(e,t){layui.each(t,function(t,l){if(e+"-"+t===o){var d=l.hide;l.hide=!n,i.elem.find('*[data-key="'+a.index+"-"+o+'"]')[n?"removeClass":"addClass"](f),d!=l.hide&&i.setParentCol(!n,r),i.resize()}})})})}});break;case"LAYTABLE_EXPORT":r.ie?l.tips("导出功能不支持 IE,请用 Chrome 等高级浏览器导出",this,{tips:3}):s({list:function(){return['
          • 导出到 Csv 文件
          • ','
          • 导出到 Excel 文件
          • '].join("")}(),done:function(e,l){l.on("click",function(){var e=t(this).data("type");d.exportFile.call(i,a.id,null,e)})}});break;case"LAYTABLE_PRINT":var u=window.open("打印窗口","_blank"),h=[""].join(""),v=t(i.layHeader.html());v.append(i.layMain.find("table").html()),v.append(i.layTotal.find("table").html()),v.find("th.layui-table-patch").remove(),v.find(".layui-table-col-special").remove(),u.document.write(h+v.prop("outerHTML")),u.document.close(),u.print(),u.close()}layui.event.call(this,y,"toolbar("+p+")",t.extend({event:c,config:a},{}))}),s.on("mousemove",function(e){var i=t(this),a=i.offset().left,l=e.clientX-a;i.data("unresize")||c.resizeStart||(c.allowResize=i.width()-l<=10,o.css("cursor",c.allowResize?"col-resize":""))}).on("mouseleave",function(){t(this);c.resizeStart||o.css("cursor","")}).on("mousedown",function(e){var l=t(this);if(c.allowResize){var n=l.data("key");e.preventDefault(),c.resizeStart=!0,c.offset=[e.clientX,e.clientY],i.getCssRule(n,function(e){var t=e.style.width||l.outerWidth();c.rule=e,c.ruleWidth=parseFloat(t),c.minWidth=l.data("minwidth")||a.cellMinWidth})}}),j.on("mousemove",function(t){if(c.resizeStart){if(t.preventDefault(),c.rule){var a=c.ruleWidth+t.clientX-c.offset[0];a');return n[0].value=i.data("content")||l.text(),i.find("."+R)[0]||i.append(n),n.focus(),void layui.stope(e)}}).on("mouseenter","td",function(){b.call(this)}).on("mouseleave","td",function(){b.call(this,"hide")});var g="layui-table-grid-down",b=function(e){var i=t(this),a=i.children(h);if(!i.data("off"))if(e)i.find(".layui-table-grid-down").remove();else if(a.prop("scrollWidth")>a.outerWidth()){if(a.find("."+g)[0])return;i.append('
            ')}};i.layBody.on("click","."+g,function(e){var n=t(this),o=n.parent(),d=o.children(h);i.tipsIndex=l.tips(['
            ',d.html(),"
            ",''].join(""),d[0],{tips:[3,""],time:-1,anim:-1,maxWidth:r.ios||r.android?300:i.elem.width()/2,isOutAnim:!1,skin:"layui-table-tips",success:function(e,t){e.find(".layui-table-tips-c").on("click",function(){l.close(t)})}}),layui.stope(e)}),i.layBody.on("click","*[lay-event]",function(){var e=t(this),a=e.parents("tr").eq(0).data("index");layui.event.call(this,y,"tool("+p+")",v.call(this,{event:e.attr("lay-event")})),i.setThisRowChecked(a)}),i.layMain.on("scroll",function(){var e=t(this),a=e.scrollLeft(),n=e.scrollTop();i.layHeader.scrollLeft(a),i.layTotal.scrollLeft(a),i.layFixed.find(k).scrollTop(n),l.close(i.tipsIndex)}),H.on("resize",function(){i.resize()})},function(){j.on("click",function(){j.trigger("table.remove.tool.panel")}),j.on("table.remove.tool.panel",function(){t(".layui-table-tool-panel").remove()})}(),d.init=function(e,i){i=i||{};var a=this,l=t(e?'table[lay-filter="'+e+'"]':h+"[lay-data]"),n="Table element property lay-data configuration item has a syntax error: ";return l.each(function(){var a=t(this),l=a.attr("lay-data");try{l=new Function("return "+l)()}catch(r){o.error(n+l)}var c=[],s=t.extend({elem:this,cols:[],data:[],skin:a.attr("lay-skin"),size:a.attr("lay-size"),even:"string"==typeof a.attr("lay-even")},d.config,i,l);e&&a.hide(),a.find("thead>tr").each(function(e){s.cols[e]=[],t(this).children().each(function(i){var a=t(this),l=a.attr("lay-data");try{l=new Function("return "+l)()}catch(r){return o.error(n+l)}var d=t.extend({title:a.text(),colspan:a.attr("colspan")||0,rowspan:a.attr("rowspan")||0},l);d.colspan<2&&c.push(d),s.cols[e].push(d)})}),a.find("tbody>tr").each(function(e){var i=t(this),a={};i.children("td").each(function(e,i){var l=t(this),n=l.data("field");if(n)return a[n]=l.html()}),layui.each(c,function(e,t){var l=i.children("td").eq(e);a[t.field]=l.html()}),s.data[e]=a}),d.render(s)}),a},c.that={},c.config={},d.eachCols=function(e,i,a){var l=c.config[e]||{},n=[],o=0;a=t.extend(!0,[],a||l.cols),layui.each(a,function(e,t){layui.each(t,function(t,i){if(i.colGroup){var l=0;o++,i.CHILD_COLS=[],layui.each(a[e+1],function(e,t){t.PARENT_COL_INDEX||l>1&&l==i.colspan||(t.PARENT_COL_INDEX=o,i.CHILD_COLS.push(t),l+=parseInt(t.colspan>1?t.colspan:1))})}i.PARENT_COL_INDEX||n.push(i)})});var r=function(e){layui.each(e||n,function(e,t){return t.CHILD_COLS?r(t.CHILD_COLS):void("function"==typeof i&&i(e,t))})};r()},d.checkStatus=function(e){var t=0,i=0,a=[],l=d.cache[e]||[];return layui.each(l,function(e,l){return l.constructor===Array?void i++:void(l[d.config.checkName]&&(t++,a.push(d.clearCacheKey(l))))}),{data:a,isAll:!!l.length&&t===l.length-i}},d.exportFile=function(e,t,i){var a=this;t=t||d.clearCacheKey(d.cache[e]),i=i||"csv";var l=c.config[e]||{},n={csv:"text/csv",xls:"application/vnd.ms-excel"}[i],s=document.createElement("a");return r.ie?o.error("IE_NOT_SUPPORT_EXPORTS"):(s.href="data:"+n+";charset=utf-8,\ufeff"+encodeURIComponent(function(){var i=[],l=[],n=[];return layui.each(t,function(t,a){var n=[];"object"==typeof e?(layui.each(e,function(e,a){0==t&&i.push(a||"")}),layui.each(d.clearCacheKey(a),function(e,t){n.push('"'+(t||"")+'"')})):d.eachCols(e,function(e,l){if(l.field&&"normal"==l.type&&!l.hide){var o=a[l.field];void 0!==o&&null!==o||(o=""),0==t&&i.push(l.title||""),n.push('"'+u(l,o,a,"text")+'"')}}),l.push(n.join(","))}),layui.each(a.dataTotal,function(e,t){n.push(t)}),i.join(",")+"\r\n"+l.join("\r\n")+"\r\n"+n.join(",")}()),s.download=(l.title||"table_"+(l.index||""))+"."+i,document.body.appendChild(s),s.click(),void document.body.removeChild(s))},d.resize=function(e){if(e){var t=s(e);if(!t)return;c.that[e].resize()}else layui.each(c.that,function(){this.resize()})},d.reload=function(e,t){var i=s(e);if(i){var a=c.that[e];return a.reload(t),c.call(a)}},d.render=function(e){var t=new F(e);return c.call(t)},d.clearCacheKey=function(e){return e=t.extend({},e),delete e[d.config.checkName],delete e[d.config.indexName],e},d.init(),e(y,d)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/transfer.js b/IoTGateway/wwwroot/layui/lay/modules/transfer.js index 5ac2207..c8f920a 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/transfer.js +++ b/IoTGateway/wwwroot/layui/lay/modules/transfer.js @@ -1,437 +1,2 @@ -/** - - @Name:transfer 穿梭框组件 - @License:MIT - - */ - -layui.define(['laytpl', 'form'], function(exports){ - "use strict"; - - var $ = layui.$ - ,laytpl = layui.laytpl - ,form = layui.form - - //模块名 - ,MOD_NAME = 'transfer' - - //外部接口 - ,transfer = { - config: {} - ,index: layui[MOD_NAME] ? (layui[MOD_NAME].index + 10000) : 0 - - //设置全局项 - ,set: function(options){ - var that = this; - that.config = $.extend({}, that.config, options); - return that; - } - - //事件 - ,on: function(events, callback){ - return layui.onevent.call(this, MOD_NAME, events, callback); - } - } - - //操作当前实例 - ,thisModule = function(){ - var that = this - ,options = that.config - ,id = options.id || that.index; - - thisModule.that[id] = that; //记录当前实例对象 - thisModule.config[id] = options; //记录当前实例配置项 - - return { - config: options - //重置实例 - ,reload: function(options){ - that.reload.call(that, options); - } - //获取右侧数据 - ,getData: function(){ - return that.getData.call(that); - } - } - } - - //获取当前实例配置项 - ,getThisModuleConfig = function(id){ - var config = thisModule.config[id]; - if(!config) hint.error('The ID option was not found in the '+ MOD_NAME +' instance'); - return config || null; - } - - //字符常量 - ,ELEM = 'layui-transfer', HIDE = 'layui-hide', DISABLED = 'layui-btn-disabled', NONE = 'layui-none' - ,ELEM_BOX = 'layui-transfer-box', ELEM_HEADER = 'layui-transfer-header', ELEM_SEARCH = 'layui-transfer-search', ELEM_ACTIVE = 'layui-transfer-active', ELEM_DATA = 'layui-transfer-data' - - //穿梭框模板 - ,TPL_BOX = function(obj){ - obj = obj || {}; - return ['
            ' - ,'
            ' - ,'' - ,'
            ' - ,'{{# if(d.data.showSearch){ }}' - ,'' - ,'{{# } }}' - ,'
              ' - ,'
              '].join(''); - } - - //主模板 - ,TPL_MAIN = ['
              ' - ,TPL_BOX({ - index: 0 - ,checkAllName: 'layTransferLeftCheckAll' - }) - ,'
              ' - ,'' - ,'' - ,'
              ' - ,TPL_BOX({ - index: 1 - ,checkAllName: 'layTransferRightCheckAll' - }) - ,'
              '].join('') - - //构造器 - ,Class = function(options){ - var that = this; - that.index = ++transfer.index; - that.config = $.extend({}, that.config, transfer.config, options); - that.render(); - }; - - //默认配置 - Class.prototype.config = { - title: ['列表一', '列表二'] - ,width: 200 - ,height: 360 - ,data: [] //数据源 - ,value: [] //选中的数据 - ,showSearch: false //是否开启搜索 - ,id: '' //唯一索引,默认自增 index - ,text: { - none: '无数据' - ,searchNone: '无匹配数据' - } - }; - - //重载实例 - Class.prototype.reload = function(options){ - var that = this; - that.config = $.extend({}, that.config, options); - that.render(); - }; - - //渲染 - Class.prototype.render = function(){ - var that = this - ,options = that.config; - - //解析模板 - var thisElem = that.elem = $(laytpl(TPL_MAIN).render({ - data: options - ,index: that.index //索引 - })); - - var othis = options.elem = $(options.elem); - if(!othis[0]) return; - - //初始化属性 - options.data = options.data || []; - options.value = options.value || []; - - //索引 - that.key = options.id || that.index; - - //插入组件结构 - othis.html(that.elem); - - //各级容器 - that.layBox = that.elem.find('.'+ ELEM_BOX) - that.layHeader = that.elem.find('.'+ ELEM_HEADER) - that.laySearch = that.elem.find('.'+ ELEM_SEARCH) - that.layData = thisElem.find('.'+ ELEM_DATA); - that.layBtn = thisElem.find('.'+ ELEM_ACTIVE + ' .layui-btn'); - - //初始化尺寸 - that.layBox.css({ - width: options.width - ,height: options.height - }); - that.layData.css({ - height: function(){ - return options.height - that.layHeader.outerHeight() - that.laySearch.outerHeight() - 2 - }() - }); - - that.renderData(); //渲染数据 - that.events(); //事件 - }; - - //渲染数据 - Class.prototype.renderData = function(){ - var that = this - ,options = that.config; - - //左右穿梭框差异数据 - var arr = [{ - checkName: 'layTransferLeftCheck' - ,views: [] - }, { - checkName: 'layTransferRightCheck' - ,views: [] - }]; - - //解析格式 - that.parseData(function(item){ - //标注为 selected 的为右边的数据 - var _index = item.selected ? 1 : 0 - ,listElem = ['
            • ' - ,'' - ,'
            • '].join(''); - arr[_index].views.push(listElem); - delete item.selected; - }); - - that.layData.eq(0).html(arr[0].views.join('')); - that.layData.eq(1).html(arr[1].views.join('')); - - that.renderCheckBtn(); - } - - //渲染表单 - Class.prototype.renderForm = function(type){ - form.render(type, 'LAY-transfer-'+ this.index); - }; - - //同步复选框和按钮状态 - Class.prototype.renderCheckBtn = function(obj){ - var that = this - ,options = that.config; - - obj = obj || {}; - - that.layBox.each(function(_index){ - var othis = $(this) - ,thisDataElem = othis.find('.'+ ELEM_DATA) - ,allElemCheckbox = othis.find('.'+ ELEM_HEADER).find('input[type="checkbox"]') - ,listElemCheckbox = thisDataElem.find('input[type="checkbox"]'); - - //同步复选框和按钮状态 - var nums = 0 - ,haveChecked = false; - listElemCheckbox.each(function(){ - var isHide = $(this).data('hide'); - if(this.checked || this.disabled || isHide){ - nums++; - } - if(this.checked && !isHide){ - haveChecked = true; - } - }); - - allElemCheckbox.prop('checked', haveChecked && nums === listElemCheckbox.length); //全选复选框状态 - that.layBtn.eq(_index)[haveChecked ? 'removeClass' : 'addClass'](DISABLED); //对应的按钮状态 - - //无数据视图 - if(!obj.stopNone){ - var isNone = thisDataElem.children('li:not(.'+ HIDE +')').length - that.noneView(thisDataElem, isNone ? '' : options.text.none); - } - }); - - that.renderForm('checkbox'); - }; - - //无数据视图 - Class.prototype.noneView = function(thisDataElem, text){ - var createNoneElem = $('

              '+ (text || '') +'

              '); - if(thisDataElem.find('.'+ NONE)[0]){ - thisDataElem.find('.'+ NONE).remove(); - } - text.replace(/\s/g, '') && thisDataElem.append(createNoneElem); - }; - - //同步 value 属性值 - Class.prototype.setValue = function(){ - var that = this - ,options = that.config - ,arr = []; - that.layBox.eq(1).find('.'+ ELEM_DATA +' input[type="checkbox"]').each(function(){ - var isHide = $(this).data('hide'); - isHide || arr.push(this.value); - }); - options.value = arr; - - return that; - }; - - //解析数据 - Class.prototype.parseData = function(callback){ - var that = this - ,options = that.config - ,newData = []; - - layui.each(options.data, function(index, item){ - //解析格式 - item = (typeof options.parseData === 'function' - ? options.parseData(item) - : item) || item; - - newData.push(item = $.extend({}, item)) - - layui.each(options.value, function(index2, item2){ - if(item2 == item.value){ - item.selected = true; - } - }); - callback && callback(item); - }); - - options.data = newData; - return that; - }; - - //获得右侧面板数据 - Class.prototype.getData = function(value){ - var that = this - ,options = that.config - ,selectedData = []; - - that.setValue(); - - layui.each(value || options.value, function(index, item){ - layui.each(options.data, function(index2, item2){ - delete item2.selected; - if(item == item2.value){ - selectedData.push(item2); - }; - }); - }); - return selectedData; - }; - - //事件 - Class.prototype.events = function(){ - var that = this - ,options = that.config; - - //左右复选框 - that.elem.on('click', 'input[lay-filter="layTransferCheckbox"]+', function(){ - var thisElemCheckbox = $(this).prev() - ,checked = thisElemCheckbox[0].checked - ,thisDataElem = thisElemCheckbox.parents('.'+ ELEM_BOX).eq(0).find('.'+ ELEM_DATA); - - if(thisElemCheckbox[0].disabled) return; - - //判断是否全选 - if(thisElemCheckbox.attr('lay-type') === 'all'){ - thisDataElem.find('input[type="checkbox"]').each(function(){ - if(this.disabled) return; - this.checked = checked; - }); - } - - that.renderCheckBtn({stopNone: true}); - }); - - //按钮事件 - that.layBtn.on('click', function(){ - var othis = $(this) - ,_index = othis.data('index') - ,thisBoxElem = that.layBox.eq(_index) - ,arr = []; - if(othis.hasClass(DISABLED)) return; - - that.layBox.eq(_index).each(function(_index){ - var othis = $(this) - ,thisDataElem = othis.find('.'+ ELEM_DATA); - - thisDataElem.children('li').each(function(){ - var thisList = $(this) - ,thisElemCheckbox = thisList.find('input[type="checkbox"]') - ,isHide = thisElemCheckbox.data('hide'); - - if(thisElemCheckbox[0].checked && !isHide){ - thisElemCheckbox[0].checked = false; - thisBoxElem.siblings('.'+ ELEM_BOX).find('.'+ ELEM_DATA).append(thisList.clone()); - thisList.remove(); - - //记录当前穿梭的数据 - arr.push(thisElemCheckbox[0].value); - } - - that.setValue(); - }); - }); - - that.renderCheckBtn(); - - //穿梭时,如果另外一个框正在搜索,则触发匹配 - var siblingInput = thisBoxElem.siblings('.'+ ELEM_BOX).find('.'+ ELEM_SEARCH +' input') - siblingInput.val() === '' || siblingInput.trigger('keyup'); - - //穿梭时的回调 - options.onchange && options.onchange(that.getData(arr), _index); - }); - - //搜索 - that.laySearch.find('input').on('keyup', function(){ - var value = this.value - ,thisDataElem = $(this).parents('.'+ ELEM_SEARCH).eq(0).siblings('.'+ ELEM_DATA) - ,thisListElem = thisDataElem.children('li'); - - thisListElem.each(function(){ - var thisList = $(this) - ,thisElemCheckbox = thisList.find('input[type="checkbox"]') - ,isMatch = thisElemCheckbox[0].title.indexOf(value) !== -1; - - thisList[isMatch ? 'removeClass': 'addClass'](HIDE); - thisElemCheckbox.data('hide', isMatch ? false : true); - }); - - that.renderCheckBtn(); - - //无匹配数据视图 - var isNone = thisListElem.length === thisDataElem.children('li.'+ HIDE).length; - that.noneView(thisDataElem, isNone ? options.text.searchNone : ''); - }); - }; - - //记录所有实例 - thisModule.that = {}; //记录所有实例对象 - thisModule.config = {}; //记录所有实例配置项 - - //重载实例 - transfer.reload = function(id, options){ - var that = thisModule.that[id]; - that.reload(options); - - return thisModule.call(that); - }; - - //获得选中的数据(右侧面板) - transfer.getData = function(id){ - var that = thisModule.that[id]; - return that.getData(); - }; - - //核心入口 - transfer.render = function(options){ - var inst = new Class(options); - return thisModule.call(inst); - }; - - exports(MOD_NAME, transfer); -}); +/** layui-v2.5.7 MIT License */ + ;layui.define(["laytpl","form"],function(e){"use strict";var a=layui.$,t=layui.laytpl,n=layui.form,i="transfer",l={config:{},index:layui[i]?layui[i].index+1e4:0,set:function(e){var t=this;return t.config=a.extend({},t.config,e),t},on:function(e,a){return layui.onevent.call(this,i,e,a)}},r=function(){var e=this,a=e.config,t=a.id||e.index;return r.that[t]=e,r.config[t]=a,{config:a,reload:function(a){e.reload.call(e,a)},getData:function(){return e.getData.call(e)}}},c="layui-hide",o="layui-btn-disabled",d="layui-none",s="layui-transfer-box",u="layui-transfer-header",h="layui-transfer-search",f="layui-transfer-active",y="layui-transfer-data",p=function(e){return e=e||{},['
              ','
              ','","
              ","{{# if(d.data.showSearch){ }}",'","{{# } }}",'
                ',"
                "].join("")},v=['
                ',p({index:0,checkAllName:"layTransferLeftCheckAll"}),'
                ','",'","
                ",p({index:1,checkAllName:"layTransferRightCheckAll"}),"
                "].join(""),x=function(e){var t=this;t.index=++l.index,t.config=a.extend({},t.config,l.config,e),t.render()};x.prototype.config={title:["列表一","列表二"],width:200,height:360,data:[],value:[],showSearch:!1,id:"",text:{none:"无数据",searchNone:"无匹配数据"}},x.prototype.reload=function(e){var t=this;layui.each(e,function(e,a){a.constructor===Array&&delete t.config[e]}),t.config=a.extend(!0,{},t.config,e),t.render()},x.prototype.render=function(){var e=this,n=e.config,i=e.elem=a(t(v).render({data:n,index:e.index})),l=n.elem=a(n.elem);l[0]&&(n.data=n.data||[],n.value=n.value||[],e.key=n.id||e.index,l.html(e.elem),e.layBox=e.elem.find("."+s),e.layHeader=e.elem.find("."+u),e.laySearch=e.elem.find("."+h),e.layData=i.find("."+y),e.layBtn=i.find("."+f+" .layui-btn"),e.layBox.css({width:n.width,height:n.height}),e.layData.css({height:function(){return n.height-e.layHeader.outerHeight()-e.laySearch.outerHeight()-2}()}),e.renderData(),e.events())},x.prototype.renderData=function(){var e=this,a=(e.config,[{checkName:"layTransferLeftCheck",views:[]},{checkName:"layTransferRightCheck",views:[]}]);e.parseData(function(e){var t=e.selected?1:0,n=["
              • ",'',"
              • "].join("");a[t].views.push(n),delete e.selected}),e.layData.eq(0).html(a[0].views.join("")),e.layData.eq(1).html(a[1].views.join("")),e.renderCheckBtn()},x.prototype.renderForm=function(e){n.render(e,"LAY-transfer-"+this.index)},x.prototype.renderCheckBtn=function(e){var t=this,n=t.config;e=e||{},t.layBox.each(function(i){var l=a(this),r=l.find("."+y),d=l.find("."+u).find('input[type="checkbox"]'),s=r.find('input[type="checkbox"]'),h=0,f=!1;if(s.each(function(){var e=a(this).data("hide");(this.checked||this.disabled||e)&&h++,this.checked&&!e&&(f=!0)}),d.prop("checked",f&&h===s.length),t.layBtn.eq(i)[f?"removeClass":"addClass"](o),!e.stopNone){var p=r.children("li:not(."+c+")").length;t.noneView(r,p?"":n.text.none)}}),t.renderForm("checkbox")},x.prototype.noneView=function(e,t){var n=a('

                '+(t||"")+"

                ");e.find("."+d)[0]&&e.find("."+d).remove(),t.replace(/\s/g,"")&&e.append(n)},x.prototype.setValue=function(){var e=this,t=e.config,n=[];return e.layBox.eq(1).find("."+y+' input[type="checkbox"]').each(function(){var e=a(this).data("hide");e||n.push(this.value)}),t.value=n,e},x.prototype.parseData=function(e){var t=this,n=t.config,i=[];return layui.each(n.data,function(t,l){l=("function"==typeof n.parseData?n.parseData(l):l)||l,i.push(l=a.extend({},l)),layui.each(n.value,function(e,a){a==l.value&&(l.selected=!0)}),e&&e(l)}),n.data=i,t},x.prototype.getData=function(e){var a=this,t=a.config,n=[];return a.setValue(),layui.each(e||t.value,function(e,a){layui.each(t.data,function(e,t){delete t.selected,a==t.value&&n.push(t)})}),n},x.prototype.events=function(){var e=this,t=e.config;e.elem.on("click",'input[lay-filter="layTransferCheckbox"]+',function(){var t=a(this).prev(),n=t[0].checked,i=t.parents("."+s).eq(0).find("."+y);t[0].disabled||("all"===t.attr("lay-type")&&i.find('input[type="checkbox"]').each(function(){this.disabled||(this.checked=n)}),e.renderCheckBtn({stopNone:!0}))}),e.layBtn.on("click",function(){var n=a(this),i=n.data("index"),l=e.layBox.eq(i),r=[];if(!n.hasClass(o)){e.layBox.eq(i).each(function(t){var n=a(this),i=n.find("."+y);i.children("li").each(function(){var t=a(this),n=t.find('input[type="checkbox"]'),i=n.data("hide");n[0].checked&&!i&&(n[0].checked=!1,l.siblings("."+s).find("."+y).append(t.clone()),t.remove(),r.push(n[0].value)),e.setValue()})}),e.renderCheckBtn();var c=l.siblings("."+s).find("."+h+" input");""===c.val()||c.trigger("keyup"),t.onchange&&t.onchange(e.getData(r),i)}}),e.laySearch.find("input").on("keyup",function(){var n=this.value,i=a(this).parents("."+h).eq(0).siblings("."+y),l=i.children("li");l.each(function(){var e=a(this),t=e.find('input[type="checkbox"]'),i=t[0].title.indexOf(n)!==-1;e[i?"removeClass":"addClass"](c),t.data("hide",!i)}),e.renderCheckBtn();var r=l.length===i.children("li."+c).length;e.noneView(i,r?t.text.searchNone:"")})},r.that={},r.config={},l.reload=function(e,a){var t=r.that[e];return t.reload(a),r.call(t)},l.getData=function(e){var a=r.that[e];return a.getData()},l.render=function(e){var a=new x(e);return r.call(a)},e(i,l)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/upload.js b/IoTGateway/wwwroot/layui/lay/modules/upload.js index 14097a6..8044c6a 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/upload.js +++ b/IoTGateway/wwwroot/layui/lay/modules/upload.js @@ -1,565 +1,2 @@ -/** - - @Title: upload 文件上传组件 - @License:MIT - - */ - -layui.define('layer' , function(exports){ - "use strict"; - - var $ = layui.$ - ,layer = layui.layer - ,hint = layui.hint() - ,device = layui.device() - - //外部接口 - ,upload = { - config: {} //全局配置项 - - //设置全局项 - ,set: function(options){ - var that = this; - that.config = $.extend({}, that.config, options); - return that; - } - - //事件 - ,on: function(events, callback){ - return layui.onevent.call(this, MOD_NAME, events, callback); - } - } - - //操作当前实例 - ,thisUpload = function(){ - var that = this; - return { - upload: function(files){ - that.upload.call(that, files); - } - ,reload: function(options){ - that.reload.call(that, options); - } - ,config: that.config - } - } - - //字符常量 - ,MOD_NAME = 'upload', ELEM = '.layui-upload', THIS = 'layui-this', SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled' - - ,ELEM_FILE = 'layui-upload-file', ELEM_FORM = 'layui-upload-form', ELEM_IFRAME = 'layui-upload-iframe', ELEM_CHOOSE = 'layui-upload-choose', ELEM_DRAG = 'layui-upload-drag' - - - //构造器 - ,Class = function(options){ - var that = this; - that.config = $.extend({}, that.config, upload.config, options); - that.render(); - }; - - //默认配置 - Class.prototype.config = { - accept: 'images' //允许上传的文件类型:images/file/video/audio - ,exts: '' //允许上传的文件后缀名 - ,auto: true //是否选完文件后自动上传 - ,bindAction: '' //手动上传触发的元素 - ,url: '' //上传地址 - ,field: 'file' //文件字段名 - ,acceptMime: '' //筛选出的文件类型,默认为所有文件 - ,method: 'post' //请求上传的 http 类型 - ,data: {} //请求上传的额外参数 - ,drag: true //是否允许拖拽上传 - ,size: 0 //文件限制大小,默认不限制 - ,number: 0 //允许同时上传的文件数,默认不限制 - ,multiple: false //是否允许多文件上传,不支持ie8-9 - }; - - //初始渲染 - Class.prototype.render = function(options){ - var that = this - ,options = that.config; - - options.elem = $(options.elem); - options.bindAction = $(options.bindAction); - - that.file(); - that.events(); - }; - - //追加文件域 - Class.prototype.file = function(){ - var that = this - ,options = that.config - ,elemFile = that.elemFile = $([ - '' - ].join('')) - ,next = options.elem.next(); - - if(next.hasClass(ELEM_FILE) || next.hasClass(ELEM_FORM)){ - next.remove(); - } - - //包裹ie8/9容器 - if(device.ie && device.ie < 10){ - options.elem.wrap('
                '); - } - - that.isFile() ? ( - that.elemFile = options.elem - ,options.field = options.elem[0].name - ) : options.elem.after(elemFile); - - //初始化ie8/9的Form域 - if(device.ie && device.ie < 10){ - that.initIE(); - } - }; - - //ie8-9初始化 - Class.prototype.initIE = function(){ - var that = this - ,options = that.config - ,iframe = $('') - ,elemForm = $(['
                ' - ,'
                '].join('')); - - //插入iframe - $('#'+ ELEM_IFRAME)[0] || $('body').append(iframe); - - //包裹文件域 - if(!options.elem.next().hasClass(ELEM_FORM)){ - that.elemFile.wrap(elemForm); - - //追加额外的参数 - options.elem.next('.'+ ELEM_FORM).append(function(){ - var arr = []; - layui.each(options.data, function(key, value){ - value = typeof value === 'function' ? value() : value; - arr.push('') - }); - return arr.join(''); - }()); - } - }; - - //异常提示 - Class.prototype.msg = function(content){ - return layer.msg(content, { - icon: 2 - ,shift: 6 - }); - }; - - //判断绑定元素是否为文件域本身 - Class.prototype.isFile = function(){ - var elem = this.config.elem[0]; - if(!elem) return; - return elem.tagName.toLocaleLowerCase() === 'input' && elem.type === 'file' - } - - //预读图片信息 - Class.prototype.preview = function(callback){ - var that = this; - if(window.FileReader){ - layui.each(that.chooseFiles, function(index, file){ - var reader = new FileReader(); - reader.readAsDataURL(file); - reader.onload = function(){ - callback && callback(index, file, this.result); - } - }); - } - }; - - //执行上传 - Class.prototype.upload = function(files, type){ - var that = this - ,options = that.config - ,elemFile = that.elemFile[0] - - //高级浏览器处理方式,支持跨域 - ,ajaxSend = function(){ - var successful = 0, aborted = 0 - ,items = files || that.files || that.chooseFiles || elemFile.files - ,allDone = function(){ //多文件全部上传完毕的回调 - if(options.multiple && successful + aborted === that.fileLength){ - typeof options.allDone === 'function' && options.allDone({ - total: that.fileLength - ,successful: successful - ,aborted: aborted - }); - } - }; - layui.each(items, function(index, file){ - var formData = new FormData(); - - formData.append(options.field, file); - - //追加额外的参数 - layui.each(options.data, function(key, value){ - value = typeof value === 'function' ? value() : value; - formData.append(key, value); - }); - - //提交文件 - var opts = { - url: options.url - ,type: 'post' //统一采用 post 上传 - ,data: formData - ,contentType: false - ,processData: false - ,dataType: 'json' - ,headers: options.headers || {} - //成功回调 - ,success: function(res){ - successful++; - done(index, res); - allDone(); - } - //异常回调 - ,error: function(){ - aborted++; - that.msg('请求上传接口出现异常'); - error(index); - allDone(); - } - }; - //进度条 - if(typeof options.progress === 'function'){ - opts.xhr = function(){ - var xhr = $.ajaxSettings.xhr(); - //上传进度 - xhr.upload.addEventListener("progress", function (e) { - if(e.lengthComputable) { - var percent = Math.floor((e.loaded/e.total)* 100); //百分比 - options.progress(percent, options.item[0], e); - } - }); - return xhr; - } - } - $.ajax(opts); - }); - } - - //低版本IE处理方式,不支持跨域 - ,iframeSend = function(){ - var iframe = $('#'+ ELEM_IFRAME); - - that.elemFile.parent().submit(); - - //获取响应信息 - clearInterval(Class.timer); - Class.timer = setInterval(function() { - var res, iframeBody = iframe.contents().find('body'); - try { - res = iframeBody.text(); - } catch(e) { - that.msg('获取上传后的响应信息出现异常'); - clearInterval(Class.timer); - error(); - } - if(res){ - clearInterval(Class.timer); - iframeBody.html(''); - done(0, res); - } - }, 30); - } - - //统一回调 - ,done = function(index, res){ - that.elemFile.next('.'+ ELEM_CHOOSE).remove(); - elemFile.value = ''; - if(typeof res !== 'object'){ - try { - res = JSON.parse(res); - } catch(e){ - res = {}; - return that.msg('请对上传接口返回有效JSON'); - } - } - typeof options.done === 'function' && options.done(res, index || 0, function(files){ - that.upload(files); - }); - } - - //统一网络异常回调 - ,error = function(index){ - if(options.auto){ - elemFile.value = ''; - } - typeof options.error === 'function' && options.error(index || 0, function(files){ - that.upload(files); - }); - } - - ,exts = options.exts - ,check ,value = function(){ - var arr = []; - layui.each(files || that.chooseFiles, function(i, item){ - arr.push(item.name); - }); - return arr; - }() - - //回调返回的参数 - ,args = { - //预览 - preview: function(callback){ - that.preview(callback); - } - //上传 - ,upload: function(index, file){ - var thisFile = {}; - thisFile[index] = file; - that.upload(thisFile); - } - //追加文件到队列 - ,pushFile: function(){ - that.files = that.files || {}; - layui.each(that.chooseFiles, function(index, item){ - that.files[index] = item; - }); - return that.files; - } - //重置文件 - ,resetFile: function(index, file, filename){ - var newFile = new File([file], filename); - that.files = that.files || {}; - that.files[index] = newFile; - } - } - - //提交上传 - ,send = function(){ - //选择文件的回调 - if(type === 'choose' || options.auto){ - options.choose && options.choose(args); - if(type === 'choose'){ - return; - } - } - - //上传前的回调 - options.before && options.before(args); - - //IE兼容处理 - if(device.ie){ - return device.ie > 9 ? ajaxSend() : iframeSend(); - } - - ajaxSend(); - } - - //校验文件格式 - value = value.length === 0 - ? ((elemFile.value.match(/[^\/\\]+\..+/g)||[]) || '') - : value; - - if(value.length === 0) return; - - switch(options.accept){ - case 'file': //一般文件 - if(exts && !RegExp('\\w\\.('+ exts +')$', 'i').test(escape(value))){ - that.msg('选择的文件中包含不支持的格式'); - return elemFile.value = ''; - } - break; - case 'video': //视频文件 - if(!RegExp('\\w\\.('+ (exts || 'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(value))){ - that.msg('选择的视频中包含不支持的格式'); - return elemFile.value = ''; - } - break; - case 'audio': //音频文件 - if(!RegExp('\\w\\.('+ (exts || 'mp3|wav|mid') +')$', 'i').test(escape(value))){ - that.msg('选择的音频中包含不支持的格式'); - return elemFile.value = ''; - } - break; - default: //图片文件 - layui.each(value, function(i, item){ - if(!RegExp('\\w\\.('+ (exts || 'jpg|png|gif|bmp|jpeg$') +')', 'i').test(escape(item))){ - check = true; - } - }); - if(check){ - that.msg('选择的图片中包含不支持的格式'); - return elemFile.value = ''; - } - break; - } - - //检验文件数量 - that.fileLength = function(){ - var length = 0 - ,items = files || that.files || that.chooseFiles || elemFile.files; - layui.each(items, function(){ - length++; - }); - return length; - }(); - if(options.number && that.fileLength > options.number){ - return that.msg('同时最多只能上传的数量为:'+ options.number); - } - - //检验文件大小 - if(options.size > 0 && !(device.ie && device.ie < 10)){ - var limitSize; - - layui.each(that.chooseFiles, function(index, file){ - if(file.size > 1024*options.size){ - var size = options.size/1024; - size = size >= 1 ? (size.toFixed(2) + 'MB') : options.size + 'KB' - elemFile.value = ''; - limitSize = size; - } - }); - if(limitSize) return that.msg('文件不能超过'+ limitSize); - } - send(); - }; - - //重置方法 - Class.prototype.reload = function(options){ - options = options || {}; - delete options.elem; - delete options.bindAction; - - var that = this - ,options = that.config = $.extend({}, that.config, upload.config, options) - ,next = options.elem.next(); - - //更新文件域相关属性 - next.attr({ - name: options.name - ,accept: options.acceptMime - ,multiple: options.multiple - }); - }; - - //事件处理 - Class.prototype.events = function(){ - var that = this - ,options = that.config - - //设置当前选择的文件队列 - ,setChooseFile = function(files){ - that.chooseFiles = {}; - layui.each(files, function(i, item){ - var time = new Date().getTime(); - that.chooseFiles[time + '-' + i] = item; - }); - } - - //设置选择的文本 - ,setChooseText = function(files, filename){ - var elemFile = that.elemFile - ,value = files.length > 1 - ? files.length + '个文件' - : ((files[0] || {}).name || (elemFile[0].value.match(/[^\/\\]+\..+/g)||[]) || ''); - - if(elemFile.next().hasClass(ELEM_CHOOSE)){ - elemFile.next().remove(); - } - that.upload(null, 'choose'); - if(that.isFile() || options.choose) return; - elemFile.after(''+ value +''); - }; - - //点击上传容器 - options.elem.off('upload.start').on('upload.start', function(){ - var othis = $(this), data = othis.attr('lay-data'); - - if(data){ - try{ - data = new Function('return '+ data)(); - that.config = $.extend({}, options, data); - } catch(e){ - hint.error('Upload element property lay-data configuration item has a syntax error: ' + data) - } - } - - that.config.item = othis; - that.elemFile[0].click(); - }); - - //拖拽上传 - if(!(device.ie && device.ie < 10)){ - options.elem.off('upload.over').on('upload.over', function(){ - var othis = $(this) - othis.attr('lay-over', ''); - }) - .off('upload.leave').on('upload.leave', function(){ - var othis = $(this) - othis.removeAttr('lay-over'); - }) - .off('upload.drop').on('upload.drop', function(e, param){ - var othis = $(this), files = param.originalEvent.dataTransfer.files || []; - - othis.removeAttr('lay-over'); - setChooseFile(files); - - if(options.auto){ - that.upload(files); - } else { - setChooseText(files); - } - }); - } - - //文件选择 - that.elemFile.off('upload.change').on('upload.change', function(){ - var files = this.files || []; - setChooseFile(files); - options.auto ? that.upload() : setChooseText(files); //是否自动触发上传 - }); - - //手动触发上传 - options.bindAction.off('upload.action').on('upload.action', function(){ - that.upload(); - }); - - //防止事件重复绑定 - if(options.elem.data('haveEvents')) return; - - that.elemFile.on('change', function(){ - $(this).trigger('upload.change'); - }); - - options.elem.on('click', function(){ - if(that.isFile()) return; - $(this).trigger('upload.start'); - }); - - if(options.drag){ - options.elem.on('dragover', function(e){ - e.preventDefault(); - $(this).trigger('upload.over'); - }).on('dragleave', function(e){ - $(this).trigger('upload.leave'); - }).on('drop', function(e){ - e.preventDefault(); - $(this).trigger('upload.drop', e); - }); - } - - options.bindAction.on('click', function(){ - $(this).trigger('upload.action'); - }); - - options.elem.data('haveEvents', true); - }; - - //核心入口 - upload.render = function(options){ - var inst = new Class(options); - return thisUpload.call(inst); - }; - - exports(MOD_NAME, upload); -}); - +/** layui-v2.5.7 MIT License */ + ;layui.define("layer",function(e){"use strict";var t=layui.$,i=layui.layer,n=layui.hint(),o=layui.device(),a={config:{},set:function(e){var i=this;return i.config=t.extend({},i.config,e),i},on:function(e,t){return layui.onevent.call(this,r,e,t)}},l=function(){var e=this;return{upload:function(t){e.upload.call(e,t)},reload:function(t){e.reload.call(e,t)},config:e.config}},r="upload",u="layui-upload-file",c="layui-upload-form",f="layui-upload-iframe",s="layui-upload-choose",p=function(e){var i=this;i.config=t.extend({},i.config,a.config,e),i.render()};p.prototype.config={accept:"images",exts:"",auto:!0,bindAction:"",url:"",field:"file",acceptMime:"",method:"post",data:{},drag:!0,size:0,number:0,multiple:!1},p.prototype.render=function(e){var i=this,e=i.config;e.elem=t(e.elem),e.bindAction=t(e.bindAction),i.file(),i.events()},p.prototype.file=function(){var e=this,i=e.config,n=e.elemFile=t(['"].join("")),a=i.elem.next();(a.hasClass(u)||a.hasClass(c))&&a.remove(),o.ie&&o.ie<10&&i.elem.wrap('
                '),e.isFile()?(e.elemFile=i.elem,i.field=i.elem[0].name):i.elem.after(n),o.ie&&o.ie<10&&e.initIE()},p.prototype.initIE=function(){var e=this,i=e.config,n=t(''),o=t(['
                ',"
                "].join(""));t("#"+f)[0]||t("body").append(n),i.elem.next().hasClass(c)||(e.elemFile.wrap(o),i.elem.next("."+c).append(function(){var e=[];return layui.each(i.data,function(t,i){i="function"==typeof i?i():i,e.push('')}),e.join("")}()))},p.prototype.msg=function(e){return i.msg(e,{icon:2,shift:6})},p.prototype.isFile=function(){var e=this.config.elem[0];if(e)return"input"===e.tagName.toLocaleLowerCase()&&"file"===e.type},p.prototype.preview=function(e){var t=this;window.FileReader&&layui.each(t.chooseFiles,function(t,i){var n=new FileReader;n.readAsDataURL(i),n.onload=function(){e&&e(t,i,this.result)}})},p.prototype.upload=function(e,i){var n,a=this,l=a.config,r=a.elemFile[0],u=function(){var i=0,n=0,o=e||a.files||a.chooseFiles||r.files,u=function(){l.multiple&&i+n===a.fileLength&&"function"==typeof l.allDone&&l.allDone({total:a.fileLength,successful:i,aborted:n})};layui.each(o,function(e,o){var r=new FormData;r.append(l.field,o),layui.each(l.data,function(e,t){t="function"==typeof t?t():t,r.append(e,t)});var c={url:l.url,type:"post",data:r,contentType:!1,processData:!1,dataType:"json",headers:l.headers||{},success:function(t){i++,d(e,t),u()},error:function(){n++,a.msg("请求上传接口出现异常"),m(e),u()}};"function"==typeof l.progress&&(c.xhr=function(){var e=t.ajaxSettings.xhr();return e.upload.addEventListener("progress",function(e){if(e.lengthComputable){var t=Math.floor(e.loaded/e.total*100);l.progress(t,l.item[0],e)}}),e}),t.ajax(c)})},c=function(){var e=t("#"+f);a.elemFile.parent().submit(),clearInterval(p.timer),p.timer=setInterval(function(){var t,i=e.contents().find("body");try{t=i.text()}catch(n){a.msg("获取上传后的响应信息出现异常"),clearInterval(p.timer),m()}t&&(clearInterval(p.timer),i.html(""),d(0,t))},30)},d=function(e,t){if(a.elemFile.next("."+s).remove(),r.value="","object"!=typeof t)try{t=JSON.parse(t)}catch(i){return t={},a.msg("请对上传接口返回有效JSON")}"function"==typeof l.done&&l.done(t,e||0,function(e){a.upload(e)})},m=function(e){l.auto&&(r.value=""),"function"==typeof l.error&&l.error(e||0,function(e){a.upload(e)})},h=l.exts,v=function(){var t=[];return layui.each(e||a.chooseFiles,function(e,i){t.push(i.name)}),t}(),g={preview:function(e){a.preview(e)},upload:function(e,t){var i={};i[e]=t,a.upload(i)},pushFile:function(){return a.files=a.files||{},layui.each(a.chooseFiles,function(e,t){a.files[e]=t}),a.files},resetFile:function(e,t,i){var n=new File([t],i);a.files=a.files||{},a.files[e]=n}},y=function(){if("choose"!==i&&!l.auto||(l.choose&&l.choose(g),"choose"!==i))return l.before&&l.before(g),o.ie?o.ie>9?u():c():void u()};if(v=0===v.length?r.value.match(/[^\/\\]+\..+/g)||[]||"":v,0!==v.length){switch(l.accept){case"file":if(h&&!RegExp("\\w\\.("+h+")$","i").test(escape(v)))return a.msg("选择的文件中包含不支持的格式"),r.value="";break;case"video":if(!RegExp("\\w\\.("+(h||"avi|mp4|wma|rmvb|rm|flash|3gp|flv")+")$","i").test(escape(v)))return a.msg("选择的视频中包含不支持的格式"),r.value="";break;case"audio":if(!RegExp("\\w\\.("+(h||"mp3|wav|mid")+")$","i").test(escape(v)))return a.msg("选择的音频中包含不支持的格式"),r.value="";break;default:if(layui.each(v,function(e,t){RegExp("\\w\\.("+(h||"jpg|png|gif|bmp|jpeg$")+")","i").test(escape(t))||(n=!0)}),n)return a.msg("选择的图片中包含不支持的格式"),r.value=""}if(a.fileLength=function(){var t=0,i=e||a.files||a.chooseFiles||r.files;return layui.each(i,function(){t++}),t}(),l.number&&a.fileLength>l.number)return a.msg("同时最多只能上传的数量为:"+l.number);if(l.size>0&&!(o.ie&&o.ie<10)){var F;if(layui.each(a.chooseFiles,function(e,t){if(t.size>1024*l.size){var i=l.size/1024;i=i>=1?i.toFixed(2)+"MB":l.size+"KB",r.value="",F=i}}),F)return a.msg("文件不能超过"+F)}y()}},p.prototype.reload=function(e){e=e||{},delete e.elem,delete e.bindAction;var i=this,e=i.config=t.extend({},i.config,a.config,e),n=e.elem.next();n.attr({name:e.name,accept:e.acceptMime,multiple:e.multiple})},p.prototype.events=function(){var e=this,i=e.config,a=function(t){e.chooseFiles={},layui.each(t,function(t,i){var n=(new Date).getTime();e.chooseFiles[n+"-"+t]=i})},l=function(t,n){var o=e.elemFile,a=t.length>1?t.length+"个文件":(t[0]||{}).name||o[0].value.match(/[^\/\\]+\..+/g)||[]||"";o.next().hasClass(s)&&o.next().remove(),e.upload(null,"choose"),e.isFile()||i.choose||o.after(''+a+"")};i.elem.off("upload.start").on("upload.start",function(){var o=t(this),a=o.attr("lay-data");if(a)try{a=new Function("return "+a)(),e.config=t.extend({},i,a)}catch(l){n.error("Upload element property lay-data configuration item has a syntax error: "+a)}e.config.item=o,e.elemFile[0].click()}),o.ie&&o.ie<10||i.elem.off("upload.over").on("upload.over",function(){var e=t(this);e.attr("lay-over","")}).off("upload.leave").on("upload.leave",function(){var e=t(this);e.removeAttr("lay-over")}).off("upload.drop").on("upload.drop",function(n,o){var r=t(this),u=o.originalEvent.dataTransfer.files||[];r.removeAttr("lay-over"),a(u),i.auto?e.upload(u):l(u)}),e.elemFile.off("upload.change").on("upload.change",function(){var t=this.files||[];a(t),i.auto?e.upload():l(t)}),i.bindAction.off("upload.action").on("upload.action",function(){e.upload()}),i.elem.data("haveEvents")||(e.elemFile.on("change",function(){t(this).trigger("upload.change")}),i.elem.on("click",function(){e.isFile()||t(this).trigger("upload.start")}),i.drag&&i.elem.on("dragover",function(e){e.preventDefault(),t(this).trigger("upload.over")}).on("dragleave",function(e){t(this).trigger("upload.leave")}).on("drop",function(e){e.preventDefault(),t(this).trigger("upload.drop",e)}),i.bindAction.on("click",function(){t(this).trigger("upload.action")}),i.elem.data("haveEvents",!0))},a.render=function(e){var t=new p(e);return l.call(t)},e(r,a)}); \ No newline at end of file diff --git a/IoTGateway/wwwroot/layui/lay/modules/util.js b/IoTGateway/wwwroot/layui/lay/modules/util.js index 10eb3ed..5c74c3e 100644 --- a/IoTGateway/wwwroot/layui/lay/modules/util.js +++ b/IoTGateway/wwwroot/layui/lay/modules/util.js @@ -1,213 +1,2 @@ -/** - - @Name:util 工具集组件 - @License:MIT - -*/ - -layui.define('jquery', function(exports){ - "use strict"; - - var $ = layui.$ - - //外部接口 - ,util = { - //固定块 - fixbar: function(options){ - var ELEM = 'layui-fixbar', TOP_BAR = 'layui-fixbar-top' - ,dom = $(document), body = $('body') - ,is, timer; - - options = $.extend({ - showHeight: 200 //出现TOP的滚动条高度临界值 - }, options); - - options.bar1 = options.bar1 === true ? '' : options.bar1; - options.bar2 = options.bar2 === true ? '' : options.bar2; - options.bgcolor = options.bgcolor ? ('background-color:' + options.bgcolor) : ''; - - var icon = [options.bar1, options.bar2, ''] //图标:信息、问号、TOP - ,elem = $(['
                  ' - ,options.bar1 ? '
                • '+ icon[0] +'
                • ' : '' - ,options.bar2 ? '
                • '+ icon[1] +'
                • ' : '' - ,'
                • '+ icon[2] +'
                • ' - ,'
                '].join('')) - ,topBar = elem.find('.'+TOP_BAR) - ,scroll = function(){ - var stop = dom.scrollTop(); - if(stop >= (options.showHeight)){ - is || (topBar.show(), is = 1); - } else { - is && (topBar.hide(), is = 0); - } - }; - if($('.'+ ELEM)[0]) return; - - typeof options.css === 'object' && elem.css(options.css); - body.append(elem), scroll(); - - //bar点击事件 - elem.find('li').on('click', function(){ - var othis = $(this), type = othis.attr('lay-type'); - if(type === 'top'){ - $('html,body').animate({ - scrollTop : 0 - }, 200); - } - options.click && options.click.call(this, type); - }); - - //Top显示控制 - dom.on('scroll', function(){ - clearTimeout(timer); - timer = setTimeout(function(){ - scroll(); - }, 100); - }); - } - - //倒计时 - ,countdown: function(endTime, serverTime, callback){ - var that = this - ,type = typeof serverTime === 'function' - ,end = new Date(endTime).getTime() - ,now = new Date((!serverTime || type) ? new Date().getTime() : serverTime).getTime() - ,count = end - now - ,time = [ - Math.floor(count/(1000*60*60*24)) //天 - ,Math.floor(count/(1000*60*60)) % 24 //时 - ,Math.floor(count/(1000*60)) % 60 //分 - ,Math.floor(count/1000) % 60 //秒 - ]; - - if(type) callback = serverTime; - - var timer = setTimeout(function(){ - that.countdown(endTime, now + 1000, callback); - }, 1000); - - callback && callback(count > 0 ? time : [0,0,0,0], serverTime, timer); - - if(count <= 0) clearTimeout(timer); - return timer; - } - - //某个时间在当前时间的多久前 - ,timeAgo: function(time, onlyDate){ - var that = this - ,arr = [[], []] - ,stamp = new Date().getTime() - new Date(time).getTime(); - - //返回具体日期 - if(stamp > 1000*60*60*24*31){ - stamp = new Date(time); - arr[0][0] = that.digit(stamp.getFullYear(), 4); - arr[0][1] = that.digit(stamp.getMonth() + 1); - arr[0][2] = that.digit(stamp.getDate()); - - //是否输出时间 - if(!onlyDate){ - arr[1][0] = that.digit(stamp.getHours()); - arr[1][1] = that.digit(stamp.getMinutes()); - arr[1][2] = that.digit(stamp.getSeconds()); - } - return arr[0].join('-') + ' ' + arr[1].join(':'); - } - - //30天以内,返回“多久前” - if(stamp >= 1000*60*60*24){ - return ((stamp/1000/60/60/24)|0) + '天前'; - } else if(stamp >= 1000*60*60){ - return ((stamp/1000/60/60)|0) + '小时前'; - } else if(stamp >= 1000*60*3){ //3分钟以内为:刚刚 - return ((stamp/1000/60)|0) + '分钟前'; - } else if(stamp < 0){ - return '未来'; - } else { - return '刚刚'; - } - } - - //数字前置补零 - ,digit: function(num, length){ - var str = ''; - num = String(num); - length = length || 2; - for(var i = num.length; i < length; i++){ - str += '0'; - } - return num < Math.pow(10, length) ? str + (num|0) : num; - } - - //转化为日期格式字符 - ,toDateString: function(time, format){ - var that = this - ,date = new Date(time || new Date()) - ,ymd = [ - that.digit(date.getFullYear(), 4) - ,that.digit(date.getMonth() + 1) - ,that.digit(date.getDate()) - ] - ,hms = [ - that.digit(date.getHours()) - ,that.digit(date.getMinutes()) - ,that.digit(date.getSeconds()) - ]; - - format = format || 'yyyy-MM-dd HH:mm:ss'; - - return format.replace(/yyyy/g, ymd[0]) - .replace(/MM/g, ymd[1]) - .replace(/dd/g, ymd[2]) - .replace(/HH/g, hms[0]) - .replace(/mm/g, hms[1]) - .replace(/ss/g, hms[2]); - } - - //防 xss 攻击 - ,escape: function(html){ - return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') - .replace(//g, '>') - .replace(/'/g, ''').replace(/"/g, '"'); - } - - ,unescape: function(str){ - return String(str || '').replace(/\&/g, '&') - .replace(/\</g, '<').replace(/\>/g, '>') - .replace(/\'/, '\'').replace(/\"/, '"'); - } - - //批量事件 - ,event: function(attr, obj, eventType){ - var _body = $('body'); - eventType = eventType || 'click'; - - //记录事件回调集合 - obj = util.event[attr] = $.extend(true, util.event[attr], obj) || {}; - - //清除委托事件 - util.event.UTIL_EVENT_CALLBACK = util.event.UTIL_EVENT_CALLBACK || {}; - _body.off(eventType, '*['+ attr +']', util.event.UTIL_EVENT_CALLBACK[attr]) - - //绑定委托事件 - util.event.UTIL_EVENT_CALLBACK[attr] = function(){ - var othis = $(this) - ,key = othis.attr(attr); - (typeof obj[key] === 'function') && obj[key].call(this, othis); - }; - - //清除旧事件,绑定新事件 - _body.on(eventType, '*['+ attr +']', util.event.UTIL_EVENT_CALLBACK[attr]); - - return obj; - } - }; - - // DOM 尺寸变化,该创意来自:http://benalman.com/projects/jquery-resize-plugin/ - /* - !function(a,b,c){"$:nomunge";function l(){f=b[g](function(){d.each(function(){var b=a(this),c=b.width(),d=b.height(),e=a.data(this,i);(c!==e.w||d!==e.h)&&b.trigger(h,[e.w=c,e.h=d])}),l()},e[j])}var f,d=a([]),e=a.resize=a.extend(a.resize,{}),g="setTimeout",h="resize",i=h+"-special-event",j="delay",k="throttleWindow";e[j]=250,e[k]=!0,a.event.special[h]={setup:function(){if(!e[k]&&this[g])return!1;var b=a(this);d=d.add(b),a.data(this,i,{w:b.width(),h:b.height()}),1===d.length&&l()},teardown:function(){if(!e[k]&&this[g])return!1;var b=a(this);d=d.not(b),b.removeData(i),d.length||clearTimeout(f)},add:function(b){function f(b,e,f){var g=a(this),h=a.data(this,i)||{};h.w=e!==c?e:g.width(),h.h=f!==c?f:g.height(),d.apply(this,arguments)}if(!e[k]&&this[g])return!1;var d;return a.isFunction(b)?(d=b,f):(d=b.handler,b.handler=f,void 0)}}}($,window); - */ - - //暴露接口 - exports('util', util); -}); \ No newline at end of file +/** layui-v2.5.7 MIT License */ + ;layui.define("jquery",function(e){"use strict";var t=layui.$,i={fixbar:function(e){var i,n,a="layui-fixbar",o="layui-fixbar-top",r=t(document),l=t("body");e=t.extend({showHeight:200},e),e.bar1=e.bar1===!0?"":e.bar1,e.bar2=e.bar2===!0?"":e.bar2,e.bgcolor=e.bgcolor?"background-color:"+e.bgcolor:"";var c=[e.bar1,e.bar2,""],u=t(['
                  ',e.bar1?'
                • '+c[0]+"
                • ":"",e.bar2?'
                • '+c[1]+"
                • ":"",'
                • '+c[2]+"
                • ","
                "].join("")),g=u.find("."+o),s=function(){var t=r.scrollTop();t>=e.showHeight?i||(g.show(),i=1):i&&(g.hide(),i=0)};t("."+a)[0]||("object"==typeof e.css&&u.css(e.css),l.append(u),s(),u.find("li").on("click",function(){var i=t(this),n=i.attr("lay-type");"top"===n&&t("html,body").animate({scrollTop:0},200),e.click&&e.click.call(this,n)}),r.on("scroll",function(){clearTimeout(n),n=setTimeout(function(){s()},100)}))},countdown:function(e,t,i){var n=this,a="function"==typeof t,o=new Date(e).getTime(),r=new Date(!t||a?(new Date).getTime():t).getTime(),l=o-r,c=[Math.floor(l/864e5),Math.floor(l/36e5)%24,Math.floor(l/6e4)%60,Math.floor(l/1e3)%60];a&&(i=t);var u=setTimeout(function(){n.countdown(e,r+1e3,i)},1e3);return i&&i(l>0?c:[0,0,0,0],t,u),l<=0&&clearTimeout(u),u},timeAgo:function(e,t){var i=this,n=[[],[]],a=(new Date).getTime()-new Date(e).getTime();return a>26784e5?(a=new Date(e),n[0][0]=i.digit(a.getFullYear(),4),n[0][1]=i.digit(a.getMonth()+1),n[0][2]=i.digit(a.getDate()),t||(n[1][0]=i.digit(a.getHours()),n[1][1]=i.digit(a.getMinutes()),n[1][2]=i.digit(a.getSeconds())),n[0].join("-")+" "+n[1].join(":")):a>=864e5?(a/1e3/60/60/24|0)+"天前":a>=36e5?(a/1e3/60/60|0)+"小时前":a>=18e4?(a/1e3/60|0)+"分钟前":a<0?"未来":"刚刚"},digit:function(e,t){var i="";e=String(e),t=t||2;for(var n=e.length;n/g,">").replace(/'/g,"'").replace(/"/g,""")},event:function(e,n,a){var o=t("body");return a=a||"click",n=i.event[e]=t.extend(!0,i.event[e],n)||{},i.event.UTIL_EVENT_CALLBACK=i.event.UTIL_EVENT_CALLBACK||{},o.off(a,"*["+e+"]",i.event.UTIL_EVENT_CALLBACK[e]),i.event.UTIL_EVENT_CALLBACK[e]=function(){var i=t(this),a=i.attr(e);"function"==typeof n[a]&&n[a].call(this,i)},o.on(a,"*["+e+"]",i.event.UTIL_EVENT_CALLBACK[e]),n}};!function(e,t,i){"$:nomunge";function n(){a=t[l](function(){o.each(function(){var t=e(this),i=t.width(),n=t.height(),a=e.data(this,u);(i!==a.w||n!==a.h)&&t.trigger(c,[a.w=i,a.h=n])}),n()},r[g])}var a,o=e([]),r=e.resize=e.extend(e.resize,{}),l="setTimeout",c="resize",u=c+"-special-event",g="delay",s="throttleWindow";r[g]=250,r[s]=!0,e.event.special[c]={setup:function(){if(!r[s]&&this[l])return!1;var t=e(this);o=o.add(t),e.data(this,u,{w:t.width(),h:t.height()}),1===o.length&&n()},teardown:function(){if(!r[s]&&this[l])return!1;var t=e(this);o=o.not(t),t.removeData(u),o.length||clearTimeout(a)},add:function(t){function n(t,n,o){var r=e(this),l=e.data(this,u)||{};l.w=n!==i?n:r.width(),l.h=o!==i?o:r.height(),a.apply(this,arguments)}if(!r[s]&&this[l])return!1;var a;return e.isFunction(t)?(a=t,n):(a=t.handler,void(t.handler=n))}}}(t,window),e("util",i)}); \ No newline at end of file diff --git a/Plugins/Drivers/DriverAllenBradley/AllenBradley.cs b/Plugins/Drivers/DriverAllenBradley/AllenBradley.cs index f56512a..05b6bd3 100644 --- a/Plugins/Drivers/DriverAllenBradley/AllenBradley.cs +++ b/Plugins/Drivers/DriverAllenBradley/AllenBradley.cs @@ -96,102 +96,46 @@ namespace DriverAllenBradley switch (ioarg.ValueType) { case PluginInterface.DataTypeEnum.Bit: - var resultBit = plc.ReadBoolean(ioarg.Address); - if (resultBit.IsSucceed) - ret.Value = resultBit.Value == true ? 1 : 0; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadBoolean(ioarg.Address).Value == true ? 1 : 0; break; case PluginInterface.DataTypeEnum.Bool: - var resultBool = plc.ReadBoolean(ioarg.Address); - if (resultBool.IsSucceed) - ret.Value = resultBool.Value == true ? 1 : 0; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadBoolean(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.UByte: - var resultUByte = plc.ReadByte(ioarg.Address); - if (resultUByte.IsSucceed) - ret.Value = resultUByte.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadByte(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Byte: - var resultByte = plc.ReadByte(ioarg.Address); - if (resultByte.IsSucceed) - ret.Value = (sbyte)resultByte.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = (sbyte)plc.ReadByte(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Uint16: - var resultUint = plc.ReadUInt16(ioarg.Address); - if (resultUint.IsSucceed) - ret.Value = resultUint.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value =plc.ReadUInt16(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Int16: - var resultInt = plc.ReadInt16(ioarg.Address); - if (resultInt.IsSucceed) - ret.Value = resultInt.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadInt16(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Uint32: - var resultUint32 = plc.ReadUInt32(ioarg.Address); - if (resultUint32.IsSucceed) - ret.Value = resultUint32.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value =plc.ReadUInt32(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Int32: - var resultInt32 = plc.ReadInt32(ioarg.Address); - if (resultInt32.IsSucceed) - ret.Value = resultInt32.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadInt32(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Float: - var resultFloat = plc.ReadFloat(ioarg.Address); - if (resultFloat.IsSucceed) - ret.Value = resultFloat.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadFloat(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Double: - var resultDouble = plc.ReadDouble(ioarg.Address); - if (resultDouble.IsSucceed) - ret.Value = resultDouble.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadDouble(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Uint64: - var resultUint64 = plc.ReadUInt64(ioarg.Address); - if (resultUint64.IsSucceed) - ret.Value = resultUint64.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadUInt64(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Int64: - var resultInt64 = plc.ReadInt64(ioarg.Address); - if (resultInt64.IsSucceed) - ret.Value = resultInt64.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadInt64(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.AsciiString: - var resultIntAsciiStr = plc.ReadString(ioarg.Address); - if (resultIntAsciiStr.IsSucceed) - ret.Value = resultIntAsciiStr.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadString(ioarg.Address); break; case PluginInterface.DataTypeEnum.Utf8String: - var resultIntUtf8Str = plc.ReadString(ioarg.Address); - if (resultIntUtf8Str.IsSucceed) - ret.Value = resultIntUtf8Str.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadString(ioarg.Address); break; default: break; diff --git a/Plugins/Drivers/DriverAllenBradley/DriverAllenBradley.csproj b/Plugins/Drivers/DriverAllenBradley/DriverAllenBradley.csproj index 0269645..f87e0c2 100644 --- a/Plugins/Drivers/DriverAllenBradley/DriverAllenBradley.csproj +++ b/Plugins/Drivers/DriverAllenBradley/DriverAllenBradley.csproj @@ -1,9 +1,11 @@ - + - net5.0 - ../../../IoTGateway/bin/Debug/net5.0/drivers + net6.0 + ../../../IoTGateway/bin/Debug/net6.0/drivers true + enable + enable @@ -13,5 +15,4 @@ - diff --git a/Plugins/Drivers/DriverMTConnect/DriverMTConnect.csproj b/Plugins/Drivers/DriverMTConnect/DriverMTConnect.csproj index 1aef235..82c2e3e 100644 --- a/Plugins/Drivers/DriverMTConnect/DriverMTConnect.csproj +++ b/Plugins/Drivers/DriverMTConnect/DriverMTConnect.csproj @@ -1,10 +1,12 @@  - - net5.0 - ../../../IoTGateway/bin/Debug/net5.0/drivers + + net6.0 + ../../../IoTGateway/bin/Debug/net6.0/drivers true - + enable + enable + diff --git a/Plugins/Drivers/DriverMitsubishi/DriverMitsubishi.csproj b/Plugins/Drivers/DriverMitsubishi/DriverMitsubishi.csproj index 0830062..f87e0c2 100644 --- a/Plugins/Drivers/DriverMitsubishi/DriverMitsubishi.csproj +++ b/Plugins/Drivers/DriverMitsubishi/DriverMitsubishi.csproj @@ -1,9 +1,11 @@ - + - net5.0 - ../../../IoTGateway/bin/Debug/net5.0/drivers - true + net6.0 + ../../../IoTGateway/bin/Debug/net6.0/drivers + true + enable + enable @@ -13,5 +15,4 @@ - diff --git a/Plugins/Drivers/DriverMitsubishi/Mitsubishi.cs b/Plugins/Drivers/DriverMitsubishi/Mitsubishi.cs index 6633a4d..fae7134 100644 --- a/Plugins/Drivers/DriverMitsubishi/Mitsubishi.cs +++ b/Plugins/Drivers/DriverMitsubishi/Mitsubishi.cs @@ -100,102 +100,46 @@ namespace DriverMitsubishi switch (ioarg.ValueType) { case PluginInterface.DataTypeEnum.Bit: - var resultBit = plc.ReadBoolean(ioarg.Address); - if (resultBit.IsSucceed) - ret.Value = resultBit.Value == true ? 1 : 0; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadBoolean(ioarg.Address).Value == true ? 1 : 0; break; case PluginInterface.DataTypeEnum.Bool: - var resultBool = plc.ReadBoolean(ioarg.Address); - if (resultBool.IsSucceed) - ret.Value = resultBool.Value == true ? 1 : 0; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadBoolean(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.UByte: - var resultUByte = plc.ReadByte(ioarg.Address); - if (resultUByte.IsSucceed) - ret.Value = resultUByte.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadByte(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Byte: - var resultByte = plc.ReadByte(ioarg.Address); - if (resultByte.IsSucceed) - ret.Value = (sbyte)resultByte.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = (sbyte)plc.ReadByte(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Uint16: - var resultUint = plc.ReadUInt16(ioarg.Address); - if (resultUint.IsSucceed) - ret.Value = resultUint.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value =plc.ReadUInt16(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Int16: - var resultInt = plc.ReadInt16(ioarg.Address); - if (resultInt.IsSucceed) - ret.Value = resultInt.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadInt16(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Uint32: - var resultUint32 = plc.ReadUInt32(ioarg.Address); - if (resultUint32.IsSucceed) - ret.Value = resultUint32.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value =plc.ReadUInt32(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Int32: - var resultInt32 = plc.ReadInt32(ioarg.Address); - if (resultInt32.IsSucceed) - ret.Value = resultInt32.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadInt32(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Float: - var resultFloat = plc.ReadFloat(ioarg.Address); - if (resultFloat.IsSucceed) - ret.Value = resultFloat.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadFloat(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Double: - var resultDouble = plc.ReadDouble(ioarg.Address); - if (resultDouble.IsSucceed) - ret.Value = resultDouble.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadDouble(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Uint64: - var resultUint64 = plc.ReadUInt64(ioarg.Address); - if (resultUint64.IsSucceed) - ret.Value = resultUint64.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadUInt64(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Int64: - var resultInt64 = plc.ReadInt64(ioarg.Address); - if (resultInt64.IsSucceed) - ret.Value = resultInt64.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadInt64(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.AsciiString: - var resultIntAsciiStr = plc.ReadString(ioarg.Address); - if (resultIntAsciiStr.IsSucceed) - ret.Value = resultIntAsciiStr.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadString(ioarg.Address); break; case PluginInterface.DataTypeEnum.Utf8String: - var resultIntUtf8Str = plc.ReadString(ioarg.Address); - if (resultIntUtf8Str.IsSucceed) - ret.Value = resultIntUtf8Str.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadString(ioarg.Address); break; default: break; diff --git a/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj b/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj index 1d82259..bca6eb3 100644 --- a/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj +++ b/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj @@ -1,24 +1,25 @@  - - net5.0 - false - ../../../IoTGateway/bin/Debug/net5.0/drivers - + + net6.0 + ../../../IoTGateway/bin/Debug/net6.0/drivers + enable + enable + - - - + + + - - - - - - - System.IO.Ports.dll - true - - + + + + + + System.IO.Ports.dll + true + + + diff --git a/Plugins/Drivers/DriverOPCUaClient/DriverOPCUaClient.csproj b/Plugins/Drivers/DriverOPCUaClient/DriverOPCUaClient.csproj index 92d7e01..5845e7c 100644 --- a/Plugins/Drivers/DriverOPCUaClient/DriverOPCUaClient.csproj +++ b/Plugins/Drivers/DriverOPCUaClient/DriverOPCUaClient.csproj @@ -1,17 +1,18 @@  - - net5.0 - ../../../IoTGateway/bin/Debug/net5.0/drivers - true - - - - - - - - - + + net6.0 + ../../../IoTGateway/bin/Debug/net6.0/drivers + true + enable + enable + + + + + + + + diff --git a/Plugins/Drivers/DriverOmronFins/DriverOmronFins.csproj b/Plugins/Drivers/DriverOmronFins/DriverOmronFins.csproj new file mode 100644 index 0000000..f87e0c2 --- /dev/null +++ b/Plugins/Drivers/DriverOmronFins/DriverOmronFins.csproj @@ -0,0 +1,18 @@ + + + + net6.0 + ../../../IoTGateway/bin/Debug/net6.0/drivers + true + enable + enable + + + + + + + + + + diff --git a/Plugins/Drivers/DriverOmronFins/OmronFins.cs b/Plugins/Drivers/DriverOmronFins/OmronFins.cs new file mode 100644 index 0000000..c887eba --- /dev/null +++ b/Plugins/Drivers/DriverOmronFins/OmronFins.cs @@ -0,0 +1,160 @@ +using IoTClient.Clients.PLC; +using IoTClient.Enums; +using PluginInterface; +using System; +using System.Text; + +namespace DriverOmronFins +{ + [DriverSupported("OmronFins")] + [DriverInfoAttribute("OmronFins", "V1.0.0", "Copyright WHD-IoTClient© 2022-01-15")] + public class OmronFins : IDriver + { + private OmronFinsClient plc = null; + #region 配置参数 + + [ConfigParameter("设备Id")] + public Guid DeviceId { get; set; } + + [ConfigParameter("IP地址")] + public string IpAddress { get; set; } = "127.0.0.1"; + + [ConfigParameter("端口号")] + public int Port { get; set; } = 6000; + + [ConfigParameter("超时时间ms")] + public int Timeout { get; set; } = 3000; + + [ConfigParameter("最小通讯周期ms")] + public uint MinPeriod { get; set; } = 3000; + + #endregion + + public OmronFins(Guid deviceId) + { + DeviceId = deviceId; + } + + + public bool IsConnected + { + get + { + return plc != null && plc.Connected; + } + } + + public bool Connect() + { + try + { + plc = new OmronFinsClient(IpAddress, Port); + plc.Open(); + } + catch (Exception) + { + return false; + } + return IsConnected; + } + + public bool Close() + { + try + { + plc?.Close(); + return !IsConnected; + } + catch (Exception) + { + + return false; + } + } + + public void Dispose() + { + try + { + plc = null; + } + catch (Exception) + { + + } + } + + [Method("读西门子PLC标准地址", description: "读西门子PLC标准地址")] + public DriverReturnValueModel Read(DriverAddressIoArgModel ioarg) + { + var ret = new DriverReturnValueModel { StatusType = VaribaleStatusTypeEnum.Good }; + + if (plc != null && this.IsConnected) + { + try + { + switch (ioarg.ValueType) + { + case PluginInterface.DataTypeEnum.Bit: + ret.Value = plc.ReadBoolean(ioarg.Address).Value == true ? 1 : 0; + break; + case PluginInterface.DataTypeEnum.Bool: + ret.Value = plc.ReadBoolean(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.UByte: + ret.Value = plc.ReadByte(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.Byte: + ret.Value = (sbyte)plc.ReadByte(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.Uint16: + ret.Value =plc.ReadUInt16(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.Int16: + ret.Value = plc.ReadInt16(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.Uint32: + ret.Value =plc.ReadUInt32(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.Int32: + ret.Value = plc.ReadInt32(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.Float: + ret.Value = plc.ReadFloat(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.Double: + ret.Value = plc.ReadDouble(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.Uint64: + ret.Value = plc.ReadUInt64(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.Int64: + ret.Value = plc.ReadInt64(ioarg.Address).Value; + break; + case PluginInterface.DataTypeEnum.AsciiString: + ret.Value = plc.ReadString(ioarg.Address); + break; + case PluginInterface.DataTypeEnum.Utf8String: + ret.Value = plc.ReadString(ioarg.Address); + break; + default: + break; + } + } + catch (Exception ex) + { + + ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Message = $"读取失败,{ex.Message}"; + } + } + else + { + ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Message = "连接失败"; + } + return ret; + } + + } +} \ No newline at end of file diff --git a/Plugins/Drivers/DriverSiemensS7/DriverSiemensS7.csproj b/Plugins/Drivers/DriverSiemensS7/DriverSiemensS7.csproj index d9e44ca..2617eb5 100644 --- a/Plugins/Drivers/DriverSiemensS7/DriverSiemensS7.csproj +++ b/Plugins/Drivers/DriverSiemensS7/DriverSiemensS7.csproj @@ -1,12 +1,13 @@ - + - net5.0 - ../../../IoTGateway/bin/Debug/net5.0/drivers + net6.0 + ../../../IoTGateway/bin/Debug/net6.0/drivers + enable + enable - + - diff --git a/Plugins/Drivers/DriverSiemensS7/S7.Net/PLCHelpers.cs b/Plugins/Drivers/DriverSiemensS7/S7.Net/PLCHelpers.cs index 7715922..0ef5fef 100644 --- a/Plugins/Drivers/DriverSiemensS7/S7.Net/PLCHelpers.cs +++ b/Plugins/Drivers/DriverSiemensS7/S7.Net/PLCHelpers.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using DateTime = S7.Net.Types.DateTime; +using Timer = S7.Net.Types.Timer; namespace S7.Net { diff --git a/Plugins/Drivers/OmronFins/OmronFins.cs b/Plugins/Drivers/OmronFins/OmronFins.cs index 193dae6..c887eba 100644 --- a/Plugins/Drivers/OmronFins/OmronFins.cs +++ b/Plugins/Drivers/OmronFins/OmronFins.cs @@ -96,102 +96,46 @@ namespace DriverOmronFins switch (ioarg.ValueType) { case PluginInterface.DataTypeEnum.Bit: - var resultBit = plc.ReadBoolean(ioarg.Address); - if (resultBit.IsSucceed) - ret.Value = resultBit.Value == true ? 1 : 0; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadBoolean(ioarg.Address).Value == true ? 1 : 0; break; case PluginInterface.DataTypeEnum.Bool: - var resultBool = plc.ReadBoolean(ioarg.Address); - if (resultBool.IsSucceed) - ret.Value = resultBool.Value == true ? 1 : 0; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadBoolean(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.UByte: - var resultUByte = plc.ReadByte(ioarg.Address); - if (resultUByte.IsSucceed) - ret.Value = resultUByte.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadByte(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Byte: - var resultByte = plc.ReadByte(ioarg.Address); - if (resultByte.IsSucceed) - ret.Value = (sbyte)resultByte.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = (sbyte)plc.ReadByte(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Uint16: - var resultUint = plc.ReadUInt16(ioarg.Address); - if (resultUint.IsSucceed) - ret.Value = resultUint.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value =plc.ReadUInt16(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Int16: - var resultInt = plc.ReadInt16(ioarg.Address); - if (resultInt.IsSucceed) - ret.Value = resultInt.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadInt16(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Uint32: - var resultUint32 = plc.ReadUInt32(ioarg.Address); - if (resultUint32.IsSucceed) - ret.Value = resultUint32.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value =plc.ReadUInt32(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Int32: - var resultInt32 = plc.ReadInt32(ioarg.Address); - if (resultInt32.IsSucceed) - ret.Value = resultInt32.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadInt32(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Float: - var resultFloat = plc.ReadFloat(ioarg.Address); - if (resultFloat.IsSucceed) - ret.Value = resultFloat.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadFloat(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Double: - var resultDouble = plc.ReadDouble(ioarg.Address); - if (resultDouble.IsSucceed) - ret.Value = resultDouble.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadDouble(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Uint64: - var resultUint64 = plc.ReadUInt64(ioarg.Address); - if (resultUint64.IsSucceed) - ret.Value = resultUint64.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadUInt64(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.Int64: - var resultInt64 = plc.ReadInt64(ioarg.Address); - if (resultInt64.IsSucceed) - ret.Value = resultInt64.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadInt64(ioarg.Address).Value; break; case PluginInterface.DataTypeEnum.AsciiString: - var resultIntAsciiStr = plc.ReadString(ioarg.Address); - if (resultIntAsciiStr.IsSucceed) - ret.Value = resultIntAsciiStr.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadString(ioarg.Address); break; case PluginInterface.DataTypeEnum.Utf8String: - var resultIntUtf8Str = plc.ReadString(ioarg.Address); - if (resultIntUtf8Str.IsSucceed) - ret.Value = resultIntUtf8Str.Value; - else - ret.StatusType = VaribaleStatusTypeEnum.Bad; + ret.Value = plc.ReadString(ioarg.Address); break; default: break; diff --git a/Plugins/Plugin/DrvierService.cs b/Plugins/Plugin/DrvierService.cs index 0b0a937..fcaa65f 100644 --- a/Plugins/Plugin/DrvierService.cs +++ b/Plugins/Plugin/DrvierService.cs @@ -16,7 +16,7 @@ namespace Plugin { public class DrvierService//: IDependency { - string DriverPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"drivers/net5.0"); + string DriverPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"drivers/net6.0"); string[] driverFiles; public List DriverInfos = new List(); public DrvierService(IConfiguration ConfigRoot) diff --git a/Plugins/Plugin/MyMqttClient.cs b/Plugins/Plugin/MyMqttClient.cs index 3ef6c01..7cdd84b 100644 --- a/Plugins/Plugin/MyMqttClient.cs +++ b/Plugins/Plugin/MyMqttClient.cs @@ -70,25 +70,34 @@ namespace Plugin { try { - string TopicBase = "v1/gateway/telemetry"; - if (!systemConfig.Disperse) - _mqttClient.PublishAsync(TopicBase, JsonConvert.SerializeObject(SendModel)); - else + switch (systemConfig.IoTPlatformType) { - foreach (var payload in SendModel[device.DeviceName]) - { - foreach (var kv in payload.Values) + case IoTPlatformType.ThingsBoard: + _mqttClient.PublishAsync("v1/gateway/telemetry", JsonConvert.SerializeObject(SendModel)); + break; + case IoTPlatformType.IoTSharp: + foreach (var payload in SendModel[device.DeviceName]) { - _mqttClient.PublishAsync($"{TopicBase}/{device.DeviceName}/{kv.Key}", kv.Value?.ToString()); - - //更新到UAService - _uaNodeManager.UpdateNode($"{device.Parent.DeviceName}.{device.DeviceName}.{kv.Key}", kv.Value); + _mqttClient.PublishAsync($"devices/{device.DeviceName}/telemetry", JsonConvert.SerializeObject(payload.Values)); } + break; + case IoTPlatformType.AliCloudIoT: + case IoTPlatformType.TencentIoTHub: + case IoTPlatformType.BaiduIoTCore: + case IoTPlatformType.OneNET: + default: + break; + } + foreach (var payload in SendModel[device.DeviceName]) + { + foreach (var kv in payload.Values) + { + //更新到UAService + _uaNodeManager.UpdateNode($"{device.Parent.DeviceName}.{device.DeviceName}.{kv.Key}", kv.Value); } } - } catch (Exception ex) { diff --git a/Plugins/Plugin/Plugin.csproj b/Plugins/Plugin/Plugin.csproj index 7217246..5ddbe29 100644 --- a/Plugins/Plugin/Plugin.csproj +++ b/Plugins/Plugin/Plugin.csproj @@ -1,11 +1,13 @@ - net5.0 + net6.0 + enable + enable - + diff --git a/Plugins/Plugin/UA.Server/UAServer.cs b/Plugins/Plugin/UA.Server/UAServer.cs index 1210e7f..b1cbb7a 100644 --- a/Plugins/Plugin/UA.Server/UAServer.cs +++ b/Plugins/Plugin/UA.Server/UAServer.cs @@ -230,7 +230,7 @@ namespace Quickstarts } item.AppendFormat(":{0}", session.Id); } - Console.WriteLine(item.ToString()); + //Console.WriteLine(item.ToString()); } } diff --git a/Plugins/PluginInterface/PluginInterface.csproj b/Plugins/PluginInterface/PluginInterface.csproj index 47c5a70..933c8b2 100644 --- a/Plugins/PluginInterface/PluginInterface.csproj +++ b/Plugins/PluginInterface/PluginInterface.csproj @@ -1,7 +1,9 @@ - net5.0 + net6.0 + enable + enable diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/BaseBatchVM.cs b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/BaseBatchVM.cs index 66c2fc5..38af472 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/BaseBatchVM.cs +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/BaseBatchVM.cs @@ -311,7 +311,8 @@ namespace WalkingTec.Mvvm.Core { val = FC["LinkedVM." + pro.Name + "[]"]; } - if (proToSet != null && val != null) + var valuetoset = pro.GetValue(LinkedVM); + if (proToSet != null && val != null && valuetoset != null) { var hasvalue = true; if ( val is StringValues sv && StringValues.IsNullOrEmpty(sv) == true) @@ -320,7 +321,7 @@ namespace WalkingTec.Mvvm.Core } if (hasvalue) { - proToSet.SetValue(entity, pro.GetValue(LinkedVM)); + proToSet.SetValue(entity, valuetoset); } } } diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Extensions/DCExtension.cs b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Extensions/DCExtension.cs index 41ca0e0..d3eaf3f 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Extensions/DCExtension.cs +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Extensions/DCExtension.cs @@ -202,10 +202,10 @@ namespace WalkingTec.Mvvm.Core.Extensions //如果没有指定忽略权限,则拼接权限过滤的where条件 if (ignorDataPrivilege == false) { - query = AppendSelfDPWhere(query,wtmcontext,dps); + query = AppendSelfDPWhere(query, wtmcontext, dps); } - if (typeof(IPersistPoco).IsAssignableFrom( typeof(T))) + if (typeof(IPersistPoco).IsAssignableFrom(typeof(T))) { var mod = new IsValidModifier(); var newExp = mod.Modify(query.Expression); @@ -277,23 +277,15 @@ namespace WalkingTec.Mvvm.Core.Extensions private static IQueryable AppendSelfDPWhere(IQueryable query, WTMContext wtmcontext, List dps) where T : TopBasePoco { var dpsSetting = wtmcontext?.DataPrivilegeSettings; - Type modelTye = typeof(T); - bool isBasePoco = typeof(IBasePoco).IsAssignableFrom(modelTye); - ParameterExpression pe = Expression.Parameter(modelTye); - Expression peid = Expression.Property(pe, modelTye.GetSingleProperty("ID")); + ParameterExpression pe = Expression.Parameter(typeof(T)); + Expression peid = Expression.Property(pe, typeof(T).GetSingleProperty("ID")); //循环数据权限,加入到where条件中,达到自动过滤的效果 - - Expression selfexp = Expression.NotEqual(Expression.Constant(1), Expression.Constant(1)); - if(isBasePoco == true) - { - selfexp = Expression.Equal(Expression.Property(pe, "CreateBy"), Expression.Constant(wtmcontext.LoginUserInfo?.ITCode)); - } if (dpsSetting?.Where(x => x.ModelName == query.ElementType.Name).SingleOrDefault() != null) { //如果dps参数是空,则生成 1!=1 这种错误的表达式,这样就查不到任何数据了 if (dps == null) { - query = query.Where(Expression.Lambda>(selfexp, pe)); + query = query.Where(Expression.Lambda>(Expression.NotEqual(Expression.Constant(1), Expression.Constant(1)), pe)); } else { @@ -301,14 +293,13 @@ namespace WalkingTec.Mvvm.Core.Extensions var ids = dps.Where(x => x.TableName == query.ElementType.Name).Select(x => x.RelateId).ToList(); if (ids == null || ids.Count() == 0) { - query = query.Where(Expression.Lambda>(selfexp, pe)); + query = query.Where(Expression.Lambda>(Expression.NotEqual(Expression.Constant(1), Expression.Constant(1)), pe)); } else { if (!ids.Contains(null)) { - var exp = Expression.OrElse(selfexp, ids.GetContainIdExpression(typeof(T), pe).Body); - query = query.Where(Expression.Lambda>(exp,pe)); + query = query.Where(ids.GetContainIdExpression()); } } } @@ -324,7 +315,7 @@ namespace WalkingTec.Mvvm.Core.Extensions /// /// 关联表外键 /// 修改后的查询语句 - public static IQueryable DPWhere(this IQueryable baseQuery, WTMContext wtmcontext, params Expression>[] IdFields) where T:TopBasePoco + public static IQueryable DPWhere(this IQueryable baseQuery, WTMContext wtmcontext, params Expression>[] IdFields) where T : TopBasePoco { var dps = wtmcontext?.LoginUserInfo?.DataPrivileges; //循环所有关联外键 @@ -351,7 +342,7 @@ namespace WalkingTec.Mvvm.Core.Extensions } //var test = DPWhere(baseQuery, dps, tableNameList, IdFields); - return DPWhere(baseQuery,wtmcontext,tableNameList, IdFields); + return DPWhere(baseQuery, wtmcontext, tableNameList, IdFields); } #region AddBy YOUKAI 20160310 @@ -364,24 +355,17 @@ namespace WalkingTec.Mvvm.Core.Extensions /// 关联数据权限的表名,如果关联外键为自身,则参数第一个为自身 /// 关联表外键 /// 修改后的查询语句 - public static IQueryable DPWhere(this IQueryable baseQuery,WTMContext wtmcontext,List tableName, params Expression>[] IdFields) where T:TopBasePoco + public static IQueryable DPWhere(this IQueryable baseQuery, WTMContext wtmcontext, List tableName, params Expression>[] IdFields) where T : TopBasePoco { var dps = wtmcontext?.LoginUserInfo?.DataPrivileges; - Type modelTye = typeof(T); - bool isBasePoco = typeof(IBasePoco).IsAssignableFrom(modelTye); // var dpsSetting = BaseVM.AllDPS; - ParameterExpression pe = Expression.Parameter(modelTye); + ParameterExpression pe = Expression.Parameter(typeof(T)); Expression left1 = Expression.Constant(1); Expression right1 = Expression.Constant(1); Expression trueExp = Expression.Equal(left1, right1); Expression falseExp = Expression.NotEqual(left1, right1); Expression finalExp = null; - Expression selfexp = falseExp; - if (isBasePoco == true) - { - selfexp = Expression.Equal(Expression.Property(pe, "CreateBy"), Expression.Constant(wtmcontext.LoginUserInfo?.ITCode)); - } int tindex = 0; //循环所有关联外键 foreach (var IdField in IdFields) @@ -415,7 +399,7 @@ namespace WalkingTec.Mvvm.Core.Extensions //如果dps为空,则拼接一个返回假的表达式,这样就查询不出任何数据 if (dps == null) { - exp = selfexp; + exp = falseExp; } else { @@ -451,7 +435,15 @@ namespace WalkingTec.Mvvm.Core.Extensions //如果没有关联的id,则拼接一个返回假的where,是语句查询不到任何数据 if (ids == null || ids.Count() == 0) { - exp = selfexp; + exp = falseExp; + //if (peid.Type == typeof(Guid)) + //{ + // exp = Expression.Equal(peid, Expression.Constant(Guid.NewGuid())); + //} + //else + //{ + // exp = Expression.Equal(peid, Expression.Constant(null)); + //} } //如果有关联 Id else @@ -485,7 +477,6 @@ namespace WalkingTec.Mvvm.Core.Extensions { exp = ids.GetContainIdExpression(typeof(T), pe, peid).Body; } - exp = Expression.OrElse(selfexp, exp); } } } @@ -601,7 +592,7 @@ namespace WalkingTec.Mvvm.Core.Extensions return rv; } - public static IQueryable CheckID(this IQueryable baseQuery, object val, Expression> member=null) + public static IQueryable CheckID(this IQueryable baseQuery, object val, Expression> member = null) { ParameterExpression pe = Expression.Parameter(typeof(T)); PropertyInfo idproperty = null; @@ -625,7 +616,7 @@ namespace WalkingTec.Mvvm.Core.Extensions idproperty = typeof(T).GetSingleProperty("ParentId"); Expression peid = Expression.Property(pe, idproperty); var p = Expression.Call(peid, "ToString", new Type[] { }); - if(val == null) + if (val == null) { return baseQuery.Where(Expression.Lambda>(Expression.Equal(peid, Expression.Constant(null)), pe)); } @@ -638,7 +629,7 @@ namespace WalkingTec.Mvvm.Core.Extensions public static IQueryable CheckIDs(this IQueryable baseQuery, List val, Expression> member = null) { - if(val == null) + if (val == null) { return baseQuery; } @@ -658,7 +649,7 @@ namespace WalkingTec.Mvvm.Core.Extensions } - public static IQueryable CheckNotNull(this IQueryable baseQuery, Expression> member) + public static IQueryable CheckNotNull(this IQueryable baseQuery, Expression> member) { return baseQuery.CheckNotNull(member.GetPropertyName()); } @@ -695,7 +686,7 @@ namespace WalkingTec.Mvvm.Core.Extensions { return baseQuery; } - else if(val is string s && string.IsNullOrEmpty(s)) + else if (val is string s && string.IsNullOrEmpty(s)) { return baseQuery; } diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Json/DynamicDataConverter.cs b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Json/DynamicDataConverter.cs index 921c8a1..37f0a1d 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Json/DynamicDataConverter.cs +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Json/DynamicDataConverter.cs @@ -71,7 +71,7 @@ namespace WalkingTec.Mvvm.Core.Json { if(item.Value == null) { - if (options.IgnoreNullValues == false) + if (options.DefaultIgnoreCondition == JsonIgnoreCondition.Never) { writer.WriteNull(item.Key); } diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Json/PocoConverter.cs b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Json/PocoConverter.cs index 3697017..05ec9fc 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Json/PocoConverter.cs +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Json/PocoConverter.cs @@ -54,12 +54,9 @@ namespace WalkingTec.Mvvm.Core.Json rv.DefaultIgnoreCondition = op.DefaultIgnoreCondition; rv.DictionaryKeyPolicy = op.DictionaryKeyPolicy; rv.Encoder = op.Encoder; - rv.IgnoreNullValues = op.IgnoreNullValues; rv.IgnoreReadOnlyFields = op.IgnoreReadOnlyFields; rv.IgnoreReadOnlyProperties = op.IgnoreReadOnlyProperties; rv.IncludeFields = op.IncludeFields; - rv.DefaultIgnoreCondition = op.DefaultIgnoreCondition; - rv.DictionaryKeyPolicy = op.DictionaryKeyPolicy; rv.MaxDepth = op.MaxDepth; rv.NumberHandling = op.NumberHandling; rv.ReadCommentHandling = op.ReadCommentHandling; diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Support/WTMLogger.cs b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Support/WTMLogger.cs index ca5ffa8..83e2916 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Support/WTMLogger.cs +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Support/WTMLogger.cs @@ -69,7 +69,7 @@ namespace WalkingTec.Mvvm.Core .Select(x => x.LogLevel).FirstOrDefault(); if (level == null) { - level = LogLevel.Error; + level = LogLevel.None; } if (logLevel >= level) { diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Utils.cs b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Utils.cs index e6ad09e..c274aae 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Utils.cs +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/Utils.cs @@ -655,9 +655,9 @@ namespace WalkingTec.Mvvm.Core return stringDecrypted; } - private static DESCryptoServiceProvider GenerateDESCryptoServiceProvider(string key) + private static DES GenerateDESCryptoServiceProvider(string key) { - DESCryptoServiceProvider dCrypter = new DESCryptoServiceProvider(); + var dCrypter = DES.Create(); string sTemp; if (dCrypter.LegalKeySizes.Length > 0) @@ -730,7 +730,7 @@ namespace WalkingTec.Mvvm.Core private static string MD5String(byte[] buffer) { - MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); + var md5 = MD5.Create(); byte[] cryptBuffer = md5.ComputeHash(buffer); StringBuilder sb = new StringBuilder(); foreach (byte item in cryptBuffer) diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/WalkingTec.Mvvm.Core.csproj b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/WalkingTec.Mvvm.Core.csproj index 0fa8616..dac8f92 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/WalkingTec.Mvvm.Core.csproj +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Core/WalkingTec.Mvvm.Core.csproj @@ -1,6 +1,6 @@ - net5.0 + net6.0 WalkingTec.Mvvm WalkingTec.Mvvm.Core $(AssemblyName) @@ -13,32 +13,32 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + + all runtime; build; native; contentfiles; analyzers - - - - - - - - - - - - + + + + + + + + + + + + - + diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/Filters/FrameworkFilter.cs b/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/Filters/FrameworkFilter.cs index d85688a..7e9f50c 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/Filters/FrameworkFilter.cs +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/Filters/FrameworkFilter.cs @@ -203,7 +203,7 @@ namespace WalkingTec.Mvvm.Mvc.Filters { check = m.Groups[1] + "[0]" + m.Groups[2]; } - if (model.FC.ContainsKey(check) == false) + if (model.FC.Keys.Any(x=>x.ToLower() == check.ToLower()) == false) { ctrl.ModelState.Remove(v); } @@ -263,9 +263,9 @@ namespace WalkingTec.Mvvm.Mvc.Filters var ctrlActDesc = context.ActionDescriptor as ControllerActionDescriptor; //get viewname string viewName = ""; - if(context.Result is PartialViewResult pvr) + if (context.Result is PartialViewResult pvr) { - viewName = pvr.ViewName??""; + viewName = pvr.ViewName ?? ""; if (viewName?.StartsWith("/") == false) { var viewEngine = context.HttpContext.RequestServices.GetRequiredService(); diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/Helper/MvcOptionExtension.cs b/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/Helper/MvcOptionExtension.cs index e1f8b97..af567bb 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/Helper/MvcOptionExtension.cs +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/Helper/MvcOptionExtension.cs @@ -47,7 +47,7 @@ namespace WalkingTec.Mvvm.Mvc public static void UseWtmJsonOptions(this JsonOptions options) { options.JsonSerializerOptions.PropertyNamingPolicy = null; - options.JsonSerializerOptions.IgnoreNullValues = true; + options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString; options.JsonSerializerOptions.AllowTrailingCommas = true; options.JsonSerializerOptions.Converters.Add(new DateTimeConverter()); diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/WalkingTec.Mvvm.Mvc.csproj b/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/WalkingTec.Mvvm.Mvc.csproj index f7daed1..931b5f0 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/WalkingTec.Mvvm.Mvc.csproj +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/WalkingTec.Mvvm.Mvc.csproj @@ -1,6 +1,6 @@ - net5.0 + net6.0 WalkingTec.Mvvm WalkingTec.Mvvm.Mvc true @@ -59,11 +59,13 @@ - - - - - + + + + + + + diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/_FrameworkController.cs b/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/_FrameworkController.cs index 992d877..4124034 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/_FrameworkController.cs +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/_FrameworkController.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Linq.Expressions; @@ -16,6 +14,12 @@ using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using SixLabors.Fonts; +using SixLabors.ImageSharp; +using SixLabors.ImageSharp.Drawing; +using SixLabors.ImageSharp.Drawing.Processing; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using WalkingTec.Mvvm.Core; using WalkingTec.Mvvm.Core.Extensions; using WalkingTec.Mvvm.Core.Models; @@ -307,7 +311,7 @@ namespace WalkingTec.Mvvm.Mvc } var FileData = Request.Form.Files[0]; - Image oimage = Image.FromStream(FileData.OpenReadStream()); + Image oimage = Image.Load(FileData.OpenReadStream()); if (oimage == null) { return JsonMore(new { Id = string.Empty, Name = string.Empty }, StatusCodes.Status404NotFound); @@ -321,7 +325,8 @@ namespace WalkingTec.Mvvm.Mvc height = width * oimage.Height / oimage.Width; } MemoryStream ms = new MemoryStream(); - oimage.GetThumbnailImage(width.Value, height.Value, null, IntPtr.Zero).Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); + oimage.Mutate(x => x.Resize(width.Value, height.Value)); + oimage.SaveAsJpeg(ms); ms.Position = 0; var file = fp.Upload(FileData.FileName, ms.Length, ms, groupName,subdir,extra,sm, Wtm.CreateDC(cskey: _DONOT_USE_CS)); @@ -368,7 +373,7 @@ namespace WalkingTec.Mvvm.Mvc try { rv = file.DataStream; - Image oimage = Image.FromStream(rv); + Image oimage = Image.Load(rv); if (oimage != null && (width != null || height != null)) { if (width == null) @@ -380,7 +385,8 @@ namespace WalkingTec.Mvvm.Mvc height = oimage.Height * width / oimage.Width; } var ms = new MemoryStream(); - oimage.GetThumbnailImage(width.Value, height.Value, null, IntPtr.Zero).Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); + oimage.Mutate(x => x.Resize(width.Value, height.Value)); + oimage.SaveAsJpeg(ms); rv.Dispose(); rv = ms; } @@ -632,8 +638,8 @@ namespace WalkingTec.Mvvm.Mvc LocalizeMenu(resultMenus); return Content(JsonSerializer.Serialize(new { Code = 200, Msg = string.Empty, Data = resultMenus }, new JsonSerializerOptions() { - IgnoreNullValues = true - }), "application/json"); + DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault + }), "application/json") ; } else { @@ -644,7 +650,7 @@ namespace WalkingTec.Mvvm.Mvc LocalizeMenu(resultMenus); return Content(JsonSerializer.Serialize(new { Code = 200, Msg = string.Empty, Data = resultMenus }, new JsonSerializerOptions() { - IgnoreNullValues = true + DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault }), "application/json"); } } @@ -714,7 +720,7 @@ namespace WalkingTec.Mvvm.Mvc { int codeW = 80; int codeH = 30; - int fontSize = 16; + int fontSize = 20; string chkCode = string.Empty; Color[] color = { Color.Black, Color.Red, Color.Blue, Color.Green, Color.Orange, Color.Brown, Color.DarkBlue, Color.PaleGreen }; string[] font = { "Times New Roman" }; @@ -729,34 +735,32 @@ namespace WalkingTec.Mvvm.Mvc HttpContext.Session.Set("verify_code", chkCode); //创建画布 - Bitmap bmp = new Bitmap(codeW, codeH); - Graphics g = Graphics.FromImage(bmp); - g.Clear(Color.Linen); + Image bmp = new Image(codeW, codeH); //画噪线 for (int i = 0; i < 3; i++) { - int x1 = rnd.Next(codeW); - int y1 = rnd.Next(codeH); - int x2 = rnd.Next(codeW); - int y2 = rnd.Next(codeH); + float x1 = rnd.Next(codeW); + float y1 = rnd.Next(codeH); + float x2 = rnd.Next(codeW); + float y2 = rnd.Next(codeH); Color clr = color[rnd.Next(color.Length)]; - g.DrawLine(new Pen(clr), x1, y1, x2, y2); + bmp.Mutate(x => x.DrawLines(clr, 1.0f, new PointF(x1,y1), new PointF(x2,y2))); } //画验证码 for (int i = 0; i < chkCode.Length; i++) { string fnt = font[rnd.Next(font.Length)]; - Font ft = new Font(fnt, fontSize); + Font ft = new Font(SystemFonts.Find(fnt), fontSize); Color clr = color[rnd.Next(color.Length)]; - g.DrawString(chkCode[i].ToString(), ft, new SolidBrush(clr), (float)i * 18, (float)0); + bmp.Mutate(x => x.DrawText(chkCode[i].ToString(),ft,clr,new PointF((float)i * 18, (float)0))); } //将验证码写入图片内存流中,以image/png格式输出 MemoryStream ms = new MemoryStream(); try { - bmp.Save(ms, ImageFormat.Png); + bmp.SaveAsPng(ms); return File(ms.ToArray(), "image/jpeg"); } catch (Exception) @@ -765,7 +769,6 @@ namespace WalkingTec.Mvvm.Mvc } finally { - g.Dispose(); bmp.Dispose(); } } diff --git a/WalkingTec.Mvvm/WalkingTec.Mvvm.TagHelpers.LayUI/DataTableTagHelper.cs b/WalkingTec.Mvvm/WalkingTec.Mvvm.TagHelpers.LayUI/DataTableTagHelper.cs index 6ad0e7a..5a399d3 100644 --- a/WalkingTec.Mvvm/WalkingTec.Mvvm.TagHelpers.LayUI/DataTableTagHelper.cs +++ b/WalkingTec.Mvvm/WalkingTec.Mvvm.TagHelpers.LayUI/DataTableTagHelper.cs @@ -557,7 +557,7 @@ namespace WalkingTec.Mvvm.TagHelpers.LayUI } var joption = new JsonSerializerOptions(); joption.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)); - joption.IgnoreNullValues = true; + joption.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; output.PostElement.AppendHtml($@"