Browse Source

Merge pull request #212 in FUI/fineui from ~GUY/fineui:master to master

* commit 'c48c6a6274130dc9e1f5442d85741d3337ea16fd':
  ChinesePinYin更换
  update
  周首改成周一
  update
  BI.cjkDecode和htmlEncode
  getTime
  方法修改
es6
guy 7 years ago
parent
commit
c8b75a5090
  1. 2
      bi/base.js
  2. 6
      dist/base.css
  3. 2
      dist/base.js
  4. 6
      dist/bundle.css
  5. 168
      dist/bundle.js
  6. 2
      dist/bundle.min.css
  7. 88
      dist/bundle.min.js
  8. 166
      dist/core.js
  9. 2
      src/base/single/text.js
  10. 47
      src/core/alias.js
  11. 6
      src/core/func/dom.js
  12. 21
      src/core/func/function.js
  13. 92
      src/core/proto/date.js
  14. 2
      src/css/base/single/tip/tip.bubble.css
  15. 2
      src/css/base/single/tip/tip.toast.css
  16. 2
      src/css/base/single/tip/tip.tooltip.css
  17. 2
      src/less/base/single/tip/tip.bubble.less
  18. 4
      src/less/base/single/tip/tip.toast.less
  19. 4
      src/less/base/single/tip/tip.tooltip.less
  20. 13
      src/less/lib/colors.less
  21. 3
      src/less/lib/constant.less

2
bi/base.js

@ -587,7 +587,7 @@ BI.Text = BI.inherit(BI.Single, {
setText: function (text) { setText: function (text) {
BI.Text.superclass.setText.apply(this, arguments); BI.Text.superclass.setText.apply(this, arguments);
this.options.text = text; this.options.text = text;
this.text.element.html(BI.Func.formatSpecialCharInHtml(text)); this.text.element.html(BI.htmlEncode(text));
} }
}); });

6
dist/base.css vendored

@ -997,7 +997,7 @@ body .bi-button.button-ignore.disabled.clear:active,
-webkit-border-radius: 2px; -webkit-border-radius: 2px;
-moz-border-radius: 2px; -moz-border-radius: 2px;
border-radius: 2px; border-radius: 2px;
background: #ff4949; background: #fddddd;
color: #ff4949; color: #ff4949;
} }
.bi-tip { .bi-tip {
@ -1014,7 +1014,7 @@ body .bi-button.button-ignore.disabled.clear:active,
color: #5cb75d; color: #5cb75d;
} }
.bi-toast.toast-warning { .bi-toast.toast-warning {
background: #ff4949; background: #fddddd;
color: #ff4949; color: #ff4949;
} }
.bi-tooltip { .bi-tooltip {
@ -1030,7 +1030,7 @@ body .bi-button.button-ignore.disabled.clear:active,
color: #1a1a1a; color: #1a1a1a;
} }
.bi-tooltip.tooltip-warning { .bi-tooltip.tooltip-warning {
background: #ff4949; background: #fddddd;
color: #ff4949; color: #ff4949;
border: 1px solid #f4cbcb; border: 1px solid #f4cbcb;
} }

2
dist/base.js vendored

@ -587,7 +587,7 @@ BI.Text = BI.inherit(BI.Single, {
setText: function (text) { setText: function (text) {
BI.Text.superclass.setText.apply(this, arguments); BI.Text.superclass.setText.apply(this, arguments);
this.options.text = text; this.options.text = text;
this.text.element.html(BI.Func.formatSpecialCharInHtml(text)); this.text.element.html(BI.htmlEncode(text));
} }
}); });

6
dist/bundle.css vendored

@ -2592,7 +2592,7 @@ body .bi-button.button-ignore.disabled.clear:active,
-webkit-border-radius: 2px; -webkit-border-radius: 2px;
-moz-border-radius: 2px; -moz-border-radius: 2px;
border-radius: 2px; border-radius: 2px;
background: #ff4949; background: #fddddd;
color: #ff4949; color: #ff4949;
} }
.bi-tip { .bi-tip {
@ -2609,7 +2609,7 @@ body .bi-button.button-ignore.disabled.clear:active,
color: #5cb75d; color: #5cb75d;
} }
.bi-toast.toast-warning { .bi-toast.toast-warning {
background: #ff4949; background: #fddddd;
color: #ff4949; color: #ff4949;
} }
.bi-tooltip { .bi-tooltip {
@ -2625,7 +2625,7 @@ body .bi-button.button-ignore.disabled.clear:active,
color: #1a1a1a; color: #1a1a1a;
} }
.bi-tooltip.tooltip-warning { .bi-tooltip.tooltip-warning {
background: #ff4949; background: #fddddd;
color: #ff4949; color: #ff4949;
border: 1px solid #f4cbcb; border: 1px solid #f4cbcb;
} }

168
dist/bundle.js vendored

@ -17448,6 +17448,53 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
return newText return newText
}; };
/**
* 将cjkEncode处理过的字符串转化为原始字符串
*
* @static
* @param text 需要做解码的字符串
* @return {String} 解码后的字符串
*/
BI.cjkDecode = function (text) {
if (text == null) {
return "";
}
//查找没有 "[", 直接返回. kunsnat:数字的时候, 不支持indexOf方法, 也是直接返回.
if (!isNaN(text) || text.indexOf('[') == -1) {
return text;
}
var newText = "";
for (var i = 0; i < text.length; i++) {
var ch = text.charAt(i);
if (ch == '[') {
var rightIdx = text.indexOf(']', i + 1);
if (rightIdx > i + 1) {
var subText = text.substring(i + 1, rightIdx);
//james:主要是考虑[CDATA[]]这样的值的出现
if (subText.length > 0) {
ch = String.fromCharCode(eval("0x" + subText));
}
i = rightIdx;
}
}
newText += ch;
}
return newText;
};
//replace the html special tags
BI.htmlEncode = function (text) {
return (text == null) ? '' : String(text).replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
};
//html decode
BI.htmlDecode = function (text) {
return (text == null) ? '' : String(text).replace(/&amp;/g, '&').replace(/&quot;/g, '\"').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&nbsp;/g, ' ');
};
BI.cjkEncodeDO = function (o) { BI.cjkEncodeDO = function (o) {
if (BI.isPlainObject(o)) { if (BI.isPlainObject(o)) {
var result = {}; var result = {};
@ -19174,7 +19221,7 @@ BI.extend(jQuery.fn, {
*/ */
__textKeywordMarked__: function (text, keyword, py) { __textKeywordMarked__: function (text, keyword, py) {
if (!BI.isKey(keyword) || (text + "").length > 100) { if (!BI.isKey(keyword) || (text + "").length > 100) {
return this.html(BI.Func.formatSpecialCharInHtml(text)); return this.html(BI.htmlEncode(text));
} }
keyword = keyword + ""; keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
@ -19197,7 +19244,7 @@ BI.extend(jQuery.fn, {
if (tidx >= 0) { if (tidx >= 0) {
this.append(textLeft.substr(0, tidx)); this.append(textLeft.substr(0, tidx));
this.append($("<span>").addClass("bi-keyword-red-mark") this.append($("<span>").addClass("bi-keyword-red-mark")
.html(BI.Func.formatSpecialCharInHtml(textLeft.substr(tidx, keyword.length)))); .html(BI.htmlEncode(textLeft.substr(tidx, keyword.length))));
textLeft = textLeft.substr(tidx + keyword.length); textLeft = textLeft.substr(tidx + keyword.length);
if (py != null) { if (py != null) {
@ -19206,7 +19253,7 @@ BI.extend(jQuery.fn, {
} else if (pidx != null && pidx >= 0 && Math.floor(pidx / text.length) === Math.floor((pidx + keyword.length - 1) / text.length)) { } else if (pidx != null && pidx >= 0 && Math.floor(pidx / text.length) === Math.floor((pidx + keyword.length - 1) / text.length)) {
this.append(textLeft.substr(0, pidx)); this.append(textLeft.substr(0, pidx));
this.append($("<span>").addClass("bi-keyword-red-mark") this.append($("<span>").addClass("bi-keyword-red-mark")
.html(BI.Func.formatSpecialCharInHtml(textLeft.substr(pidx, keyword.length)))); .html(BI.htmlEncode(textLeft.substr(pidx, keyword.length))));
if (py != null) { if (py != null) {
py = py.substr(pidx + keyword.length); py = py.substr(pidx + keyword.length);
} }
@ -19811,27 +19858,6 @@ BI.extend(BI.Func, {
matched: matched, matched: matched,
finded: finded finded: finded
} }
},
/**
* 将字符串中的尖括号等字符encode成html能解析的形式
* @param str
*/
formatSpecialCharInHtml: function (str) {
return (str + "").replaceAll("\\s|<=?|>=?", function (str) {
switch (str) {
case "<":
return "&lt;";
case "<=":
return "&le;";
case ">":
return "&gt;";
case ">=":
return "&ge;";
default:
return "&nbsp;";
}
});
} }
}); });
@ -20786,16 +20812,17 @@ Date.prototype.getDayOfYear = function () {
Date.prototype.getWeekNumber = function () { Date.prototype.getWeekNumber = function () {
var d = Date.getDate(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0); var d = Date.getDate(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
//周一是一周第一天 //周一是一周第一天
var week = d.getDay(); var week = d.getDay() === 0 ? 7 : d.getDay();
//var week = d.getDay();
if (this.getMonth() === 0 && this.getDate() <= week) { if (this.getMonth() === 0 && this.getDate() <= week) {
return 1; return 1;
} }
d.setDate(this.getDate() - week); d.setDate(this.getDate() - (week - 1));
var ms = d.valueOf(); // GMT var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() > 0) { if (d.getDay() !== 1) {
offset++; offset++;
} }
return offset; return offset;
@ -20807,17 +20834,17 @@ Date.prototype.getQuarter = function () {
//离当前时间多少天的时间 //离当前时间多少天的时间
Date.prototype.getOffsetDate = function (offset) { Date.prototype.getOffsetDate = function (offset) {
return Date.getDate(this.getTime() + offset * 864e5); return Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()) + offset * 864e5);
}; };
Date.prototype.getAfterMulQuarter = function (n) { Date.prototype.getAfterMulQuarter = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() + n * 3); dt.setMonth(dt.getMonth() + n * 3);
return dt; return dt;
}; };
//获得n个季度前的日期 //获得n个季度前的日期
Date.prototype.getBeforeMulQuarter = function (n) { Date.prototype.getBeforeMulQuarter = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() - n * 3); dt.setMonth(dt.getMonth() - n * 3);
return dt; return dt;
}; };
@ -20849,49 +20876,19 @@ Date.prototype.getQuarterEndDate = function () {
return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth)); return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth));
}; };
Date.prototype.getAfterMultiMonth = function (n) { Date.prototype.getAfterMultiMonth = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() + n | 0); dt.setMonth(dt.getMonth() + n | 0);
return dt; return dt;
}; };
Date.prototype.getBeforeMultiMonth = function (n) { Date.prototype.getBeforeMultiMonth = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() - n | 0); dt.setMonth(dt.getMonth() - n | 0);
return dt; return dt;
}; };
Date.prototype.getAfterMulQuarter = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() + n * 3);
return dt;
};
//获得n个季度前的日期
Date.prototype.getBeforeMulQuarter = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() - n * 3);
return dt;
};
//得到本季度的起始月份
Date.prototype.getQuarterStartMonth = function () {
var quarterStartMonth = 0;
var nowMonth = this.getMonth();
if (nowMonth < 3) {
quarterStartMonth = 0;
}
if (2 < nowMonth && nowMonth < 6) {
quarterStartMonth = 3;
}
if (5 < nowMonth && nowMonth < 9) {
quarterStartMonth = 6;
}
if (nowMonth > 8) {
quarterStartMonth = 9;
}
return quarterStartMonth;
};
//指定日期n个月之前或之后的日期 //指定日期n个月之前或之后的日期
Date.prototype.getOffsetMonth = function (n) { Date.prototype.getOffsetMonth = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
var day = dt.getDate(); var day = dt.getDate();
var monthDay = Date.getDate(dt.getFullYear(), dt.getMonth() + parseInt(n), 1).getMonthDays(); var monthDay = Date.getDate(dt.getFullYear(), dt.getMonth() + parseInt(n), 1).getMonthDays();
if (day > monthDay) { if (day > monthDay) {
@ -20905,42 +20902,12 @@ Date.prototype.getOffsetMonth = function (n) {
//获得本周的起始日期 //获得本周的起始日期
Date.prototype.getWeekStartDate = function () { Date.prototype.getWeekStartDate = function () {
var w = this.getDay(); var w = this.getDay();
return this.getOffsetDate(-w); return this.getOffsetDate(w === 0 ? -6 : 1 - w);
}; };
//得到本周的结束日期 //得到本周的结束日期
Date.prototype.getWeekEndDate = function () { Date.prototype.getWeekEndDate = function () {
var w = this.getDay(); var w = this.getDay();
var offset = (w === 0 ? 6 : 6 - w); return this.getOffsetDate(w === 0 ? 0 : 7 - w);
return this.getOffsetDate(offset);
};
//获得本季度的起始日期
Date.prototype.getQuarterStartDate = function () {
return Date.getDate(this.getFullYear(), this.getQuarterStartMonth(), 1);
};
//得到本季度的结束日期
Date.prototype.getQuarterEndDate = function () {
var quarterEndMonth = this.getQuarterStartMonth() + 2;
return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth));
};
Date.prototype.getAfterMultiMonth = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() + n | 0);
return dt;
};
Date.prototype.getBeforeMultiMonth = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() - n | 0);
return dt;
};
//获得当前时区对应指定时区的时间
Date.prototype.getTimeZoneTimeByTimezoneOffset = function (offset) {
var dt = Date.getDate(this.getTime());
var localTime = dt.getTime();
var localOffset = dt.getTimezoneOffset() * 60000; //获得当地时间偏移的毫秒数
var utc = localTime + localOffset; //utc即GMT时间标准时区
return Date.getDate(utc + offset);
}; };
/** Checks date and time equality */ /** Checks date and time equality */
@ -21245,6 +21212,15 @@ Date.getDate = function () {
return dt; return dt;
} }
}; };
Date.getTime = function () {
var dt = Function.prototype.bind.apply(Date.getDate, BI.concat([null], [].slice.apply(arguments)))();
if(BI.isNotNull(Date.timeZone)){
return dt.getTime() - Date.timeZone - dt.getTimezoneOffset() * 60000;
}else{
return dt.getTime();
}
};
/* /*
* 给jQuery.Event对象添加的工具方法 * 给jQuery.Event对象添加的工具方法
*/ */
@ -26399,7 +26375,7 @@ BI.Text = BI.inherit(BI.Single, {
setText: function (text) { setText: function (text) {
BI.Text.superclass.setText.apply(this, arguments); BI.Text.superclass.setText.apply(this, arguments);
this.options.text = text; this.options.text = text;
this.text.element.html(BI.Func.formatSpecialCharInHtml(text)); this.text.element.html(BI.htmlEncode(text));
} }
}); });

