W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
插件描述:iziModal是一款時(shí)尚炫酷的jQuery模態(tài)窗口插件。該模態(tài)窗口插件提供基本的打開(kāi)模態(tài)窗口動(dòng)畫(huà)特效,并且可以調(diào)用iframe內(nèi)容,Ajax加載,制作alert效果,加載超大內(nèi)容等。
在頁(yè)面中引入iziModal.min.css和jquery、iziModal.min.js文件。
<link rel="stylesheet" href="iziModal.min.css">
<script src="jquery.min.js" type="text/javascript"></script>
<script src="iziModal.min.js" type="text/javascript"></script>
可以通過(guò)按鈕或<a>元素來(lái)觸發(fā)一個(gè)模態(tài)窗口。
<!-- Trigger to open Modal -->
<a href="#" class="trigger">打開(kāi)模態(tài)窗口</a>
<!-- 模態(tài)窗口 -->
<div id="modal">
<!-- 模態(tài)窗口的內(nèi)容 -->
</div>
在頁(yè)面DOM元素加載完畢之后,可以通過(guò)iziModal()方法來(lái)初始化該模態(tài)窗口插件。
$("#modal").iziModal();
或者也可以通過(guò)jqurey事件來(lái)打開(kāi)模態(tài)窗口。
$(document).on('click', '.trigger', function (event) {
event.preventDefault();
$('#modal').iziModal('open', this); // 需要帶上 "this"
});
要在模態(tài)窗口中使用iframe功能,結(jié)構(gòu)如下:
<a href="http://www.jq22.com" class="trigger">打開(kāi)模態(tài)窗口</a>
初始化:
$("#modal").iziModal({
iframe: true,
iframeHeight: 800,
iframeURL: "http://www.jq22.com"
});
或者也可以通過(guò)jquery事件來(lái)打開(kāi)模態(tài)窗口。
$(document).on('click', '.trigger', function (event) {
event.preventDefault();
$('#modal').iziModal('open', this); // 需要帶上 "this"
});
iziModal模態(tài)窗口插件配置有Ajax功能。
$("#modal").iziModal('open', function(modal){
modal.startLoading();
$.get('/path/to/file', function(data) {
$("#modal .iziModal-content").html(data);
modal.stopLoading();
});
});
iziModal模態(tài)窗口插件的默認(rèn)配置參數(shù)如下:
$("#modal").iziModal({
title: "",
subtitle: "",
theme: "",
headerColor: "#88A0B9",
overlayColor: "rgba(0, 0, 0, 0.4)",
iconColor: "",
iconClass: null,
width: 600,
padding: 0,
iframe: false,
iframeHeight: 400,
iframeURL: null,
overlayClose: true,
closeOnEscape: true,
bodyOverflow: false,
focusInput: true,
autoOpen: false,
transitionInModal: 'transitionIn',
transitionOutModal: 'transitionOut',
transitionInOverlay: 'fadeIn',
transitionOutOverlay: 'fadeOut',
onOpening: function() {},
onOpened: function() {},
onClosing: function() {},
onClosed: function() {}
});
參數(shù) | 默認(rèn)值 | 描述 |
title | "" | 模態(tài)窗口的標(biāo)題。 |
subtitle | "" | 模態(tài)窗口的子標(biāo)題。 |
theme | "" | 模態(tài)窗口的主題,可以是空或"light"。 |
headerColor | #6d7d8d | 模態(tài)窗口的頭部顏色。 |
overlayColor | rgba(0,0,0,0.4) | 遮罩層的顏色。 |
iconColor | "" | 頭部圖標(biāo)的顏色。 |
iconClass | null | 圖標(biāo)圖標(biāo)的class(你使用的字體圖標(biāo)的class名稱) |
width | 600 | 模態(tài)窗口的固定寬度。你可以使用%, px, em 或 cm。如果不帶單位,默認(rèn)為像素。 |
padding | 0 | 模態(tài)窗口的內(nèi)邊距。 |
iframe | false | 是否在模態(tài)窗口中啟用iframe功能。 |
iframeHeight | null | iframe的高度。 |
iframeURL | null | iframe加載內(nèi)容的URL地址。如果沒(méi)有設(shè)置,可以使用超鏈接的地址來(lái)作為URL地址。 |
overlayClose | true | 是否允許點(diǎn)擊模態(tài)窗口的外部來(lái)關(guān)閉模態(tài)窗口。 |
closeOnEscape | true | 是否允許通過(guò)點(diǎn)擊ESC鍵來(lái)關(guān)閉模態(tài)窗口。 |
bodyOverflow | false | 強(qiáng)制在打開(kāi)模態(tài)窗口時(shí)超出文檔的內(nèi)容被隱藏。 |
focusInput | true | 設(shè)置為true時(shí),當(dāng)打開(kāi)模態(tài)窗口時(shí),第一個(gè)可見(jiàn)的表單域?qū)⒈患せ睢?/td> |
autoOpen | false | 是否自動(dòng)打開(kāi)模態(tài)窗口。 |
transitionInModal | transitionIn | 打開(kāi)模態(tài)窗口的默認(rèn)過(guò)渡動(dòng)畫(huà)。 |
transitionOutModal | transitionOut | 關(guān)閉模態(tài)窗口的默認(rèn)過(guò)渡動(dòng)畫(huà)。 |
transitionInOverlay | fadeIn | 遮罩層打開(kāi)時(shí)的過(guò)渡動(dòng)畫(huà)。 |
transitionOutOverlay | fadeOut | 遮罩層關(guān)閉時(shí)的過(guò)渡動(dòng)畫(huà)。 |
onOpening | function() {} | 模態(tài)窗口打開(kāi)時(shí)的回調(diào)函數(shù)。 |
onOpened | function() {} | 模態(tài)窗口打開(kāi)后的回調(diào)函數(shù)。 |
onClosing | function() {} | 模態(tài)窗口關(guān)閉時(shí)的回調(diào)函數(shù)。 |
onClosed | function() {} | 模態(tài)窗口關(guān)閉后的回調(diào)函數(shù)。 |
$('#modal').iziModal();//初始化模態(tài)窗口。
$('#modal').iziModal('open');//打開(kāi)模態(tài)窗口。
$('#modal').iziModal('close');//關(guān)閉模態(tài)窗口。
$('#modal').iziModal('getState');//獲取模態(tài)窗口的狀態(tài),返回:{'closed'|'closing'|'opened'|'opening'}。
$('#modal').iziModal('startLoading');//開(kāi)啟模態(tài)窗口中的加載進(jìn)度指示器。
$('#modal').iziModal('stopLoading');//關(guān)閉模態(tài)窗口中的加載進(jìn)度指示器。
$('#modal').iziModal('destroy');//銷毀模態(tài)窗口。
$('#modal').iziModal('setHeaderColor', 'color');//設(shè)置模態(tài)窗口頭部的背景顏色。
$('#modal').iziModal('setTitle', 'Title');//設(shè)置模態(tài)窗口的標(biāo)題。
$('#modal').iziModal('setSubtitle', 'Subtitle');//設(shè)置模態(tài)窗口的子標(biāo)題。
$('#modal').iziModal('setIconClass', 'iconClass');//設(shè)置模態(tài)窗口的圖標(biāo)。
$('#modal').iziModal('recalculateLayout');//重新計(jì)算模態(tài)窗口的尺寸和位置。
Opening:在模態(tài)窗口打開(kāi)時(shí)觸發(fā)。
$(document).on('opening', '#modal', function (e) {
//console.log('Modal is opening');
});
Opened:在模態(tài)窗口打開(kāi)之后觸發(fā)。
$(document).on('opened', '#modal', function (e) {
//console.log('Modal is opened');
});
Closing:在模態(tài)窗口關(guān)閉時(shí)觸發(fā)。
$(document).on('closing', '#modal', function (e) {
//console.log('Modal is closing');
});
Closed:在模態(tài)窗口關(guān)閉之后觸發(fā)。
$(document).on('closed', '#modal', function (e) {
// console.log('Modal is closed');
});
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: