Browse Source

polyfill移出来

es6
guy 8 years ago
parent
commit
ad3cef6195
  1. 43
      Gruntfile.js
  2. 322
      bi/core.js
  3. 322
      docs/core.js
  4. 1
      docs/index.html
  5. 257
      src/core/proto/array.js
  6. 20
      src/core/proto/cache.js
  7. 31
      src/polyfill/array.js
  8. 12
      src/polyfill/console.js
  9. 21
      src/polyfill/localStorage.js
  10. 14
      src/polyfill/sort.js

43
Gruntfile.js

@ -7,6 +7,10 @@ module.exports = function (grunt) {
options: { options: {
separator: '' separator: ''
}, },
polyfillJs: {
src: ['src/polyfill/**/*.js'],
dest: 'docs/polyfill.js'
},
coreJs: { coreJs: {
src: [ src: [
'src/core/jquery.js', 'src/core/jquery.js',
@ -30,41 +34,7 @@ module.exports = function (grunt) {
], ],
dest: 'docs/core.js' dest: 'docs/core.js'
}, },
biCoreJs: {
src: [
'src/core/underscore.js',
'src/core/foundation.js',
'src/core/mvc/**/*.js',
'src/core/base.js',
'src/core/alias.js',
'src/core/events.js',
'src/core/var.js',
'src/core/ob.js',
'src/core/widget.js',
'src/core/model.js',
'src/core/view.js',
'src/core/shortcut.js',
'src/core/plugin.js',
'src/core/controller.js',
'src/core/proto/**/*.js',
'src/core/utils/**/*.js',
'src/core/behavior/behavior.js',
'src/core/wrapper/layout.js',
'src/core/action/**/*.js',
'src/core/adapter/**/*.js',
'src/core/controller/**/*.js',
'src/core/event/**/*.js',
'src/core/func/**/*.js',
'src/core/listener/**/*.js',
'src/core/loader/**/*.js',
'src/core/logic/**/*.js',
'src/data/data.js',
'src/data/**/*.js',
'src/config.js'
],
dest: 'bi/core.js'
},
//最基础的控件 //最基础的控件
baseJs: { baseJs: {
src: [ src: [
@ -137,6 +107,11 @@ module.exports = function (grunt) {
dest: 'docs/demo.css' dest: 'docs/demo.css'
}, },
bi_polyfillJs: {
src: ['src/polyfill/**/*.js'],
dest: 'bi/polyfill.js'
},
bi_coreJs: { bi_coreJs: {
src: [ src: [
'src/core/foundation.js', 'src/core/foundation.js',

322
bi/core.js

@ -5843,34 +5843,6 @@ $.extend(Array.prototype, {
contains: function (o) { contains: function (o) {
return this.indexOf(o) > -1; return this.indexOf(o) > -1;
}, },
/**
* 检查指定的值是否在数组中
* @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;
},
/**
* 检查指定的值是否在数组中
* 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;
},
/** /**
* 从数组中移除指定的值如果值不在数组中则不产生任何效果 * 从数组中移除指定的值如果值不在数组中则不产生任何效果
@ -5879,265 +5851,29 @@ $.extend(Array.prototype, {
*/ */
remove: function (o) { remove: function (o) {
var index = this.indexOf(o); var index = this.indexOf(o);
if (index != -1) { if (index !== -1) {
this.splice(index, 1); this.splice(index, 1);
} }
return this; return this;
}, },
/**
* 移除数组中的所有元素
*/
clear: function () {
while (this.length > 0) {
this.pop();
}
}
});
/** pushArray: function (array) {
* Array原型拓展
* Created by wang on 15/6/23.
*/
!function () {
Array.prototype.pushArray = function (array) {
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
this.push(array[i]); this.push(array[i]);
} }
}; },
Array.prototype.pushDistinct = function (obj) { pushDistinct: function (obj) {
if (!this.contains(obj)) { if (!this.contains(obj)) {
this.push(obj); this.push(obj);
} }
}; },
Array.prototype.pushDistinctArray = function (array) { pushDistinctArray: function (array) {
for (var i = 0, len = array.length; i < len; i++) { for (var i = 0, len = array.length; i < len; i++) {
this.pushDistinct(array[i]); this.pushDistinct(array[i]);
} }
};
}();
/**
* 规定bi的数组分为两种其中value和type值为key值
* 1[{"text":1,"value":2,"children":[]}]
* 2[{"name":1,"type":2,"children":[]}]
* guy
* 对数组的操作
* @type {{}}
*/
ArrayUtils = {};
$.extend(ArrayUtils, {
/**
* 遍历方法
* @param array
* @param back
*/
traversal: function (array, back) {
if (BI.isNull(array)) {
return;
}
var self = this;
BI.each(array, function (i, item) {
if (back(i, item) === BI.Status.END) {
return false;
}
self.traversal(item.children, back);
})
},
getAllChildNames: function (array) {
var names = [];
this.traversal(array, function (i, item) {
if (BI.isNotEmptyArray(item.children)) {
return BI.Status.RUNNING;
}
names.push(item.text || item.name);
});
return names;
},
/**
* 获取第一个子节点
* @param array
*/
getFirstChild: function (array) {
var first = {};
this.traversal(array, function (i, item) {
if (BI.isNotEmptyArray(item.children)) {
return;
}
first = item;
return BI.Status.END;
})
return first;
},
/**
* 获取最后一个子节点
* @param array
*/
getLastChild: function (array) {
var first = {};
this.traversal(array, function (i, item) {
if (item.children && item.children.length > 0) {
return;
}
first = item;
})
return first;
},
getTextByValue: function (array, value) {
if (!array) {
return value;
}
var text = "";
this.traversal(array, function (i, item) {
if (BI.isEqual(item.value, value)) {
text = item.text;
return BI.Status.END;
}
});
return text;
},
getNameByType: function (array, type) {
if (!array) {
return type;
}
var name = "";
this.traversal(array, function (i, item) {
if (BI.isEqual(item.type, type)) {
name = item.name;
return BI.Status.END;
}
});
return name;
},
getItemByText: function (array, text) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.text, text)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByText: function (array, text) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.text, text)) {
res = i;
return BI.Status.END;
}
});
return res;
},
getItemByValue: function (array, value) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.value, value)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByValue: function (array, value) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.value, value)) {
res = i;
return BI.Status.END;
}
});
return res;
},
getItemByName: function (array, name) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.name, name)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByName: function (array, name) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.name, name)) {
res = i;
return BI.Status.END;
}
});
return res;
},
getItemByType: function (array, type) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.type, type)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByType: function (array, type) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.type, type)) {
res = i;
return BI.Status.END;
}
});
return res;
},
deleteItemByType: function (array, type) {
var item = this.getItemByType(array, type);
array.remove(item);
},
deleteItemByName: function (array, name) {
var item = this.getItemByName(array, name);
array.remove(item);
},
deleteItemByValue: function (array, value) {
var item = this.getItemByValue(array, value);
array.remove(item);
}
});/*
* 前端缓存
*/
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 = {};
} }
}); });
BI.Cache = { BI.Cache = {
_prefix: "bi", _prefix: "bi",
setUsername: function (username) { setUsername: function (username) {
@ -7094,50 +6830,6 @@ function accDiv(arg1, arg2) {
Number.prototype.div = function (arg) { Number.prototype.div = function (arg) {
return accDiv(this, arg); return accDiv(this, arg);
};/** };/**
* 特殊情况
* 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;
})();
//修复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);/**
* 对字符串对象的扩展 * 对字符串对象的扩展
* @class String * @class String
*/ */

322
docs/core.js

@ -23326,34 +23326,6 @@ $.extend(Array.prototype, {
contains: function (o) { contains: function (o) {
return this.indexOf(o) > -1; return this.indexOf(o) > -1;
}, },
/**
* 检查指定的值是否在数组中
* @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;
},
/**
* 检查指定的值是否在数组中
* 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;
},
/** /**
* 从数组中移除指定的值如果值不在数组中则不产生任何效果 * 从数组中移除指定的值如果值不在数组中则不产生任何效果
@ -23362,265 +23334,29 @@ $.extend(Array.prototype, {
*/ */
remove: function (o) { remove: function (o) {
var index = this.indexOf(o); var index = this.indexOf(o);
if (index != -1) { if (index !== -1) {
this.splice(index, 1); this.splice(index, 1);
} }
return this; return this;
}, },
/**
* 移除数组中的所有元素
*/
clear: function () {
while (this.length > 0) {
this.pop();
}
}
});
/** pushArray: function (array) {
* Array原型拓展
* Created by wang on 15/6/23.
*/
!function () {
Array.prototype.pushArray = function (array) {
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
this.push(array[i]); this.push(array[i]);
} }
}; },
Array.prototype.pushDistinct = function (obj) { pushDistinct: function (obj) {
if (!this.contains(obj)) { if (!this.contains(obj)) {
this.push(obj); this.push(obj);
} }
}; },
Array.prototype.pushDistinctArray = function (array) { pushDistinctArray: function (array) {
for (var i = 0, len = array.length; i < len; i++) { for (var i = 0, len = array.length; i < len; i++) {
this.pushDistinct(array[i]); this.pushDistinct(array[i]);
} }
};
}();
/**
* 规定bi的数组分为两种其中value和type值为key值
* 1[{"text":1,"value":2,"children":[]}]
* 2[{"name":1,"type":2,"children":[]}]
* guy
* 对数组的操作
* @type {{}}
*/
ArrayUtils = {};
$.extend(ArrayUtils, {
/**
* 遍历方法
* @param array
* @param back
*/
traversal: function (array, back) {
if (BI.isNull(array)) {
return;
}
var self = this;
BI.each(array, function (i, item) {
if (back(i, item) === BI.Status.END) {
return false;
}
self.traversal(item.children, back);
})
},
getAllChildNames: function (array) {
var names = [];
this.traversal(array, function (i, item) {
if (BI.isNotEmptyArray(item.children)) {
return BI.Status.RUNNING;
}
names.push(item.text || item.name);
});
return names;
},
/**
* 获取第一个子节点
* @param array
*/
getFirstChild: function (array) {
var first = {};
this.traversal(array, function (i, item) {
if (BI.isNotEmptyArray(item.children)) {
return;
}
first = item;
return BI.Status.END;
})
return first;
},
/**
* 获取最后一个子节点
* @param array
*/
getLastChild: function (array) {
var first = {};
this.traversal(array, function (i, item) {
if (item.children && item.children.length > 0) {
return;
}
first = item;
})
return first;
},
getTextByValue: function (array, value) {
if (!array) {
return value;
}
var text = "";
this.traversal(array, function (i, item) {
if (BI.isEqual(item.value, value)) {
text = item.text;
return BI.Status.END;
}
});
return text;
},
getNameByType: function (array, type) {
if (!array) {
return type;
}
var name = "";
this.traversal(array, function (i, item) {
if (BI.isEqual(item.type, type)) {
name = item.name;
return BI.Status.END;
}
});
return name;
},
getItemByText: function (array, text) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.text, text)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByText: function (array, text) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.text, text)) {
res = i;
return BI.Status.END;
}
});
return res;
},
getItemByValue: function (array, value) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.value, value)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByValue: function (array, value) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.value, value)) {
res = i;
return BI.Status.END;
}
});
return res;
},
getItemByName: function (array, name) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.name, name)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByName: function (array, name) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.name, name)) {
res = i;
return BI.Status.END;
}
});
return res;
},
getItemByType: function (array, type) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.type, type)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByType: function (array, type) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.type, type)) {
res = i;
return BI.Status.END;
}
});
return res;
},
deleteItemByType: function (array, type) {
var item = this.getItemByType(array, type);
array.remove(item);
},
deleteItemByName: function (array, name) {
var item = this.getItemByName(array, name);
array.remove(item);
},
deleteItemByValue: function (array, value) {
var item = this.getItemByValue(array, value);
array.remove(item);
}
});/*
* 前端缓存
*/
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 = {};
} }
}); });
BI.Cache = { BI.Cache = {
_prefix: "bi", _prefix: "bi",
setUsername: function (username) { setUsername: function (username) {
@ -24577,50 +24313,6 @@ function accDiv(arg1, arg2) {
Number.prototype.div = function (arg) { Number.prototype.div = function (arg) {
return accDiv(this, arg); return accDiv(this, arg);
};/** };/**
* 特殊情况
* 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;
})();
//修复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);/**
* 对字符串对象的扩展 * 对字符串对象的扩展
* @class String * @class String
*/ */

1
docs/index.html

@ -15,6 +15,7 @@
<link rel="stylesheet" type="text/css" <link rel="stylesheet" type="text/css"
href="demo.css"/> href="demo.css"/>
<script src="polyfill.js"></script>
<script src="core.js"></script> <script src="core.js"></script>
<script src="base.js"></script> <script src="base.js"></script>
<script src="case.js"></script> <script src="case.js"></script>

257
src/core/proto/array.js

@ -6,34 +6,6 @@ $.extend(Array.prototype, {
contains: function (o) { contains: function (o) {
return this.indexOf(o) > -1; return this.indexOf(o) > -1;
}, },
/**
* 检查指定的值是否在数组中
* @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;
},
/**
* 检查指定的值是否在数组中
* 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;
},
/** /**
* 从数组中移除指定的值如果值不在数组中则不产生任何效果 * 从数组中移除指定的值如果值不在数组中则不产生任何效果
@ -42,242 +14,25 @@ $.extend(Array.prototype, {
*/ */
remove: function (o) { remove: function (o) {
var index = this.indexOf(o); var index = this.indexOf(o);
if (index != -1) { if (index !== -1) {
this.splice(index, 1); this.splice(index, 1);
} }
return this; return this;
}, },
/**
* 移除数组中的所有元素
*/
clear: function () {
while (this.length > 0) {
this.pop();
}
}
});
/** pushArray: function (array) {
* Array原型拓展
* Created by wang on 15/6/23.
*/
!function () {
Array.prototype.pushArray = function (array) {
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
this.push(array[i]); this.push(array[i]);
} }
}; },
Array.prototype.pushDistinct = function (obj) { pushDistinct: function (obj) {
if (!this.contains(obj)) { if (!this.contains(obj)) {
this.push(obj); this.push(obj);
} }
}; },
Array.prototype.pushDistinctArray = function (array) { pushDistinctArray: function (array) {
for (var i = 0, len = array.length; i < len; i++) { for (var i = 0, len = array.length; i < len; i++) {
this.pushDistinct(array[i]); this.pushDistinct(array[i]);
} }
};
}();
/**
* 规定bi的数组分为两种其中value和type值为key值
* 1[{"text":1,"value":2,"children":[]}]
* 2[{"name":1,"type":2,"children":[]}]
* guy
* 对数组的操作
* @type {{}}
*/
ArrayUtils = {};
$.extend(ArrayUtils, {
/**
* 遍历方法
* @param array
* @param back
*/
traversal: function (array, back) {
if (BI.isNull(array)) {
return;
}
var self = this;
BI.each(array, function (i, item) {
if (back(i, item) === BI.Status.END) {
return false;
}
self.traversal(item.children, back);
})
},
getAllChildNames: function (array) {
var names = [];
this.traversal(array, function (i, item) {
if (BI.isNotEmptyArray(item.children)) {
return BI.Status.RUNNING;
}
names.push(item.text || item.name);
});
return names;
},
/**
* 获取第一个子节点
* @param array
*/
getFirstChild: function (array) {
var first = {};
this.traversal(array, function (i, item) {
if (BI.isNotEmptyArray(item.children)) {
return;
}
first = item;
return BI.Status.END;
})
return first;
},
/**
* 获取最后一个子节点
* @param array
*/
getLastChild: function (array) {
var first = {};
this.traversal(array, function (i, item) {
if (item.children && item.children.length > 0) {
return;
}
first = item;
})
return first;
},
getTextByValue: function (array, value) {
if (!array) {
return value;
}
var text = "";
this.traversal(array, function (i, item) {
if (BI.isEqual(item.value, value)) {
text = item.text;
return BI.Status.END;
}
});
return text;
},
getNameByType: function (array, type) {
if (!array) {
return type;
}
var name = "";
this.traversal(array, function (i, item) {
if (BI.isEqual(item.type, type)) {
name = item.name;
return BI.Status.END;
}
});
return name;
},
getItemByText: function (array, text) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.text, text)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByText: function (array, text) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.text, text)) {
res = i;
return BI.Status.END;
}
});
return res;
},
getItemByValue: function (array, value) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.value, value)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByValue: function (array, value) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.value, value)) {
res = i;
return BI.Status.END;
}
});
return res;
},
getItemByName: function (array, name) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.name, name)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByName: function (array, name) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isCapitalEqual(item.name, name)) {
res = i;
return BI.Status.END;
}
});
return res;
},
getItemByType: function (array, type) {
var res = void 0;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.type, type)) {
res = item;
return BI.Status.END;
}
});
return res;
},
getIndexByType: function (array, type) {
var res = -1;
this.traversal(array, function (i, item) {
if (BI.isEqual(item.type, type)) {
res = i;
return BI.Status.END;
}
});
return res;
},
deleteItemByType: function (array, type) {
var item = this.getItemByType(array, type);
array.remove(item);
},
deleteItemByName: function (array, name) {
var item = this.getItemByName(array, name);
array.remove(item);
},
deleteItemByValue: function (array, value) {
var item = this.getItemByValue(array, value);
array.remove(item);
} }
}); });

20
src/core/proto/cache.js

@ -1,24 +1,4 @@
/*
* 前端缓存
*/
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 = {};
}
});
BI.Cache = { BI.Cache = {
_prefix: "bi", _prefix: "bi",
setUsername: function (username) { setUsername: function (username) {

31
src/polyfill/array.js

@ -0,0 +1,31 @@
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;
}
}

12
src/polyfill/console.js

@ -0,0 +1,12 @@
/**
* 特殊情况
* 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;
})();

21
src/polyfill/localStorage.js

@ -0,0 +1,21 @@
/*
* 前端缓存
*/
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 = {};
}
});

14
src/core/proto/special.js → src/polyfill/sort.js

@ -1,17 +1,3 @@
/**
* 特殊情况
* 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;
})();
//修复ie9下sort方法的bug //修复ie9下sort方法的bug
!function (window) { !function (window) {
var ua = window.navigator.userAgent.toLowerCase(), var ua = window.navigator.userAgent.toLowerCase(),
Loading…
Cancel
Save