jQuery TOOLS / Expose - Make your HTML elements stand out

ExposeJS是一款JavaScript工具,用于突出显示页面上的HTML元素,并使周围元素逐渐淡化。该工具可用于覆盖层、表单、图像、视频等多种场景,可通过CSS自定义遮罩外观。

Keywords:expose html,expose html jquery,javascript expose,stand out html javascript,javascript expose plugin

Description:Make your HTML elements stand out

 

Demo

Start entering text on the input fields below and you'll see the masking effect:

Username
Password

The story

Expose is a JavaScript tool that exposes selected HTML elements on the page so that the surrounding elements will gradually fade out. The exposing effect was first introduced in the overlay tool. Usually the effect is an integral part of the program and cannot be used separately. This tool takes the idea of exposing a little further. It is a separate tool that can be used as a general purpose masking utility. You can use it for overlays, forms, images, videos or Flash objects. You can use CSS to tweak the look of the mask.

Usage

Here are some most common ways of using the mask:

// place a white mask over the page
$(document).mask();

// place a custom colored mask over the page
$(document).mask("#789");

// place a non-closable mask
$(document).mask{ closeOnEsc: false, closeOnClick: false });

// place a mask but let selected elements show through (expose)
$("div.to_be_exposed").expose();

// close the mask
$.mask.close();

There are two different calls: mask and expose. The mask method is only available for the document object and you cannot use any other selector. The expose() method can take any jQuery selector and all elements returned by the selector are placed on top of the mask.

The mask is loaded immediately after the expose or mask call. You can supply a different configuration on each call and the latest call is remembered. A subsequent expose call for example will use the previously used configuration if no arguments are given.

You can also use an existing element as a mask. By default the tool uses an element whose id is exposeMask and if it does not exist already exist then it will be created automatically.

Demos

We believe that the best way to learn is through demos. The following demos are fully documented and a standalone page is provided to get mask working on your site. It's really important to study the first demo "Minimal setup for mask" because it teaches you the basics of using the library.

Expose and Flowplayer demos

These demos show how to use a video player together with the mask tool:

Mask Graphics

Download tooltip graphics

You can use our graphics as the basis for your design. You can freely change the design as you see fit. Click the image on the right to download a zip file. Before using the graphics, you should consult the User's Guideon how graphics can be used when designing the look and feel of the tools.

Here are a few examples of what is included in the zip file:


 

Configuration

Here is a full list of available configuration options:

propertydefaultdescription
closeOnClicktrueSpecifies whether the masking disappears when the mask is clicked. By default, this is set to true.
closeOnEsctrueSpecifies whether masking disappears when the ESC key is pressed from the keyboard. By default, this is set to true.
closeSpeed'fast'How quickly the mask disappears. Possible values are 'slow', 'normal' and 'fast or you can supply the number of milliseconds. For example, a value of 2000 will cause the mask to disappear in 2 seconds. By setting this to zero there is no animation and the mask disappears immediately.
color'#fff'The background color of the mask. This will dramatically affect how it appears. If you supply a value of null here, you can control the background color with CSS. See themaskId property below for more information.
loadSpeed'slow'How quickly the mask will appear. Possible values are 'slow', 'normal' and 'fast or you can supply the number of milliseconds. For example, a value of 2000 will cause the mask to appear in 2 seconds. By setting this to zero there is no animation and the mask appears immediately.
maskId'exposeMask'The mask is a normal div element placed on top of your page and whose size is automatically adjusted to cover the user's screen completely. You can style it normally with CSS just like any other element on the page. By default, the mask's id is set to mask, but you can change that with tis configuration option. Since version 1.2.0 you can use an existing element as the mask if it's id matches the one given in this configuration option.
opacity0.8The transparency setting of the mask. A decimal value from 0 to 1. A bigger value means less transparency while a value of 0 is fully transparent (invisible).
startOpacity0 since 1.2.0. The initial transparency level of the mask before it starts fading in to the desired opacity as specified by the opacity option. A decimal value from 0 to 1. A bigger value means less transparency while a value of 0 is fully transparent (invisible). For example, you can start with full opacity and gradually fade to a semi-transparent mask.
zIndex9998This is the z-index CSS property for the mask. The zIndex specifies the placement of the element along the z-axis of the document. The default zIndex value is very high, so it is unlikely that you will need to alter it; however, this value must be greater than the z-index of any other element on the page so that the overlay will always be visible when called.
onBeforeLoadThis callback function is triggered before the masking effect. Returning false or callingevent.preventDefault() in the callback prevents masking from occurring.
onLoadThis callback function is triggered after masking takes place.
onBeforeCloseThis callback function is triggered before mask is closed. Returning false or callingevent.preventDefault() in the callback prevents it from closing.
onCloseThis callback function is triggered when mask is closed.