2
dist/bundle.min.css vendored

File diff suppressed because one or more lines are too long

88
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

166
dist/core.js vendored

@ -17448,6 +17448,53 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
return newText return newText
}; };
/**
* 将cjkEncode处理过的字符串转化为原始字符串
*
* @static
* @param text 需要做解码的字符串
* @return {String} 解码后的字符串
*/
BI.cjkDecode = function (text) {
if (text == null) {
return "";
}
//查找没有 "[", 直接返回. kunsnat:数字的时候, 不支持indexOf方法, 也是直接返回.
if (!isNaN(text) || text.indexOf('[') == -1) {
return text;
}
var newText = "";
for (var i = 0; i < text.length; i++) {
var ch = text.charAt(i);
if (ch == '[') {
var rightIdx = text.indexOf(']', i + 1);
if (rightIdx > i + 1) {
var subText = text.substring(i + 1, rightIdx);
//james:主要是考虑[CDATA[]]这样的值的出现
if (subText.length > 0) {
ch = String.fromCharCode(eval("0x" + subText));
}
i = rightIdx;
}
}
newText += ch;
}
return newText;
};
//replace the html special tags
BI.htmlEncode = function (text) {
return (text == null) ? '' : String(text).replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
};
//html decode
BI.htmlDecode = function (text) {
return (text == null) ? '' : String(text).replace(/&amp;/g, '&').replace(/&quot;/g, '\"').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&nbsp;/g, ' ');
};
BI.cjkEncodeDO = function (o) { BI.cjkEncodeDO = function (o) {
if (BI.isPlainObject(o)) { if (BI.isPlainObject(o)) {
var result = {}; var result = {};
@ -19174,7 +19221,7 @@ BI.extend(jQuery.fn, {
*/ */
__textKeywordMarked__: function (text, keyword, py) { __textKeywordMarked__: function (text, keyword, py) {
if (!BI.isKey(keyword) || (text + "").length > 100) { if (!BI.isKey(keyword) || (text + "").length > 100) {
return this.html(BI.Func.formatSpecialCharInHtml(text)); return this.html(BI.htmlEncode(text));
} }
keyword = keyword + ""; keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
@ -19197,7 +19244,7 @@ BI.extend(jQuery.fn, {
if (tidx >= 0) { if (tidx >= 0) {
this.append(textLeft.substr(0, tidx)); this.append(textLeft.substr(0, tidx));
this.append($("<span>").addClass("bi-keyword-red-mark") this.append($("<span>").addClass("bi-keyword-red-mark")
.html(BI.Func.formatSpecialCharInHtml(textLeft.substr(tidx, keyword.length)))); .html(BI.htmlEncode(textLeft.substr(tidx, keyword.length))));
textLeft = textLeft.substr(tidx + keyword.length); textLeft = textLeft.substr(tidx + keyword.length);
if (py != null) { if (py != null) {
@ -19206,7 +19253,7 @@ BI.extend(jQuery.fn, {
} else if (pidx != null && pidx >= 0 && Math.floor(pidx / text.length) === Math.floor((pidx + keyword.length - 1) / text.length)) { } else if (pidx != null && pidx >= 0 && Math.floor(pidx / text.length) === Math.floor((pidx + keyword.length - 1) / text.length)) {
this.append(textLeft.substr(0, pidx)); this.append(textLeft.substr(0, pidx));
this.append($("<span>").addClass("bi-keyword-red-mark") this.append($("<span>").addClass("bi-keyword-red-mark")
.html(BI.Func.formatSpecialCharInHtml(textLeft.substr(pidx, keyword.length)))); .html(BI.htmlEncode(textLeft.substr(pidx, keyword.length))));
if (py != null) { if (py != null) {
py = py.substr(pidx + keyword.length); py = py.substr(pidx + keyword.length);
} }
@ -19811,27 +19858,6 @@ BI.extend(BI.Func, {
matched: matched, matched: matched,
finded: finded finded: finded
} }
},
/**
* 将字符串中的尖括号等字符encode成html能解析的形式
* @param str
*/
formatSpecialCharInHtml: function (str) {
return (str + "").replaceAll("\\s|<=?|>=?", function (str) {
switch (str) {
case "<":
return "&lt;";
case "<=":
return "&le;";
case ">":
return "&gt;";
case ">=":
return "&ge;";
default:
return "&nbsp;";
}
});
} }
}); });
@ -20786,16 +20812,17 @@ Date.prototype.getDayOfYear = function () {
Date.prototype.getWeekNumber = function () { Date.prototype.getWeekNumber = function () {
var d = Date.getDate(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0); var d = Date.getDate(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
//周一是一周第一天 //周一是一周第一天
var week = d.getDay(); var week = d.getDay() === 0 ? 7 : d.getDay();
//var week = d.getDay();
if (this.getMonth() === 0 && this.getDate() <= week) { if (this.getMonth() === 0 && this.getDate() <= week) {
return 1; return 1;
} }
d.setDate(this.getDate() - week); d.setDate(this.getDate() - (week - 1));
var ms = d.valueOf(); // GMT var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() > 0) { if (d.getDay() !== 1) {
offset++; offset++;
} }
return offset; return offset;
@ -20807,17 +20834,17 @@ Date.prototype.getQuarter = function () {
//离当前时间多少天的时间 //离当前时间多少天的时间
Date.prototype.getOffsetDate = function (offset) { Date.prototype.getOffsetDate = function (offset) {
return Date.getDate(this.getTime() + offset * 864e5); return Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()) + offset * 864e5);
}; };
Date.prototype.getAfterMulQuarter = function (n) { Date.prototype.getAfterMulQuarter = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() + n * 3); dt.setMonth(dt.getMonth() + n * 3);
return dt; return dt;
}; };
//获得n个季度前的日期 //获得n个季度前的日期
Date.prototype.getBeforeMulQuarter = function (n) { Date.prototype.getBeforeMulQuarter = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() - n * 3); dt.setMonth(dt.getMonth() - n * 3);
return dt; return dt;
}; };
@ -20849,49 +20876,19 @@ Date.prototype.getQuarterEndDate = function () {
return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth)); return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth));
}; };
Date.prototype.getAfterMultiMonth = function (n) { Date.prototype.getAfterMultiMonth = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() + n | 0); dt.setMonth(dt.getMonth() + n | 0);
return dt; return dt;
}; };
Date.prototype.getBeforeMultiMonth = function (n) { Date.prototype.getBeforeMultiMonth = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() - n | 0); dt.setMonth(dt.getMonth() - n | 0);
return dt; return dt;
}; };
Date.prototype.getAfterMulQuarter = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() + n * 3);
return dt;
};
//获得n个季度前的日期
Date.prototype.getBeforeMulQuarter = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() - n * 3);
return dt;
};
//得到本季度的起始月份
Date.prototype.getQuarterStartMonth = function () {
var quarterStartMonth = 0;
var nowMonth = this.getMonth();
if (nowMonth < 3) {
quarterStartMonth = 0;
}
if (2 < nowMonth && nowMonth < 6) {
quarterStartMonth = 3;
}
if (5 < nowMonth && nowMonth < 9) {
quarterStartMonth = 6;
}
if (nowMonth > 8) {
quarterStartMonth = 9;
}
return quarterStartMonth;
};
//指定日期n个月之前或之后的日期 //指定日期n个月之前或之后的日期
Date.prototype.getOffsetMonth = function (n) { Date.prototype.getOffsetMonth = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
var day = dt.getDate(); var day = dt.getDate();
var monthDay = Date.getDate(dt.getFullYear(), dt.getMonth() + parseInt(n), 1).getMonthDays(); var monthDay = Date.getDate(dt.getFullYear(), dt.getMonth() + parseInt(n), 1).getMonthDays();
if (day > monthDay) { if (day > monthDay) {
@ -20905,42 +20902,12 @@ Date.prototype.getOffsetMonth = function (n) {
//获得本周的起始日期 //获得本周的起始日期
Date.prototype.getWeekStartDate = function () { Date.prototype.getWeekStartDate = function () {
var w = this.getDay(); var w = this.getDay();
return this.getOffsetDate(-w); return this.getOffsetDate(w === 0 ? -6 : 1 - w);
}; };
//得到本周的结束日期 //得到本周的结束日期
Date.prototype.getWeekEndDate = function () { Date.prototype.getWeekEndDate = function () {
var w = this.getDay(); var w = this.getDay();
var offset = (w === 0 ? 6 : 6 - w); return this.getOffsetDate(w === 0 ? 0 : 7 - w);
return this.getOffsetDate(offset);
};
//获得本季度的起始日期
Date.prototype.getQuarterStartDate = function () {
return Date.getDate(this.getFullYear(), this.getQuarterStartMonth(), 1);
};
//得到本季度的结束日期
Date.prototype.getQuarterEndDate = function () {
var quarterEndMonth = this.getQuarterStartMonth() + 2;
return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth));
};
Date.prototype.getAfterMultiMonth = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() + n | 0);
return dt;
};
Date.prototype.getBeforeMultiMonth = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() - n | 0);
return dt;
};
//获得当前时区对应指定时区的时间
Date.prototype.getTimeZoneTimeByTimezoneOffset = function (offset) {
var dt = Date.getDate(this.getTime());
var localTime = dt.getTime();
var localOffset = dt.getTimezoneOffset() * 60000; //获得当地时间偏移的毫秒数
var utc = localTime + localOffset; //utc即GMT时间标准时区
return Date.getDate(utc + offset);
}; };
/** Checks date and time equality */ /** Checks date and time equality */
@ -21245,6 +21212,15 @@ Date.getDate = function () {
return dt; return dt;
} }
}; };
Date.getTime = function () {
var dt = Function.prototype.bind.apply(Date.getDate, BI.concat([null], [].slice.apply(arguments)))();
if(BI.isNotNull(Date.timeZone)){
return dt.getTime() - Date.timeZone - dt.getTimezoneOffset() * 60000;
}else{
return dt.getTime();
}
};
/* /*
* 给jQuery.Event对象添加的工具方法 * 给jQuery.Event对象添加的工具方法
*/ */

