avalon-rails 1.5.5 → 1.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avalon-rails/version.rb +1 -1
- data/vendor/assets/javascripts/avalon.js +219 -173
- data/vendor/assets/javascripts/avalon.min.js +3 -3
- data/vendor/assets/javascripts/avalon.mobile.js +355 -337
- data/vendor/assets/javascripts/avalon.mobile.min.js +3 -3
- data/vendor/assets/javascripts/avalon.mobile.shim.js +353 -336
- data/vendor/assets/javascripts/avalon.mobile.shim.min.js +3 -3
- data/vendor/assets/javascripts/avalon.modern.js +265 -240
- data/vendor/assets/javascripts/avalon.modern.min.js +3 -3
- data/vendor/assets/javascripts/avalon.modern.shim.js +263 -239
- data/vendor/assets/javascripts/avalon.modern.shim.min.js +2 -2
- data/vendor/assets/javascripts/avalon.shim.js +240 -221
- data/vendor/assets/javascripts/avalon.shim.min.js +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8f08555d9453746ee97816cd94c4e8b1ca602bc
|
4
|
+
data.tar.gz: b0cdcbe82e87408d744ced71f7dcec1216ee2828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9039c2a59f7646c58eed5b5ace5b303d7397602838cbfaf510aec0dde3eb323ee09b9267958eaa5875fe9f3ef988e009c41d672581cdac26e277054e12a4acca
|
7
|
+
data.tar.gz: 23ff09cea6beee67527d76284850f73f680bc233f1d0d4493c26a29374aed62220f9155fc3d51b5c826b2178989a84a3f0d441b02373335bf4ca8b3970a54fc8
|
data/lib/avalon-rails/version.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
http://weibo.com/jslouvre/
|
6
6
|
|
7
7
|
Released under the MIT license
|
8
|
-
avalon.js 1.5.
|
8
|
+
avalon.js 1.5.6 built in 2015.12.1
|
9
9
|
support IE6+ and other browsers
|
10
10
|
==================================================*/
|
11
11
|
(function(global, factory) {
|
@@ -31,8 +31,9 @@
|
|
31
31
|
}(typeof window !== "undefined" ? window : this, function(window, noGlobal){
|
32
32
|
|
33
33
|
/*********************************************************************
|
34
|
-
* 全局变量及方法
|
34
|
+
* 全局变量及方法 *
|
35
35
|
**********************************************************************/
|
36
|
+
|
36
37
|
var expose = new Date() - 0
|
37
38
|
//http://stackoverflow.com/questions/7290086/javascript-use-strict-and-nicks-find-global-function
|
38
39
|
var DOC = window.document
|
@@ -43,20 +44,17 @@ ifGroup.setAttribute("ms-skip", "1")
|
|
43
44
|
ifGroup.className = "avalonHide"
|
44
45
|
var rnative = /\[native code\]/ //判定是否原生函数
|
45
46
|
function log() {
|
46
|
-
if (window.console &&
|
47
|
+
if (window.console && kernel.debug) {
|
47
48
|
// http://stackoverflow.com/questions/8785624/how-to-safely-wrap-console-log
|
48
49
|
Function.apply.call(console.log, console, arguments)
|
49
50
|
}
|
50
51
|
}
|
51
52
|
|
52
|
-
|
53
53
|
var subscribers = "$" + expose
|
54
54
|
|
55
|
-
var stopRepeatAssign = false
|
56
55
|
var nullObject = {} //作用类似于noop,只用于代码防御,千万不要在它上面添加属性
|
57
56
|
var rword = /[^, ]+/g //切割字符串为一个个小块,以空格或豆号分开它们,结合replace实现字符串的forEach
|
58
57
|
var rw20g = /\w+/g
|
59
|
-
var rcomplexType = /^(?:object|array)$/
|
60
58
|
var rsvg = /^\[object SVG\w*Element\]$/
|
61
59
|
var rwindow = /^\[object (?:Window|DOMWindow|global)\]$/
|
62
60
|
var oproto = Object.prototype
|
@@ -72,10 +70,16 @@ var class2type = {}
|
|
72
70
|
"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) {
|
73
71
|
class2type["[object " + name + "]"] = name.toLowerCase()
|
74
72
|
})
|
75
|
-
|
76
|
-
|
73
|
+
|
74
|
+
var IEVersion = NaN
|
75
|
+
if (window.VBArray) {
|
76
|
+
IEVersion = document.documentMode || (window.XMLHttpRequest ? 7 : 6)
|
77
77
|
}
|
78
|
+
|
78
79
|
function noop(){}
|
80
|
+
function scpCompile(array){
|
81
|
+
return Function.apply(noop, array)
|
82
|
+
}
|
79
83
|
|
80
84
|
function oneObject(array, val) {
|
81
85
|
if (typeof array === "string") {
|
@@ -94,21 +98,11 @@ var generateID = function (prefix) {
|
|
94
98
|
prefix = prefix || "avalon"
|
95
99
|
return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix)
|
96
100
|
}
|
97
|
-
function IE() {
|
98
|
-
if (window.VBArray) {
|
99
|
-
var mode = document.documentMode
|
100
|
-
return mode ? mode : window.XMLHttpRequest ? 7 : 6
|
101
|
-
} else {
|
102
|
-
return NaN
|
103
|
-
}
|
104
|
-
}
|
105
|
-
var IEVersion = IE()
|
106
101
|
|
107
102
|
avalon = function (el) { //创建jQuery式的无new 实例化结构
|
108
103
|
return new avalon.init(el)
|
109
104
|
}
|
110
105
|
|
111
|
-
|
112
106
|
/*视浏览器情况采用最快的异步回调*/
|
113
107
|
avalon.nextTick = new function () {// jshint ignore:line
|
114
108
|
var tickImmediate = window.setImmediate
|
@@ -142,9 +136,11 @@ avalon.nextTick = new function () {// jshint ignore:line
|
|
142
136
|
setTimeout(fn, 4)
|
143
137
|
}
|
144
138
|
}// jshint ignore:line
|
139
|
+
|
145
140
|
/*********************************************************************
|
146
141
|
* avalon的静态方法定义区 *
|
147
142
|
**********************************************************************/
|
143
|
+
|
148
144
|
avalon.init = function (el) {
|
149
145
|
this[0] = this.element = el
|
150
146
|
}
|
@@ -160,7 +156,7 @@ avalon.type = function (obj) { //取得目标的类型
|
|
160
156
|
typeof obj
|
161
157
|
}
|
162
158
|
|
163
|
-
|
159
|
+
avalon.isFunction = typeof alert === "object" ? function (fn) {
|
164
160
|
try {
|
165
161
|
return /^\s*\bfunction\b/.test(fn + "")
|
166
162
|
} catch (e) {
|
@@ -169,7 +165,6 @@ var isFunction = typeof alert === "object" ? function (fn) {
|
|
169
165
|
} : function (fn) {
|
170
166
|
return serialize.call(fn) === "[object Function]"
|
171
167
|
}
|
172
|
-
avalon.isFunction = isFunction
|
173
168
|
|
174
169
|
avalon.isWindow = function (obj) {
|
175
170
|
if (!obj)
|
@@ -185,11 +180,13 @@ function isWindow(obj) {
|
|
185
180
|
if (isWindow(window)) {
|
186
181
|
avalon.isWindow = isWindow
|
187
182
|
}
|
188
|
-
|
183
|
+
|
184
|
+
var enu, enumerateBUG
|
189
185
|
for (enu in avalon({})) {
|
190
186
|
break
|
191
187
|
}
|
192
|
-
|
188
|
+
enumerateBUG = enu !== "0" //IE6下为true, 其他为false
|
189
|
+
|
193
190
|
/*判定是否是一个朴素的javascript对象(Object),不是DOM对象,不是BOM对象,不是自定义类的实例*/
|
194
191
|
avalon.isPlainObject = function (obj, key) {
|
195
192
|
if (!obj || avalon.type(obj) !== "object" || obj.nodeType || avalon.isWindow(obj)) {
|
@@ -217,6 +214,7 @@ if (rnative.test(Object.getPrototypeOf)) {
|
|
217
214
|
return serialize.call(obj) === "[object Object]" && Object.getPrototypeOf(obj) === oproto
|
218
215
|
}
|
219
216
|
}
|
217
|
+
|
220
218
|
//与jQuery.extend方法,可用于浅拷贝,深拷贝
|
221
219
|
avalon.mix = avalon.fn.mix = function () {
|
222
220
|
var options, name, src, copy, copyIsArray, clone,
|
@@ -233,7 +231,7 @@ avalon.mix = avalon.fn.mix = function () {
|
|
233
231
|
}
|
234
232
|
|
235
233
|
//确保接受方为一个复杂的数据类型
|
236
|
-
if (typeof target !== "object" && !isFunction(target)) {
|
234
|
+
if (typeof target !== "object" && !avalon.isFunction(target)) {
|
237
235
|
target = {}
|
238
236
|
}
|
239
237
|
|
@@ -285,7 +283,7 @@ function _number(a, len) { //用于模拟slice, splice的效果
|
|
285
283
|
avalon.mix({
|
286
284
|
rword: rword,
|
287
285
|
subscribers: subscribers,
|
288
|
-
version: 1.
|
286
|
+
version: 1.56,
|
289
287
|
ui: {},
|
290
288
|
log: log,
|
291
289
|
slice: W3C ? function (nodes, start, end) {
|
@@ -484,7 +482,6 @@ function isArrayLike(obj) {
|
|
484
482
|
return false
|
485
483
|
}
|
486
484
|
|
487
|
-
|
488
485
|
// https://github.com/rsms/js-lru
|
489
486
|
var Cache = new function() {// jshint ignore:line
|
490
487
|
function LRU(maxLength) {
|
@@ -560,8 +557,9 @@ var Cache = new function() {// jshint ignore:line
|
|
560
557
|
}// jshint ignore:line
|
561
558
|
|
562
559
|
/*********************************************************************
|
563
|
-
* javascript 底层补丁
|
560
|
+
* javascript 底层补丁 *
|
564
561
|
**********************************************************************/
|
562
|
+
|
565
563
|
if (!"司徒正美".trim) {
|
566
564
|
var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g
|
567
565
|
String.prototype.trim = function () {
|
@@ -678,6 +676,7 @@ if (!rnative.test([].map)) {
|
|
678
676
|
every: iterator("", 'if(!_)return false', 'return true')
|
679
677
|
})
|
680
678
|
}
|
679
|
+
|
681
680
|
/*********************************************************************
|
682
681
|
* DOM 底层补丁 *
|
683
682
|
**********************************************************************/
|
@@ -879,8 +878,6 @@ if (DOC.onmousewheel === void 0) {
|
|
879
878
|
}
|
880
879
|
}
|
881
880
|
|
882
|
-
|
883
|
-
|
884
881
|
/*********************************************************************
|
885
882
|
* 配置系统 *
|
886
883
|
**********************************************************************/
|
@@ -900,6 +897,8 @@ function kernel(settings) {
|
|
900
897
|
}
|
901
898
|
return this
|
902
899
|
}
|
900
|
+
avalon.config = kernel
|
901
|
+
|
903
902
|
var openTag, closeTag, rexpr, rexprg, rbind, rregexp = /[-.*+?^${}()|[\]\/\\]/g
|
904
903
|
|
905
904
|
function escapeRegExp(target) {
|
@@ -930,18 +929,20 @@ var plugins = {
|
|
930
929
|
rbind = new RegExp(o + ".*?" + c + "|\\sms-")
|
931
930
|
}
|
932
931
|
}
|
933
|
-
kernel.async =true
|
934
|
-
kernel.debug = true
|
935
932
|
kernel.plugins = plugins
|
936
933
|
kernel.plugins['interpolate'](["{{", "}}"])
|
934
|
+
|
935
|
+
kernel.async =true
|
936
|
+
kernel.debug = true
|
937
937
|
kernel.paths = {}
|
938
938
|
kernel.shim = {}
|
939
939
|
kernel.maxRepeatSize = 100
|
940
|
-
|
940
|
+
|
941
941
|
function $watch(expr, binding) {
|
942
942
|
var $events = this.$events || (this.$events = {})
|
943
943
|
|
944
944
|
var queue = $events[expr] || ($events[expr] = [])
|
945
|
+
|
945
946
|
if (typeof binding === "function") {
|
946
947
|
var backup = binding
|
947
948
|
backup.uniqueNumber = Math.random()
|
@@ -957,7 +958,7 @@ function $watch(expr, binding) {
|
|
957
958
|
}
|
958
959
|
|
959
960
|
if (!binding.update) {
|
960
|
-
if (/\w\.*\B/.test(expr)) {
|
961
|
+
if (/\w\.*\B/.test(expr) || expr === "*") {
|
961
962
|
binding.getter = noop
|
962
963
|
var host = this
|
963
964
|
binding.update = function () {
|
@@ -990,6 +991,14 @@ function $emit(key, args) {
|
|
990
991
|
}
|
991
992
|
var arr = event[key]
|
992
993
|
notifySubscribers(arr, args)
|
994
|
+
if (args && event["*"] && !/\./.test(key)) {
|
995
|
+
for (var sub, k = 0; sub = event["*"][k++]; ) {
|
996
|
+
try {
|
997
|
+
sub.handler.apply(this, args)
|
998
|
+
} catch (e) {
|
999
|
+
}
|
1000
|
+
}
|
1001
|
+
}
|
993
1002
|
var parent = this.$up
|
994
1003
|
if (parent) {
|
995
1004
|
if (this.$pathname) {
|
@@ -1000,10 +1009,10 @@ function $emit(key, args) {
|
|
1000
1009
|
}
|
1001
1010
|
} else {
|
1002
1011
|
parent = this.$up
|
1003
|
-
|
1004
|
-
if(this.$ups
|
1005
|
-
for(var i in this.$ups){
|
1006
|
-
$emit.call(this.$ups[i], i+"."+key, args)//以确切的值往上冒泡
|
1012
|
+
|
1013
|
+
if (this.$ups) {
|
1014
|
+
for (var i in this.$ups) {
|
1015
|
+
$emit.call(this.$ups[i], i + "." + key, args)//以确切的值往上冒泡
|
1007
1016
|
}
|
1008
1017
|
return
|
1009
1018
|
}
|
@@ -1024,7 +1033,6 @@ function $emit(key, args) {
|
|
1024
1033
|
}
|
1025
1034
|
}
|
1026
1035
|
|
1027
|
-
|
1028
1036
|
function collectDependency(el, key) {
|
1029
1037
|
do {
|
1030
1038
|
if (el.$watch) {
|
@@ -1043,7 +1051,6 @@ function collectDependency(el, key) {
|
|
1043
1051
|
} while (true)
|
1044
1052
|
}
|
1045
1053
|
|
1046
|
-
|
1047
1054
|
function notifySubscribers(subs, args) {
|
1048
1055
|
if (!subs)
|
1049
1056
|
return
|
@@ -1084,6 +1091,7 @@ function notifySubscribers(subs, args) {
|
|
1084
1091
|
sub.update()
|
1085
1092
|
}
|
1086
1093
|
}
|
1094
|
+
|
1087
1095
|
//avalon最核心的方法的两个方法之一(另一个是avalon.scan),返回一个ViewModel(VM)
|
1088
1096
|
var VMODELS = avalon.vmodels = {} //所有vmodel都储存在这里
|
1089
1097
|
avalon.define = function (source) {
|
@@ -1172,7 +1180,6 @@ function observeObject(source, options) {
|
|
1172
1180
|
}
|
1173
1181
|
}
|
1174
1182
|
|
1175
|
-
|
1176
1183
|
for (name in source) {
|
1177
1184
|
var value = source[name]
|
1178
1185
|
if (!$$skipArray[name])
|
@@ -1212,7 +1219,6 @@ function observeObject(source, options) {
|
|
1212
1219
|
}
|
1213
1220
|
}
|
1214
1221
|
|
1215
|
-
|
1216
1222
|
accessors["$model"] = $modelDescriptor
|
1217
1223
|
$vmodel = defineProperties($vmodel, accessors, source)
|
1218
1224
|
function trackBy(name) {
|
@@ -1264,6 +1270,7 @@ function observeObject(source, options) {
|
|
1264
1270
|
$vmodel.$active = true
|
1265
1271
|
return $vmodel
|
1266
1272
|
}
|
1273
|
+
|
1267
1274
|
/*
|
1268
1275
|
新的VM拥有如下私有属性
|
1269
1276
|
$id: vm.id
|
@@ -1350,6 +1357,7 @@ function observe(obj, old, hasReturn, watch) {
|
|
1350
1357
|
return obj
|
1351
1358
|
}
|
1352
1359
|
}
|
1360
|
+
|
1353
1361
|
var getKeys = rnative.test(Object.key) ? Object.key : function (a) {
|
1354
1362
|
var ret = []
|
1355
1363
|
for (var i in a) {
|
@@ -1359,8 +1367,9 @@ var getKeys = rnative.test(Object.key) ? Object.key : function (a) {
|
|
1359
1367
|
}
|
1360
1368
|
return ret
|
1361
1369
|
}
|
1370
|
+
|
1362
1371
|
function observeArray(array, old, watch) {
|
1363
|
-
if (old) {
|
1372
|
+
if (old && old.splice) {
|
1364
1373
|
var args = [0, old.length].concat(array)
|
1365
1374
|
old.splice.apply(old, args)
|
1366
1375
|
return old
|
@@ -1448,7 +1457,6 @@ var $modelDescriptor = {
|
|
1448
1457
|
configurable: true
|
1449
1458
|
}
|
1450
1459
|
|
1451
|
-
|
1452
1460
|
//===================修复浏览器对Object.defineProperties的支持=================
|
1453
1461
|
if (!canHideOwn) {
|
1454
1462
|
if ("__defineGetter__" in avalon) {
|
@@ -1631,6 +1639,7 @@ var newProto = {
|
|
1631
1639
|
return this.removeAll()
|
1632
1640
|
}
|
1633
1641
|
}
|
1642
|
+
|
1634
1643
|
var _splice = arrayProto.splice
|
1635
1644
|
arrayMethods.forEach(function (method) {
|
1636
1645
|
var original = arrayProto[method]
|
@@ -1723,9 +1732,11 @@ function addTrack(track, method, args) {
|
|
1723
1732
|
}
|
1724
1733
|
Array.prototype[method].apply(track, args)
|
1725
1734
|
}
|
1735
|
+
|
1726
1736
|
/*********************************************************************
|
1727
|
-
* 依赖调度系统
|
1737
|
+
* 依赖调度系统 *
|
1728
1738
|
**********************************************************************/
|
1739
|
+
|
1729
1740
|
//检测两个对象间的依赖关系
|
1730
1741
|
var dependencyDetection = (function () {
|
1731
1742
|
var outerFrames = []
|
@@ -1747,6 +1758,7 @@ var dependencyDetection = (function () {
|
|
1747
1758
|
}
|
1748
1759
|
};
|
1749
1760
|
})()
|
1761
|
+
|
1750
1762
|
//将绑定对象注入到其依赖项的订阅数组中
|
1751
1763
|
var roneval = /^on$/
|
1752
1764
|
|
@@ -1779,7 +1791,11 @@ avalon.injectBinding = function (binding) {
|
|
1779
1791
|
if (binding.type === "on") {
|
1780
1792
|
a = binding.getter + ""
|
1781
1793
|
} else {
|
1782
|
-
|
1794
|
+
try {
|
1795
|
+
a = binding.getter.apply(0, binding.args)
|
1796
|
+
} catch (ex) {
|
1797
|
+
a = null
|
1798
|
+
}
|
1783
1799
|
}
|
1784
1800
|
} else {
|
1785
1801
|
a = args[0]
|
@@ -1826,7 +1842,6 @@ avalon.injectBinding = function (binding) {
|
|
1826
1842
|
binding.update()
|
1827
1843
|
}
|
1828
1844
|
|
1829
|
-
|
1830
1845
|
//将依赖项(比它高层的访问器或构建视图刷新函数的绑定对象)注入到订阅者数组
|
1831
1846
|
function injectDependency(list, binding) {
|
1832
1847
|
if (binding.oneTime)
|
@@ -1839,7 +1854,6 @@ function injectDependency(list, binding) {
|
|
1839
1854
|
}
|
1840
1855
|
}
|
1841
1856
|
|
1842
|
-
|
1843
1857
|
function getProxyIds(a, isArray) {
|
1844
1858
|
var ret = []
|
1845
1859
|
for (var i = 0, el; el = a[i++]; ) {
|
@@ -1851,6 +1865,7 @@ function getProxyIds(a, isArray) {
|
|
1851
1865
|
/*********************************************************************
|
1852
1866
|
* 定时GC回收机制 *
|
1853
1867
|
**********************************************************************/
|
1868
|
+
|
1854
1869
|
var disposeCount = 0
|
1855
1870
|
var disposeQueue = avalon.$$subscribers = []
|
1856
1871
|
var beginTime = new Date()
|
@@ -1957,11 +1972,10 @@ function shouldDispose(el) {
|
|
1957
1972
|
return el.msRetain ? 0 : (el.nodeType === 1 ? !root.contains(el) : !avalon.contains(root, el))
|
1958
1973
|
}
|
1959
1974
|
|
1960
|
-
|
1961
|
-
|
1962
1975
|
/************************************************************************
|
1963
|
-
*
|
1964
|
-
|
1976
|
+
* HTML处理(parseHTML, innerHTML, clearHTML) *
|
1977
|
+
*************************************************************************/
|
1978
|
+
|
1965
1979
|
// We have to close these tags to support XHTML
|
1966
1980
|
var tagHooks = {
|
1967
1981
|
area: [1, "<map>", "</map>"],
|
@@ -1982,6 +1996,7 @@ tagHooks.tbody = tagHooks.tfoot = tagHooks.colgroup = tagHooks.caption = tagHook
|
|
1982
1996
|
String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(rword, function (tag) {
|
1983
1997
|
tagHooks[tag] = tagHooks.g //处理SVG
|
1984
1998
|
})
|
1999
|
+
|
1985
2000
|
var rtagName = /<([\w:]+)/ //取得其tagName
|
1986
2001
|
var rxhtml = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig
|
1987
2002
|
var rcreate = W3C ? /[^\d\D]/ : /(<(?:script|link|style|meta|noscript))/ig
|
@@ -1989,6 +2004,7 @@ var scriptTypes = oneObject(["", "text/javascript", "text/ecmascript", "applicat
|
|
1989
2004
|
var rnest = /<(?:tb|td|tf|th|tr|col|opt|leg|cap|area)/ //需要处理套嵌关系的标签
|
1990
2005
|
var script = DOC.createElement("script")
|
1991
2006
|
var rhtml = /<|&#?\w+;/
|
2007
|
+
|
1992
2008
|
avalon.parseHTML = function (html) {
|
1993
2009
|
var fragment = avalonFragment.cloneNode(false)
|
1994
2010
|
if (typeof html !== "string") {
|
@@ -2071,6 +2087,7 @@ function fixVML(node) {
|
|
2071
2087
|
node.style.zoom = 1 //hasLayout
|
2072
2088
|
}
|
2073
2089
|
}
|
2090
|
+
|
2074
2091
|
avalon.innerHTML = function (node, html) {
|
2075
2092
|
if (!W3C && (!rcreate.test(html) && !rnest.test(html))) {
|
2076
2093
|
try {
|
@@ -2081,6 +2098,7 @@ avalon.innerHTML = function (node, html) {
|
|
2081
2098
|
var a = this.parseHTML(html)
|
2082
2099
|
this.clearHTML(node).appendChild(a)
|
2083
2100
|
}
|
2101
|
+
|
2084
2102
|
avalon.clearHTML = function (node) {
|
2085
2103
|
node.textContent = ""
|
2086
2104
|
while (node.firstChild) {
|
@@ -2090,7 +2108,7 @@ avalon.clearHTML = function (node) {
|
|
2090
2108
|
}
|
2091
2109
|
|
2092
2110
|
/*********************************************************************
|
2093
|
-
* avalon的原型方法定义区
|
2111
|
+
* avalon的原型方法定义区 *
|
2094
2112
|
**********************************************************************/
|
2095
2113
|
|
2096
2114
|
function hyphen(target) {
|
@@ -2321,6 +2339,20 @@ avalon.parseJSON = window.JSON ? JSON.parse : function (data) {
|
|
2321
2339
|
return data
|
2322
2340
|
}
|
2323
2341
|
|
2342
|
+
avalon.fireDom = function (elem, type, opts) {
|
2343
|
+
if (DOC.createEvent) {
|
2344
|
+
var hackEvent = DOC.createEvent("Events");
|
2345
|
+
hackEvent.initEvent(type, true, true, opts)
|
2346
|
+
avalon.mix(hackEvent, opts)
|
2347
|
+
|
2348
|
+
elem.dispatchEvent(hackEvent)
|
2349
|
+
} else if (root.contains(elem)) {//IE6-8触发事件必须保证在DOM树中,否则报"SCRIPT16389: 未指明的错误"
|
2350
|
+
hackEvent = DOC.createEventObject()
|
2351
|
+
avalon.mix(hackEvent, opts)
|
2352
|
+
elem.fireEvent("on" + type, hackEvent)
|
2353
|
+
}
|
2354
|
+
}
|
2355
|
+
|
2324
2356
|
//生成avalon.fn.scrollLeft, avalon.fn.scrollTop方法
|
2325
2357
|
avalon.each({
|
2326
2358
|
scrollLeft: "pageXOffset",
|
@@ -2652,13 +2684,13 @@ var keys = ["break,case,catch,continue,debugger,default,delete,do,else,false",
|
|
2652
2684
|
keys.replace(/\w+/g, function (a) {
|
2653
2685
|
keyMap[a] = true
|
2654
2686
|
})
|
2687
|
+
|
2655
2688
|
var ridentStart = /[a-z_$]/i
|
2656
2689
|
var rwhiteSpace = /[\s\uFEFF\xA0]/
|
2657
2690
|
function getIdent(input, lastIndex) {
|
2658
2691
|
var result = []
|
2659
2692
|
var subroutine = !!lastIndex
|
2660
2693
|
lastIndex = lastIndex || 0
|
2661
|
-
|
2662
2694
|
//将表达式中的标识符抽取出来
|
2663
2695
|
var state = "unknown"
|
2664
2696
|
var variable = ""
|
@@ -2742,12 +2774,14 @@ function getIdent(input, lastIndex) {
|
|
2742
2774
|
addVar(result, variable)
|
2743
2775
|
return result
|
2744
2776
|
}
|
2777
|
+
|
2745
2778
|
function addVar(array, element) {
|
2746
2779
|
if (element && !keyMap[element]) {
|
2747
2780
|
array.push(element)
|
2748
2781
|
return true
|
2749
2782
|
}
|
2750
2783
|
}
|
2784
|
+
|
2751
2785
|
function addAssign(vars, vmodel, name, binding) {
|
2752
2786
|
var ret = [],
|
2753
2787
|
prefix = " = " + name + "."
|
@@ -2769,6 +2803,7 @@ function addAssign(vars, vmodel, name, binding) {
|
|
2769
2803
|
}
|
2770
2804
|
return ret
|
2771
2805
|
}
|
2806
|
+
|
2772
2807
|
var rproxy = /(\$proxy\$[a-z]+)\d+$/
|
2773
2808
|
var variablePool = new Cache(218)
|
2774
2809
|
//缓存求值函数,以便多次利用
|
@@ -2871,7 +2906,6 @@ function parseExpr(expr, vmodels, binding) {
|
|
2871
2906
|
return evaluatorPool.put(exprId, getter)
|
2872
2907
|
|
2873
2908
|
}
|
2874
|
-
//========
|
2875
2909
|
|
2876
2910
|
function normalizeExpr(code) {
|
2877
2911
|
var hasExpr = rexpr.test(code) //比如ms-class="width{{w}}"的情况
|
@@ -2916,9 +2950,11 @@ function parseFilter(filters) {
|
|
2916
2950
|
/* jshint ignore:end */
|
2917
2951
|
|
2918
2952
|
}
|
2953
|
+
|
2919
2954
|
/*********************************************************************
|
2920
2955
|
* 编译系统 *
|
2921
2956
|
**********************************************************************/
|
2957
|
+
|
2922
2958
|
var meta = {
|
2923
2959
|
'\b': '\\b',
|
2924
2960
|
'\t': '\\t',
|
@@ -2960,7 +2996,6 @@ function checkScan(elem, callback, innerHTML) {
|
|
2960
2996
|
})
|
2961
2997
|
}
|
2962
2998
|
|
2963
|
-
|
2964
2999
|
function createSignalTower(elem, vmodel) {
|
2965
3000
|
var id = elem.getAttribute("avalonctrl") || vmodel.$id
|
2966
3001
|
elem.setAttribute("avalonctrl", id)
|
@@ -3021,6 +3056,26 @@ function bindingSorter(a, b) {
|
|
3021
3056
|
return a.priority - b.priority
|
3022
3057
|
}
|
3023
3058
|
|
3059
|
+
var rnoCollect = /^(ms-\S+|data-\S+|on[a-z]+|id|style|class)$/
|
3060
|
+
var ronattr = /^on\-[\w-]+$/
|
3061
|
+
function getOptionsFromTag(elem, vmodels) {
|
3062
|
+
var attributes = elem.attributes
|
3063
|
+
var ret = {}
|
3064
|
+
for (var i = 0, attr; attr = attributes[i++]; ) {
|
3065
|
+
var name = attr.name
|
3066
|
+
if (attr.specified && !rnoCollect.test(name)) {
|
3067
|
+
var camelizeName = camelize(attr.name)
|
3068
|
+
if (/^on\-[\w-]+$/.test(name)) {
|
3069
|
+
ret[camelizeName] = getBindingCallback(elem, name, vmodels)
|
3070
|
+
} else {
|
3071
|
+
ret[camelizeName] = parseData(attr.value)
|
3072
|
+
}
|
3073
|
+
}
|
3074
|
+
|
3075
|
+
}
|
3076
|
+
return ret
|
3077
|
+
}
|
3078
|
+
|
3024
3079
|
function scanAttr(elem, vmodels, match) {
|
3025
3080
|
var scanNode = true
|
3026
3081
|
if (vmodels.length) {
|
@@ -3159,28 +3214,21 @@ if (!W3C) {
|
|
3159
3214
|
}
|
3160
3215
|
}
|
3161
3216
|
|
3162
|
-
var rnoCollect = /^(ms-\S+|data-\S+|on[a-z]+|id|style|class|tabindex)$/
|
3163
|
-
function getOptionsFromTag(elem) {
|
3164
|
-
var attributes = getAttributes ? getAttributes(elem) : elem.attributes
|
3165
|
-
var ret = {}
|
3166
|
-
for (var i = 0, attr; attr = attributes[i++]; ) {
|
3167
|
-
if (attr.specified && !rnoCollect.test(attr.name)) {
|
3168
|
-
ret[camelize(attr.name)] = parseData(attr.value)
|
3169
|
-
}
|
3170
|
-
}
|
3171
|
-
return ret
|
3172
|
-
}
|
3173
3217
|
function scanNodeList(parent, vmodels) {
|
3174
3218
|
var nodes = avalon.slice(parent.childNodes)
|
3175
3219
|
scanNodeArray(nodes, vmodels)
|
3176
3220
|
}
|
3177
3221
|
|
3178
|
-
|
3179
3222
|
function scanNodeArray(nodes, vmodels) {
|
3223
|
+
function _delay_component(name) {
|
3224
|
+
setTimeout(function () {
|
3225
|
+
avalon.component(name)
|
3226
|
+
})
|
3227
|
+
}
|
3180
3228
|
for (var i = 0, node; node = nodes[i++]; ) {
|
3181
3229
|
switch (node.nodeType) {
|
3182
3230
|
case 1:
|
3183
|
-
var elem = node
|
3231
|
+
var elem = node
|
3184
3232
|
if (!elem.msResolved && elem.parentNode && elem.parentNode.nodeType === 1) {
|
3185
3233
|
var library = isWidget(elem)
|
3186
3234
|
if (library) {
|
@@ -3195,11 +3243,14 @@ function scanNodeArray(nodes, vmodels) {
|
|
3195
3243
|
name: "widget"
|
3196
3244
|
})
|
3197
3245
|
if (avalon.components[fullName]) {
|
3198
|
-
|
3246
|
+
//确保所有ms-attr-name扫描完再处理
|
3247
|
+
_delay_component(fullName)
|
3199
3248
|
}
|
3200
3249
|
}
|
3201
3250
|
}
|
3202
|
-
|
3251
|
+
|
3252
|
+
scanTag(node, vmodels) //扫描元素节点
|
3253
|
+
|
3203
3254
|
if (node.msHasEvent) {
|
3204
3255
|
avalon.fireDom(node, "datasetchanged", {
|
3205
3256
|
bubble: node.msHasEvent
|
@@ -3217,7 +3268,6 @@ function scanNodeArray(nodes, vmodels) {
|
|
3217
3268
|
}
|
3218
3269
|
}
|
3219
3270
|
|
3220
|
-
|
3221
3271
|
function scanTag(elem, vmodels, node) {
|
3222
3272
|
//扫描顺序 ms-skip(0) --> ms-important(1) --> ms-controller(2) --> ms-if(10) --> ms-repeat(100)
|
3223
3273
|
//--> ms-if-loop(110) --> ms-attr(970) ...--> ms-each(1400)-->ms-with(1500)--〉ms-duplex(2000)垫后
|
@@ -3242,12 +3292,15 @@ function scanTag(elem, vmodels, node) {
|
|
3242
3292
|
avalon(elem).removeClass(name)
|
3243
3293
|
createSignalTower(elem, newVmodel)
|
3244
3294
|
}
|
3245
|
-
|
3295
|
+
|
3246
3296
|
scanAttr(elem, vmodels) //扫描特性节点
|
3297
|
+
if (newVmodel) {
|
3298
|
+
setTimeout(function () {
|
3299
|
+
newVmodel.$fire("ms-scan-end", elem)
|
3300
|
+
})
|
3301
|
+
}
|
3247
3302
|
}
|
3248
3303
|
|
3249
|
-
|
3250
|
-
|
3251
3304
|
var rhasHtml = /\|\s*html(?:\b|$)/,
|
3252
3305
|
r11a = /\|\|/g,
|
3253
3306
|
rlt = /</g,
|
@@ -3337,8 +3390,6 @@ function scanText(textNode, vmodels, index) {
|
|
3337
3390
|
}
|
3338
3391
|
}
|
3339
3392
|
|
3340
|
-
|
3341
|
-
|
3342
3393
|
//使用来自游戏界的双缓冲技术,减少对视图的冗余刷新
|
3343
3394
|
var Buffer = function () {
|
3344
3395
|
this.queue = []
|
@@ -3363,6 +3414,7 @@ Buffer.prototype = {
|
|
3363
3414
|
}
|
3364
3415
|
|
3365
3416
|
var buffer = new Buffer()
|
3417
|
+
|
3366
3418
|
var componentQueue = []
|
3367
3419
|
var widgetList = []
|
3368
3420
|
var componentHooks = {
|
@@ -3381,7 +3433,6 @@ var componentHooks = {
|
|
3381
3433
|
}
|
3382
3434
|
}
|
3383
3435
|
|
3384
|
-
|
3385
3436
|
avalon.components = {}
|
3386
3437
|
avalon.component = function (name, opts) {
|
3387
3438
|
if (opts) {
|
@@ -3393,15 +3444,24 @@ avalon.component = function (name, opts) {
|
|
3393
3444
|
i--;
|
3394
3445
|
|
3395
3446
|
(function (host, hooks, elem, widget) {
|
3396
|
-
|
3447
|
+
//如果elem已从Document里移除,直接返回
|
3448
|
+
//issuse : https://github.com/RubyLouvre/avalon2/issues/40
|
3449
|
+
if (!avalon.contains(DOC, elem) || elem.msResolved) {
|
3450
|
+
avalon.Array.remove(componentQueue, host)
|
3451
|
+
return
|
3452
|
+
}
|
3453
|
+
|
3397
3454
|
var dependencies = 1
|
3398
3455
|
var library = host.library
|
3399
3456
|
var global = avalon.libraries[library] || componentHooks
|
3400
3457
|
|
3401
3458
|
//===========收集各种配置=======
|
3402
|
-
|
3403
|
-
|
3404
|
-
|
3459
|
+
if (elem.getAttribute("ms-attr-identifier")) {
|
3460
|
+
//如果还没有解析完,就延迟一下 #1155
|
3461
|
+
return
|
3462
|
+
}
|
3463
|
+
var elemOpts = getOptionsFromTag(elem, host.vmodels)
|
3464
|
+
var vmOpts = getOptionsFromVM(host.vmodels, elemOpts.config || host.fullName)
|
3405
3465
|
var $id = elemOpts.$id || elemOpts.identifier || generateID(widget)
|
3406
3466
|
delete elemOpts.config
|
3407
3467
|
delete elemOpts.$id
|
@@ -3431,7 +3491,7 @@ avalon.component = function (name, opts) {
|
|
3431
3491
|
delete componentDefinition.$construct
|
3432
3492
|
|
3433
3493
|
var vmodel = avalon.define(componentDefinition) || {}
|
3434
|
-
elem.msResolved = 1
|
3494
|
+
elem.msResolved = 1 //防止二进扫描此元素
|
3435
3495
|
vmodel.$init(vmodel, elem)
|
3436
3496
|
global.$init(vmodel, elem)
|
3437
3497
|
var nodes = elem.childNodes
|
@@ -3448,7 +3508,6 @@ avalon.component = function (name, opts) {
|
|
3448
3508
|
}
|
3449
3509
|
}
|
3450
3510
|
|
3451
|
-
|
3452
3511
|
if (vmodel.$$template) {
|
3453
3512
|
avalon.clearHTML(elem)
|
3454
3513
|
elem.innerHTML = vmodel.$$template(keepTemplate)
|
@@ -3467,12 +3526,17 @@ avalon.component = function (name, opts) {
|
|
3467
3526
|
}
|
3468
3527
|
}
|
3469
3528
|
slots = null
|
3470
|
-
var child = elem.firstChild
|
3529
|
+
var child = elem.children[0] || elem.firstChild
|
3471
3530
|
if (keepReplace) {
|
3472
|
-
child = elem.firstChild
|
3473
3531
|
elem.parentNode.replaceChild(child, elem)
|
3474
3532
|
child.msResolved = 1
|
3533
|
+
var cssText = elem.style.cssText
|
3534
|
+
var className = elem.className
|
3475
3535
|
elem = host.element = child
|
3536
|
+
elem.style.cssText += ";"+ cssText
|
3537
|
+
if (className) {
|
3538
|
+
avalon(elem).addClass(className)
|
3539
|
+
}
|
3476
3540
|
}
|
3477
3541
|
if (keepContainer) {
|
3478
3542
|
keepContainer.appendChild(elem)
|
@@ -3495,7 +3559,7 @@ avalon.component = function (name, opts) {
|
|
3495
3559
|
if (dependencies === 0) {
|
3496
3560
|
var id1 = setTimeout(function () {
|
3497
3561
|
clearTimeout(id1)
|
3498
|
-
|
3562
|
+
|
3499
3563
|
vmodel.$ready(vmodel, elem, host.vmodels)
|
3500
3564
|
global.$ready(vmodel, elem, host.vmodels)
|
3501
3565
|
}, children ? Math.max(children * 17, 100) : 17)
|
@@ -3519,7 +3583,6 @@ avalon.component = function (name, opts) {
|
|
3519
3583
|
}
|
3520
3584
|
})
|
3521
3585
|
scanTag(elem, [vmodel].concat(host.vmodels))
|
3522
|
-
|
3523
3586
|
avalon.vmodels[vmodel.$id] = vmodel
|
3524
3587
|
if (!elem.childNodes.length) {
|
3525
3588
|
avalon.fireDom(elem, "datasetchanged", {library: library, vm: vmodel, childReady: -1})
|
@@ -3530,28 +3593,12 @@ avalon.component = function (name, opts) {
|
|
3530
3593
|
}, 17)
|
3531
3594
|
}
|
3532
3595
|
|
3533
|
-
|
3534
3596
|
})(obj, avalon.components[name], obj.element, obj.widget)// jshint ignore:line
|
3535
3597
|
|
3536
|
-
|
3537
3598
|
}
|
3538
3599
|
}
|
3539
3600
|
}
|
3540
3601
|
|
3541
|
-
avalon.fireDom = function (elem, type, opts) {
|
3542
|
-
if (DOC.createEvent) {
|
3543
|
-
var hackEvent = DOC.createEvent("Events");
|
3544
|
-
hackEvent.initEvent(type, true, true, opts)
|
3545
|
-
avalon.mix(hackEvent, opts)
|
3546
|
-
|
3547
|
-
elem.dispatchEvent(hackEvent)
|
3548
|
-
} else if (root.contains(elem)) {//IE6-8触发事件必须保证在DOM树中,否则报"SCRIPT16389: 未指明的错误"
|
3549
|
-
hackEvent = DOC.createEventObject()
|
3550
|
-
avalon.mix(hackEvent, opts)
|
3551
|
-
elem.fireEvent("on" + type, hackEvent)
|
3552
|
-
}
|
3553
|
-
}
|
3554
|
-
|
3555
3602
|
|
3556
3603
|
function getOptionsFromVM(vmodels, pre) {
|
3557
3604
|
if (pre) {
|
@@ -3566,8 +3613,6 @@ function getOptionsFromVM(vmodels, pre) {
|
|
3566
3613
|
return {}
|
3567
3614
|
}
|
3568
3615
|
|
3569
|
-
|
3570
|
-
|
3571
3616
|
avalon.libraries = []
|
3572
3617
|
avalon.library = function (name, opts) {
|
3573
3618
|
if (DOC.namespaces) {
|
@@ -3581,19 +3626,20 @@ avalon.library = function (name, opts) {
|
|
3581
3626
|
}
|
3582
3627
|
|
3583
3628
|
avalon.library("ms")
|
3584
|
-
/*
|
3585
|
-
broswer nodeName scopeName localName
|
3586
|
-
IE9 ONI:BUTTON oni button
|
3587
|
-
IE10 ONI:BUTTON undefined oni:button
|
3588
|
-
IE8 button oni undefined
|
3589
|
-
chrome ONI:BUTTON undefined oni:button
|
3590
3629
|
|
3591
|
-
|
3630
|
+
/*
|
3631
|
+
broswer nodeName scopeName localName
|
3632
|
+
IE9 ONI:BUTTON oni button
|
3633
|
+
IE10 ONI:BUTTON undefined oni:button
|
3634
|
+
IE8 button oni undefined
|
3635
|
+
chrome ONI:BUTTON undefined oni:button
|
3636
|
+
|
3637
|
+
*/
|
3592
3638
|
function isWidget(el) { //如果为自定义标签,返回UI库的名字
|
3593
|
-
if(el.scopeName && el.scopeName !== "HTML"
|
3639
|
+
if (el.scopeName && el.scopeName !== "HTML") {
|
3594
3640
|
return el.scopeName
|
3595
3641
|
}
|
3596
|
-
var fullName = el.nodeName.toLowerCase()
|
3642
|
+
var fullName = el.nodeName.toLowerCase()
|
3597
3643
|
var index = fullName.indexOf(":")
|
3598
3644
|
if (index > 0) {
|
3599
3645
|
return fullName.slice(0, index)
|
@@ -3602,7 +3648,6 @@ function isWidget(el) { //如果为自定义标签,返回UI库的名字
|
|
3602
3648
|
//各种MVVM框架在大型表格下的性能测试
|
3603
3649
|
// https://github.com/RubyLouvre/avalon/issues/859
|
3604
3650
|
|
3605
|
-
|
3606
3651
|
var bools = ["autofocus,autoplay,async,allowTransparency,checked,controls",
|
3607
3652
|
"declare,disabled,defer,defaultChecked,defaultSelected",
|
3608
3653
|
"contentEditable,isMap,loop,multiple,noHref,noResize,noShade",
|
@@ -3702,8 +3747,6 @@ var attrDir = avalon.directive("attr", {
|
|
3702
3747
|
}
|
3703
3748
|
})
|
3704
3749
|
|
3705
|
-
|
3706
|
-
|
3707
3750
|
//这几个指令都可以使用插值表达式,如ms-src="aaa/{{b}}/{{c}}.html"
|
3708
3751
|
"title,alt,src,value,css,include,href".replace(rword, function (name) {
|
3709
3752
|
directives[name] = attrDir
|
@@ -3777,7 +3820,6 @@ avalon.directive("class", {
|
|
3777
3820
|
directives[name] = directives["class"]
|
3778
3821
|
})
|
3779
3822
|
|
3780
|
-
|
3781
3823
|
//ms-controller绑定已经在scanTag 方法中实现
|
3782
3824
|
avalon.directive("css", {
|
3783
3825
|
init: directives.attr.init,
|
@@ -3848,7 +3890,7 @@ var duplexBinding = avalon.directive("duplex", {
|
|
3848
3890
|
"input"
|
3849
3891
|
}
|
3850
3892
|
//===================绑定事件======================
|
3851
|
-
binding.bound = function (type, callback) {
|
3893
|
+
var bound = binding.bound = function (type, callback) {
|
3852
3894
|
if (elem.addEventListener) {
|
3853
3895
|
elem.addEventListener(type, callback, false)
|
3854
3896
|
} else {
|
@@ -3861,22 +3903,24 @@ var duplexBinding = avalon.directive("duplex", {
|
|
3861
3903
|
old && old()
|
3862
3904
|
}
|
3863
3905
|
}
|
3864
|
-
var composing = false
|
3865
3906
|
function callback(value) {
|
3866
3907
|
binding.changed.call(this, value, binding)
|
3867
3908
|
}
|
3909
|
+
var composing = false
|
3868
3910
|
function compositionStart() {
|
3869
3911
|
composing = true
|
3870
3912
|
}
|
3871
3913
|
function compositionEnd() {
|
3872
3914
|
composing = false
|
3873
3915
|
}
|
3874
|
-
|
3916
|
+
|
3917
|
+
var updateVModel = function (e) {
|
3875
3918
|
var val = elem.value //防止递归调用形成死循环
|
3876
3919
|
if (composing || val === binding.oldValue || binding.pipe === null) //处理中文输入法在minlengh下引发的BUG
|
3877
3920
|
return
|
3878
3921
|
var lastValue = binding.pipe(val, binding, "get")
|
3879
3922
|
try {
|
3923
|
+
binding.oldValue = val
|
3880
3924
|
binding.setter(lastValue)
|
3881
3925
|
callback.call(elem, lastValue)
|
3882
3926
|
} catch (ex) {
|
@@ -3896,7 +3940,7 @@ var duplexBinding = avalon.directive("duplex", {
|
|
3896
3940
|
})
|
3897
3941
|
break
|
3898
3942
|
case "checkbox":
|
3899
|
-
|
3943
|
+
bound(W3C ? "change" : "click", function () {
|
3900
3944
|
var method = elem.checked ? "ensure" : "remove"
|
3901
3945
|
var array = binding.getter.apply(0, binding.vmodels)
|
3902
3946
|
if (!Array.isArray(array)) {
|
@@ -3909,27 +3953,33 @@ var duplexBinding = avalon.directive("duplex", {
|
|
3909
3953
|
})
|
3910
3954
|
break
|
3911
3955
|
case "change":
|
3912
|
-
|
3956
|
+
bound("change", updateVModel)
|
3913
3957
|
break
|
3914
3958
|
case "input":
|
3915
3959
|
if (!IEVersion) { // W3C
|
3916
|
-
|
3960
|
+
bound("input", updateVModel)
|
3917
3961
|
//非IE浏览器才用这个
|
3918
|
-
|
3919
|
-
|
3920
|
-
|
3921
|
-
} else {
|
3962
|
+
bound("compositionstart", compositionStart)
|
3963
|
+
bound("compositionend", compositionEnd)
|
3964
|
+
bound("DOMAutoComplete", updateVModel)
|
3965
|
+
} else {
|
3922
3966
|
// IE下通过selectionchange事件监听IE9+点击input右边的X的清空行为,及粘贴,剪切,删除行为
|
3923
3967
|
if (IEVersion > 8) {
|
3924
|
-
|
3968
|
+
if (IEVersion === 9) {
|
3969
|
+
//IE9删除字符后再失去焦点不会同步 #1167
|
3970
|
+
bound("keyup", updateVModel)
|
3971
|
+
}
|
3972
|
+
bound("input", updateVModel) //IE9使用propertychange无法监听中文输入改动
|
3925
3973
|
} else {
|
3926
|
-
|
3974
|
+
//onpropertychange事件无法区分是程序触发还是用户触发
|
3975
|
+
//IE6-8下第一次修改时不会触发,需要使用keydown或selectionchange修正
|
3976
|
+
bound("propertychange", function (e) {
|
3927
3977
|
if (e.propertyName === "value") {
|
3928
3978
|
updateVModel()
|
3929
3979
|
}
|
3930
3980
|
})
|
3931
3981
|
}
|
3932
|
-
|
3982
|
+
bound("dragend", function () {
|
3933
3983
|
setTimeout(function () {
|
3934
3984
|
updateVModel()
|
3935
3985
|
}, 17)
|
@@ -3939,7 +3989,7 @@ var duplexBinding = avalon.directive("duplex", {
|
|
3939
3989
|
}
|
3940
3990
|
break
|
3941
3991
|
case "select":
|
3942
|
-
|
3992
|
+
bound("change", function () {
|
3943
3993
|
var val = avalon(elem).val() //字符串或字符串数组
|
3944
3994
|
if (Array.isArray(val)) {
|
3945
3995
|
val = val.map(function (v) {
|
@@ -3956,7 +4006,7 @@ var duplexBinding = avalon.directive("duplex", {
|
|
3956
4006
|
}
|
3957
4007
|
}
|
3958
4008
|
})
|
3959
|
-
|
4009
|
+
bound("datasetchanged", function (e) {
|
3960
4010
|
if (e.bubble === "selectDuplex") {
|
3961
4011
|
var value = binding._value
|
3962
4012
|
var curValue = Array.isArray(value) ? value.map(String) : value + ""
|
@@ -3969,17 +4019,17 @@ var duplexBinding = avalon.directive("duplex", {
|
|
3969
4019
|
}
|
3970
4020
|
if (binding.xtype === "input" && !rnoduplexInput.test(elem.type)) {
|
3971
4021
|
if (elem.type !== "hidden") {
|
3972
|
-
|
4022
|
+
bound("focus", function () {
|
3973
4023
|
elem.msFocus = true
|
3974
4024
|
})
|
3975
|
-
|
4025
|
+
bound("blur", function () {
|
3976
4026
|
elem.msFocus = false
|
3977
4027
|
})
|
3978
4028
|
}
|
3979
4029
|
elem.avalonSetter = updateVModel //#765
|
3980
4030
|
watchValueInTimer(function () {
|
3981
|
-
if (
|
3982
|
-
if (!this.msFocus
|
4031
|
+
if (avalon.contains(root, elem)) {
|
4032
|
+
if (!this.msFocus) {
|
3983
4033
|
updateVModel()
|
3984
4034
|
}
|
3985
4035
|
} else if (!elem.msRetain) {
|
@@ -4016,7 +4066,7 @@ var duplexBinding = avalon.directive("duplex", {
|
|
4016
4066
|
} catch (e) {
|
4017
4067
|
}
|
4018
4068
|
}
|
4019
|
-
elem.value =
|
4069
|
+
elem.value = binding.oldValue = curValue
|
4020
4070
|
if (fixCaret) {
|
4021
4071
|
setCaret(elem, pos, pos)
|
4022
4072
|
}
|
@@ -4054,16 +4104,13 @@ var duplexBinding = avalon.directive("duplex", {
|
|
4054
4104
|
}
|
4055
4105
|
break
|
4056
4106
|
}
|
4057
|
-
if (binding.xtype !== "select") {
|
4058
|
-
binding.changed.call(elem, curValue, binding)
|
4059
|
-
}
|
4060
4107
|
}
|
4061
4108
|
})
|
4062
4109
|
|
4063
4110
|
if (IEVersion) {
|
4064
4111
|
avalon.bind(DOC, "selectionchange", function (e) {
|
4065
|
-
var el = DOC.activeElement
|
4066
|
-
if (el &&
|
4112
|
+
var el = DOC.activeElement || {}
|
4113
|
+
if (!el.msFocus && el.avalonSetter) {
|
4067
4114
|
el.avalonSetter()
|
4068
4115
|
}
|
4069
4116
|
})
|
@@ -4149,7 +4196,7 @@ new function () { // jshint ignore:line
|
|
4149
4196
|
var bproto = HTMLTextAreaElement.prototype
|
4150
4197
|
function newSetter(value) { // jshint ignore:line
|
4151
4198
|
setters[this.tagName].call(this, value)
|
4152
|
-
if (!this.msFocus && this.avalonSetter
|
4199
|
+
if (!this.msFocus && this.avalonSetter) {
|
4153
4200
|
this.avalonSetter()
|
4154
4201
|
}
|
4155
4202
|
}
|
@@ -4171,7 +4218,8 @@ new function () { // jshint ignore:line
|
|
4171
4218
|
watchValueInTimer = avalon.tick
|
4172
4219
|
}
|
4173
4220
|
} // jshint ignore:line
|
4174
|
-
function getCaret(ctrl
|
4221
|
+
function getCaret(ctrl) {
|
4222
|
+
var start = NaN, end = NaN
|
4175
4223
|
if (ctrl.setSelectionRange) {
|
4176
4224
|
start = ctrl.selectionStart
|
4177
4225
|
end = ctrl.selectionEnd
|
@@ -4188,14 +4236,11 @@ function getCaret(ctrl, start, end) {
|
|
4188
4236
|
function setCaret(ctrl, begin, end) {
|
4189
4237
|
if (!ctrl.value || ctrl.readOnly)
|
4190
4238
|
return
|
4191
|
-
if (ctrl.createTextRange) {//IE6-
|
4192
|
-
|
4193
|
-
|
4194
|
-
|
4195
|
-
|
4196
|
-
// range.moveEnd("character", end) #1125
|
4197
|
-
range.select()
|
4198
|
-
}, 17)
|
4239
|
+
if (ctrl.createTextRange) {//IE6-8
|
4240
|
+
var range = ctrl.createTextRange()
|
4241
|
+
range.collapse(true)
|
4242
|
+
range.moveStart("character", begin)
|
4243
|
+
range.select()
|
4199
4244
|
} else {
|
4200
4245
|
ctrl.selectionStart = begin
|
4201
4246
|
ctrl.selectionEnd = end
|
@@ -4383,7 +4428,7 @@ function upperFirstChar(str) {
|
|
4383
4428
|
}
|
4384
4429
|
var effectBuffer = new Buffer()
|
4385
4430
|
function Effect() {
|
4386
|
-
}
|
4431
|
+
}//动画实例,做成类的形式,是为了共用所有原型方法
|
4387
4432
|
|
4388
4433
|
Effect.prototype = {
|
4389
4434
|
contrustor: Effect,
|
@@ -4406,7 +4451,7 @@ Effect.prototype = {
|
|
4406
4451
|
callEffectHook(me, "abort" + upperFirstChar(oppositeName))
|
4407
4452
|
callEffectHook(me, "before" + upperFirstChar(name))
|
4408
4453
|
if (!isLeave)
|
4409
|
-
before(el)
|
4454
|
+
before(el) //这里可能做插入DOM树的操作,因此必须在修改类名前执行
|
4410
4455
|
var cssCallback = function (cancel) {
|
4411
4456
|
el.removeEventListener(me.cssEvent, me.cssCallback)
|
4412
4457
|
if (isLeave) {
|
@@ -4525,7 +4570,6 @@ avalon.mix(avalon.effect, {
|
|
4525
4570
|
}
|
4526
4571
|
})
|
4527
4572
|
|
4528
|
-
|
4529
4573
|
avalon.directive("html", {
|
4530
4574
|
update: function (val) {
|
4531
4575
|
var binding = this
|
@@ -4633,7 +4677,7 @@ avalon.directive("if", {
|
|
4633
4677
|
elem.required = false
|
4634
4678
|
elem.setAttribute("_required", "true")
|
4635
4679
|
}
|
4636
|
-
try {
|
4680
|
+
try {//如果不支持querySelectorAll或:required,可以直接无视
|
4637
4681
|
avalon.each(elem.querySelectorAll(":required"), function (el) {
|
4638
4682
|
elem.required = false
|
4639
4683
|
el.setAttribute("_required", "true")
|
@@ -4669,8 +4713,6 @@ avalon.directive("if", {
|
|
4669
4713
|
}
|
4670
4714
|
})
|
4671
4715
|
|
4672
|
-
|
4673
|
-
|
4674
4716
|
//ms-important绑定已经在scanTag 方法中实现
|
4675
4717
|
var rnoscripts = /<noscript.*?>(?:[\s\S]+?)<\/noscript>/img
|
4676
4718
|
var rnoscriptText = /<noscript.*?>([\s\S]+?)<\/noscript>/im
|
@@ -4790,7 +4832,7 @@ avalon.directive("include", {
|
|
4790
4832
|
return nodesToFrag(nodes)
|
4791
4833
|
}
|
4792
4834
|
} else {
|
4793
|
-
before = function () {
|
4835
|
+
before = function () {//新添加元素的动画
|
4794
4836
|
target.insertBefore(fragment, binding.end)
|
4795
4837
|
scanNodeArray(nodes, vmodels)
|
4796
4838
|
}
|
@@ -5026,7 +5068,7 @@ avalon.directive("repeat", {
|
|
5026
5068
|
}
|
5027
5069
|
|
5028
5070
|
//重写proxy
|
5029
|
-
if (this.enterCount === 1) {
|
5071
|
+
if (this.enterCount === 1) {//防止多次进入,导致位置不对
|
5030
5072
|
proxy.$active = false
|
5031
5073
|
proxy.$oldIndex = proxy.$index
|
5032
5074
|
proxy.$active = true
|
@@ -5039,7 +5081,7 @@ avalon.directive("repeat", {
|
|
5039
5081
|
proxy.$last = i === length - 1
|
5040
5082
|
// proxy[param] = value[i]
|
5041
5083
|
} else {
|
5042
|
-
proxy.$val = toJson(value[keyOrId])
|
5084
|
+
proxy.$val = toJson(value[keyOrId]) //这里是处理vm.object = newObject的情况
|
5043
5085
|
}
|
5044
5086
|
proxies.push(proxy)
|
5045
5087
|
}
|
@@ -5090,7 +5132,7 @@ avalon.directive("repeat", {
|
|
5090
5132
|
} else if (proxy.$index !== proxy.$oldIndex) {
|
5091
5133
|
(function (proxy2, preElement) {
|
5092
5134
|
staggerIndex = mayStaggerAnimate(binding.effectEnterStagger, function () {
|
5093
|
-
var curNode = removeItem(proxy2.$anchor)
|
5135
|
+
var curNode = removeItem(proxy2.$anchor)//如果位置被挪动了
|
5094
5136
|
var inserted = avalon.slice(curNode.childNodes)
|
5095
5137
|
parent.insertBefore(curNode, preElement.nextSibling)
|
5096
5138
|
animateRepeat(inserted, 1, binding)
|
@@ -5326,9 +5368,11 @@ function proxyRecycler(cache, key, param) {
|
|
5326
5368
|
delete cache[key]
|
5327
5369
|
}
|
5328
5370
|
}
|
5371
|
+
|
5329
5372
|
/*********************************************************************
|
5330
5373
|
* 各种指令 *
|
5331
5374
|
**********************************************************************/
|
5375
|
+
|
5332
5376
|
//ms-skip绑定已经在scanTag 方法中实现
|
5333
5377
|
avalon.directive("text", {
|
5334
5378
|
update: function (value) {
|
@@ -5375,7 +5419,7 @@ avalon.directive("visible", {
|
|
5375
5419
|
var binding = this, elem = this.element, stamp
|
5376
5420
|
var noEffect = !this.effectName
|
5377
5421
|
if (!this.stamp) {
|
5378
|
-
stamp = this.stamp = +new Date
|
5422
|
+
stamp = this.stamp = +new Date()
|
5379
5423
|
if (val) {
|
5380
5424
|
elem.style.display = binding.display || ""
|
5381
5425
|
if (avalon(elem).css("display") === "none") {
|
@@ -5386,7 +5430,7 @@ avalon.directive("visible", {
|
|
5386
5430
|
}
|
5387
5431
|
return
|
5388
5432
|
}
|
5389
|
-
stamp = this.stamp = +new Date
|
5433
|
+
stamp = this.stamp = +new Date()
|
5390
5434
|
if (val) {
|
5391
5435
|
avalon.effect.apply(elem, 1, function () {
|
5392
5436
|
if (stamp !== binding.stamp)
|
@@ -5414,8 +5458,9 @@ avalon.directive("visible", {
|
|
5414
5458
|
})
|
5415
5459
|
|
5416
5460
|
/*********************************************************************
|
5417
|
-
* 自带过滤器
|
5461
|
+
* 自带过滤器 *
|
5418
5462
|
**********************************************************************/
|
5463
|
+
|
5419
5464
|
var rscripts = /<script[^>]*>([\S\s]*?)<\/script\s*>/gim
|
5420
5465
|
var ron = /\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g
|
5421
5466
|
var ropen = /<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/ig
|
@@ -5429,10 +5474,10 @@ var rnoalphanumeric = /([^\#-~| |!])/g;
|
|
5429
5474
|
|
5430
5475
|
function numberFormat(number, decimals, point, thousands) {
|
5431
5476
|
//form http://phpjs.org/functions/number_format/
|
5432
|
-
//number
|
5433
|
-
//decimals
|
5434
|
-
//point
|
5435
|
-
//thousands
|
5477
|
+
//number 必需,要格式化的数字
|
5478
|
+
//decimals 可选,规定多少个小数位。
|
5479
|
+
//point 可选,规定用作小数点的字符串(默认为 . )。
|
5480
|
+
//thousands 可选,规定用作千位分隔符的字符串(默认为 , ),如果设置了该参数,那么所有其他参数都是必需的。
|
5436
5481
|
number = (number + '')
|
5437
5482
|
.replace(/[^0-9+\-Ee.]/g, '')
|
5438
5483
|
var n = !isFinite(+number) ? 0 : +number,
|
@@ -5460,7 +5505,6 @@ function numberFormat(number, decimals, point, thousands) {
|
|
5460
5505
|
return s.join(dec)
|
5461
5506
|
}
|
5462
5507
|
|
5463
|
-
|
5464
5508
|
var filters = avalon.filters = {
|
5465
5509
|
uppercase: function(str) {
|
5466
5510
|
return str.toUpperCase()
|
@@ -5527,6 +5571,7 @@ var filters = avalon.filters = {
|
|
5527
5571
|
},
|
5528
5572
|
number: numberFormat
|
5529
5573
|
}
|
5574
|
+
|
5530
5575
|
/*
|
5531
5576
|
'yyyy': 4 digit representation of year (e.g. AD 1 => 0001, AD 2010 => 2010)
|
5532
5577
|
'yy': 2 digit representation of year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
|
@@ -5761,9 +5806,11 @@ new function() {// jshint ignore:line
|
|
5761
5806
|
locate.SHORTMONTH = locate.MONTH
|
5762
5807
|
filters.date.locate = locate
|
5763
5808
|
}// jshint ignore:line
|
5809
|
+
|
5764
5810
|
/*********************************************************************
|
5765
|
-
* AMD加载器
|
5811
|
+
* AMD加载器 *
|
5766
5812
|
**********************************************************************/
|
5813
|
+
|
5767
5814
|
//https://www.devbridge.com/articles/understanding-amd-requirejs/
|
5768
5815
|
//http://maxogden.com/nested-dependencies.html
|
5769
5816
|
var modules = avalon.modules = {
|
@@ -6454,7 +6501,7 @@ new function () { // jshint ignore:line
|
|
6454
6501
|
} // jshint ignore:line
|
6455
6502
|
|
6456
6503
|
/*********************************************************************
|
6457
|
-
* DOMReady
|
6504
|
+
* DOMReady *
|
6458
6505
|
**********************************************************************/
|
6459
6506
|
|
6460
6507
|
var readyList = [],
|
@@ -6510,7 +6557,6 @@ avalon.ready = function (fn) {
|
|
6510
6557
|
avalon.config({
|
6511
6558
|
loader: true
|
6512
6559
|
})
|
6513
|
-
|
6514
6560
|
avalon.ready(function () {
|
6515
6561
|
avalon.scan(DOC.body)
|
6516
6562
|
})
|