windy 7 years ago
parent
commit
683f966515
  1. 13
      bi/core.js
  2. 93
      bi/polyfill.js
  3. 13
      docs/core.js
  4. 93
      docs/polyfill.js
  5. 13
      src/core/utils/tree.js

13
bi/core.js

@ -10403,6 +10403,19 @@ $.extend(BI, {
} else {
return [sNodes];
}
},
traversal: function (array, callback) {
if (BI.isNull(array)) {
return;
}
var self = this;
BI.any(array, function (i, item) {
if (callback(i, item) === false) {
return true;
}
self.traversal(item.children, callback);
})
}
})
})();//向量操作

93
bi/polyfill.js

@ -0,0 +1,93 @@
if(![].indexOf){
/**
* 检查指定的值是否在数组中
* @param {Object} o 要检查的值
* @return {Number} o在数组中的索引如果不在数组中则返回-1
*/
[].indexOf = function (o) {
for (var i = 0, len = this.length; i < len; i++) {
if (_.isEqual(o, this[i])) {
return i;
}
}
return -1;
}
}
if(![].lastIndexOf){
/**
* 检查指定的值是否在数组中
* ie67不支持数组的这个方法
* @param {Object} o 要检查的值
* @return {Number} o在数组中的索引如果不在数组中则返回-1
*/
[].lastIndexOf = function (o) {
for (var len = this.length, i = len - 1; i >= 0; i--) {
if (_.isEqual(o, this[i])) {
return i;
}
}
return -1;
}
}/**
* 特殊情况
* Created by wang on 15/6/23.
*/
//解决console未定义问题 guy
window.console = window.console || (function () {
var c = {};
c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile
= c.clear = c.exception = c.trace = c.assert = function () {
};
return c;
})();
/*
* 前端缓存
*/
window.localStorage || (window.localStorage = {
items: {},
setItem: function (k, v) {
BI.Cache.addCookie(k, v);
},
getItem: function (k) {
return BI.Cache.getCookie(k);
},
removeItem: function (k) {
BI.Cache.deleteCookie(k);
},
key: function () {
},
clear: function () {
this.items = {};
}
});//修复ie9下sort方法的bug
!function (window) {
var ua = window.navigator.userAgent.toLowerCase(),
reg = /msie|applewebkit.+safari/;
if (reg.test(ua)) {
var _sort = Array.prototype.sort;
Array.prototype.sort = function (fn) {
if (!!fn && typeof fn === 'function') {
if (this.length < 2) {
return this;
}
var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0;
for (; i < l; i++) {
for (j = i + 1; j < l; j++) {
t = fn.call(this, this[i], this[j]);
r = (typeof t === 'number' ? t :
!!t ? 1 : 0) > 0;
if (r === true) {
tmp = this[i];
this[i] = this[j];
this[j] = tmp;
}
}
}
return this;
} else {
return _sort.call(this);
}
};
}
}(window);

13
docs/core.js

@ -18862,6 +18862,19 @@ $.extend(BI, {
} else {
return [sNodes];
}
},
traversal: function (array, callback) {
if (BI.isNull(array)) {
return;
}
var self = this;
BI.any(array, function (i, item) {
if (callback(i, item) === false) {
return true;
}
self.traversal(item.children, callback);
})
}
})
})();//向量操作

93
docs/polyfill.js

@ -0,0 +1,93 @@
if(![].indexOf){
/**
* 检查指定的值是否在数组中
* @param {Object} o 要检查的值
* @return {Number} o在数组中的索引如果不在数组中则返回-1
*/
[].indexOf = function (o) {
for (var i = 0, len = this.length; i < len; i++) {
if (_.isEqual(o, this[i])) {
return i;
}
}
return -1;
}
}
if(![].lastIndexOf){
/**
* 检查指定的值是否在数组中
* ie67不支持数组的这个方法
* @param {Object} o 要检查的值
* @return {Number} o在数组中的索引如果不在数组中则返回-1
*/
[].lastIndexOf = function (o) {
for (var len = this.length, i = len - 1; i >= 0; i--) {
if (_.isEqual(o, this[i])) {
return i;
}
}
return -1;
}
}/**
* 特殊情况
* Created by wang on 15/6/23.
*/
//解决console未定义问题 guy
window.console = window.console || (function () {
var c = {};
c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile
= c.clear = c.exception = c.trace = c.assert = function () {
};
return c;
})();
/*
* 前端缓存
*/
window.localStorage || (window.localStorage = {
items: {},
setItem: function (k, v) {
BI.Cache.addCookie(k, v);
},
getItem: function (k) {
return BI.Cache.getCookie(k);
},
removeItem: function (k) {
BI.Cache.deleteCookie(k);
},
key: function () {
},
clear: function () {
this.items = {};
}
});//修复ie9下sort方法的bug
!function (window) {
var ua = window.navigator.userAgent.toLowerCase(),
reg = /msie|applewebkit.+safari/;
if (reg.test(ua)) {
var _sort = Array.prototype.sort;
Array.prototype.sort = function (fn) {
if (!!fn && typeof fn === 'function') {
if (this.length < 2) {
return this;
}
var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0;
for (; i < l; i++) {
for (j = i + 1; j < l; j++) {
t = fn.call(this, this[i], this[j]);
r = (typeof t === 'number' ? t :
!!t ? 1 : 0) > 0;
if (r === true) {
tmp = this[i];
this[i] = this[j];
this[j] = tmp;
}
}
}
return this;
} else {
return _sort.call(this);
}
};
}
}(window);

13
src/core/utils/tree.js

@ -464,6 +464,19 @@
} else {
return [sNodes];
}
},
traversal: function (array, callback) {
if (BI.isNull(array)) {
return;
}
var self = this;
BI.any(array, function (i, item) {
if (callback(i, item) === false) {
return true;
}
self.traversal(item.children, callback);
})
}
})
})();
Loading…
Cancel
Save