2
src/base/single/text.js

@ -114,7 +114,7 @@ BI.Text = BI.inherit(BI.Single, {
setText: function (text) { setText: function (text) {
BI.Text.superclass.setText.apply(this, arguments); BI.Text.superclass.setText.apply(this, arguments);
this.options.text = text; this.options.text = text;
this.text.element.html(BI.Func.formatSpecialCharInHtml(text)); this.text.element.html(BI.htmlEncode(text));
} }
}); });

47
src/core/alias.js

@ -251,6 +251,53 @@
return newText return newText
}; };
/**
* 将cjkEncode处理过的字符串转化为原始字符串
*
* @static
* @param text 需要做解码的字符串
* @return {String} 解码后的字符串
*/
BI.cjkDecode = function (text) {
if (text == null) {
return "";
}
//查找没有 "[", 直接返回. kunsnat:数字的时候, 不支持indexOf方法, 也是直接返回.
if (!isNaN(text) || text.indexOf('[') == -1) {
return text;
}
var newText = "";
for (var i = 0; i < text.length; i++) {
var ch = text.charAt(i);
if (ch == '[') {
var rightIdx = text.indexOf(']', i + 1);
if (rightIdx > i + 1) {
var subText = text.substring(i + 1, rightIdx);
//james:主要是考虑[CDATA[]]这样的值的出现
if (subText.length > 0) {
ch = String.fromCharCode(eval("0x" + subText));
}
i = rightIdx;
}
}
newText += ch;
}
return newText;
};
//replace the html special tags
BI.htmlEncode = function (text) {
return (text == null) ? '' : String(text).replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
};
//html decode
BI.htmlDecode = function (text) {
return (text == null) ? '' : String(text).replace(/&amp;/g, '&').replace(/&quot;/g, '\"').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&nbsp;/g, ' ');
};
BI.cjkEncodeDO = function (o) { BI.cjkEncodeDO = function (o) {
if (BI.isPlainObject(o)) { if (BI.isPlainObject(o)) {
var result = {}; var result = {};

6
src/core/func/dom.js

@ -20,7 +20,7 @@ BI.extend(jQuery.fn, {
*/ */
__textKeywordMarked__: function (text, keyword, py) { __textKeywordMarked__: function (text, keyword, py) {
if (!BI.isKey(keyword) || (text + "").length > 100) { if (!BI.isKey(keyword) || (text + "").length > 100) {
return this.html(BI.Func.formatSpecialCharInHtml(text)); return this.html(BI.htmlEncode(text));
} }
keyword = keyword + ""; keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
@ -43,7 +43,7 @@ BI.extend(jQuery.fn, {
if (tidx >= 0) { if (tidx >= 0) {
this.append(textLeft.substr(0, tidx)); this.append(textLeft.substr(0, tidx));
this.append($("<span>").addClass("bi-keyword-red-mark") this.append($("<span>").addClass("bi-keyword-red-mark")
.html(BI.Func.formatSpecialCharInHtml(textLeft.substr(tidx, keyword.length)))); .html(BI.htmlEncode(textLeft.substr(tidx, keyword.length))));
textLeft = textLeft.substr(tidx + keyword.length); textLeft = textLeft.substr(tidx + keyword.length);
if (py != null) { if (py != null) {
@ -52,7 +52,7 @@ BI.extend(jQuery.fn, {
} else if (pidx != null && pidx >= 0 && Math.floor(pidx / text.length) === Math.floor((pidx + keyword.length - 1) / text.length)) { } else if (pidx != null && pidx >= 0 && Math.floor(pidx / text.length) === Math.floor((pidx + keyword.length - 1) / text.length)) {
this.append(textLeft.substr(0, pidx)); this.append(textLeft.substr(0, pidx));
this.append($("<span>").addClass("bi-keyword-red-mark") this.append($("<span>").addClass("bi-keyword-red-mark")
.html(BI.Func.formatSpecialCharInHtml(textLeft.substr(pidx, keyword.length)))); .html(BI.htmlEncode(textLeft.substr(pidx, keyword.length))));
if (py != null) { if (py != null) {
py = py.substr(pidx + keyword.length); py = py.substr(pidx + keyword.length);
} }

21
src/core/func/function.js

@ -68,27 +68,6 @@ BI.extend(BI.Func, {
matched: matched, matched: matched,
finded: finded finded: finded
} }
},
/**
* 将字符串中的尖括号等字符encode成html能解析的形式
* @param str
*/
formatSpecialCharInHtml: function (str) {
return (str + "").replaceAll("\\s|<=?|>=?", function (str) {
switch (str) {
case "<":
return "&lt;";
case "<=":
return "&le;";
case ">":
return "&gt;";
case ">=":
return "&ge;";
default:
return "&nbsp;";
}
});
} }
}); });

92
src/core/proto/date.js

@ -109,16 +109,17 @@ Date.prototype.getDayOfYear = function () {
Date.prototype.getWeekNumber = function () { Date.prototype.getWeekNumber = function () {
var d = Date.getDate(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0); var d = Date.getDate(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
//周一是一周第一天 //周一是一周第一天
var week = d.getDay(); var week = d.getDay() === 0 ? 7 : d.getDay();
//var week = d.getDay();
if (this.getMonth() === 0 && this.getDate() <= week) { if (this.getMonth() === 0 && this.getDate() <= week) {
return 1; return 1;
} }
d.setDate(this.getDate() - week); d.setDate(this.getDate() - (week - 1));
var ms = d.valueOf(); // GMT var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() > 0) { if (d.getDay() !== 1) {
offset++; offset++;
} }
return offset; return offset;
@ -130,17 +131,17 @@ Date.prototype.getQuarter = function () {
//离当前时间多少天的时间 //离当前时间多少天的时间
Date.prototype.getOffsetDate = function (offset) { Date.prototype.getOffsetDate = function (offset) {
return Date.getDate(this.getTime() + offset * 864e5); return Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()) + offset * 864e5);
}; };
Date.prototype.getAfterMulQuarter = function (n) { Date.prototype.getAfterMulQuarter = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() + n * 3); dt.setMonth(dt.getMonth() + n * 3);
return dt; return dt;
}; };
//获得n个季度前的日期 //获得n个季度前的日期
Date.prototype.getBeforeMulQuarter = function (n) { Date.prototype.getBeforeMulQuarter = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() - n * 3); dt.setMonth(dt.getMonth() - n * 3);
return dt; return dt;
}; };
@ -172,49 +173,19 @@ Date.prototype.getQuarterEndDate = function () {
return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth)); return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth));
}; };
Date.prototype.getAfterMultiMonth = function (n) { Date.prototype.getAfterMultiMonth = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() + n | 0); dt.setMonth(dt.getMonth() + n | 0);
return dt; return dt;
}; };
Date.prototype.getBeforeMultiMonth = function (n) { Date.prototype.getBeforeMultiMonth = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() - n | 0); dt.setMonth(dt.getMonth() - n | 0);
return dt; return dt;
}; };
Date.prototype.getAfterMulQuarter = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() + n * 3);
return dt;
};
//获得n个季度前的日期
Date.prototype.getBeforeMulQuarter = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() - n * 3);
return dt;
};
//得到本季度的起始月份
Date.prototype.getQuarterStartMonth = function () {
var quarterStartMonth = 0;
var nowMonth = this.getMonth();
if (nowMonth < 3) {
quarterStartMonth = 0;
}
if (2 < nowMonth && nowMonth < 6) {
quarterStartMonth = 3;
}
if (5 < nowMonth && nowMonth < 9) {
quarterStartMonth = 6;
}
if (nowMonth > 8) {
quarterStartMonth = 9;
}
return quarterStartMonth;
};
//指定日期n个月之前或之后的日期 //指定日期n个月之前或之后的日期
Date.prototype.getOffsetMonth = function (n) { Date.prototype.getOffsetMonth = function (n) {
var dt = Date.getDate(this.getTime()); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
var day = dt.getDate(); var day = dt.getDate();
var monthDay = Date.getDate(dt.getFullYear(), dt.getMonth() + parseInt(n), 1).getMonthDays(); var monthDay = Date.getDate(dt.getFullYear(), dt.getMonth() + parseInt(n), 1).getMonthDays();
if (day > monthDay) { if (day > monthDay) {
@ -228,42 +199,12 @@ Date.prototype.getOffsetMonth = function (n) {
//获得本周的起始日期 //获得本周的起始日期
Date.prototype.getWeekStartDate = function () { Date.prototype.getWeekStartDate = function () {
var w = this.getDay(); var w = this.getDay();
return this.getOffsetDate(-w); return this.getOffsetDate(w === 0 ? -6 : 1 - w);
}; };
//得到本周的结束日期 //得到本周的结束日期
Date.prototype.getWeekEndDate = function () { Date.prototype.getWeekEndDate = function () {
var w = this.getDay(); var w = this.getDay();
var offset = (w === 0 ? 6 : 6 - w); return this.getOffsetDate(w === 0 ? 0 : 7 - w);
return this.getOffsetDate(offset);
};
//获得本季度的起始日期
Date.prototype.getQuarterStartDate = function () {
return Date.getDate(this.getFullYear(), this.getQuarterStartMonth(), 1);
};
//得到本季度的结束日期
Date.prototype.getQuarterEndDate = function () {
var quarterEndMonth = this.getQuarterStartMonth() + 2;
return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth));
};
Date.prototype.getAfterMultiMonth = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() + n | 0);
return dt;
};
Date.prototype.getBeforeMultiMonth = function (n) {
var dt = Date.getDate(this.getTime());
dt.setMonth(dt.getMonth() - n | 0);
return dt;
};
//获得当前时区对应指定时区的时间
Date.prototype.getTimeZoneTimeByTimezoneOffset = function (offset) {
var dt = Date.getDate(this.getTime());
var localTime = dt.getTime();
var localOffset = dt.getTimezoneOffset() * 60000; //获得当地时间偏移的毫秒数
var utc = localTime + localOffset; //utc即GMT时间标准时区
return Date.getDate(utc + offset);
}; };
/** Checks date and time equality */ /** Checks date and time equality */
@ -568,3 +509,12 @@ Date.getDate = function () {
return dt; return dt;
} }
}; };
Date.getTime = function () {
var dt = Function.prototype.bind.apply(Date.getDate, BI.concat([null], [].slice.apply(arguments)))();
if(BI.isNotNull(Date.timeZone)){
return dt.getTime() - Date.timeZone - dt.getTimezoneOffset() * 60000;
}else{
return dt.getTime();
}
};

