From e0f2c83ab8496d7a9ce717762f0aae00ef1aa232 Mon Sep 17 00:00:00 2001
From: 2betop <2betop.cn@gmail.com>
Date: Wed, 25 Dec 2013 13:24:13 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BA=A0=E6=AD=A3=E4=BE=9D=E8=B5=96=E9=94=99?=
=?UTF-8?q?=E8=AF=AF=EF=BC=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
examples/widget/tabs/tabs.html | 2 ++
examples/widget/tabs/tabs_ajax.html | 2 ++
examples/widget/tabs/tabs_history.html | 2 ++
examples/widget/tabs/tabs_json.html | 2 ++
examples/widget/tabs/tabs_nocache.html | 2 ++
examples/widget/tabs/tabs_render.html | 2 ++
examples/widget/tabs/tabs_tabs.html | 2 ++
src/extend/matchMedia.js | 16 ++++++++--------
src/widget/tabs/tabs.js | 12 ++++++------
9 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/examples/widget/tabs/tabs.html b/examples/widget/tabs/tabs.html
index 56ee2062..e6b4ad5b 100644
--- a/examples/widget/tabs/tabs.html
+++ b/examples/widget/tabs/tabs.html
@@ -27,6 +27,8 @@
+
+
diff --git a/examples/widget/tabs/tabs_ajax.html b/examples/widget/tabs/tabs_ajax.html
index 440da360..a827653d 100644
--- a/examples/widget/tabs/tabs_ajax.html
+++ b/examples/widget/tabs/tabs_ajax.html
@@ -28,6 +28,8 @@
+
+
diff --git a/examples/widget/tabs/tabs_history.html b/examples/widget/tabs/tabs_history.html
index 77b0a28d..4b6ca340 100644
--- a/examples/widget/tabs/tabs_history.html
+++ b/examples/widget/tabs/tabs_history.html
@@ -28,6 +28,8 @@
+
+
diff --git a/examples/widget/tabs/tabs_json.html b/examples/widget/tabs/tabs_json.html
index 46b0d8fa..d11bcce5 100644
--- a/examples/widget/tabs/tabs_json.html
+++ b/examples/widget/tabs/tabs_json.html
@@ -28,6 +28,8 @@
+
+
diff --git a/examples/widget/tabs/tabs_nocache.html b/examples/widget/tabs/tabs_nocache.html
index 16f5cc6b..34a48872 100644
--- a/examples/widget/tabs/tabs_nocache.html
+++ b/examples/widget/tabs/tabs_nocache.html
@@ -28,6 +28,8 @@
+
+
diff --git a/examples/widget/tabs/tabs_render.html b/examples/widget/tabs/tabs_render.html
index 52a52874..16f881cc 100644
--- a/examples/widget/tabs/tabs_render.html
+++ b/examples/widget/tabs/tabs_render.html
@@ -28,6 +28,8 @@
+
+
diff --git a/examples/widget/tabs/tabs_tabs.html b/examples/widget/tabs/tabs_tabs.html
index a0e3f33a..b8b78f57 100644
--- a/examples/widget/tabs/tabs_tabs.html
+++ b/examples/widget/tabs/tabs_tabs.html
@@ -28,6 +28,8 @@
+
+
diff --git a/src/extend/matchMedia.js b/src/extend/matchMedia.js
index 1c17abfb..5f2a1af4 100644
--- a/src/extend/matchMedia.js
+++ b/src/extend/matchMedia.js
@@ -19,22 +19,20 @@
* - ***addListener*** 添加MediaQueryList对象监听器,接收回调函数,回调参数为MediaQueryList对象
* - ***removeListener*** 移除MediaQueryList对象监听器
*
- *
+ *
* @method $.matchMedia
* @grammar $.matchMedia(query) ⇒ MediaQueryList
* @param {String} query 查询的css query,类似\'screen and (orientation: portrait)\'
* @return {Object} MediaQueryList
- * @example
+ * @example
* $.matchMedia('screen and (orientation: portrait)').addListener(fn);
*/
-
-
$.matchMedia = (function() {
var mediaId = 0,
cls = 'gmu-media-detect',
transitionEnd = $.fx.transitionEnd,
cssPrefix = $.fx.cssPrefix,
- $style = $('').append('.' + cls + '{' + cssPrefix + 'transition: width 0.001ms; width: 0; position: absolute; top: -10000px;}\n').appendTo('head');
+ $style = $('').append('.' + cls + '{' + cssPrefix + 'transition: width 0.001ms; width: 0; position: absolute; clip: rect(1px, 1px, 1px, 1px);}\n').appendTo('head');
return function (query) {
var id = cls + mediaId++,
@@ -43,9 +41,11 @@
ret;
$style.append('@media ' + query + ' { #' + id + ' { width: 1px; } }\n') ; //原生matchMedia也需要添加对应的@media才能生效
- if ('matchMedia' in window) {
- return window.matchMedia(query);
- }
+
+ // 统一用模拟的,时机更好。
+ // if ('matchMedia' in window) {
+ // return window.matchMedia(query);
+ // }
$mediaElem = $('