@@ -1048,8 +1015,11 @@
shake()
art.dialog({
id: 'shake-demo',
title: '登录',
- content: '帐号:<input type="text" value="guest" /><br />'
- + '密码:<input id="login-pw" type="text" value="****" />',
+ content: '帐号:<input id="login-na" type="text" value="guest" />'
+ + '<br />密码:<input id="login-pw" type="text" value="****" />',
+ initialize: function () {
+ document.getElementById('login-na').focus();
+ },
lock: true,
fixed: true,
ok: function () {
diff --git a/source/artDialog.js b/source/artDialog.js
index b801e69..9a8add5 100644
--- a/source/artDialog.js
+++ b/source/artDialog.js
@@ -1,6 +1,6 @@
/*!
-* artDialog 5.0.3
-* Date: 2013-02-20
+* artDialog 5.0.4
+* Date: 2013-02-24
* https://github.com/aui/artDialog
* (c) 2009-2013 TangBin, http://www.planeArt.cn
*
@@ -615,7 +615,6 @@ var artDialog = function (config, ok, cancel) {
api.follow(elem)
};
api.zIndex().focus();
- _activeElement = document.activeElement;
return api;
};
@@ -666,18 +665,16 @@ var artDialog = function (config, ok, cancel) {
_count ++;
return artDialog.list[config.id] = _singleton ?
- _singleton.constructor(config) : new artDialog.fn.constructor(config);
+ _singleton._create(config) : new artDialog.fn._create(config);
};
-artDialog.version = '5.0.3';
+artDialog.version = '5.0.4';
artDialog.fn = artDialog.prototype = {
- /** @inner */
- constructor: function (config) {
- var dom;
- _activeElement = document.activeElement;
+ _create: function (config) {
+ var dom;
this.closed = false;
this.config = config;
@@ -1116,16 +1113,25 @@ artDialog.fn = artDialog.prototype = {
/** @inner 设置焦点 */
focus: function () {
- if (this.config.focus) {
- //setTimeout(function () {
+ var that = this,
+ isFocus = function () {
+ return that.dom.wrap[0].contains(document.activeElement);
+ };
+
+ if (!isFocus()) {
+ _activeElement = document.activeElement;
+ }
+
+ setTimeout(function () {
+ if (!isFocus()) {
try {
- var elem = this._focus && this._focus[0] || this.dom.close[0];
- elem && elem.focus();
+ var elem = that._focus || that.dom.close || taht.dom.wrap;
+ elem[0].focus();
// IE对不可见元素设置焦点会报错
} catch (e) {};
- //}, 0);
- };
-
+ }
+ }, 16);
+
return this;
},
@@ -1317,10 +1323,11 @@ artDialog.fn = artDialog.prototype = {
};
-artDialog.fn.constructor.prototype = artDialog.fn;
+artDialog.fn._create.prototype = artDialog.fn;
+// 快捷方式绑定触发元素
$.fn.dialog = $.fn.artDialog = function () {
var config = arguments;
this[this.live ? 'live' : 'bind']('click', function () {
@@ -1360,7 +1367,7 @@ $(document).bind('keydown', function (event) {
api = artDialog.focus,
keyCode = event.keyCode;
- if (!api || !api.config.esc || rinput.test(nodeName) && target.type !== 'button') {
+ if (!api || rinput.test(nodeName) && target.type !== 'button') {
return;
};
@@ -1495,15 +1502,9 @@ artDialog.defaults = {
// 皮肤名(多皮肤共存预留接口)
skin: null,
- // 自动关闭时间
+ // 自动关闭时间(毫秒)
time: null,
-
- // 是否支持Esc键关闭
- esc: true,
-
- // 是否支持对话框按钮自动聚焦
- focus: true,
-
+
// 初始化后是否显示对话框
visible: true,
From 30e89ff867026cc8516336f6ad0a4efaf3bb75c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=94=90=E6=96=8C?= <1987.tangbin@gmail.com>
Date: Wed, 31 Jul 2013 22:35:41 +0800
Subject: [PATCH 6/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20iframe=20=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=E4=B8=AD=E4=B8=8A=E4=B8=80=E7=89=88=E6=8A=A5=E9=94=99?=
=?UTF-8?q?=E9=97=AE=E9=A2=98(ie8,9)=20#26=20#21?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 6 ++-
artDialog.min.js | 7 ++--
jquery.artDialog.min.js | 7 ++--
source/artDialog.js | 22 ++++++++---
source/jquery.artDialog.js | 78 ++++++++++++++++++++++----------------
5 files changed, 71 insertions(+), 49 deletions(-)
diff --git a/README.md b/README.md
index ad3b6e1..ccbfeac 100644
--- a/README.md
+++ b/README.md
@@ -60,8 +60,10 @@ artDialog 是一个精心设计的 web 对话框控件,它继承与延伸了
### 5.0.4
-1. 取消focus参数,对话框能自动处理
-2. 取消鸡肋的esc参数
+1. 取消 focus 参数,对话框能自动处理
+2. 取消鸡肋的 esc 参数
+3. 给关闭按钮增加 title,以便让读屏器正常发音(感谢 @杨永全 老师的建议)
+4. 解决 iframe 页面中上一版报错问题(ie8,9)#26 #21
### 5.0.3
diff --git a/artDialog.min.js b/artDialog.min.js
index dc805bc..de573c8 100644
--- a/artDialog.min.js
+++ b/artDialog.min.js
@@ -1,10 +1,9 @@
/*!
-* artDialog 5.0.3
-* Date: 2013-02-20
+* artDialog 5.0.4
+* Date: 2013-07-31
* https://github.com/aui/artDialog
* (c) 2009-2013 TangBin, http://www.planeArt.cn
*
* This is licensed under the GNU LGPL, version 2.1 or later.
* For details, see: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-(function(e,t){function s(e,t,n){t=t||document,n=n||"*";var r=0,i=0,s=[],o=t.getElementsByTagName(n),u=o.length,a=new RegExp("(^|\\s)"+e+"(\\s|$)");for(;r)[^>]*$|#([\w\-]+)$)/,i=/[\n\t]/g;return e.$===t&&(e.$=n),n.fn=n.prototype={constructor:function(e,t){var n,i;t=t||document;if(!e)return this;if(e.nodeType)return this[0]=e,this;if(typeof e=="string"){n=r.exec(e);if(n&&n[2])return i=t.getElementById(n[2]),i&&i.parentNode&&(this[0]=i),this}return this[0]=e,this},hasClass:function(e){var t=" "+e+" ";return(" "+this[0].className+" ").replace(i," ").indexOf(t)>-1?!0:!1},addClass:function(e){return this.hasClass(e)||(this[0].className+=" "+e),this},removeClass:function(e){var t=this[0];return e?this.hasClass(e)&&(t.className=t.className.replace(e," ")):t.className="",this},css:function(e,r){var i,s=this[0],o=arguments[0];if(typeof e=="string"){if(r===t)return n.css(s,e);s.style[e]=r}else for(i in o)s.style[i]=o[i];return this},show:function(){return this.css("display","block")},hide:function(){return this.css("display","none")},offset:function(){var e=this[0],t=e.getBoundingClientRect(),n=e.ownerDocument,r=n.body,i=n.documentElement,s=i.clientTop||r.clientTop||0,o=i.clientLeft||r.clientLeft||0,u=t.top+(self.pageYOffset||i.scrollTop)-s,a=t.left+(self.pageXOffset||i.scrollLeft)-o;return{left:a,top:u}},html:function(e){var r=this[0];return e===t?r.innerHTML:(n.cleanData(r.getElementsByTagName("*")),r.innerHTML=e,this)},remove:function(){var e=this[0];return n.cleanData(e.getElementsByTagName("*")),n.cleanData([e]),e.parentNode.removeChild(e),this},bind:function(e,t){return n.event.add(this[0],e,t),this},unbind:function(e,t){return n.event.remove(this[0],e,t),this}},n.fn.constructor.prototype=n.fn,n.isWindow=function(e){return e&&typeof e=="object"&&"setInterval"in e},n.fn.find=function(e){var t,r=this[0],i=e.split(".")[1];return i?document.getElementsByClassName?t=r.getElementsByClassName(i):t=s(i,r):t=r.getElementsByTagName(e),n(t[0])},n.each=function(e,n){var r,i=0,s=e.length,o=s===t;if(o){for(r in e)if(n.call(e[r],r,e[r])===!1)break}else for(var u=e[0];il&&g-E>N?g-E+v:x,T=T+S>c+C&&y-S>C?y-S:T,w.left=parseInt(x)+"px",w.top=parseInt(T)+"px",this._follow&&this._follow.removeAttribute(s),this._follow=t,t[s]=r.id,this},button:function(){var t=this.dom,n=t.buttons,r=n[0],i="d-state-highlight",s=this._listeners=this._listeners||{},o=[].slice.call(arguments),a=0,f,l,c,h,p;for(;a
',c.defaults={content:'