2
src/css/base/single/tip/tip.bubble.css

@ -5,6 +5,6 @@
-webkit-border-radius: 2px; -webkit-border-radius: 2px;
-moz-border-radius: 2px; -moz-border-radius: 2px;
border-radius: 2px; border-radius: 2px;
background: #ff4949; background: #fddddd;
color: #ff4949; color: #ff4949;
} }

2
src/css/base/single/tip/tip.toast.css

@ -9,6 +9,6 @@
color: #5cb75d; color: #5cb75d;
} }
.bi-toast.toast-warning { .bi-toast.toast-warning {
background: #ff4949; background: #fddddd;
color: #ff4949; color: #ff4949;
} }

2
src/css/base/single/tip/tip.tooltip.css

@ -11,7 +11,7 @@
color: #1a1a1a; color: #1a1a1a;
} }
.bi-tooltip.tooltip-warning { .bi-tooltip.tooltip-warning {
background: #ff4949; background: #fddddd;
color: #ff4949; color: #ff4949;
border: 1px solid #f4cbcb; border: 1px solid #f4cbcb;
} }

2
src/less/base/single/tip/tip.bubble.less

@ -4,7 +4,7 @@
font-size: @font-size-14; font-size: @font-size-14;
& .bubble-text{ & .bubble-text{
.border-radius(2px); .border-radius(2px);
background: @color-bi-tip-warning-background; background: @color-bi-background-light-failure;
color: @color-bi-text-failure; color: @color-bi-text-failure;
} }
} }

