You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
797 lines
28 KiB
797 lines
28 KiB
6 years ago
|
<!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>artDialog</title>
|
||
|
<script>
|
||
|
// skin demo
|
||
|
(function() {
|
||
|
var _skin, _jQuery;
|
||
|
var _search = window.location.search;
|
||
|
if (_search) {
|
||
|
_skin = _search.split('demoSkin=')[1];
|
||
|
_jQuery = _search.indexOf('jQuery=true') !== -1;
|
||
|
if (_jQuery) document.write('<scr'+'ipt src="../jquery-1.6.2.min.js"></sc'+'ript>');
|
||
|
};
|
||
|
|
||
|
document.write('<scr'+'ipt src="../artDialog.source.js?skin=' + (_skin || 'default') +'"></sc'+'ript>');
|
||
|
window._isDemoSkin = !!_skin;
|
||
|
})();
|
||
|
</script>
|
||
|
|
||
|
<script src="demo.js"></script>
|
||
|
<script src="highlight/highlight.pack.js"></script>
|
||
|
<script src="highlight/languages/javascript.js"></script>
|
||
|
<script>
|
||
|
hljs.tabReplace = ' ';
|
||
|
hljs.initHighlightingOnLoad();
|
||
|
</script>
|
||
|
<link href="demo.css" rel="stylesheet" type="text/css" />
|
||
|
<link rel="stylesheet" href="highlight/styles/magula.css" />
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<div id="doc">
|
||
|
<div id="header">
|
||
|
<h1 id="logo"><a href="../index.html">artDialog</a></h1>
|
||
|
<ul id="nav" class="nav">
|
||
|
<li><a href="../index.html" class="home">首页</a></li>
|
||
|
<li><a href="./API.html" class="api">文档</a></li>
|
||
|
<li><a href="./down.html" class="down">下载</a></li>
|
||
|
<li><a href="./log.html" class="log">更新</a></li>
|
||
|
<li><a href="./labs.html" class="labs">实验</a></li>
|
||
|
<li><a href="./license.html" class="license">授权</a></li>
|
||
|
|
|
||
|
<li><a href="#" id="nav-skin">皮肤</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div id="main">
|
||
|
|
||
|
<h2 id="options">配置参数</h2>
|
||
|
<table class="zebra">
|
||
|
<colgroup>
|
||
|
<col class="col1" />
|
||
|
<col class="col2" />
|
||
|
<col class="col3" />
|
||
|
<col class="col4" />
|
||
|
</colgroup>
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th class="parameter">名称</th>
|
||
|
<th class="type">类型</th>
|
||
|
<th class="default">默认值</th>
|
||
|
<th class="note">描述</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<th class="separate" colspan="4"><abbrev>内容</abbrev></th>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th><a href="#title">title</a></th>
|
||
|
<td>String</td>
|
||
|
<td>'消息'</td>
|
||
|
<td>标题内容</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th rowspan="2"><a href="#content">content</a></th>
|
||
|
<td>String</td>
|
||
|
<td rowspan="2">'loading..'</td>
|
||
|
<td rowspan="2">消息内容。<br />
|
||
|
1、如果传入的是HTMLElement类型,如果是隐藏元素会给其设置display:block以显示该元素,其他属性与绑定的事件都会完整保留,对话框关闭后此元素又将恢复原来的display属性,并且重新插入原文档所在位置<br />
|
||
|
2、如果没有设定content的值则会有loading的动画</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>HTMLElement</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th class="separate" colspan="4"><abbrev>按钮</abbrev></th>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th rowspan="2"><a href="#ok">ok</a></th>
|
||
|
<td>Function</td>
|
||
|
<td rowspan="2">null</td>
|
||
|
<td rowspan="2">确定按钮回调函数。<br />
|
||
|
函数如果返回false将阻止对话框关闭;函数this指针指向内部api;如果传入true表示只显示有关闭功能的按钮</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>Boolean</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th rowspan="2"><a href="#cancel">cancel</a></th>
|
||
|
<td>Function</td>
|
||
|
<td rowspan="2">null</td>
|
||
|
<td rowspan="2">取消按钮回调函数。<br />
|
||
|
函数如果返回false将阻止对话框关闭;函数this指针指向内部api;如果传入true表示只显示有关闭功能的按钮<br />
|
||
|
对话框标题栏的关闭按钮其实就是取消按钮,只不过视觉不同罢了,点击同样触发cancel事件</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<td>Boolean</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th><a href="#okText">okVal</a></th>
|
||
|
<td>String</td>
|
||
|
<td>'确定'</td>
|
||
|
<td>"确定按钮"文字</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th><a href="#cancelText">cancelVal</a></th>
|
||
|
<td>String</td>
|
||
|
<td>'取消'</td>
|
||
|
<td>"取消按钮"文字</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th><a href="#button">button</a></th>
|
||
|
<td>Array</td>
|
||
|
<td>null</td>
|
||
|
<td>自定义按钮。<br />
|
||
|
配置参数成员:
|
||
|
<div>name —— 按钮名称</div>
|
||
|
<div>callback —— 按下后执行的函数</div>
|
||
|
<div>focus —— 是否聚焦点</div>
|
||
|
<div>disabled —— 是否标记按钮为不可用状态(后续可使用扩展方法让其恢复可用状态)</div>
|
||
|
<br />
|
||
|
<div>示例:</div>
|
||
|
参数如:[{name: '登录', callback: function () {}}, {name: '取消'}] 。注意点击按钮默认会触发按钮关闭动作,需要阻止触发关闭请让回调函数返回false</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th class="separate" colspan="4"><abbrev>尺寸</abbrev></th>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th rowspan="2"><a href="#width">width</a></th>
|
||
|
<td>Number</td>
|
||
|
<td rowspan="2">'auto'</td>
|
||
|
<td rowspan="2">设置消息内容宽度,可以带单位。一般不需要设置此,对话框框架会自己适应内容。<br />
|
||
|
如果设置为百分值单位,将会以根据浏览器可视范围作为基准,此时如果浏览器窗口大小被改变其也会进行相应的调整</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>String</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th rowspan="2"><a href="#height">height</a></th>
|
||
|
<td>Number</td>
|
||
|
<td rowspan="2">'auto'</td>
|
||
|
<td rowspan="2">设置消息内容高度,可以带单位。不建议设置此,而应该让内容自己撑开高度。<br />
|
||
|
如果设置为百分值单位,将会以根据浏览器可视范围作为基准,此时如果浏览器窗口大小被改变其也会进行相应的调整</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<td>String</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th class="separate" colspan="4"><abbrev>位置</abbrev></th>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th><a href="#fixed">fixed</a></th>
|
||
|
<td>Boolean</td>
|
||
|
<td>false</td>
|
||
|
<td>开启静止定位。静止定位是css2.1的一个属性,它静止在浏览器某个地方不动,也不受滚动条拖动影响。(artDialog支持IE6 fixed)</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th rowspan="2"><a href="#follow">follow</a></th>
|
||
|
<td>HTMLElement</td>
|
||
|
<td rowspan="2">null</td>
|
||
|
<td rowspan="2">让对话框依附在指定元素附近。<br />
|
||
|
可传入元素ID名称,注意ID名称需要以“#”号作为前缀</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<td>String</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th rowspan="2"><a href="#left">left</a></th>
|
||
|
<td>Number</td>
|
||
|
<td rowspan="2">'50%'</td>
|
||
|
<td rowspan="2">相对于可视区域的X轴的坐标。<br />
|
||
|
可以使用'0%' ~ '100%'作为相对坐标,如果浏览器窗口大小被改变其也会进行相应的调整</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>String</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th rowspan="2"><a href="#top">top</a></th>
|
||
|
<td>Number</td>
|
||
|
<td rowspan="2">'38.2%'</td>
|
||
|
<td rowspan="2">相对于可视区域的Y轴的坐标。<br />
|
||
|
可以使用'0%' ~ '100%'作为相对坐标,如果浏览器窗口大小被改变其也会进行相应的调整</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<td>String</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th class="separate" colspan="4">视觉</th>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th><a href="#lock">lock</a></th>
|
||
|
<td>Boolean</td>
|
||
|
<td>false</td>
|
||
|
<td>开启锁屏。<br />
|
||
|
中断用户对话框之外的交互,用于显示非常重要的操作/消息,所以不建议频繁使用它,它会让操作变得繁琐</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th><a href="#background">background</a></th>
|
||
|
<td>String</td>
|
||
|
<td>'#000'</td>
|
||
|
<td>锁屏遮罩颜色</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th><a href="#opacity">opacity</a></th>
|
||
|
<td>Number</td>
|
||
|
<td>0.7</td>
|
||
|
<td>锁屏遮罩透明度</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th><a href="#icon">icon</a></th>
|
||
|
<td>String</td>
|
||
|
<td>null</td>
|
||
|
<td>定义消息图标。可定义“skins/icons/”目录下的图标名作为参数名(不包含后缀名)</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th><a href="#padding">padding</a></th>
|
||
|
<td>String</td>
|
||
|
<td>'20px 25px'</td>
|
||
|
<td>内容与边界填充边距(即css padding)</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th class="separate" colspan="4"><abbrev>交互</abbrev></th>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th><a href="#time">time</a></th>
|
||
|
<td>Number</td>
|
||
|
<td>null</td>
|
||
|
<td>设置对话框显示时间。以秒为单位</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th><a href="#resize">resize</a></th>
|
||
|
<td>Boolean</td>
|
||
|
<td>true</td>
|
||
|
<td>是否允许用户调节尺寸</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th><a href="#drag">drag</a></th>
|
||
|
<td>Boolean</td>
|
||
|
<td>true</td>
|
||
|
<td>是否允许用户拖动位置</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th><a href="#esc">esc</a></th>
|
||
|
<td>Boolean</td>
|
||
|
<td>true</td>
|
||
|
<td>是否允许用户按Esc键关闭对话框</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th class="separate" colspan="4"><abbrev>高级</abbrev></th>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th rowspan="2"><a href="#id">id</a></th>
|
||
|
<td>String</td>
|
||
|
<td rowspan="2">null</td>
|
||
|
<td rowspan="2">设定对话框唯一标识。用途:<br />
|
||
|
1、防止重复弹出<br />
|
||
|
2、定义id后可以使用art.dialog.list[youID]获取扩展方法</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<td>Number</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th><a href="#zIndex">zIndex</a></th>
|
||
|
<td>Number</td>
|
||
|
<td>1987</td>
|
||
|
<td>重置全局zIndex初始值。<br />
|
||
|
用来改变对话框叠加高度。比如有时候配合外部浮动层UI组件,但是它们可能默认zIndex没有artDialog高,导致无法浮动到artDialog之上,这个时候你就可以给对话框指定一个较小的zIndex值。<br />
|
||
|
请注意这是一个会影响到全局的配置,后续出现的对话框叠加高度将重新按此累加。</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th><a href="#init">init</a></th>
|
||
|
<td>Function</td>
|
||
|
<td>null</td>
|
||
|
<td>对话框弹出后执行的函数</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th><a href="#close">close</a></th>
|
||
|
<td>Function</td>
|
||
|
<td>null</td>
|
||
|
<td>对话框关闭前执行的函数。函数如果返回false将阻止对话框关闭。<br />
|
||
|
请注意这不是关闭按钮的回调函数,无论何种方式关闭对话框,close都将执行。</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th><a href="#show">show</a></th>
|
||
|
<td>Boolean</td>
|
||
|
<td>true</td>
|
||
|
<td>是否显示对话框</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<h2 id="API">扩展方法</h2>
|
||
|
<table class="zebra">
|
||
|
<colgroup>
|
||
|
<col class="col1" />
|
||
|
<col class="col2" />
|
||
|
<col class="col3" />
|
||
|
</colgroup>
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th class="name">名称</th>
|
||
|
<th class="note" colspan="3">描述</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<th>close()</th>
|
||
|
<td colspan="3">关闭对话框</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th>show()</th>
|
||
|
<td colspan="3">显示对话框</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th>hide()</th>
|
||
|
<td colspan="3">隐藏对话框</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th>title(value)</th>
|
||
|
<td colspan="3">写入标题。无参数则返回标题容器元素</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th>content(value)</th>
|
||
|
<td colspan="3">向消息容器中写入内容。参数支持字符串、DOM对象,无参数则返回内容容器元素</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th>button(arguments)</th>
|
||
|
<td colspan="3">插入一个自定义按钮。<br />
|
||
|
配置参数成员:
|
||
|
<div>name —— 按钮名称</div>
|
||
|
<div>callback —— 按下后执行的函数</div>
|
||
|
<div>focus —— 是否聚焦点</div>
|
||
|
<div>disabled —— 是否标记按钮为不可用状态(后续可使用扩展方法让其恢复可用状态)</div>
|
||
|
<br />
|
||
|
<div>示例:</div>
|
||
|
<pre style="background:none; border:none 0;">button({
|
||
|
name: '登录',
|
||
|
focus: true,
|
||
|
callback: function () {}
|
||
|
}, {
|
||
|
name: '取消'
|
||
|
})</pre></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th>follow(element)</th>
|
||
|
<td colspan="3">让对话框吸附到指定元素附近</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th>position(left, top)</th>
|
||
|
<td colspan="3">重新定位对话框</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th>size(width, height)</th>
|
||
|
<td colspan="3">重新设定对话框大小</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th>lock()</th>
|
||
|
<td colspan="3">锁屏</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th>unlock()</th>
|
||
|
<td colspan="3">解锁</td>
|
||
|
</tr>
|
||
|
<tr class="odd">
|
||
|
<th>time(val)</th>
|
||
|
<td colspan="3">定时关闭(单位秒)</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<h2>配置参数演示</h2>
|
||
|
<h3 id="content">内容 [content]</h3>
|
||
|
<h4>1. 传入字符串</h4>
|
||
|
<div id="demoCode_content">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
content: '我支持HTML'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_content">运行»</button>
|
||
|
</p>
|
||
|
<h4>2. 传入HTMLElement</h4>
|
||
|
<p>备注:1、元素不是复制而是完整移动到对话框中,所以原有的事件与属性都将会保留 2、如果隐藏元素被传入到对话框,会设置display:block属性显示该元素 3、对话框关闭的时候元素将恢复到原来在页面的位置,style display属性也将恢复</p>
|
||
|
<div id="demoCode_content_DOM">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
content: document.getElementById('demoCode_content_DOM'),
|
||
|
id: 'EF893L'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_content_DOM">运行»</button>
|
||
|
</p>
|
||
|
<h3 id="title">标题 [title]</h3>
|
||
|
<div id="demoCode_title">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
title: 'hello world!'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_title">运行»</button>
|
||
|
</p>
|
||
|
<h3>确定取消按钮 [ok & cancel]<span id="ok"></span><span id="cancel"></span><span id="okText"></span><span id="cancelText"></span></h3>
|
||
|
<p>备注:回调函数this指向扩展接口,如果返回false将阻止对话框关闭</p>
|
||
|
<div id="demoCode_yes_no">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
content: '如果定义了回调函数才会出现相应的按钮',
|
||
|
ok: function () {
|
||
|
this.title('3秒后自动关闭').time(3);
|
||
|
return false;
|
||
|
},
|
||
|
cancelVal: '关闭',
|
||
|
cancel: true //为true等价于function(){}
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_yes_no">运行»</button>
|
||
|
</p>
|
||
|
<h3 id="button">自定义按钮 [button]</h3>
|
||
|
<p>备注:回调函数this指向扩展接口,如果返回false将阻止对话框关闭;button参数对应的扩展方法名称也是"button"</p>
|
||
|
<div id="demoCode_button">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
id: 'testID',
|
||
|
content: 'hello world!',
|
||
|
button: [
|
||
|
{
|
||
|
name: '同意',
|
||
|
callback: function () {
|
||
|
this.content('你同意了').time(2);
|
||
|
return false;
|
||
|
},
|
||
|
focus: true
|
||
|
},
|
||
|
{
|
||
|
name: '不同意',
|
||
|
callback: function () {
|
||
|
alert('你不同意')
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
name: '无效按钮',
|
||
|
disabled: true
|
||
|
},
|
||
|
{
|
||
|
name: '关闭我'
|
||
|
}
|
||
|
]
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_button">运行»</button>
|
||
|
</p>
|
||
|
<h3 id="time">定时关闭的消息 [time]</h3>
|
||
|
<div id="demoCode_time">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
time: 2,
|
||
|
content: '两秒后关闭'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_time">运行»</button>
|
||
|
</p>
|
||
|
<h3 id="id">防止重复弹出 [id]</h3>
|
||
|
<div id="demoCode_id">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
id: 'testID2',
|
||
|
content: '再次点击运行看看'
|
||
|
});
|
||
|
art.dialog({id: 'testID2'}).title('3秒后关闭').time(3);
|
||
|
</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_id">运行»</button>
|
||
|
</p>
|
||
|
<h3 id="icon">定义消息图标 [icon]</h3>
|
||
|
<p>请查看skins/icons目录下的图标</p>
|
||
|
<div id="demoCode_icon">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
icon: 'succeed',
|
||
|
content: '我可以定义消息图标哦'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_icon">运行»</button>
|
||
|
</p>
|
||
|
<h3 id="padding">内容与边界填充边距 [padding]</h3>
|
||
|
<p>有时候并不需要默认的内容填充边距,如展示图片与视频</p>
|
||
|
<div id="demoCode_padding">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
padding: 0,
|
||
|
title: '照片',
|
||
|
content: '<img src="./images/photo.jpg" width="379" height="500" />',
|
||
|
lock: true
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_padding">运行»</button>
|
||
|
</p>
|
||
|
<h3 id="lock">锁屏 [lock & background & opacity] <span id="background"></span><span id="opacity"></span><span id="duration"></span></h3>
|
||
|
<div id="demoCode_lock">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
lock: true,
|
||
|
background: '#600', // 背景色
|
||
|
opacity: 0.87, // 透明度
|
||
|
content: '中断用户在对话框以外的交互,展示重要操作与消息',
|
||
|
icon: 'error',
|
||
|
ok: function () {
|
||
|
art.dialog({content: '再来一个锁屏', lock: true});
|
||
|
return false;
|
||
|
},
|
||
|
cancel: true
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_lock">运行»</button>
|
||
|
</p>
|
||
|
<h3 id="follow">跟随元素 [follw]</h3>
|
||
|
<h4>1、标准形式</h4>
|
||
|
<div id="demoCode_follow">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
follow: document.getElementById('followTestBtn'),
|
||
|
content: '让对话框跟着某个元素,一个元素同时只能出现一个对话框'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" id="followTestBtn" title="id=followTestBtn" name="demoCode_follow">运行»</button>
|
||
|
</p>
|
||
|
<h4>2、使用简写形式 (已经绑定onclick事件,注意此返回值不再是对话框扩展方法)</h4>
|
||
|
<div id="demoCode_follow_fn">
|
||
|
<pre><code class="javascript">art('#demoCode_follow_a').dialog({
|
||
|
content: '让对话框跟着某个元素,一个元素同时只能出现一个对话框'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons"><a href="javascript:alert('点击运行后再来点击我!');void(0)" id="demoCode_follow_a" style="margin-right:10px; text-decoration:underline">元素触发</a>
|
||
|
<button class="runCode" id="followTestBtn" title="id=followTestBtn" name="demoCode_follow_fn">运行»</button>
|
||
|
</p>
|
||
|
<h3>自定义坐标 [left & top]<span id="left"></span><span id="top"></span></h3>
|
||
|
<div id="demoCode_position">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
left: 100,
|
||
|
top: '60%',
|
||
|
content: '我改变坐标了'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_position">运行»</button>
|
||
|
</p>
|
||
|
<h4>创建一个右下角浮动的消息窗口</h4>
|
||
|
<div id="demoCode_position2">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
id: 'msg',
|
||
|
title: '公告',
|
||
|
content: 'hello world!',
|
||
|
width: 320,
|
||
|
height: 240,
|
||
|
left: '100%',
|
||
|
top: '100%',
|
||
|
fixed: true,
|
||
|
drag: false,
|
||
|
resize: false
|
||
|
})</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_position2">运行»</button>
|
||
|
</p>
|
||
|
<h3>设置大小 [width & height]<span id="width"></span><span id="height"></span></h3>
|
||
|
<div id="demoCode_size">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
width: '20em',
|
||
|
height: 55,
|
||
|
content: '尺寸可以带单位'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_size">运行»</button>
|
||
|
</p>
|
||
|
<h4>创建一个全屏对话框</h4>
|
||
|
<div id="demoCode_size_full">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
width: '100%',
|
||
|
height: '100%',
|
||
|
left: '0%',
|
||
|
top: '0%',
|
||
|
fixed: true,
|
||
|
resize: false,
|
||
|
drag: false
|
||
|
})</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_size_full">运行»</button>
|
||
|
</p>
|
||
|
<h3 id="fixed">静止定位 [fixed]</h3>
|
||
|
<div id="demoCode_fixed">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
fixed: true,
|
||
|
content: '请拖动滚动条查看'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_fixed">运行»</button>
|
||
|
</p>
|
||
|
<h3 id="drag">不许拖拽 [drag & resize] <span id="resize"></span></h3>
|
||
|
<div id="demoCode_drag">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
drag: false,
|
||
|
resize: false,
|
||
|
content: '禁止拖拽'
|
||
|
});</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_drag">运行»</button>
|
||
|
</p>
|
||
|
|
||
|
<h2>扩展方法演示</h2>
|
||
|
<p>特别说明:扩展方法支持链式操作</p>
|
||
|
<h3>获取扩展方法一:直接引用返回</h3>
|
||
|
<div id="demoCode_api_1">
|
||
|
<pre><code class="javascript">var dialog = art.dialog({
|
||
|
title: '我是对话框',
|
||
|
content: '我是初始化的内容'
|
||
|
});
|
||
|
|
||
|
dialog.content('对话框内容被扩展方法改变了').title('提示');
|
||
|
</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_api_1">运行»</button>
|
||
|
</p>
|
||
|
<h3>获取扩展方法二:通过对话框ID</h3>
|
||
|
<div id="demoCode_api_2">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
id: 'KDf435',
|
||
|
title: '警告',
|
||
|
content: '我是初始化的内容'
|
||
|
});
|
||
|
|
||
|
art.dialog.list['KDf435'].content('对话框内容被扩展方法改变了');
|
||
|
</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_api_2">运行»</button>
|
||
|
</p>
|
||
|
|
||
|
<h3>获取扩展方法三:回调函数中this</h3>
|
||
|
<div id="demoCode_api_3">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
title: '警告',
|
||
|
content: '我是初始化的内容',
|
||
|
ok: function () {
|
||
|
this.content('你点了确定按钮').lock();
|
||
|
return false;
|
||
|
},
|
||
|
init: function () {
|
||
|
this.content('对话框内容被扩展方法改变了');
|
||
|
}
|
||
|
});
|
||
|
</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_api_3">运行»</button>
|
||
|
</p>
|
||
|
<h3>关闭页面所有对话框</h3>
|
||
|
<div id="demoCode_api_4">
|
||
|
<pre><code class="javascript">var list = art.dialog.list;
|
||
|
for (var i in list) {
|
||
|
list[i].close();
|
||
|
};
|
||
|
</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_api_4">运行»</button>
|
||
|
</p>
|
||
|
<h3>按钮接口演示</h3>
|
||
|
<p>备注:回调函数如果返回false将阻止对话框关闭</p>
|
||
|
<div id="demoCode_api_button">
|
||
|
<pre><code class="javascript">var dialog = art.dialog({
|
||
|
title: '警告',
|
||
|
content: '点击管理按钮将让删除按钮可用',
|
||
|
width: '20em',
|
||
|
button: [{
|
||
|
name: '管理',
|
||
|
callback: function () {
|
||
|
this
|
||
|
.content('我更改了删除按钮')
|
||
|
.button({
|
||
|
name: '删除',
|
||
|
disabled: false
|
||
|
})
|
||
|
.lock();
|
||
|
return false;
|
||
|
},
|
||
|
focus: true
|
||
|
}]
|
||
|
});
|
||
|
|
||
|
dialog.button(
|
||
|
{
|
||
|
name: '删除',
|
||
|
callback: function () {
|
||
|
alert('delect')
|
||
|
},
|
||
|
disabled: true
|
||
|
}
|
||
|
)
|
||
|
</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_api_button">运行»</button>
|
||
|
</p>
|
||
|
<h3>标题倒计时</h3>
|
||
|
<div id="demoCode_api_title">
|
||
|
<pre><code class="javascript">var timer;
|
||
|
art.dialog({
|
||
|
content: '时间越来越少,越来越少..',
|
||
|
init: function () {
|
||
|
var that = this, i = 5;
|
||
|
var fn = function () {
|
||
|
that.title(i + '秒后关闭');
|
||
|
!i && that.close();
|
||
|
i --;
|
||
|
};
|
||
|
timer = setInterval(fn, 1000);
|
||
|
fn();
|
||
|
},
|
||
|
close: function () {
|
||
|
clearInterval(timer);
|
||
|
}
|
||
|
}).show();</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_api_title">运行»</button>
|
||
|
</p>
|
||
|
<h3>关闭不删除内容</h3>
|
||
|
<div id="demoCode_api_fn">
|
||
|
<pre><code class="javascript">art.dialog({
|
||
|
id: 'show-hide',
|
||
|
content: '关闭后阻止对话框被删除,只隐藏对话框',
|
||
|
close: function () {
|
||
|
this.hide();
|
||
|
return false;
|
||
|
}
|
||
|
}).show();</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_api_fn">运行»</button>
|
||
|
</p>
|
||
|
<h3>AJAX高级应用:执行HTML片段中特殊script标签</h3>
|
||
|
<p>HTML片段中的<span style=" padding:1px; margin:0 3px; color:#03C; background:#F8F8F8"><script type="<span style="color:#090">text/dialog</span>"></script></span>标签包裹的javascript将会在artDialog内部执行,其this指向对话框扩展方法,这样可以进一步实现消息内容模块化。 </p>
|
||
|
<p>(本例子使用了AJAX,需要在服务器上运行。可打开 <a href="./ajaxContent/login.html" target="_blank">./ajaxContent/login.html</a> 查看源码中的自定义脚本)</p>
|
||
|
<div id="demoCode_api_content">
|
||
|
<pre><code class="javascript">var dialog = art.dialog({id: 'N3690',title: false});
|
||
|
|
||
|
// jQuery ajax
|
||
|
$.ajax({
|
||
|
url: './ajaxContent/login.html',
|
||
|
success: function (data) {
|
||
|
dialog.content(data);
|
||
|
},
|
||
|
cache: false
|
||
|
});
|
||
|
</code></pre>
|
||
|
</div>
|
||
|
<p class="buttons">
|
||
|
<button class="runCode" name="demoCode_api_content">运行»</button>
|
||
|
</p>
|
||
|
<h2 id="plugin">插件:iframe应用工具</h2>
|
||
|
<p>请新打开新页面查看范例:<a href="./iframeTop.html" target="_blank">./iframeTop.html</a></p>
|
||
|
<h2 id="in">应用到你的项目</h2>
|
||
|
<p>在页面head引入artDialog,其中skin参数表示对话框使用的风格文件(如果项目采用jQuery作为框架,则引用jQuery artDialog版本)。</p>
|
||
|
<pre><code><script src="artDialog/artDialog.js?skin=default"></script></code></pre>
|
||
|
<p>如果需要在iframe应用下提供 <a href="#plugin">更好的支持</a> ,可加载插件:</p>
|
||
|
<pre><code><script src="artDialog/plugins/iframeTools.js"></script></code></pre>
|
||
|
<p>配置全局默认参数(可选):</p>
|
||
|
<pre><code class="javascript">(function (config) {
|
||
|
config['lock'] = true;
|
||
|
config['fixed'] = true;
|
||
|
config['okVal'] = 'Ok';
|
||
|
config['cancelVal'] = 'Cancel';
|
||
|
// [more..]
|
||
|
})(art.dialog.defaults);
|
||
|
</code></pre>
|
||
|
</div>
|
||
|
<div id="footer"></div>
|
||
|
</div>
|
||
|
<script>_isDemoSkin && window._demoSkin && _demoSkin();</script>
|
||
|
</body>
|
||
|
|
||
|
</html>
|