jquery tools系列 expose 学习

2016-02-19 15:08 22 1 收藏

想不想get新技能酷炫一下,今天图老师小编就跟大家分享个简单的jquery tools系列 expose 学习教程,一起来看看吧!超容易上手~

【 tulaoshi.com - Web开发 】

如overlay的学习,首先给出操作的html目标代码:
代码如下:
div id="test"
expose test!
/div

div style="margin:0 auto;width:300px"
img src="http://flowplayer.org/tools/img/expose/ball_large.png" id="ball" style="width:130px" /
/div
div style="position:relative;z-index:10000"
button type="button" id="btn_open"open div/button
button type="button" id="btn_close"close div/button
/div

该功能是通过jqueryObject.expose()方法来实现的,其具体实现方式如下:
$("jquery selector").expose({config object}) //该方法通过配置对象将来定制expose的显示。
以下代码为配置参数说明描述:
属性默认值详细描述color'#456'设置页面中非expose(突出显示)区域在expose(突出显示)效果显示时的背景颜色。如果此处未设置背景色,那么expose功能会提供一个默认的颜色。另外属性亦可通过maskId的CSS样式来设置。opacity0.8设置页面中非expose(突出显示)区域在expose(突出显示)效果显示时的背景透明度。该处透明度的取值范围为[0,1],该处值越大,透明度越低。loadSpeed'slow'设置页面中非expose(突出显示)区域在expose(突出显示)效果触发时的显示速度。该处值可设置为:'slow','normal','fast'和毫秒数值。例如:如果此处设置值为2000,那么非expose(突出显示)区域效果将会在2秒钟中内显示完成。如果此处设置值为0,那么非expose(突出显示)区域将会没有动画效果并立即显示出来。closeSpeed'fast'设置页面中非expose(突出显示)区域在expose(突出显示)效果关闭时的关闭速度。该处值可设置为:'slow','normal','fast'和毫秒数值。具体示例可参见本文相关示例。  maskId'exposeMask'非expose(突出显示)区域对应的页面div元素id,它是一个普通的div元素,当expose(突出显示)被触发后,他会自动调整以完全的覆盖整个页面。非expose(突出显示)区域的显示效果可以通过设置该处div的样式来改变。如果此处没有设置,那么该插件会默认提供一个id为exposeMask的div来实现非expose区域。closeOnClickTRUE该属性用于设置非expose区域被点击时,是否关闭expose(突出显示)效果。该属性默认值为true,及非expose区域被点击后,expose效果被关闭。closeOnEscTRUE该属性用于设置Esc键被按下后,是否关闭expose(突出显示)效果。该属性默认值为true,及Esc键被按下后,expose效果被关闭。zIndex9998设置页面设置页面中非expose(突出显示)区域的z-index(CSS)属性。一般情况下,默认的zIndex属性值都非常大,所以这里不需要设置,但是,有一点需要注意的是,该非expose(突出显示)的z-index属性值一定要大于页面中任何一个元素的z-index属性。apiFALSE该属性解释可参见本系列中tabs,scollable等功能同属性的解释。  onBeforeLoad expose(突出显示)效果触发前调用函数。如果该函数返回false,那么expose(突出效果)将会被阻止实现。onLoad expose(突出显示)效果实现后,该函数被触发。onBeforeClose expose(突出显示)效果关闭前调用函数。如果该函数返回false,那么expose(突出效果)将会被阻止关闭。onClose expose(突出显示)效果关闭后,该函数被触发。此外,expose还提供了一系列获取expose对象的方法,这些方法的说明描述如下:
方法返回值详细描述load()API触发expose(突出显示)效果,该方法只有expose(突出显示)被初始化后才能调用成功。close()API关闭expose(突出显示)效果。isLoaded()boolean判断当前expose(突出显示)是否已被触发。getMask()jQuery返回非expose(突出显示)的jquery对象。可以通过jquery的相关方法来改变非expose(突出显示)区域的显示效果。getExposed()jQuery返回expose(突出显示)的jquery对象。getConf()Object返回expose(突出显示)的配置对象。  onBeforeLoad(fn)API同配置文件中onBeforeLoad属性。onLoad(fn)API同配置文件中onLoad属性。onBeforeClose(fn)API同配置文件中onBeforeClose属性。onClose(fn)API同配置文件中onClose属性。对于expose配置对象属性设置及方法调用的具体使用方法如下:
代码如下:
var testApi=$("#test").expose({
color:'#44f',
opacity:0.5,
loadSpeed:2000,
closeSpeed:3000,
closeOnClick:false,
closeOnEsc:false,
api: true,
lazy:true,
onBeforeLoad:function(){
alert("before load!");
},
onLoad:function(){
alert("onLoad!");
},
onBeforeClose:function(){
alert("mask-background:"+this.getMask().css("color")+",exposeId:"+this.getExposed().attr("id")
+"n expose color:"+this.getConf().color);
//alert("Before close!");
},
onClose:function(){
alert("Close!");
}

});


$("#test").click(function() {
testApi.load();
});

$("#btn_open").click(function(){
testApi.load();
});
$("#btn_close").click(function(){
testApi.close();
});

alert("test is load:"+testApi.isLoaded());

$("#ball").expose({
//此处通过maskId中样式的backgroundcolor来设置color属性
maskId:'mask',
opacity:0.5,
closeSpeed:'slow',
onBeforeLoad:function(){
this.getExposed().animate({width:298});
},
onBeforeClose:function(){
this.getExposed().animate({width:130});
}

}).click(function(){
$(this).expose().load();
});

最后,给出完整示例代码及该功能得部分demo图片:
代码如下:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

script src="http://flowplayer.org/tools/js/tools/1.0.2/jquery.tools.min.js" /script
style!--
#test {
border:1px solid #ccc;
background-color:#fff;
padding:50px;
font-size:30px;
margin:20px auto;
text-align:center;
width:600px;
}
#mask {
background:#072a88 url(http://flowplayer.org/tools/img/expose/mask_star_1600px.jpg) no-repeat scroll 50% -274px;
}
--/stylestyle #test {
border:1px solid #ccc;
background-color:#fff;
padding:50px;
font-size:30px;
margin:20px auto;
text-align:center;
width:600px;
}
#mask {
background:#072a88 url(http://flowplayer.org/tools/img/expose/mask_star_1600px.jpg) no-repeat scroll 50% -274px;
}/style

div id="test"
expose test!
/div

div style="margin:0 auto;width:300px"
img src="http://flowplayer.org/tools/img/expose/ball_large.png" id="ball" style="width:130px" /
/div
div style="position:relative;z-index:10000"
button type="button" id="btn_open"open div/button
button type="button" id="btn_close"close div/button
/div
script type="text/javascript"!--
$(function(){

var testApi=$("#test").expose({
color:'#44f',
opacity:0.5,
loadSpeed:2000,
closeSpeed:3000,
closeOnClick:false,
closeOnEsc:false,
api: true,
lazy:true,
onBeforeLoad:function(){
alert("before load!");
},
onLoad:function(){
alert("onLoad!");
},
onBeforeClose:function(){
alert("mask-background:"+this.getMask().css("color")+",exposeId:"+this.getExposed().attr("id")
+"n expose color:"+this.getConf().color);
//alert("Before close!");
},
onClose:function(){
alert("Close!");
}

});


$("#test").click(function() {
testApi.load();
});

$("#btn_open").click(function(){
testApi.load();
});
$("#btn_close").click(function(){
testApi.close();
});

alert("test is load:"+testApi.isLoaded());

$("#ball").expose({
//此处通过maskId中样式的backgroundcolor来设置color属性
maskId:'mask',
opacity:0.5,
closeSpeed:'slow',
onBeforeLoad:function(){
this.getExposed().animate({width:298});
},
onBeforeClose:function(){
this.getExposed().animate({width:130});
}

}).click(function(){
$(this).expose().load();
});

});
// --/script

来源:https://www.tulaoshi.com/n/20160219/1608997.html

延伸阅读
标签: Web开发
1、属性: 为所有匹配的元素设置一个计算的属性值 //为所有的input添加属性class="btn" //$("input").attr("class","btn"); 2、CSS:为每个匹配的元素添加指定的类名 //对所有的提交按钮添加样式 $("input:submit").addClass("btn"); 3、值:获得第一个匹配元素的当前值 //取的某一按钮的值 //alert($("#Button1").val()); 4、H...
标签: Web开发
基础知识: 想要结构与行为分离当然不能使用button onclick="…"/button之类的东西了,js是写在head之间的,那就说起了 window.onload——这不是一个好东西,所以就有了Jquery颇具创意的 代码如下: $(document).ready(funciton(){ … }); 当然还会更精简: 代码如下: $(function(){ … }); 所以我的第一个Jquery脚本就是这...
标签: Web开发
虽然方便好用,但是个人觉得其在UI方面的表现不是太出彩,今天无意中看到jquery tools--一种基于jquery的UI表现框架,其UI功能展示风格类似(或模仿)flex。该框架提供了tabs(选项卡/页签)overlay(覆盖层),tooltip(提示框),scrollable(滚动信息栏),expose(突出显示),flahembed(视频播放嵌入)六大类功能(其官方网站自称为六大工具),这...
标签: Web开发
jQuery 是一个强大的Javascript类库,里面封装好了很多现有的方法和属性。可以使开发人员用很少的代码更好更快的开发出自己想实现的效果。 在平时的开发中,我们可能经常会用到jQuery。这里总结了一些经典的实例应用。分享给大家。 jQuery=轻松实现表单验证: 在我们的开发中,常会有注册或是添加信息的时候,难免的我们就会需要对表单进行验...
标签: Web开发
测试代码如下 代码如下: !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" html xmlns="http://www.w3.org/1999/xhtml" head meta http-equiv="Content-Type" content="text/html; charset=utf-8" / title无标题文档/title style type="text/css" .test1{ ...

经验教程

16

收藏

22
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部