jQuery Overlay @ jQuery TOOLS - Overlay your HTML with eyecandy

本文介绍了一种使用jQuery实现的通用JavaScript覆盖层效果,具备苹果风格的外观与体验。通过简单的配置即可创建轻量级的覆盖层,适用于模态对话框、图片灯箱等多种场景。文章提供了丰富的示例及API说明。

Usage

The general way to setup overlay is as follows:

// select one or more elements to be overlay triggers
$(".my_overlay_trigger").overlay({

	// one configuration property
	color: '#ccc',

	// another property
	top: 50

	// ... the rest of the configuration properties
});

When you click on one of the triggers it will open an overlay that is being specified by the trigger's rel attribute. Look at theminimal setup to get started quickly.

Demos

You can study the workings of overlay in the following examples. Each contains documented source code, along with a standalone page to allow you to easily transfer the examples to your own site. The most important example is the first one, "Minimal setup for overlay".

Combining overlay with Flowplayer

These demos provide some examples of how to use overlay and Flowplayer together.

Overlay 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:


White overlay White overlay White overlay

Configuration

Here is a list of all available configuration options:

PropertyDefault valueDescription
closeA jQuery selector for the closing elements inside the overlay. These can be any elements such as links, buttons or images. If this is not supplied, a close element is auto-generated. Read more about this in defining close actions.
closeOnClicktrueBy default, overlays are closed when the mouse is clicked outside the overlay area. Setting this property to false suppresses this behaviour which is suitable formodal dialogs.
closeOnEsctrueBy default, overlays are closed when the ESC keyboard key is pressed. Setting this property to false suppresses this behaviour.
effect'default'

The effect to be used when an overlay is opened and closed. This can dramatically change the behaviour of the overlay. By default this tool uses an effect called "default" which is a simple show/hide effect.

Here is a list of currently available effects and you can also make your own effects.

fixedtrue since 1.2.0. whether overlay stays in the same position while the screen is scrolled. This is the default behaviour for all browsers except IE6 and below. IE6 does not support fixed positioning. If this property is set to false then the overlay is positioned in relationship to the document so that when the screen is scrolled then the overlay moves along with the document.
maskPreviously known as expose. Overlay is very often used together with the Mask Tool. Because of this, the support for this feature has been built inside the tool. This option accepts the mask configuration. This is either a simple string specifying the background color of the mask or a more complex object literal specifying more configuration variables.

See an example of an overlay together with mask. By default masking is disabled.

left"center"Specifies how far from the left-hand edge of the screen the overlay should be placed. By default the overlay is horizontally centered with the value "center" but you can also supply a numerical value specifying a distance in pixels.
loadfalse since 1.2.0. If enabled then the overlay loads immediately after it has been initialized.
oneInstancetrueBy default, there can be only one overlay on the page at once. Setting this property to false allows you to have multiple overlay instances.
speed'normal'The speed of the fade-in animation on the "default" effect. Valid values are 'slow', 'normal' and 'fast', or you can supply a numerical value (in milliseconds). By setting this property to 0, the overlay will appear immediately without any animation.
targetThe element to be overlayed (if not specified in the rel attribute of the triggering element).
top'10%'Specifies how far from the top edge of the screen the overlay should be placed. Acceptable values are an integer number specifying a distance in pixels, a string (such as '15%') specifying a percentage value or "center" in which case the overlay is vertically centered. Percentage values work consistently at different screen resolutions.

Events

Make sure you have read about Events in jQuery Tools. All event listeners receive the Event Object as the first argument and there are no other arguments for Overlay.

eventWhen it occurs?
onBeforeLoadbefore the overlay is displayed. The overlay has already been positioned at the location from where it will start animating.
onLoadwhen the overlay has completely been displayed
onBeforeClosebefore the overlay is closed
onClosewhen the overlay is closed

Scripting API

First make sure you have familiarized yourself with jQuery Tools scripting. Here is a list of all available API methods:

MethodReturn value typeDescription
close()OverlayCloses the overlay.
getClosers()jQueryReturns the closing element(s) as a jQuery object.
getConf()ObjectReturns the configuration for the overlay.
getOverlay()jQueryReturns the overlayed element as a jQuery object.
getTrigger()jQueryReturns the triggering element as a jQuery object.
isOpened()booleanReturns true if the overlay is opened.
load()OverlayOpens the overlay.

Defining custom close elements

By default, a close button is auto-generated as the first element inside the container. Here is the generated HTML:

<!-- auto- generated close button -->
<div class="close"></div>

You can easily add more closing elements inside the overlay simply by assigning the CSS class name "close" to them. These elements can be styled and positioned any way you like inside the overlay.

 

If you supply a value for the 

close

 configuration variable, the close element is not auto-generated and you need to define the closing element(s) yourself.

 

Making custom effects

