jquery tools系列 expose 學(xué)習(xí)
<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>
該功能是通過(guò)jqueryObject.expose()方法來(lái)實(shí)現(xiàn)的,其具體實(shí)現(xiàn)方式如下:
$("jquery selector").expose({config object}) //該方法通過(guò)配置對(duì)象將來(lái)定制expose的顯示。
以下代碼為配置參數(shù)說(shuō)明描述:
| 方法 | 返回值 | 詳細(xì)描述 |
| load() | API | 觸發(fā)expose(突出顯示)效果,該方法只有expose(突出顯示)被初始化后才能調(diào)用成功。 |
| close() | API | 關(guān)閉expose(突出顯示)效果。 |
| isLoaded() | boolean | 判斷當(dāng)前expose(突出顯示)是否已被觸發(fā)。 |
| getMask() | jQuery | 返回非expose(突出顯示)的jquery對(duì)象??梢酝ㄟ^(guò)jquery的相關(guān)方法來(lái)改變非expose(突出顯示)區(qū)域的顯示效果。 |
| getExposed() | jQuery | 返回expose(突出顯示)的jquery對(duì)象。 |
| getConf() | Object | 返回expose(突出顯示)的配置對(duì)象。 |
| onBeforeLoad(fn) | API | 同配置文件中onBeforeLoad屬性。 |
| onLoad(fn) | API | 同配置文件中onLoad屬性。 |
| onBeforeClose(fn) | API | 同配置文件中onBeforeClose屬性。 |
| onClose(fn) | API | 同配置文件中onClose屬性。 |
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({
//此處通過(guò)maskId中樣式的backgroundcolor來(lái)設(shè)置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;
}
--></style><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;
}</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({
//此處通過(guò)maskId中樣式的backgroundcolor來(lái)設(shè)置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>
相關(guān)文章
jquery中的mouseleave和mouseout的區(qū)別 模仿下拉框效果
不論鼠標(biāo)指針離開(kāi)被選元素還是任何子元素,都會(huì)觸發(fā) mouseout 事件,只有在鼠標(biāo)指針離開(kāi)被選元素時(shí),才會(huì)觸發(fā) mouseleave 事件2012-02-02
jQuery Easyui datagrid連續(xù)發(fā)送兩次請(qǐng)求問(wèn)題
用上述方式動(dòng)態(tài)加載datagrid的數(shù)據(jù)時(shí),通過(guò)net監(jiān)聽(tīng),發(fā)現(xiàn)調(diào)用了兩遍XX方法,目前的解決方案是,將url放到datagrid初始化的時(shí)候執(zhí)行2016-12-12
jQuery實(shí)現(xiàn)的自適應(yīng)焦點(diǎn)圖效果完整實(shí)例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的自適應(yīng)焦點(diǎn)圖效果,結(jié)合完整實(shí)例形式分析了jQuery事件響應(yīng)及動(dòng)態(tài)操作頁(yè)面元素屬性的相關(guān)技巧,需要的朋友可以參考下2016-08-08
jquery仿QQ商城帶左右按鈕控制焦點(diǎn)圖片切換滾動(dòng)效果
jquery圖片特效制作仿騰訊QQ商城首頁(yè)banner焦點(diǎn)圖片輪播切換效果,帶索引按鈕控制和左右按鈕控制圖片切換,實(shí)例代碼如下,感興趣的朋友可以參考下哈2013-06-06
Jquery Ajax的Get方式時(shí)需要注意URL地方
我們要時(shí)刻注意瀏覽器緩存, 當(dāng)使用GET方式時(shí)要添加時(shí)間戳參數(shù) (net Date()).getTime() 來(lái)保證每次發(fā)送的URL不同, 可以避免瀏覽器緩存.2011-04-04
基于jquery的劃詞搜索實(shí)現(xiàn)(備忘)
最近,需要做個(gè)劃詞搜索功能。在網(wǎng)上找了好些,最后,參照進(jìn)行修改,實(shí)現(xiàn)了想要的功能。這里,做個(gè)記錄,以備日后所用。2010-09-09
jquery提示 "object expected"的解決方法
在測(cè)試代碼的時(shí)候,提示object expected,下面的解決方法,可以參考下。2009-12-12
一步一步制作jquery插件Tabs實(shí)現(xiàn)過(guò)程
自制一個(gè)簡(jiǎn)潔的tabs插件還是有必要的在設(shè)計(jì)之前,先整理好思路,實(shí)現(xiàn)tabs,自動(dòng)輪換,ajax等主要功能,然后是dom的排列形式,這里采用傳統(tǒng)的2010-07-07