Here is an example of an onBeforeLoad callback function given in configuration. Inside any callback function the this variable is a pointer to the mask scripting API.

$("#mydiv").expose({

	// before masking begins ...
	onBeforeLoad: function(event) {

		// grow the exposed elements smoothly by 100 pixels
		this.getExposed().animate({width: '+=100'});
	}
});

Note: unlike other jQuery Tools you can supply callbacks only from the configuration and you can assign only one callback for the same event.

Scripting API

Unlike other jQuery Tools in this library the mask is a singleton. Only one mask instance can exist at any given time. This singleton can be accessed directly with $.mask or via the this variable inside callback functions.

Method listing

methodreturn valuedescription/example
close()APICloses the mask.
fit()APIForces the mask to fill the whole document. This is usually not needed since the tool itself does this. You'll need this on occasions when the mask is loaded and your document has grown in size in the meantime.
isLoaded(fully)booleanReturns true if mask is loaded. Since 1.2.4 you can supply a boolean argument that makes sure that the function returns true only if the mask is fully visible in it's final position and opacity.
getMask()jQueryReturns the mask as a jQuery object. You can use jQuery methods such as css oranimate to modify it.
getExposed()jQueryReturns exposed elements (if any) as a jQuery object.
getConf()ObjectReturns the masking configuration.

 

原文地址:http://flowplayer.org/tools/toolbox/expose.html

 

 

