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