If you want to make custom effects you should use the $.tools.overlay.addEffect method. This method is "static", meaning that you don't have to have the overlay API (or instance) already loaded. You can add effects before any overlays are initialized.

This method accepts three arguments. The first argument is the effect name, the second argument is the function that performs the required functionality for loading the overlay and the third argument is a function that closes the overlay. You can use this method to modify existing effects or add new ones. Here is the official default effect taken directly from the source code of the overlay tool:

// adds an effect called "myEffect" to the overlay
$.tools.overlay.addEffect("myEffect", function(position, done) {

      /*
        - 'this' variable is a reference to the overlay API
        - here we use jQuery's fadeIn() method to perform the effect
      */
      this.getOverlay().css(position).fadeIn(this.getConf().speed, done);
   },

   // close function
   function(done) {

      // fade out the overlay
      this.getOverlay().fadeOut(this.getConf().closeSpeed, done);
   }
);

As you can see it is fairly easy to implement effects. Inside the functions the this variable is a pointer to the scripting API. This gives you access to various parts of the overlay elements.

The loading function receives two arguments. The first argument position defines the top and left properties given in the configuration. The second argument is a callback function that must be called after you have performed your loading effect.

The done callback received as an argument must be called after you have performed you effect. The reason for this is that many times those effects perform animations that have a certain duration. We must know when these animations are finished so that the onLoad and onHide events are really called after the overlay is completely shown or hidden.

Note: if you are using jQuery's animatefadeIn or fadeOut methods the done function can simply be given to this method as the last argument. jQuery will take care of it after the animation finishes. Otherwise you must call done.call().

Here is one custom overlay effect demo.

 

原文地址:http://flowplayer.org/tools/overlay/index.html

Keywords:javascript overlay,jquery lightbox,jquery applebox,jquery overlay,jquery overlayed content,applebox,apple box

Description:Generic JavaScript overlays with Apple-like look and feel


内容概要:本文介绍了一种基于蒙特卡洛模拟和拉格朗日优化方法的电动汽车充电站有序充电调度策略,重点针对分时电价机制下的分散式优化问题。通过Matlab代码实现,构建了考虑用户充电需求、电网负荷平衡及电价波动的数学模【电动汽车充电站有序充电调度的分散式优化】基于蒙特卡诺和拉格朗日的电动汽车优化调度(分时电价调度)(Matlab代码实现)型,采用拉格朗日乘子法处理约束条件,结合蒙特卡洛方法模拟大量电动汽车的随机充电行为,实现对充电功率和时间的优化分配,旨在降低用户充电成本、平抑电网峰谷差并提升充电站运营效率。该方法体现了智能优化算法在电力系统调度中的实际应用价值。; 适合人群:具备一定电力系统基础知识和Matlab编程能力的研究生、科研人员及从事新能源汽车、智能电网相关领域的工程技术人员。; 使用场景及目标:①研究电动汽车有序充电调度策略的设计与仿真;②学习蒙特卡洛模拟与拉格朗日优化在能源系统中的联合应用;③掌握基于分时电价的需求响应优化建模方法;④为微电网、充电站运营管理提供技术支持和决策参考。; 阅读建议:建议读者结合Matlab代码深入理解算法实现细节,重点关注目标函数构建、约束条件处理及优化求解过程,可尝试调整参数设置以观察不同场景下的调度效果,进一步拓展至多目标优化或多类型负荷协调调度的研究。
内容概要:本文围绕面向制造业的鲁棒机器学习集成计算流程展开研究,提出了一套基于Python实现的综合性计算框架,旨在应对制造过程中数据不确定性、噪声干扰面向制造业的鲁棒机器学习集成计算流程研究(Python代码实现)及模型泛化能力不足等问题。该流程集成了数据预处理、特征工程、异常检测、模型训练与优化、鲁棒性增强及结果可视化等关键环节,结合集成学习方法提升预测精度与稳定性,适用于质量控制、设备故障预警、工艺参数优化等典型制造场景。文中通过实际案例验证了所提方法在提升模型鲁棒性和预测性能方面的有效性。; 适合人群:具备Python编程基础和机器学习基础知识,从事智能制造、工业数据分析及相关领域研究的研发人员与工程技术人员,尤其适合工作1-3年希望将机器学习应用于实际制造系统的开发者。; 使用场景及目标:①在制造环境中构建抗干扰能力强、稳定性高的预测模型;②实现对生产过程中的关键指标(如产品质量、设备状态)进行精准监控与预测;③提升传统制造系统向智能化转型过程中的数据驱动决策能力。; 阅读建议:建议读者结合文中提供的Python代码实例,逐步复现整个计算流程,并针对自身业务场景进行数据适配与模型调优,重点关注鲁棒性设计与集成策略的应用,以充分发挥该框架在复杂工业环境下的优势。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值