<think>我们有一个Dockerfile,用于构建一个基于Alpine Linux的Java应用镜像。 这个Dockerfile的目标是运行一个名为jeecg-cloud-gateway的Java网关服务。 下面逐行解读Dockerfile: 1. `FROM anapsix/alpine-java:8_server-jre_unlimited` 使用基础镜像:anapsix/alpine-java,标签是8_server-jre_unlimited。这是一个基于Alpine Linux的镜像,预装了Java 8 Server JRE,并且没有内存使用限制。 2. `MAINTAINER jeecgos@163.com` 维护者信息,现在已经不推荐使用MAINTAINER,而是使用LABEL,但这里仍然使用MAINTAINER指定维护者的邮箱。 3. `RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime` 设置时区为Asia/Shanghai。通过软链接将上海时区文件覆盖本地时间配置。 4. `RUN mkdir -p /jeecg-cloud-gateway` 在容器中创建一个目录`/jeecg-cloud-gateway`,`-p`参数确保如果目录存在也不会报错。 5. `WORKDIR /jeecg-cloud-gateway` 设置工作目录为`/jeecg-cloud-gateway`,即后续的指令(如ADD、RUN等)都会在这个目录下执行。 6. `EXPOSE 9999` 声明容器运行时监听的端口为9999。这只是一个声明,实际运行时需要映射到宿主机端口。 7. `ADD ./target/jeecg-cloud-gateway-2.4.6.jar ./` 将构建上下文中的`./target/jeecg-cloud-gateway-2.4.6.jar`文件添加到容器的当前目录(即`/jeecg-cloud-gateway`)下,并保持原名。 8. `CMD sleep 10;java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-gateway-2.4.6.jar` 容器启动时执行的命令。这里有两个命令: - `sleep 10`:等待10秒,可能是为了等待依赖服务(如数据库、配置中心等)启动完成。 - `java ...`:运行Java程序。参数说明: - `-Dfile.encoding=utf-8`:设置JVM的默认文件编码为UTF-8。 - `-Djava.security.egd=file:/dev/./urandom`:设置随机数生成源,使用非阻塞的随机数生成器,可以加速Tomcat的启动。 - `-jar jeecg-cloud-gateway-2.4.6.jar`:运行指定的jar包。 注意:CMD指令在Dockerfile中只能有一个,如果写了多个,只有最后一个生效。这里使用分号将两个命令连接起来,所以它们会按顺序执行。 但是,这里有一个潜在问题:`CMD`指令中使用了分号连接两个命令,这会导致容器启动时先休眠10秒,然后启动Java程序。这种方式在需要等待其他服务的情况下是可行的,但固定等待时间可能不是最佳实践(因为依赖服务可能启动得更快或更慢)。 另外,在Dockerfile中,我们通常使用`ENTRYPOINT`来设置启动命令,而`CMD`用于传递参数。但这里直接使用了`CMD`。 改进建议: - 如果是为了等待其他服务,可以考虑使用更健壮的等待脚本(如等待数据库端口可用),而不是固定时间。 - 可以将`CMD`指令改为一个脚本,在脚本中实现等待逻辑,然后启动Java程序。 不过,这个Dockerfile已经能够满足基本需求。 总结:这个Dockerfile构建了一个运行jeecg-cloud-gateway服务的Docker镜像,基于轻量级的Alpine Linux,设置了时区,暴露了9999端口,并在启动时等待10秒后运行Java服务。</think>### Dockerfile 代码解读 以下是对提供的 Dockerfile 的逐行解析: ```dockerfile FROM anapsix/alpine-java:8_server-jre_unlimited ``` - **作用**: 指定基础镜像 - **解释**: 使用 `anapsix/alpine-java` 镜像作为基础,该镜像基于轻量级 Alpine Linux 并预装了 Java 8 Server JRE - **标签说明**: - `8`: Java 8 版本 - `server-jre`: Server 版 Java 运行时环境 - `unlimited`: 无内存限制策略 ```dockerfile MAINTAINER jeecgos@163.com ``` - **作用**: 设置镜像维护者信息 - **解释**: 指定镜像维护者的联系邮箱(已弃用语法,现代 Docker 推荐使用 `LABEL`) ```dockerfile RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ``` - **作用**: 配置容器时区 - **解释**: - `ln -sf`: 创建符号链接(软链接) - 将上海时区文件链接到系统本地时间配置 - 确保容器内时间与上海时区一致 ```dockerfile RUN mkdir -p /jeecg-cloud-gateway ``` - **作用**: 创建应用目录 - **解释**: - `mkdir -p`: 递归创建目录(如果不存在) - 创建 `/jeecg-cloud-gateway` 作为应用工作目录 ```dockerfile WORKDIR /jeecg-cloud-gateway ``` - **作用**: 设置工作目录 - **解释**: 后续命令都在此目录下执行(相当于 `cd /jeecg-cloud-gateway`) ```dockerfile EXPOSE 9999 ``` - **作用**: 声明容器监听端口 - **解释**: 应用将在 9999 端口提供服务(运行时需通过 `-p` 映射到宿主机) ```dockerfile ADD ./target/jeecg-cloud-gateway-2.4.6.jar ./ ``` - **作用**: 添加应用 JAR 文件 - **解释**: - 从构建上下文(本地目录)复制 JAR 文件到容器 - `./target/`: 本地构建输出目录 - `./`: 容器当前目录(即 `/jeecg-cloud-gateway`) ```dockerfile CMD sleep 10;java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-gateway-2.4.6.jar ``` - **作用**: 容器启动命令 - **命令分解**: 1. `sleep 10`: 等待 10 秒(通常用于等待依赖服务就绪) 2. `java`: 启动 JVM 3. `-Dfile.encoding=utf-8`: 设置文件编码为 UTF-8 4. `-Djava.security.egd=file:/dev/./urandom`: 使用非阻塞随机数生成器(加速启动) 5. `-jar jeecg-cloud-gateway-2.4.6.jar`: 运行指定 JAR 文件 ### 完整 Dockerfile 功能总结 ```dockerfile # 使用轻量级Java基础镜像 FROM anapsix/alpine-java:8_server-jre_unlimited # 设置维护者信息 MAINTAINER jeecgos@163.com # 配置上海时区 RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime # 创建应用目录 RUN mkdir -p /jeecg-cloud-gateway # 设置工作目录 WORKDIR /jeecg-cloud-gateway # 暴露应用端口 EXPOSE 9999 # 添加构建好的JAR文件 ADD ./target/jeecg-cloud-gateway-2.4.6.jar ./ # 启动命令:等待10秒后运行Java应用 CMD sleep 10;java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-gateway-2.4.6.jar ``` ### 构建与运行示例 #### 1. 构建 Docker 镜像 ```bash docker build -t jeecg-gateway:2.4.6 . ``` #### 2. 运行容器 ```bash docker run -d \ --name jeecg-gateway \ -p 9999:9999 \ # 端口映射 -v ./logs:/app/logs \ # 日志持久化 jeecg-gateway:2.4.6 ``` ### 优化建议 1. **多阶段构建**: ```dockerfile FROM maven:3.6-jdk-8 AS build WORKDIR /app COPY . . RUN mvn clean package -DskipTests FROM anapsix/alpine-java:8_server-jre_unlimited COPY --from=build /app/target/jeecg-cloud-gateway-*.jar /app.jar CMD ["java", "-jar", "/app.jar"] ``` 2. **健康检查**: ```dockerfile HEALTHCHECK --interval=30s --timeout=3s \ CMD curl -f http://localhost:9999/actuator/health || exit 1 ``` 3. **使用 ENTRYPOINT + CMD**: ```dockerfile ENTRYPOINT ["java", "-Dfile.encoding=utf-8", "-Djava.security.egd=file:/dev/./urandom", "-jar"] CMD ["jeecg-cloud-gateway-2.4.6.jar"] ``` 4. **环境变量配置**: ```dockerfile ENV JAVA_OPTS="-Xms512m -Xmx1024m" CMD sleep 10; java ${JAVA_OPTS} -jar jeecg-cloud-gateway-2.4.6.jar ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值