4
src/less/base/single/tip/tip.toast.less

@ -4,11 +4,11 @@
font-size: @font-size-14; font-size: @font-size-14;
.border-radius(2px); .border-radius(2px);
&.toast-success{ &.toast-success{
background: @color-bi-toast-success-background; background: @color-bi-background-light-success;
color: @color-bi-text-success; color: @color-bi-text-success;
} }
&.toast-warning{ &.toast-warning{
background: @color-bi-tip-warning-background; background: @color-bi-background-light-failure;
color: @color-bi-text-failure; color: @color-bi-text-failure;
} }
} }

4
src/less/base/single/tip/tip.tooltip.less

@ -10,8 +10,8 @@
color: @color-bi-text-black; color: @color-bi-text-black;
} }
&.tooltip-warning{ &.tooltip-warning{
background: @color-bi-tip-warning-background; background: @color-bi-background-light-failure;
color: @color-bi-text-failure; color: @color-bi-text-failure;
border: 1px solid @color-bi-tooltip-warning-border; border: 1px solid @color-bi-tooltip-failure-border;
} }
} }

13
src/less/lib/colors.less

@ -46,8 +46,12 @@
@color-bi-background-disabled: @background-color-disabled; @color-bi-background-disabled: @background-color-disabled;
//成功背景色 //成功背景色
@color-bi-background-success: @background-color-dark-success; @color-bi-background-success: @background-color-dark-success;
//成功背景色(浅)
@color-bi-background-light-success: @background-color-light-success;
//失败背景色 //失败背景色
@color-bi-background-failure: @background-color-negative; @color-bi-background-failure: @background-color-negative;
//失败背景色(浅)
@color-bi-background-light-failure: @background-color-light-negative;
//警示背景色 //警示背景色
@color-bi-background-warning: @background-color-warning; @color-bi-background-warning: @background-color-warning;
//背景提亮色 //背景提亮色
@ -72,20 +76,13 @@
//边框提亮 //边框提亮
@color-bi-border-highlight: @border-color-highlight; @color-bi-border-highlight: @border-color-highlight;
//bubble、toast、tooltip通用
@color-bi-tip-warning-background: @background-color-negative;
//toast
//成功背景
@color-bi-toast-success-background: @background-color-light-success;
//tooltip //tooltip
//成功背景 //成功背景
@color-bi-tooltip-success-background: @background-color-normal-success; @color-bi-tooltip-success-background: @background-color-normal-success;
//成功边框 //成功边框
@color-bi-tooltip-success-border: @border-color-normal-success; @color-bi-tooltip-success-border: @border-color-normal-success;
//失败边框 //失败边框
@color-bi-tooltip-warning-border: @border-color-error; @color-bi-tooltip-failure-border: @border-color-light-negative;
//mask颜色 //mask颜色
@color-bi-button-mask: @color-bi-background-black; @color-bi-button-mask: @color-bi-background-black;

3
src/less/lib/constant.less

@ -41,6 +41,7 @@
@background-color-disabled: #cccccc; @background-color-disabled: #cccccc;
@background-color-negative: #ff4949; @background-color-negative: #ff4949;
@background-color-light-negative: #fddddd;
@background-color-warning: #faaa39; @background-color-warning: #faaa39;
@background-color-dark-success: #58cc7d; @background-color-dark-success: #58cc7d;
@ -57,7 +58,7 @@
@border-color-warning: #fbb03b; @border-color-warning: #fbb03b;
@border-color-negative: #e85050; @border-color-negative: #e85050;
@border-color-success: #58cc7d; @border-color-success: #58cc7d;
@border-color-error: #f4cbcb; @border-color-light-negative: #f4cbcb;
@border-color-normal-success: #eddea2; @border-color-normal-success: #eddea2;
//split color //split color

Loading…
Cancel
Save