Skip to content
Browse files

update 事件返回值处理

  • Loading branch information...
1 parent ec4420c commit 9d544381d5fc10844538cc3f6de3ea42530de676 @RubyLouvre committed May 22, 2013
Showing with 148 additions and 138 deletions.
  1. +147 −138 avalon.js
  2. +1 −0 event.js
View
285 avalon.js
@@ -22,7 +22,8 @@
var documentFragment = DOC.createDocumentFragment();
var DONT_ENUM = "propertyIsEnumerable,isPrototypeOf,hasOwnProperty,toLocaleString,toString,valueOf,constructor".split(",");
- function noop() {}
+ function noop() {
+ }
function generateID() {
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
@@ -56,7 +57,7 @@
},
noop: noop,
error: function(str, e) { //如果不用Error对象封装一下,str在控制台下可能会乱码
- throw new(e || Error)(str);
+ throw new (e || Error)(str);
},
ready: function(fn) {
if (typeof fn === "function") {
@@ -75,7 +76,7 @@
array = array.match(rword) || [];
}
var result = {},
- value = val !== void 0 ? val : 1;
+ value = val !== void 0 ? val : 1;
for (var i = 0, n = array.length; i < n; i++) {
result[array[i]] = value;
}
@@ -88,26 +89,32 @@
start = 0;
}
var index = -1,
- length = Math.max(0, Math.ceil((end - start) / step)),
- result = Array(length);
+ length = Math.max(0, Math.ceil((end - start) / step)),
+ result = Array(length);
while (++index < length) {
result[index] = start;
start += step;
}
return result;
},
bind: W3C ? function(el, type, fn, phase) {
- el.addEventListener(type, fn, !! phase);
+ el.addEventListener(type, fn, !!phase);
return fn;
} : function(el, type, fn) {
function callback(e) {
- return fn.call(el, fixEvent(e || window.event));
+ var ex = fixEvent(e || window.event);
+ var ret = fn.call(el, ex);
+ if (ret === false) {
+ ex.preventDefault();
+ ex.stopPropagation();
+ }
+ return ret;
}
el.attachEvent && el.attachEvent("on" + type, callback);
return callback;
},
unbind: W3C ? function(el, type, fn, phase) {
- el.removeEventListener(type, fn || noop, !! phase);
+ el.removeEventListener(type, fn || noop, !!phase);
} : function(el, type, fn) {
el.detachEvent("on" + type, fn || noop);
}
@@ -116,7 +123,7 @@
function forEach(obj, fn) {
if (obj) { //不能传个null, undefined进来
var isArray = Array.isArray(obj) || avalon.type(obj) === "Object" && !obj.setTimeout && isFinite(obj.length) && obj[0],
- i = 0;
+ i = 0;
if (isArray) {
for (var n = obj.length; i < n; i++) {
fn(i, obj[i]);
@@ -138,7 +145,7 @@
function fireReady() {
if (readyList) {
- for (var i = 0, fn; fn = readyList[i++];) {
+ for (var i = 0, fn; fn = readyList[i++]; ) {
fn();
}
readyList = null;
@@ -205,7 +212,7 @@
},
toggleClass: function(value, stateVal) {
var state = stateVal,
- className, i = 0;
+ className, i = 0;
var classNames = value.match(rnospaces) || [];
var isBool = typeof stateVal === "boolean";
while ((className = classNames[i++])) {
@@ -233,8 +240,8 @@
return parseData(val);
case 0:
var attrs = this[0].attributes,
- ret = {};
- for (var i = 0, attr; attr = attrs[i++];) {
+ ret = {};
+ for (var i = 0, attr; attr = attrs[i++]; ) {
name = attr.name;
if (!name.indexOf("data-")) {
name = camelize(name.slice(5));
@@ -314,7 +321,7 @@
//=============================css相关=======================
var cssHooks = avalon.cssHooks = {};
var prefixes = ['', '-webkit-', '-o-', '-moz-', '-ms-'];
- var cssMap = { //支持检测 WebKitMutationObserver WebKitCSSMatrix mozMatchesSelector ,webkitRequestAnimationFrame
+ var cssMap = {//支持检测 WebKitMutationObserver WebKitCSSMatrix mozMatchesSelector ,webkitRequestAnimationFrame
"float": 'cssFloat' in root.style ? 'cssFloat' : 'styleFloat',
background: "backgroundColor"
};
@@ -350,7 +357,7 @@
} else {
var rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i;
var rposition = /^(top|right|bottom|left)$/;
- var ie8 = !! window.XDomainRequest;
+ var ie8 = !!window.XDomainRequest;
var salpha = "DXImageTransform.Microsoft.Alpha";
var border = {
thin: ie8 ? '1px' : '2px',
@@ -364,8 +371,8 @@
if ((rnumnonpx.test(ret) && !rposition.test(ret))) {
//①,保存原有的style.left, runtimeStyle.left,
var style = node.style,
- left = style.left,
- rsLeft = node.runtimeStyle.left;
+ left = style.left,
+ rsLeft = node.runtimeStyle.left;
//②由于③处的style.left = xxx会影响到currentStyle.left,
//因此把它currentStyle.left放到runtimeStyle.left,
//runtimeStyle.left拥有最高优先级,不会style.left影响
@@ -394,15 +401,15 @@
cssHooks["opacity:get"] = function(node) {
//这是最快的获取IE透明值的方式,不需要动用正则了!
var alpha = node.filters.alpha || node.filters[salpha],
- op = alpha ? alpha.opacity : 100;
+ op = alpha ? alpha.opacity : 100;
return (op / 100) + ""; //确保返回的是字符串
};
}
"Width,Height".replace(rword, function(name) {
var method = name.toLowerCase(),
- clientProp = "client" + name,
- scrollProp = "scroll" + name,
- offsetProp = "offset" + name;
+ clientProp = "client" + name,
+ scrollProp = "scroll" + name,
+ offsetProp = "offset" + name;
avalon.fn[method] = function(value) {
var node = this[0];
if (arguments.length === 0) {
@@ -425,7 +432,7 @@
avalon.fn.offset = function() { //取得距离页面左右角的坐标
var node = this[0],
- doc = node && node.ownerDocument;
+ doc = node && node.ownerDocument;
var pos = {
left: 0,
top: 0
@@ -437,13 +444,13 @@
//我们可以通过getBoundingClientRect来获得元素相对于client的rect.
//http://msdn.microsoft.com/en-us/library/ms536433.aspx
var box = node.getBoundingClientRect(),
- //chrome1+, firefox3+, ie4+, opera(yes) safari4+
- win = doc.defaultView || doc.parentWindow,
- root = (navigator.vendor || doc.compatMode === "BackCompat") ? doc.body : doc.documentElement,
- clientTop = root.clientTop >> 0,
- clientLeft = root.clientLeft >> 0,
- scrollTop = win.pageYOffset || root.scrollTop,
- scrollLeft = win.pageXOffset || root.scrollLeft;
+ //chrome1+, firefox3+, ie4+, opera(yes) safari4+
+ win = doc.defaultView || doc.parentWindow,
+ root = (navigator.vendor || doc.compatMode === "BackCompat") ? doc.body : doc.documentElement,
+ clientTop = root.clientTop >> 0,
+ clientLeft = root.clientLeft >> 0,
+ scrollTop = win.pageYOffset || root.scrollTop,
+ scrollLeft = win.pageXOffset || root.scrollLeft;
// 把滚动距离加到left,top中去。
// IE一些版本中会自动为HTML元素加上2px的border,我们需要去掉它
// http://msdn.microsoft.com/en-us/library/ms533564(VS.85).aspx
@@ -464,12 +471,12 @@
},
"select:get": function(node, value) {
var option, options = node.options,
- index = node.selectedIndex,
- getter = valHooks["option:get"],
- one = node.type === "select-one" || index < 0,
- values = one ? null : [],
- max = one ? index + 1 : options.length,
- i = index < 0 ? max : one ? index : 0;
+ index = node.selectedIndex,
+ getter = valHooks["option:get"],
+ one = node.type === "select-one" || index < 0,
+ values = one ? null : [],
+ max = one ? index + 1 : options.length,
+ i = index < 0 ? max : one ? index : 0;
for (; i < max; i++) {
option = options[i];
//旧式IE在reset后不会改变selected,需要改用i === index判定
@@ -489,8 +496,8 @@
"select:set": function(node, values) {
values = [].concat(values); //强制转换为数组
var getter = valHooks["option:get"];
- for (var i = 0, el; el = node.options[i++];) {
- el.selected = !! ~values.indexOf(getter(el));
+ for (var i = 0, el; el = node.options[i++]; ) {
+ el.selected = !!~values.indexOf(getter(el));
}
if (!values.length) {
node.selectedIndex = -1;
@@ -518,7 +525,7 @@
result.push(key);
}
if (DONT_ENUM && obj) {
- for (var i = 0; key = DONT_ENUM[i++];) {
+ for (var i = 0; key = DONT_ENUM[i++]; ) {
if (obj.hasOwnProperty(key)) {
result.push(key);
}
@@ -537,10 +544,10 @@
if (arguments.length < 2 && scope === void 0)
return this;
var fn = this,
- argv = arguments;
+ argv = arguments;
return function() {
var args = [],
- i;
+ i;
for (i = 1; i < argv.length; i++)
args.push(argv[i]);
for (i = 0; i < arguments.length; i++)
@@ -559,7 +566,7 @@
//定位操作,返回数组中第一个等于给定参数的元素的索引值。
indexOf: function(item, index) {
var n = this.length,
- i = ~~index;
+ i = ~~index;
if (i < 0)
i += n;
for (; i < n; i++)
@@ -570,7 +577,7 @@
//定位引操作,同上,不过是从后遍历。
lastIndexOf: function(item, index) {
var n = this.length,
- i = index == null ? n - 1 : index;
+ i = index == null ? n - 1 : index;
if (i < 0)
i = Math.max(0, n + i);
for (; i >= 0; i--)
@@ -602,7 +609,7 @@
};
}).sort(function(left, right) {
var a = left.re,
- b = right.re;
+ b = right.re;
return a < b ? -1 : a > b ? 1 : 0;
});
return avalon.Array.pluck(array, 'el');
@@ -662,8 +669,8 @@
usedTicks = 0;
maxPendingTicks *= 4;
var expectedTicks = queuedTasks && Math.min(
- queuedTasks - 1,
- maxPendingTicks);
+ queuedTasks - 1,
+ maxPendingTicks);
while (pendingTicks < expectedTicks) {
++pendingTicks;
requestTick();
@@ -686,7 +693,7 @@
next: null
};
if (
- pendingTicks < ++queuedTasks && pendingTicks < maxPendingTicks) {
+ pendingTicks < ++queuedTasks && pendingTicks < maxPendingTicks) {
++pendingTicks;
requestTick();
}
@@ -774,10 +781,10 @@
var callbacks = this.$events[type] || []; //防止影响原数组
var all = this.$events.$all || [];
var args = [].slice.call(arguments, 1);
- for (var i = 0, callback; callback = callbacks[i++];) {
+ for (var i = 0, callback; callback = callbacks[i++]; ) {
callback.apply(this, args);
}
- for (var i = 0, callback; callback = all[i++];) {
+ for (var i = 0, callback; callback = all[i++]; ) {
callback.apply(this, args);
}
}
@@ -786,7 +793,7 @@
function updateViewModel(a, b, isArray) {
if (isArray) {
var an = a.length,
- bn = b.length;
+ bn = b.length;
if (an > bn) {
a.splice(bn, an - bn);
} else if (bn > an) {
@@ -810,12 +817,12 @@
function modelFactory(scope) {
var skipArray = scope.$skipArray, //要忽略监控的属性名列表
- model = {},
- Descriptions = {}, //内部用于转换的对象
- json = {},
- callSetters = [],
- callGetters = [],
- VBPublics = Object.keys(watchOne); //用于IE6-8
+ model = {},
+ Descriptions = {}, //内部用于转换的对象
+ json = {},
+ callSetters = [],
+ callGetters = [],
+ VBPublics = Object.keys(watchOne); //用于IE6-8
skipArray = Array.isArray(skipArray) ? skipArray.concat(VBPublics) : VBPublics;
forEach(scope, function(name, value) {
if (!watchOne[name]) {
@@ -834,7 +841,7 @@
var accessor, oldArgs;
if (valueType === "Object" && typeof value.get === "function" && Object.keys(value).length <= 2) {
var setter = value.set,
- getter = value.get;
+ getter = value.get;
accessor = function(neo) { //创建计算属性
if (arguments.length) {
if (stopRepeatAssign) {
@@ -956,9 +963,9 @@
}
if (!defineProperties && window.VBArray) {
window.execScript([
- "Function parseVB(code)",
- "\tExecuteGlobal(code)",
- "End Function"
+ "Function parseVB(code)",
+ "\tExecuteGlobal(code)",
+ "End Function"
].join("\n"), "VBScript");
function VBMediator(description, name, value) {
@@ -974,14 +981,14 @@
var publics = array.slice(0);
publics.push("hasOwnProperty", "$id")
var className = "VBClass" + setTimeout("1"),
- owner = {}, buffer = [];
+ owner = {}, buffer = [];
buffer.push(
- "Class " + className,
- "\tPrivate [__data__], [__proxy__]",
- "\tPublic Default Function [__const__](d, p)",
- "\t\tSet [__data__] = d: set [__proxy__] = p",
- "\t\tSet [__const__] = Me", //链式调用
- "\tEnd Function");
+ "Class " + className,
+ "\tPrivate [__data__], [__proxy__]",
+ "\tPublic Default Function [__const__](d, p)",
+ "\t\tSet [__data__] = d: set [__proxy__] = p",
+ "\t\tSet [__const__] = Me", //链式调用
+ "\tEnd Function");
publics.forEach(function(name) { //添加公共属性,如果此时不加以后就没机会了
if (owner[name] !== true) {
owner[name] = true; //因为VBScript对象不能像JS那样随意增删属性
@@ -991,29 +998,29 @@
Object.keys(description).forEach(function(name) {
owner[name] = true;
buffer.push(
- //由于不知对方会传入什么,因此set, let都用上
- "\tPublic Property Let [" + name + "](val)", //setter
- "\t\tCall [__proxy__]([__data__], \"" + name + "\", val)",
- "\tEnd Property",
- "\tPublic Property Set [" + name + "](val)", //setter
- "\t\tCall [__proxy__]([__data__], \"" + name + "\", val)",
- "\tEnd Property",
- "\tPublic Property Get [" + name + "]", //getter
- "\tOn Error Resume Next", //必须优先使用set语句,否则它会误将数组当字符串返回
- "\t\tSet[" + name + "] = [__proxy__]([__data__],\"" + name + "\")",
- "\tIf Err.Number <> 0 Then",
- "\t\t[" + name + "] = [__proxy__]([__data__],\"" + name + "\")",
- "\tEnd If",
- "\tOn Error Goto 0",
- "\tEnd Property");
+ //由于不知对方会传入什么,因此set, let都用上
+ "\tPublic Property Let [" + name + "](val)", //setter
+ "\t\tCall [__proxy__]([__data__], \"" + name + "\", val)",
+ "\tEnd Property",
+ "\tPublic Property Set [" + name + "](val)", //setter
+ "\t\tCall [__proxy__]([__data__], \"" + name + "\", val)",
+ "\tEnd Property",
+ "\tPublic Property Get [" + name + "]", //getter
+ "\tOn Error Resume Next", //必须优先使用set语句,否则它会误将数组当字符串返回
+ "\t\tSet[" + name + "] = [__proxy__]([__data__],\"" + name + "\")",
+ "\tIf Err.Number <> 0 Then",
+ "\t\t[" + name + "] = [__proxy__]([__data__],\"" + name + "\")",
+ "\tEnd If",
+ "\tOn Error Goto 0",
+ "\tEnd Property");
});
buffer.push("End Class"); //类定义完毕
buffer.push(
- "Function " + className + "Factory(a, b)", //创建实例并传入两个关键的参数
- "\tDim o",
- "\tSet o = (New " + className + ")(a, b)",
- "\tSet " + className + "Factory = o",
- "End Function");
+ "Function " + className + "Factory(a, b)", //创建实例并传入两个关键的参数
+ "\tDim o",
+ "\tSet o = (New " + className + ")(a, b)",
+ "\tSet " + className + "Factory = o",
+ "End Function");
window.parseVB(buffer.join("\r\n"));
var model = window[className + "Factory"](description, VBMediator);
model.hasOwnProperty = function(name) {
@@ -1035,7 +1042,7 @@
if (list && list.length) {
var args = [].slice.call(arguments, 1);
var safelist = list.concat();
- for (var i = 0, fn; fn = safelist[i++];) {
+ for (var i = 0, fn; fn = safelist[i++]; ) {
el = fn.element;
if (el && (!el.noRemove) && (el.sourceIndex === 0 || el.parentNode === null)) {
avalon.Array.remove(list, fn);
@@ -1088,7 +1095,7 @@
textNodes.push(node);
}
}
- for (var i = 0; node = textNodes[i++];) { //延后执行
+ for (var i = 0; node = textNodes[i++]; ) { //延后执行
scanText(node, scopes); //扫描文本节点
}
}
@@ -1154,10 +1161,10 @@
function scanAttr(el, scopes) {
var bindings = [];
- for (var i = 0, attr; attr = el.attributes[i++];) {
+ for (var i = 0, attr; attr = el.attributes[i++]; ) {
if (attr.specified) {
var isBinding = false,
- remove = false;
+ remove = false;
if (attr.name.indexOf(prefix) !== -1) { //如果是以指定前缀命名的
var type = attr.name.replace(prefix, "");
if (type.indexOf("-") > 0) {
@@ -1194,7 +1201,7 @@
function extractTextBindings(textNode) {
var bindings = [],
- tokens = scanExpr(textNode.nodeValue);
+ tokens = scanExpr(textNode.nodeValue);
if (tokens.length) {
while (tokens.length) { //将文本转换为文本节点,并替换原来的文本节点
var token = tokens.shift();
@@ -1230,15 +1237,16 @@
function getValueFunction(name, scopes) { //得到求值函数,及其作用域
var n = name.split(".");
- for (var i = 0, scope, ok; scope = scopes[i++];) {
+ for (var i = 0, scope, ok; scope = scopes[i++]; ) {
try {
if (scope.hasOwnProperty(n[0]) && (n.length !== 2 || scope[n[0]].hasOwnProperty(n[1]))) {
var fn = Function("scope", "value", "if(arguments.length === 1){ return scope." + name + " }else{ scope." + name + " = value; }");
fn(scope);
ok = scope;
break;
}
- } catch (e) {}
+ } catch (e) {
+ }
}
if (ok) {
return [fn, ok];
@@ -1247,7 +1255,7 @@
function watchView(text, scopes, data, callback, tokens) {
var updateView, array, filters = data.filters,
- updateView = avalon.noop;
+ updateView = avalon.noop;
if (!filters && !tokens) {
array = getValueFunction(text.trim(), scopes);
@@ -1268,8 +1276,8 @@
updateView = (function(a, b) {
return function() {
var ret = "",
- fn;
- for (var i = 0, el; el = a[i++];) {
+ fn;
+ for (var i = 0, el; el = a[i++]; ) {
if (typeof el === "string") {
ret += el;
} else {
@@ -1283,7 +1291,7 @@
} else if (array) {
var fn = array[0],
- args = array[1];
+ args = array[1];
updateView = function() {
callback(fn.apply(fn, args), data.element);
};
@@ -1303,9 +1311,9 @@
function parseExpr(text, scopes, data) {
var names = [],
- args = [],
- random = new Date - 0,
- val;
+ args = [],
+ random = new Date - 0,
+ val;
//取得ViewModel的名字
scopes.forEach(function(scope) {
@@ -1316,14 +1324,14 @@
}
});
text = "var ret" + random + " = " + text + "\r\n";
- for (var i = 0, name; name = names[i++];) {
+ for (var i = 0, name; name = names[i++]; ) {
text = "with(" + name + "){\r\n" + text + "}\r\n";
}
if (data.filters) {
var textBuffer = [],
- fargs;
+ fargs;
textBuffer.push(text, "\r\n");
- for (var i = 0, f; f = data.filters[i++];) {
+ for (var i = 0, f; f = data.filters[i++]; ) {
var start = f.indexOf("(");
if (start !== -1) {
fargs = f.slice(start + 1, f.lastIndexOf(")")).trim();
@@ -1333,7 +1341,7 @@
fargs = "";
}
textBuffer.push(" if(filters", random, ".", f, "){\r\n\ttry{ret", random,
- " = filters", random, ".", f, "(ret", random, fargs, ")}catch(e){};\r\n}\r\n");
+ " = filters", random, ".", f, "(ret", random, fargs, ")}catch(e){};\r\n}\r\n");
}
text = textBuffer.join("");
names.push("filters" + random);
@@ -1474,16 +1482,16 @@
//布尔属性在IE下无法取得原来的字符串值,变成一个布尔,因此需要用ng-disabled
"disabled": function(data, scopes) {
var name = data.type,
- propName = name === "readonly" ? "readOnly" : name;
+ propName = name === "readonly" ? "readOnly" : name;
watchView(data.value, scopes, data, function(val, elem) {
- elem[propName] = !! val;
+ elem[propName] = !!val;
});
},
//ms-bind-name="callback",绑定一个属性,当属性变化时执行对应的回调,this为绑定元素
"bind": function(data, scopes) {
var fn = data.value.trim(),
- name = data.args[0];
- for (var i = 0, scope; scope = scopes[i++];) {
+ name = data.args[0];
+ for (var i = 0, scope; scope = scopes[i++]; ) {
if (scope.hasOwnProperty(fn)) {
fn = scope[fn];
break;
@@ -1510,7 +1518,7 @@
}
val = val.call(elem);
}
- avalon(elem).toggleClass(cls, !! val);
+ avalon(elem).toggleClass(cls, !!val);
});
},
"hover": function(data) {
@@ -1555,7 +1563,7 @@
data.element.setAttribute(prefix + "controller", id);
var optsName = data.args[0]; //它的参数对象
if (optsName) {
- for (var i = 0, scope; scope = scopes[i++];) {
+ for (var i = 0, scope; scope = scopes[i++]; ) {
if (scope.hasOwnProperty(optsName)) {
opts = scope[optsName];
break;
@@ -1657,9 +1665,9 @@
element.name = generateID();
}
var type = element.type,
- god = avalon(element)
- //当value变化时改变model的值
- var updateModel = function() {
+ god = avalon(element)
+ //当value变化时改变model的值
+ var updateModel = function() {
if (god.data("observe") !== false) {
fn(scope, element.value);
}
@@ -1695,7 +1703,7 @@
}
} else if (type === "radio") {
updateView = function() {
- element.checked = !! fn(scope);
+ element.checked = !!fn(scope);
};
updateModel = function() {
if (god.data("observe") !== false) {
@@ -1735,7 +1743,7 @@
modelBinding.SELECT = function(element, fn, scope) {
var god = avalon(element),
- oldValue;
+ oldValue;
function updateModel() {
if (god.data("observe") !== false) {
@@ -1768,7 +1776,7 @@
* 常用事件 binding *
**********************************************************************/
"dblclick,mouseout,click,mouseover,mouseenter,mouseleave,mousemove,mousedown,mouseup,keypress,keydown,keyup,blur,focus,change".
- replace(rword, function(name) {
+ replace(rword, function(name) {
bindingHandlers[name] = function(data) {
data.args = [name];
bindingHandlers.on.apply(0, arguments);
@@ -1787,7 +1795,7 @@
if (!t || (t !== elem && !(elem.compareDocumentPosition(t) & 16))) {
delete e.type;
e.type = type;
- fn.call(elem, e);
+ return fn.call(elem, e);
}
});
} else {
@@ -1981,8 +1989,8 @@
break;
case "splice":
var start = args[0],
- second = args[1],
- adds = [].slice.call(args, 2);
+ second = args[1],
+ adds = [].slice.call(args, 2);
var deleteCount = second >= 0 ? second : len - start;
if (deleteCount) {
var node = findIndex(parent, start);
@@ -2043,7 +2051,7 @@
}
nodes.push(check);
}
- for (var i = 0; node = nodes[i++];) {
+ for (var i = 0; node = nodes[i++]; ) {
view.appendChild(node);
}
emptyNode(view);
@@ -2072,15 +2080,15 @@
}
// parent.insertBefore(el, null) === parent.appendChild(el)
parent.insertBefore(view, list.place || null);
- for (var i = 0; node = elements[i++];) {
+ for (var i = 0; node = elements[i++]; ) {
scanTag(node, scopes.concat()); //扫描文本节点
}
if (!parent.inprocess) {
parent.inprocess = 1; //作用类似于display:none
var hidden = parent.hidden; //http://html5accessibility.com/
parent.hidden = true;
}
- for (var i = 0; node = textNodes[i++];) {
+ for (var i = 0; node = textNodes[i++]; ) {
scanText(node, scopes.concat()); //扫描文本节点
}
if (parent.inprocess) {
@@ -2158,14 +2166,14 @@
// http://kevin.vanzonneveld.net
number = (number + "").replace(/[^0-9+\-Ee.]/g, '');
var n = !isFinite(+number) ? 0 : +number,
- prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
- sep = thousands_sep || ",",
- dec = dec_point || ".",
- s = '',
- toFixedFix = function(n, prec) {
- var k = Math.pow(10, prec);
- return '' + Math.round(n * k) / k;
- };
+ prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
+ sep = thousands_sep || ",",
+ dec = dec_point || ".",
+ s = '',
+ toFixedFix = function(n, prec) {
+ var k = Math.pow(10, prec);
+ return '' + Math.round(n * k) / k;
+ };
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
if (s[0].length > 3) {
@@ -2288,18 +2296,18 @@
Z: timeZoneGetter
};
var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,
- NUMBER_STRING = /^\d+$/;
+ NUMBER_STRING = /^\d+$/;
var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
// 1 2 3 4 5 6 7 8 9 10 11
function jsonStringToDate(string) {
var match;
if (match = string.match(R_ISO8601_STR)) {
var date = new Date(0),
- tzHour = 0,
- tzMin = 0,
- dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear,
- timeSetter = match[8] ? date.setUTCHours : date.setHours;
+ tzHour = 0,
+ tzMin = 0,
+ dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear,
+ timeSetter = match[8] ? date.setUTCHours : date.setHours;
if (match[9]) {
tzHour = toInt(match[9] + match[10]);
tzMin = toInt(match[9] + match[11]);
@@ -2312,8 +2320,8 @@
}
return function(date, format) {
var text = '',
- parts = [],
- fn, match;
+ parts = [],
+ fn, match;
format = format || 'mediumDate';
format = formats[format] || format;
if (typeof(date) === "string") {
@@ -2425,4 +2433,5 @@
//2013.5.3 v5.1 性能大幅提升 新的路标系统 hidden的运用 重构model绑定的select 重构addItemView
//2013.5.9 v6 添加ms-hover绑定, 重构mouseenter, mouseleave事件,对data方法进行增强
//2013.5.15 v6.1 添加ms-active
-//2013.5.15 v6.1 添加$json与多级监听
+//2013.5.21 v6.2 添加$json与多级监听
+//ms-css bug ; avalon.bind return bug
View
1 event.js
@@ -338,6 +338,7 @@ define("event", window.dispatchEvent ? ["node"] : ["event_fix"], function($) {
handle = ontype && cur[ontype];
if (handle && handle.apply && handle.apply(cur, data) === false) {
event.preventDefault();
+ event.stopPropagation();
}
}
event.type = type;

0 comments on commit 9d54438

Please sign in to comment.
Something went wrong with that request. Please try again.