Zhenfei.Li 6 years ago
parent
commit
95c1d3a353
  1. 28
      Gruntfile.js
  2. 14
      dist/bundle.css
  3. 52311
      dist/bundle.js
  4. 2
      dist/bundle.min.css
  5. 78
      dist/bundle.min.js
  6. 55597
      dist/core.js
  7. 14
      dist/fineui.css
  8. 52311
      dist/fineui.js
  9. 2
      dist/fineui.min.css
  10. 78
      dist/fineui.min.js
  11. 905
      dist/fineui_without_jquery_polyfill.js
  12. 2
      dist/fix/fix.compact.js
  13. 363
      dist/utils.js
  14. 6
      dist/utils.min.js
  15. 14
      dist/widget.css
  16. 2
      dist/widget.js
  17. 148
      src/core/base.js
  18. 592
      src/core/func/dom.js
  19. 255
      src/core/func/function.js
  20. 22
      src/core/platform/dom/ajax.js
  21. 20
      src/core/platform/dom/config.js
  22. 0
      src/core/platform/dom/detectElementResize.js
  23. 254
      src/core/platform/dom/dom.js
  24. 0
      src/core/platform/dom/eventlistener.js
  25. 125
      src/core/platform/dom/function.js
  26. 0
      src/core/platform/dom/jquery/_jquery.js
  27. 0
      src/core/platform/dom/jquery/event.js
  28. 424
      src/core/platform/dom/jquery/extend.js
  29. 224
      src/core/platform/dom/jquery/fn.js
  30. 0
      src/core/platform/dom/load.js
  31. 58
      src/core/proto/jquery.js
  32. 14
      src/css/widget/singleslider/slider/widget.css
  33. 19
      src/less/widget/singleslider/slider/widget.slider.less
  34. 2
      src/widget/singleslider/button/iconbutton.slider.js

28
Gruntfile.js

@ -14,7 +14,6 @@ module.exports = function (grunt) {
coreJs: {
src: [
"src/core/foundation.js",
"src/core/jquery.js",
"src/core/lodash.js",
// 'src/core/mvc/**/*.js',
"src/core/base.js",
@ -23,7 +22,7 @@ module.exports = function (grunt) {
// 'src/core/model.js',
// 'src/core/view.js',
"src/core/shortcut.js",
"src/core/utils/*.js",
"src/core/utils/**/*.js",
"src/core/behavior/behavior.js",
"src/core/wrapper/layout.js",
"src/core/plugin.js",
@ -47,7 +46,6 @@ module.exports = function (grunt) {
"src/base/single/tip/tip.js",
"src/base/combination/group.button.js",
"src/base/combination/tree.button.js",
"src/base/combination/map.button.js",
"src/base/tree/treeview.js",
"src/base/tree/asynctree.js",
"src/base/tree/parttree.js",
@ -65,8 +63,6 @@ module.exports = function (grunt) {
},
widgetJs: {
src: [
"src/widget/paramsettingcombo/popup.param.js",
"src/widget/sequencetable/treenumber.sequencetable.js",
"src/widget/**/*.js",
"src/component/**/*.js"
],
@ -110,20 +106,7 @@ module.exports = function (grunt) {
},
fineuiJs: {
src: ["dist/polyfill.js", "dist/core.js", "dist/fix/fix.js", "src/third/**/*.js",
"src/base/pane.js",
"src/base/single/single.js",
"src/base/single/text.js",
"src/base/single/button/button.basic.js",
"src/base/single/button/button.node.js",
"src/base/single/tip/tip.js",
"src/base/combination/group.button.js",
"src/base/combination/tree.button.js",
"src/base/combination/map.button.js",
"src/base/tree/treeview.js",
"src/base/tree/asynctree.js",
"src/base/tree/parttree.js",
"src/base/**/*.js",
src: ["dist/polyfill.js", "dist/core.js", "dist/fix/fix.js", "dist/base.js",
"dist/case.js", "dist/widget.js", "dist/fix/fix.compact.js", "dist/router.js", "ui/js/**/*.js", "!ui/js/fineui.i18n.js"],
dest: "dist/fineui.js"
},
@ -143,10 +126,7 @@ module.exports = function (grunt) {
"src/core/wrapper/layout.js",
"src/core/plugin.js",
"src/core/**/*.js",
"!src/core/jquery.js",
"!src/core/func/dom.js",
"!src/core/proto/jquery.js",
"!src/core/proto/event.js",
"!src/core/platform/dom/**/*.js",
"src/data/data.js",
"src/data/**/*.js",
@ -170,7 +150,7 @@ module.exports = function (grunt) {
"!src/case/colorchooser/**/*.js",
"!src/case/tree/tree.display.js",
"dist/widget.js", "dist/fix/fix.compact.js", "ui/js/**/*.js", "!ui/js/fineui.i18n.js"],
"dist/widget.js", "dist/fix/fix.compact.js", "ui/js/**/*.js"],
dest: "dist/fineui_without_jquery_polyfill.js"
},

14
dist/bundle.css vendored

@ -3703,7 +3703,8 @@ ul.ztree.zTreeDragUL {
}
.bi-single-slider-button .slider-button {
cursor: ew-resize;
border: 2px solid #3685f2;
border-width: 2px;
border-style: solid;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
@ -3735,6 +3736,17 @@ ul.ztree.zTreeDragUL {
top: 6px;
left: -8px;
}
.bi-theme-dark .bi-single-slider-button .slider-button {
background-color: #242640;
}
.bi-theme-dark .bi-single-slider-button .slider-button:hover,
.bi-theme-dark .bi-single-slider-button .slider-button.hover {
background-color: #191B2B;
}
.bi-theme-dark .bi-single-slider-button .slider-button.disabled:hover,
.bi-theme-dark .bi-single-slider-button .slider-button.disabled.hover {
background-color: #191B2B;
}
.bi-slider-track .gray-track {
background-color: rgba(61, 77, 102, 0.1);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#1a3d4d66,endColorstr=#1a3d4d66);

52311
dist/bundle.js vendored

File diff suppressed because one or more lines are too long

2
dist/bundle.min.css vendored

File diff suppressed because one or more lines are too long

78
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

55597
dist/core.js vendored

File diff suppressed because one or more lines are too long

14
dist/fineui.css vendored

@ -3703,7 +3703,8 @@ ul.ztree.zTreeDragUL {
}
.bi-single-slider-button .slider-button {
cursor: ew-resize;
border: 2px solid #3685f2;
border-width: 2px;
border-style: solid;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
@ -3735,6 +3736,17 @@ ul.ztree.zTreeDragUL {
top: 6px;
left: -8px;
}
.bi-theme-dark .bi-single-slider-button .slider-button {
background-color: #242640;
}
.bi-theme-dark .bi-single-slider-button .slider-button:hover,
.bi-theme-dark .bi-single-slider-button .slider-button.hover {
background-color: #191B2B;
}
.bi-theme-dark .bi-single-slider-button .slider-button.disabled:hover,
.bi-theme-dark .bi-single-slider-button .slider-button.disabled.hover {
background-color: #191B2B;
}
.bi-slider-track .gray-track {
background-color: rgba(61, 77, 102, 0.1);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#1a3d4d66,endColorstr=#1a3d4d66);

52311
dist/fineui.js vendored

File diff suppressed because one or more lines are too long

2
dist/fineui.min.css vendored

File diff suppressed because one or more lines are too long

78
dist/fineui.min.js vendored

File diff suppressed because one or more lines are too long

905
dist/fineui_without_jquery_polyfill.js vendored

@ -11477,154 +11477,6 @@ if (!_global.BI) {
}
});
// 浏览器相关方法
_.extend(BI, {
isIE: function () {
if(!_global.navigator) {
return false;
}
if (this.__isIE == null) {
this.__isIE = /(msie|trident)/i.test(navigator.userAgent.toLowerCase());
}
return this.__isIE;
},
getIEVersion: function () {
if(!_global.navigator) {
return 0;
}
if (this.__IEVersion != null) {
return this.__IEVersion;
}
var version = 0;
var agent = navigator.userAgent.toLowerCase();
var v1 = agent.match(/(?:msie\s([\w.]+))/);
var v2 = agent.match(/(?:trident.*rv:([\w.]+))/);
if (v1 && v2 && v1[1] && v2[1]) {
version = Math.max(v1[1] * 1, v2[1] * 1);
} else if (v1 && v1[1]) {
version = v1[1] * 1;
} else if (v2 && v2[1]) {
version = v2[1] * 1;
} else {
version = 0;
}
return this.__IEVersion = version;
},
isIE9Below: function () {
if (!BI.isIE()) {
return false;
}
return this.getIEVersion() < 9;
},
isEdge: function () {
if(!_global.navigator) {
return false;
}
return /edge/i.test(navigator.userAgent.toLowerCase());
},
isChrome: function () {
if(!_global.navigator) {
return false;
}
return /chrome/i.test(navigator.userAgent.toLowerCase());
},
isFireFox: function () {
if(!_global.navigator) {
return false;
}
return /firefox/i.test(navigator.userAgent.toLowerCase());
},
isOpera: function () {
if(!_global.navigator) {
return false;
}
return /opera/i.test(navigator.userAgent.toLowerCase());
},
isSafari: function () {
if(!_global.navigator) {
return false;
}
return /safari/i.test(navigator.userAgent.toLowerCase());
},
isKhtml: function () {
if(!_global.navigator) {
return false;
}
return /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
},
isMac: function () {
if(!_global.navigator) {
return false;
}
return /macintosh|mac os x/i.test(navigator.userAgent);
},
isWindows: function () {
if(!_global.navigator) {
return false;
}
return /windows|win32/i.test(navigator.userAgent);
},
isSupportCss3: function (style) {
if(!_global.document) {
return false;
}
var prefix = ["webkit", "Moz", "ms", "o"],
i, len,
humpString = [],
htmlStyle = document.documentElement.style,
_toHumb = function (string) {
return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase();
});
};
for (i in prefix) {
humpString.push(_toHumb(prefix[i] + "-" + style));
}
humpString.push(_toHumb(style));
for (i = 0, len = humpString.length; i < len; i++) {
if (humpString[i] in htmlStyle) {
return true;
}
}
return false;
}
});
// BI请求
_.extend(BI, {
ajax: function (option) {
option || (option = {});
var async = option.async;
option.data = BI.cjkEncodeDO(option.data || {});
$.ajax({
url: option.url,
type: "POST",
data: option.data,
async: async,
error: option.error,
complete: function (res, status) {
if (BI.isFunction(option.complete)) {
option.complete(BI.jsonDecode(res.responseText), status);
}
}
});
}
});
})();/**
* 客户端观察者主要处理事件的添加删除执行等
* @class BI.OB
@ -13286,166 +13138,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return _mkPYRslt(arrResult);
}
});
})();/**
* Detect Element Resize.
* Forked in order to guard against unsafe 'window' and 'document' references.
*
* https://github.com/sdecima/javascript-detect-element-resize
* Sebastian Decima
*
* version: 0.5.3
**/
!(function () {
var attachEvent = _global.document && _global.document.attachEvent,
stylesCreated = false;
if (_global.document && !attachEvent) {
var requestFrame = (function () {
var raf = _global.requestAnimationFrame || _global.mozRequestAnimationFrame || _global.webkitRequestAnimationFrame ||
function (fn) { return _global.setTimeout(fn, 20); };
return function (fn) { return raf(fn); };
})();
var cancelFrame = (function () {
var cancel = _global.cancelAnimationFrame || _global.mozCancelAnimationFrame || _global.webkitCancelAnimationFrame ||
_global.clearTimeout;
return function (id) { return cancel(id); };
})();
var resetTriggers = function (element) {
var triggers = element.__resizeTriggers__,
expand = triggers.firstElementChild,
contract = triggers.lastElementChild,
expandChild = expand.firstElementChild;
contract.scrollLeft = contract.scrollWidth;
contract.scrollTop = contract.scrollHeight;
expandChild.style.width = expand.offsetWidth + 1 + "px";
expandChild.style.height = expand.offsetHeight + 1 + "px";
expand.scrollLeft = expand.scrollWidth;
expand.scrollTop = expand.scrollHeight;
};
var checkTriggers = function (element) {
return element.offsetWidth !== element.__resizeLast__.width ||
element.offsetHeight !== element.__resizeLast__.height;
};
var scrollListener = function (e) {
var element = this;
resetTriggers(this);
if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
this.__resizeRAF__ = requestFrame(function () {
if (checkTriggers(element)) {
element.__resizeLast__.width = element.offsetWidth;
element.__resizeLast__.height = element.offsetHeight;
element.__resizeListeners__.forEach(function (fn) {
fn.call(element, e);
});
}
});
};
/* Detect CSS Animations support to detect element display/re-attach */
var animation = false,
animationstring = "animation",
keyframeprefix = "",
animationstartevent = "animationstart",
domPrefixes = "Webkit Moz O ms".split(" "),
startEvents = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "),
pfx = "";
{
var elm = document.createElement("fakeelement");
if (elm.style.animationName !== undefined) {
animation = true;
}
if (animation === false) {
for (var i = 0; i < domPrefixes.length; i++) {
if (elm.style[domPrefixes[i] + "AnimationName"] !== undefined) {
pfx = domPrefixes[i];
animationstring = pfx + "Animation";
keyframeprefix = "-" + pfx.toLowerCase() + "-";
animationstartevent = startEvents[i];
animation = true;
break;
}
}
}
}
var animationName = "resizeanim";
var animationKeyframes = "@" + keyframeprefix + "keyframes " + animationName + " { from { opacity: 0; } to { opacity: 0; } } ";
var animationStyle = keyframeprefix + "animation: 1ms " + animationName + "; ";
}
var createStyles = function () {
if (!stylesCreated) {
// opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360
var css = (animationKeyframes ? animationKeyframes : "") +
".resize-triggers { " + (animationStyle ? animationStyle : "") + "visibility: hidden; opacity: 0; } " +
".resize-triggers, .resize-triggers > div, .contract-trigger:before { content: \" \"; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }",
head = document.head || document.getElementsByTagName("head")[0],
style = document.createElement("style");
style.type = "text/css";
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
stylesCreated = true;
}
};
var addResizeListener = function (element, fn) {
if (attachEvent) element.attachEvent("onresize", fn);
else {
if (!element.__resizeTriggers__) {
if (getComputedStyle(element).position === "static") element.style.position = "relative";
createStyles();
element.__resizeLast__ = {};
element.__resizeListeners__ = [];
(element.__resizeTriggers__ = document.createElement("div")).className = "resize-triggers";
element.__resizeTriggers__.innerHTML = "<div class=\"expand-trigger\"><div></div></div>" +
"<div class=\"contract-trigger\"></div>";
element.appendChild(element.__resizeTriggers__);
resetTriggers(element);
element.addEventListener("scroll", scrollListener, true);
/* Listen for a css animation to detect element display/re-attach */
animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
if (e.animationName === animationName) {resetTriggers(element);}
});
}
element.__resizeListeners__.push(fn);
}
};
var removeResizeListener = function (element, fn) {
if (attachEvent) element.detachEvent("onresize", fn);
else {
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
if (!element.__resizeListeners__.length) {
element.removeEventListener("scroll", scrollListener);
element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
}
}
};
BI.ResizeDetector = {
addResizeListener: function (widget, fn) {
addResizeListener(widget.element[0], fn);
return function () {
removeResizeListener(widget.element[0], fn);
};
},
removeResizeListener: function (widget, fn) {
removeResizeListener(widget.element[0], fn);
}
};
})();
(function () {
function defaultComparator (a, b) {
return a < b;
@ -13631,61 +13324,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return array;
}
};
})();_.extend(BI, {
$import: function () {
var _LOADED = {}; // alex:保存加载过的
function loadReady (src, must) {
var $scripts = $("head script, body script");
$.each($scripts, function (i, item) {
if (item.src.indexOf(src) != -1) {
_LOADED[src] = true;
}
});
var $links = $("head link");
$.each($links, function (i, item) {
if (item.href.indexOf(src) != -1 && must) {
_LOADED[src] = false;
$(item).remove();
}
});
}
// must=true 强行加载
return function (src, ext, must) {
loadReady(src, must);
// alex:如果已经加载过了的,直接return
if (_LOADED[src] === true) {
return;
}
if (ext === "css") {
var link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = src;
var head = document.getElementsByTagName("head")[0];
head.appendChild(link);
_LOADED[src] = true;
} else {
// alex:这里用同步调用的方式,必须等待ajax完成
$.ajax({
url: src,
dataType: "script", // alex:指定dataType为script,jquery会帮忙做globalEval的事情
async: false,
cache: true,
complete: function (res, status) {
/*
* alex:发现jquery会很智能地判断一下返回的数据类型是不是script,然后做一个globalEval
* 所以当status为success时就不需要再把其中的内容加到script里面去了
*/
if (status == "success") {
_LOADED[src] = true;
}
}
});
}
};
}()
});
})();
!(function () {
BI.LRU = function (limit) {
this.size = 0;
@ -16422,53 +16061,6 @@ BI.RedMarkBehavior = BI.inherit(BI.Behavior, {
}
});
}
});// 工程配置
BI.prepares.push(function () {
// 注册布局
var isSupportFlex = BI.isSupportCss3("flex");
BI.Plugin.registerWidget("bi.horizontal", function (ob) {
if (!BI.isIE() && isSupportFlex) {
return BI.extend(ob, {type: "bi.flex_horizontal"});
}
return ob;
});
BI.Plugin.registerWidget("bi.center_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex && ob.items && ob.items.length <= 1) {
// 有滚动条的情况下需要用到flex_wrapper_center布局
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
// 不是IE用flex_wrapper_center布局
return BI.extend(ob, {type: "bi.flex_wrapper_center"});
}
return BI.extend(ob, {type: "bi.flex_center"});
}
return ob;
});
BI.Plugin.registerWidget("bi.vertical_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex) {
// 有滚动条的情况下需要用到flex_wrapper_center布局
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
// 不是IE用flex_wrapper_center布局
return BI.extend({}, ob, {type: "bi.flex_wrapper_vertical_center"});
}
return BI.extend(ob, {type: "bi.flex_vertical_center"});
}
return ob;
});
BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex) {
// 有滚动条的情况下需要用到flex_wrapper_center布局
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
// 不是IE用flex_wrapper_center布局
return BI.extend({}, ob, {type: "bi.flex_wrapper_center"});
}
return BI.extend(ob, {type: "bi.flex_center"});
}
return ob;
});
});/**
* guy
* 控制器
@ -16918,6 +16510,17 @@ BI.LayerController = BI.inherit(BI.Controller, {
delete this.layerManager[name];
delete this.layouts[name];
return this;
},
removeAll: function () {
var self = this;
BI.each(BI.keys(this.layerManager), function (index, name) {
self.layerManager[name].destroy();
self.layouts[name].destroy();
});
this.layerManager = {};
this.layouts = {};
return this;
}
});/**
* 遮罩面板, z-index在1亿层级
@ -17074,6 +16677,20 @@ BI.PopoverController = BI.inherit(BI.Controller, {
delete this.floatContainer[name];
delete this.floatOpened[name];
return this;
},
removeAll: function () {
var self = this;
BI.each(this.floatContainer, function (name, container) {
container.destroy();
self.modal && self.floatContainer[name].element.__releaseZIndexMask__(self.zindexMap[name]);
});
this.floatManager = {};
this.floatLayer = {};
this.floatContainer = {};
this.floatOpened = {};
this.zindexMap = {};
return this;
}
});/**
* window.resize 控制器
@ -17790,261 +17407,6 @@ BI.extend(BI.Func, {
};
}
});
/**
* 对DOM操作的通用函数
* @type {{}}
*/
BI.DOM = {};
BI.extend(BI.DOM, {
/**
* 把dom数组或元素悬挂起来,使其不对html产生影响
* @param dom
*/
hang: function (doms) {
if (BI.isEmpty(doms)) {
return;
}
var frag = document.createDocumentFragment();
BI.each(doms, function (i, dom) {
dom instanceof BI.Widget && (dom = dom.element);
dom instanceof $ && dom[0] && frag.appendChild(dom[0]);
});
return frag;
},
isExist: function (obj) {
return BI.Widget._renderEngine.createElement("body").find(obj.element).length > 0;
},
// 预加载图片
preloadImages: function (srcArray, onload) {
var count = 0, images = [];
function complete () {
count++;
if (count >= srcArray.length) {
onload();
}
}
BI.each(srcArray, function (i, src) {
images[i] = new Image();
images[i].src = src;
images[i].onload = function () {
complete();
};
images[i].onerror = function () {
complete();
};
});
},
isColor: function (color) {
return color && (this.isRGBColor(color) || this.isHexColor(color));
},
isRGBColor: function (color) {
if (!color) {
return false;
}
return color.substr(0, 3) === "rgb";
},
isHexColor: function (color) {
if (!color) {
return false;
}
return color[0] === "#" && color.length === 7;
},
isDarkColor: function (hex) {
if (!hex || !this.isHexColor(hex)) {
return false;
}
var rgb = this.rgb2json(this.hex2rgb(hex));
var grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114);
if (grayLevel < 192/** 网上给的是140**/) {
return true;
}
return false;
},
// 获取对比颜色
getContrastColor: function (color) {
if (!color || !this.isColor(color)) {
return "";
}
if (this.isDarkColor(color)) {
return "#ffffff";
}
return "#1a1a1a";
},
rgb2hex: function (rgbColour) {
if (!rgbColour || rgbColour.substr(0, 3) != "rgb") {
return "";
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
var red = BI.parseInt(rgbValues[0]);
var green = BI.parseInt(rgbValues[1]);
var blue = BI.parseInt(rgbValues[2]);
var hexColour = "#" + this.int2hex(red) + this.int2hex(green) + this.int2hex(blue);
return hexColour;
},
rgb2json: function (rgbColour) {
if (!rgbColour) {
return {};
}
if (!this.isRGBColor(rgbColour)) {
return {};
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return {
r: BI.parseInt(rgbValues[0]),
g: BI.parseInt(rgbValues[1]),
b: BI.parseInt(rgbValues[2])
};
},
rgba2json: function (rgbColour) {
if (!rgbColour) {
return {};
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return {
r: BI.parseInt(rgbValues[0]),
g: BI.parseInt(rgbValues[1]),
b: BI.parseInt(rgbValues[2]),
a: BI.parseFloat(rgbValues[3])
};
},
json2rgb: function (rgb) {
if (!BI.isKey(rgb.r) || !BI.isKey(rgb.g) || !BI.isKey(rgb.b)) {
return "";
}
return "rgb(" + rgb.r + "," + rgb.g + "," + rgb.b + ")";
},
json2rgba: function (rgba) {
if (!BI.isKey(rgba.r) || !BI.isKey(rgba.g) || !BI.isKey(rgba.b)) {
return "";
}
return "rgba(" + rgba.r + "," + rgba.g + "," + rgba.b + "," + rgba.a + ")";
},
int2hex: function (strNum) {
var hexdig = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
return hexdig[strNum >>> 4] + "" + hexdig[strNum & 15];
},
hex2rgb: function (color) {
if (!color) {
return "";
}
if (!this.isHexColor(color)) {
return color;
}
var tempValue = "rgb(", colorArray;
if (color.length === 7) {
colorArray = [BI.parseInt("0x" + color.substring(1, 3)),
BI.parseInt("0x" + color.substring(3, 5)),
BI.parseInt("0x" + color.substring(5, 7))];
} else if (color.length === 4) {
colorArray = [BI.parseInt("0x" + color.substring(1, 2)),
BI.parseInt("0x" + color.substring(2, 3)),
BI.parseInt("0x" + color.substring(3, 4))];
}
tempValue += colorArray[0] + ",";
tempValue += colorArray[1] + ",";
tempValue += colorArray[2] + ")";
return tempValue;
},
rgba2rgb: function (rgbColour, BGcolor) {
if (BI.isNull(BGcolor)) {
BGcolor = 1;
}
if (rgbColour.substr(0, 4) != "rgba") {
return "";
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
if (rgbValues.length < 4) {
return "";
}
var R = BI.parseFloat(rgbValues[0]);
var G = BI.parseFloat(rgbValues[1]);
var B = BI.parseFloat(rgbValues[2]);
var A = BI.parseFloat(rgbValues[3]);
return "rgb(" + Math.floor(255 * (BGcolor * (1 - A )) + R * A) + "," +
Math.floor(255 * (BGcolor * (1 - A )) + G * A) + "," +
Math.floor(255 * (BGcolor * (1 - A )) + B * A) + ")";
},
getTextSizeWidth: function (text, fontSize) {
var span = BI.Widget._renderEngine.createElement("<span></span>").addClass("text-width-span").appendTo($("body"));
if (fontSize == null) {
fontSize = 12;
}
fontSize = fontSize + "px";
span.css("font-size", fontSize).text(text);
var width = span.width();
span.remove();
return width;
},
// 获取滚动条的宽度
getScrollWidth: function () {
if (this._scrollWidth == null) {
var ul = BI.Widget._renderEngine.createElement("<div>").width(50).height(50).css({
position: "absolute",
top: "-9999px",
overflow: "scroll"
}).appendTo("body");
this._scrollWidth = ul[0].offsetWidth - ul[0].clientWidth;
ul.destroy();
}
return this._scrollWidth;
},
getImage: function (param, fillStyle, backgroundColor) {
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 14) + 6;
canvas.width = w * ratio;
canvas.height = 24 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3D4D66";
ctx.textBaseline = "middle";
ctx.fillText(param, 6 * ratio, 12 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "#EAF2FD";
// IE可以放大缩小所以要固定最大最小宽高
return {
width: w,
height: 24,
src: canvas.toDataURL("image/png"),
style: "background-color: " + backColor + ";vertical-align: middle; margin: 0 3px; width:" + w + "px;height: 24px; max-width:" + w + "px;max-height: 24px; min-width:" + w + "px;min-height: 24px",
param: param
};
}
});
(function () {
var constantInjection = {};
BI.constant = function (xtype, cls) {
@ -19378,43 +18740,7 @@ _.extend(String.prototype, {
}
return location;
}
});BI.EventListener = {
listen: function listen (target, eventType, callback) {
if (target.addEventListener) {
target.addEventListener(eventType, callback, false);
return {
remove: function remove () {
target.removeEventListener(eventType, callback, false);
}
};
} else if (target.attachEvent) {
target.attachEvent("on" + eventType, callback);
return {
remove: function remove () {
target.detachEvent("on" + eventType, callback);
}
};
}
},
capture: function capture (target, eventType, callback) {
if (target.addEventListener) {
target.addEventListener(eventType, callback, true);
return {
remove: function remove () {
target.removeEventListener(eventType, callback, true);
}
};
}
return {
remove: BI.emptyFn
};
},
registerDefault: function registerDefault () {
}
};!(function () {
});!(function () {
var cancelAnimationFrame =
_global.cancelAnimationFrame ||
_global.webkitCancelAnimationFrame ||
@ -59848,7 +59174,7 @@ BI.SliderIconButton = BI.inherit(BI.Widget, {
el: {
type: "bi.text_button",
forceNotSelected: true,
cls: "slider-button bi-list-item-select3",
cls: "slider-button bi-list-item-select3 bi-high-light-border",
ref: function () {
self.slider = this;
}
@ -65362,7 +64688,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
});
});
if (BI.isIE9Below()) {
if (BI.isIE9Below && BI.isIE9Below()) {
_.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
"sortBy", "groupBy", "indexBy", "countBy", "partition",
"keys", "allKeys", "values", "pairs", "invert",
@ -65415,4 +64741,175 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
};
}
BI.watch = Fix.watch;
}());BI.resourceURL = "file?path=/com/fr/web/ui/resource";
}());BI.i18n = {
"BI-Multi_Date_Quarter_End": "季度末",
"BI-Multi_Date_Month_Begin": "月初",
"BI-Multi_Date_YMD": "年/月/日",
"BI-Custom_Color": "自定义颜色",
"BI-Numerical_Interval_Input_Data": "请输入数值",
"BI-Please_Input_Natural_Number": "请输入非负整数",
"BI-No_More_Data": "无更多数据",
"BI-Basic_Altogether": "共",
"BI-Basic_Sunday": "星期日",
"BI-Widget_Background_Colour": "组件背景",
"BI-Color_Picker_Error_Text": "请输入0~255的正整数",
"BI-Multi_Date_Month": "月",
"BI-No_Selected_Item": "没有可选项",
"BI-Multi_Date_Year_Begin": "年初",
"BI-Quarter_1": "第1季度",
"BI-Quarter_2": "第2季度",
"BI-Quarter_3": "第3季度",
"BI-Quarter_4": "第4季度",
"BI-Multi_Date_Year_Next": "年后",
"BI-Multi_Date_Month_Prev": "个月前",
"BI-Month_Trigger_Error_Text": "请输入1~12的正整数",
"BI-Less_And_Equal": "小于等于",
"BI-Year_Trigger_Invalid_Text": "请输入有效时间",
"BI-Multi_Date_Week_Next": "周后",
"BI-Font_Size": "字号",
"BI-Basic_Total": "共",
"BI-Already_Selected": "已选择",
"BI-Formula_Insert": "插入",
"BI-Select_All": "全选",
"BI-Basic_Tuesday": "星期二",
"BI-Multi_Date_Month_End": "月末",
"BI-Load_More": "点击加载更多数据",
"BI-Basic_September": "九月",
"BI-Current_Is_Last_Page": "当前已是最后一页",
"BI-Basic_Auto": "自动",
"BI-Basic_Count": "个",
"BI-Basic_Value": "值",
"BI-Basic_Unrestricted": "无限制",
"BI-Quarter_Trigger_Error_Text": "请输入1~4的正整数",
"BI-Basic_More": "更多",
"BI-Basic_Wednesday": "星期三",
"BI-Basic_Bold": "加粗",
"BI-Basic_Simple_Saturday": "六",
"BI-Multi_Date_Month_Next": "个月后",
"BI-Basic_March": "三月",
"BI-Current_Is_First_Page": "当前已是第一页",
"BI-Basic_Thursday": "星期四",
"BI-Basic_Prompt": "提示",
"BI-Multi_Date_Today": "今天",
"BI-Multi_Date_Quarter_Prev": "个季度前",
"BI-Row_Header": "行表头",
"BI-Date_Trigger_Error_Text": "日期格式示例:2015-3-11",
"BI-Basic_Cancel": "取消",
"BI-Basic_January": "一月",
"BI-Basic_June": "六月",
"BI-Basic_July": "七月",
"BI-Basic_April": "四月",
"BI-Multi_Date_Quarter_Begin": "季度初",
"BI-Multi_Date_Week": "周",
"BI-Click_Blank_To_Select": "点击\"空格键\"选中完全匹配项",
"BI-Basic_August": "八月",
"BI-Word_Align_Left": "文字居左",
"BI-Basic_November": "十一月",
"BI-Font_Colour": "字体颜色",
"BI-Multi_Date_Day_Prev": "天前",
"BI-Select_Part": "部分选择",
"BI-Multi_Date_Day_Next": "天后",
"BI-Less_Than": "小于",
"BI-Basic_February": "二月",
"BI-Multi_Date_Year": "年",
"BI-Number_Index": "序号",
"BI-Multi_Date_Week_Prev": "周前",
"BI-Next_Page": "下一页",
"BI-Right_Page": "向右翻页",
"BI-Numerical_Interval_Signal_Value": "前后值相等,请将操作符改为“≤”",
"BI-Basic_December": "十二月",
"BI-Basic_Saturday": "星期六",
"BI-Basic_Simple_Wednesday": "三",
"BI-Multi_Date_Quarter_Next": "个季度后",
"BI-Basic_October": "十月",
"BI-Basic_Simple_Friday": "五",
"BI-Basic_Save": "保存",
"BI-Numerical_Interval_Number_Value": "请保证前面的数值小于/等于后面的数值",
"BI-Previous_Page": "上一页",
"BI-No_Select": "搜索结果为空",
"BI-Basic_Clears": "清空",
"BI-Created_By_Me": "我创建的",
"BI-Basic_Simple_Tuesday": "二",
"BI-Word_Align_Right": "文字居右",
"BI-Summary_Values": "汇总",
"BI-Basic_Clear": "清除",
"BI-Upload_File_Size_Error": "文件大小不支",
"BI-Up_Page": "向上翻页",
"BI-Basic_Simple_Sunday": "日",
"BI-Multi_Date_Relative_Current_Time": "相对当前时间",
"BI-Selected_Data": "已选数据:",
"BI-Multi_Date_Quarter": "季度",
"BI-Check_Selected": "查看已选",
"BI-Basic_Search": "搜索",
"BI-Basic_May": "五月",
"BI-Continue_Select": "继续选择",
"BI-Please_Input_Positive_Integer": "请输入正整数",
"BI-Upload_File_Type_Error": "文件类型不支持",
"BI-Basic_Friday": "星期五",
"BI-Down_Page": "向下翻页",
"BI-Basic_Monday": "星期一",
"BI-Left_Page": "向左翻页",
"BI-Transparent_Color": "透明",
"BI-Basic_Simple_Monday": "一",
"BI-Multi_Date_Year_End": "年末",
"BI-Time_Interval_Error_Text": "请保证开始时间早于/等于结束时间",
"BI-Basic_Time": "时间",
"BI-Basic_OK": "确定",
"BI-Basic_Sure": "确定",
"BI-Basic_Simple_Thursday": "四",
"BI-Multi_Date_Year_Prev": "年前",
"BI-Tiao_Data": "条数据",
"BI-Basic_Italic": "斜体",
"BI-Basic_Dynamic_Title": "动态时间",
"BI-Basic_Year": "年",
"BI-Basic_Single_Quarter": "季",
"BI-Basic_Month": "月",
"BI-Basic_Week": "周",
"BI-Basic_Day": "天",
"BI-Basic_Work_Day": "工作日",
"BI-Basic_Front": "前",
"BI-Basic_Behind": "后",
"BI-Basic_Empty": "空",
"BI-Basic_Month_End": "月末",
"BI-Basic_Month_Begin": "月初",
"BI-Basic_Year_End": "年末",
"BI-Basic_Year_Begin": "年初",
"BI-Basic_Quarter_End": "季末",
"BI-Basic_Quarter_Begin": "季初",
"BI-Basic_Week_End": "周末",
"BI-Basic_Week_Begin": "周初",
"BI-Basic_Current_Day": "当天",
"BI-Basic_Begin_Start": "初",
"BI-Basic_End_Stop": "末",
"BI-Basic_Current_Year": "今年",
"BI-Basic_Year_Fen": "年份",
"BI-Basic_Current_Month": "本月",
"BI-Basic_Current_Quarter": "本季度",
"BI-Basic_Year_Month": "年月",
"BI-Basic_Year_Quarter": "年季度",
"BI-Basic_Input_Can_Not_Null": "输入框不能为空",
"BI-Basic_Date_Time_Error_Text": "日期格式示例:2015-3-11 00:00:00",
"BI-Basic_Input_From_To_Number": "请输入{R1}的数值",
"BI-Basic_Or": "或",
"BI-Basic_And": "且",
"BI-Conf_Add_Formula": "添加公式",
"BI-Conf_Add_Condition": "添加条件",
"BI-Conf_Formula_And": "且公式条件",
"BI-Conf_Formula_Or": "或公式条件",
"BI-Conf_Condition_And": "且条件",
"BI-Conf_Condition_Or": "或条件",
"BI-Microsoft_YaHei": "微软雅黑",
"BI-Apple_Light": "苹方-light",
"BI-Font_Family": "字体",
"BI-Basic_Please_Input_Content": "请输入内容",
"BI-Word_Align_Center": "文字居中",
"BI-Basic_Please_Enter_Number_Between": "请输入{R1}-{R2}的值",
"BI-More_Than": "大于",
"BI-More_And_Equal": "大于等于",
"BI-Please_Enter_SQL": "请输入SQL",
"BI-Basic_Click_To_Add_Text": "+点击新增\"{R1}\"",
"BI-Basic_Please_Select": "请选择",
"BI-Basic_Font_Color": "文字颜色",
"BI-Basic_Background_Color": "背景色",
"BI-Basic_Underline": "下划线"
};BI.resourceURL = "file?path=/com/fr/web/ui/resource";

2
dist/fix/fix.compact.js vendored

@ -178,7 +178,7 @@
});
});
if (BI.isIE9Below()) {
if (BI.isIE9Below && BI.isIE9Below()) {
_.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
"sortBy", "groupBy", "indexBy", "countBy", "partition",
"keys", "allKeys", "values", "pairs", "invert",

363
dist/utils.js vendored

@ -12296,154 +12296,6 @@ if (!_global.BI) {
}
});
// 浏览器相关方法
_.extend(BI, {
isIE: function () {
if(!_global.navigator) {
return false;
}
if (this.__isIE == null) {
this.__isIE = /(msie|trident)/i.test(navigator.userAgent.toLowerCase());
}
return this.__isIE;
},
getIEVersion: function () {
if(!_global.navigator) {
return 0;
}
if (this.__IEVersion != null) {
return this.__IEVersion;
}
var version = 0;
var agent = navigator.userAgent.toLowerCase();
var v1 = agent.match(/(?:msie\s([\w.]+))/);
var v2 = agent.match(/(?:trident.*rv:([\w.]+))/);
if (v1 && v2 && v1[1] && v2[1]) {
version = Math.max(v1[1] * 1, v2[1] * 1);
} else if (v1 && v1[1]) {
version = v1[1] * 1;
} else if (v2 && v2[1]) {
version = v2[1] * 1;
} else {
version = 0;
}
return this.__IEVersion = version;
},
isIE9Below: function () {
if (!BI.isIE()) {
return false;
}
return this.getIEVersion() < 9;
},
isEdge: function () {
if(!_global.navigator) {
return false;
}
return /edge/i.test(navigator.userAgent.toLowerCase());
},
isChrome: function () {
if(!_global.navigator) {
return false;
}
return /chrome/i.test(navigator.userAgent.toLowerCase());
},
isFireFox: function () {
if(!_global.navigator) {
return false;
}
return /firefox/i.test(navigator.userAgent.toLowerCase());
},
isOpera: function () {
if(!_global.navigator) {
return false;
}
return /opera/i.test(navigator.userAgent.toLowerCase());
},
isSafari: function () {
if(!_global.navigator) {
return false;
}
return /safari/i.test(navigator.userAgent.toLowerCase());
},
isKhtml: function () {
if(!_global.navigator) {
return false;
}
return /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
},
isMac: function () {
if(!_global.navigator) {
return false;
}
return /macintosh|mac os x/i.test(navigator.userAgent);
},
isWindows: function () {
if(!_global.navigator) {
return false;
}
return /windows|win32/i.test(navigator.userAgent);
},
isSupportCss3: function (style) {
if(!_global.document) {
return false;
}
var prefix = ["webkit", "Moz", "ms", "o"],
i, len,
humpString = [],
htmlStyle = document.documentElement.style,
_toHumb = function (string) {
return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase();
});
};
for (i in prefix) {
humpString.push(_toHumb(prefix[i] + "-" + style));
}
humpString.push(_toHumb(style));
for (i = 0, len = humpString.length; i < len; i++) {
if (humpString[i] in htmlStyle) {
return true;
}
}
return false;
}
});
// BI请求
_.extend(BI, {
ajax: function (option) {
option || (option = {});
var async = option.async;
option.data = BI.cjkEncodeDO(option.data || {});
$.ajax({
url: option.url,
type: "POST",
data: option.data,
async: async,
error: option.error,
complete: function (res, status) {
if (BI.isFunction(option.complete)) {
option.complete(BI.jsonDecode(res.responseText), status);
}
}
});
}
});
})();/**
* 客户端观察者主要处理事件的添加删除执行等
* @class BI.OB
@ -14652,166 +14504,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return _mkPYRslt(arrResult);
}
});
})();/**
* Detect Element Resize.
* Forked in order to guard against unsafe 'window' and 'document' references.
*
* https://github.com/sdecima/javascript-detect-element-resize
* Sebastian Decima
*
* version: 0.5.3
**/
!(function () {
var attachEvent = _global.document && _global.document.attachEvent,
stylesCreated = false;
if (_global.document && !attachEvent) {
var requestFrame = (function () {
var raf = _global.requestAnimationFrame || _global.mozRequestAnimationFrame || _global.webkitRequestAnimationFrame ||
function (fn) { return _global.setTimeout(fn, 20); };
return function (fn) { return raf(fn); };
})();
var cancelFrame = (function () {
var cancel = _global.cancelAnimationFrame || _global.mozCancelAnimationFrame || _global.webkitCancelAnimationFrame ||
_global.clearTimeout;
return function (id) { return cancel(id); };
})();
var resetTriggers = function (element) {
var triggers = element.__resizeTriggers__,
expand = triggers.firstElementChild,
contract = triggers.lastElementChild,
expandChild = expand.firstElementChild;
contract.scrollLeft = contract.scrollWidth;
contract.scrollTop = contract.scrollHeight;
expandChild.style.width = expand.offsetWidth + 1 + "px";
expandChild.style.height = expand.offsetHeight + 1 + "px";
expand.scrollLeft = expand.scrollWidth;
expand.scrollTop = expand.scrollHeight;
};
var checkTriggers = function (element) {
return element.offsetWidth !== element.__resizeLast__.width ||
element.offsetHeight !== element.__resizeLast__.height;
};
var scrollListener = function (e) {
var element = this;
resetTriggers(this);
if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
this.__resizeRAF__ = requestFrame(function () {
if (checkTriggers(element)) {
element.__resizeLast__.width = element.offsetWidth;
element.__resizeLast__.height = element.offsetHeight;
element.__resizeListeners__.forEach(function (fn) {
fn.call(element, e);
});
}
});
};
/* Detect CSS Animations support to detect element display/re-attach */
var animation = false,
animationstring = "animation",
keyframeprefix = "",
animationstartevent = "animationstart",
domPrefixes = "Webkit Moz O ms".split(" "),
startEvents = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "),
pfx = "";
{
var elm = document.createElement("fakeelement");
if (elm.style.animationName !== undefined) {
animation = true;
}
if (animation === false) {
for (var i = 0; i < domPrefixes.length; i++) {
if (elm.style[domPrefixes[i] + "AnimationName"] !== undefined) {
pfx = domPrefixes[i];
animationstring = pfx + "Animation";
keyframeprefix = "-" + pfx.toLowerCase() + "-";
animationstartevent = startEvents[i];
animation = true;
break;
}
}
}
}
var animationName = "resizeanim";
var animationKeyframes = "@" + keyframeprefix + "keyframes " + animationName + " { from { opacity: 0; } to { opacity: 0; } } ";
var animationStyle = keyframeprefix + "animation: 1ms " + animationName + "; ";
}
var createStyles = function () {
if (!stylesCreated) {
// opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360
var css = (animationKeyframes ? animationKeyframes : "") +
".resize-triggers { " + (animationStyle ? animationStyle : "") + "visibility: hidden; opacity: 0; } " +
".resize-triggers, .resize-triggers > div, .contract-trigger:before { content: \" \"; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }",
head = document.head || document.getElementsByTagName("head")[0],
style = document.createElement("style");
style.type = "text/css";
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
stylesCreated = true;
}
};
var addResizeListener = function (element, fn) {
if (attachEvent) element.attachEvent("onresize", fn);
else {
if (!element.__resizeTriggers__) {
if (getComputedStyle(element).position === "static") element.style.position = "relative";
createStyles();
element.__resizeLast__ = {};
element.__resizeListeners__ = [];
(element.__resizeTriggers__ = document.createElement("div")).className = "resize-triggers";
element.__resizeTriggers__.innerHTML = "<div class=\"expand-trigger\"><div></div></div>" +
"<div class=\"contract-trigger\"></div>";
element.appendChild(element.__resizeTriggers__);
resetTriggers(element);
element.addEventListener("scroll", scrollListener, true);
/* Listen for a css animation to detect element display/re-attach */
animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
if (e.animationName === animationName) {resetTriggers(element);}
});
}
element.__resizeListeners__.push(fn);
}
};
var removeResizeListener = function (element, fn) {
if (attachEvent) element.detachEvent("onresize", fn);
else {
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
if (!element.__resizeListeners__.length) {
element.removeEventListener("scroll", scrollListener);
element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
}
}
};
BI.ResizeDetector = {
addResizeListener: function (widget, fn) {
addResizeListener(widget.element[0], fn);
return function () {
removeResizeListener(widget.element[0], fn);
};
},
removeResizeListener: function (widget, fn) {
removeResizeListener(widget.element[0], fn);
}
};
})();
(function () {
function defaultComparator (a, b) {
return a < b;
@ -14997,61 +14690,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return array;
}
};
})();_.extend(BI, {
$import: function () {
var _LOADED = {}; // alex:保存加载过的
function loadReady (src, must) {
var $scripts = $("head script, body script");
$.each($scripts, function (i, item) {
if (item.src.indexOf(src) != -1) {
_LOADED[src] = true;
}
});
var $links = $("head link");
$.each($links, function (i, item) {
if (item.href.indexOf(src) != -1 && must) {
_LOADED[src] = false;
$(item).remove();
}
});
}
// must=true 强行加载
return function (src, ext, must) {
loadReady(src, must);
// alex:如果已经加载过了的,直接return
if (_LOADED[src] === true) {
return;
}
if (ext === "css") {
var link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = src;
var head = document.getElementsByTagName("head")[0];
head.appendChild(link);
_LOADED[src] = true;
} else {
// alex:这里用同步调用的方式,必须等待ajax完成
$.ajax({
url: src,
dataType: "script", // alex:指定dataType为script,jquery会帮忙做globalEval的事情
async: false,
cache: true,
complete: function (res, status) {
/*
* alex:发现jquery会很智能地判断一下返回的数据类型是不是script,然后做一个globalEval
* 所以当status为success时就不需要再把其中的内容加到script里面去了
*/
if (status == "success") {
_LOADED[src] = true;
}
}
});
}
};
}()
});
})();
!(function () {
BI.LRU = function (limit) {
this.size = 0;

6
dist/utils.min.js vendored

File diff suppressed because one or more lines are too long

14
dist/widget.css vendored

@ -193,7 +193,8 @@
}
.bi-single-slider-button .slider-button {
cursor: ew-resize;
border: 2px solid #3685f2;
border-width: 2px;
border-style: solid;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
@ -225,6 +226,17 @@
top: 6px;
left: -8px;
}
.bi-theme-dark .bi-single-slider-button .slider-button {
background-color: #242640;
}
.bi-theme-dark .bi-single-slider-button .slider-button:hover,
.bi-theme-dark .bi-single-slider-button .slider-button.hover {
background-color: #191B2B;
}
.bi-theme-dark .bi-single-slider-button .slider-button.disabled:hover,
.bi-theme-dark .bi-single-slider-button .slider-button.disabled.hover {
background-color: #191B2B;
}
.bi-slider-track .gray-track {
background-color: rgba(61, 77, 102, 0.1);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#1a3d4d66,endColorstr=#1a3d4d66);

2
dist/widget.js vendored

@ -17646,7 +17646,7 @@ BI.SliderIconButton = BI.inherit(BI.Widget, {
el: {
type: "bi.text_button",
forceNotSelected: true,
cls: "slider-button bi-list-item-select3",
cls: "slider-button bi-list-item-select3 bi-high-light-border",
ref: function () {
self.slider = this;
}

148
src/core/base.js

@ -1367,152 +1367,4 @@ if (!_global.BI) {
}
});
// 浏览器相关方法
_.extend(BI, {
isIE: function () {
if(!_global.navigator) {
return false;
}
if (this.__isIE == null) {
this.__isIE = /(msie|trident)/i.test(navigator.userAgent.toLowerCase());
}
return this.__isIE;
},
getIEVersion: function () {
if(!_global.navigator) {
return 0;
}
if (this.__IEVersion != null) {
return this.__IEVersion;
}
var version = 0;
var agent = navigator.userAgent.toLowerCase();
var v1 = agent.match(/(?:msie\s([\w.]+))/);
var v2 = agent.match(/(?:trident.*rv:([\w.]+))/);
if (v1 && v2 && v1[1] && v2[1]) {
version = Math.max(v1[1] * 1, v2[1] * 1);
} else if (v1 && v1[1]) {
version = v1[1] * 1;
} else if (v2 && v2[1]) {
version = v2[1] * 1;
} else {
version = 0;
}
return this.__IEVersion = version;
},
isIE9Below: function () {
if (!BI.isIE()) {
return false;
}
return this.getIEVersion() < 9;
},
isEdge: function () {
if(!_global.navigator) {
return false;
}
return /edge/i.test(navigator.userAgent.toLowerCase());
},
isChrome: function () {
if(!_global.navigator) {
return false;
}
return /chrome/i.test(navigator.userAgent.toLowerCase());
},
isFireFox: function () {
if(!_global.navigator) {
return false;
}
return /firefox/i.test(navigator.userAgent.toLowerCase());
},
isOpera: function () {
if(!_global.navigator) {
return false;
}
return /opera/i.test(navigator.userAgent.toLowerCase());
},
isSafari: function () {
if(!_global.navigator) {
return false;
}
return /safari/i.test(navigator.userAgent.toLowerCase());
},
isKhtml: function () {
if(!_global.navigator) {
return false;
}
return /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
},
isMac: function () {
if(!_global.navigator) {
return false;
}
return /macintosh|mac os x/i.test(navigator.userAgent);
},
isWindows: function () {
if(!_global.navigator) {
return false;
}
return /windows|win32/i.test(navigator.userAgent);
},
isSupportCss3: function (style) {
if(!_global.document) {
return false;
}
var prefix = ["webkit", "Moz", "ms", "o"],
i, len,
humpString = [],
htmlStyle = document.documentElement.style,
_toHumb = function (string) {
return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase();
});
};
for (i in prefix) {
humpString.push(_toHumb(prefix[i] + "-" + style));
}
humpString.push(_toHumb(style));
for (i = 0, len = humpString.length; i < len; i++) {
if (humpString[i] in htmlStyle) {
return true;
}
}
return false;
}
});
// BI请求
_.extend(BI, {
ajax: function (option) {
option || (option = {});
var async = option.async;
option.data = BI.cjkEncodeDO(option.data || {});
$.ajax({
url: option.url,
type: "POST",
data: option.data,
async: async,
error: option.error,
complete: function (res, status) {
if (BI.isFunction(option.complete)) {
option.complete(BI.jsonDecode(res.responseText), status);
}
}
});
}
});
})();

592
src/core/func/dom.js

@ -1,592 +0,0 @@
/**
* guy
* 最基础的dom操作
*/
BI.extend(jQuery.fn, {
destroy: function () {
this.remove();
if (BI.isIE() === true) {
this[0].outerHTML = "";
}
},
/**
* 高亮显示
* @param text 必需
* @param keyword
* @param py 必需
* @returns {*}
* @private
*/
__textKeywordMarked__: function (text, keyword, py) {
if (!BI.isKey(keyword) || (text + "").length > 100) {
return this.html(BI.htmlEncode(text));
}
keyword = keyword + "";
keyword = BI.toUpperCase(keyword);
var textLeft = (text || "") + "";
py = (py || BI.makeFirstPY(text)) + "";
if (py != null) {
py = BI.toUpperCase(py);
}
this.empty();
while (true) {
var tidx = BI.toUpperCase(textLeft).indexOf(keyword);
var pidx = null;
if (py != null) {
pidx = py.indexOf(keyword);
if (pidx >= 0) {
pidx = pidx % text.length;
}
}
if (tidx >= 0) {
this.append(textLeft.substr(0, tidx));
this.append($("<span>").addClass("bi-keyword-red-mark")
.html(BI.htmlEncode(textLeft.substr(tidx, keyword.length))));
textLeft = textLeft.substr(tidx + keyword.length);
if (py != null) {
py = py.substr(tidx + keyword.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($("<span>").addClass("bi-keyword-red-mark")
.html(BI.htmlEncode(textLeft.substr(pidx, keyword.length))));
if (py != null) {
py = py.substr(pidx + keyword.length);
}
textLeft = textLeft.substr(pidx + keyword.length);
} else {
this.append(textLeft);
break;
}
}
return this;
},
getDomHeight: function (parent) {
var clone = $(this).clone();
clone.appendTo($(parent || "body"));
var height = clone.height();
clone.remove();
return height;
},
// 是否有竖直滚动条
hasVerticalScroll: function () {
return this.height() > 0 && this[0].clientWidth < this[0].offsetWidth;
},
// 是否有水平滚动条
hasHorizonScroll: function () {
return this.width() > 0 && this[0].clientHeight < this[0].offsetHeight;
},
// 获取计算后的样式
getStyle: function (name) {
var node = this[0];
var computedStyle = void 0;
// W3C Standard
if (_global.getComputedStyle) {
// In certain cases such as within an iframe in FF3, this returns null.
computedStyle = _global.getComputedStyle(node, null);
if (computedStyle) {
return computedStyle.getPropertyValue(BI.hyphenate(name));
}
}
// Safari
if (document.defaultView && document.defaultView.getComputedStyle) {
computedStyle = document.defaultView.getComputedStyle(node, null);
// A Safari bug causes this to return null for `display: none` elements.
if (computedStyle) {
return computedStyle.getPropertyValue(BI.hyphenate(name));
}
if (name === "display") {
return "none";
}
}
// Internet Explorer
if (node.currentStyle) {
if (name === "float") {
return node.currentStyle.cssFloat || node.currentStyle.styleFloat;
}
return node.currentStyle[BI.camelize(name)];
}
return node.style && node.style[BI.camelize(name)];
},
__isMouseInBounds__: function (e) {
var offset2Body = this.get(0).getBoundingClientRect ? this.get(0).getBoundingClientRect() : this.offset();
var width = offset2Body.width || this.outerWidth();
var height = offset2Body.height || this.outerHeight();
return !(e.pageX < offset2Body.left || e.pageX > offset2Body.left + width
|| e.pageY < offset2Body.top || e.pageY > offset2Body.top + height);
},
__hasZIndexMask__: function (zindex) {
return zindex && this.zIndexMask[zindex] != null;
},
__buildZIndexMask__: function (zindex, domArray) {
this.zIndexMask = this.zIndexMask || {};// 存储z-index的mask
this.indexMask = this.indexMask || [];// 存储mask
var mask = BI.createWidget({
type: "bi.center_adapt",
cls: "bi-z-index-mask",
items: domArray
});
mask.element.css({"z-index": zindex});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: mask,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.indexMask.push(mask);
zindex && (this.zIndexMask[zindex] = mask);
return mask.element;
},
__releaseZIndexMask__: function (zindex) {
if (zindex && this.zIndexMask[zindex]) {
this.indexMask.remove(this.zIndexMask[zindex]);
this.zIndexMask[zindex].destroy();
return;
}
this.indexMask = this.indexMask || [];
var indexMask = this.indexMask.pop();
indexMask && indexMask.destroy();
}
});
BI.extend(jQuery, {
getLeftPosition: function (combo, popup, extraWidth) {
return {
left: combo.element.offset().left - popup.element.outerWidth() - (extraWidth || 0)
};
},
getRightPosition: function (combo, popup, extraWidth) {
var el = combo.element;
return {
left: el.offset().left + el.outerWidth() + (extraWidth || 0)
};
},
getTopPosition: function (combo, popup, extraHeight) {
return {
top: combo.element.offset().top - popup.element.outerHeight() - (extraHeight || 0)
};
},
getBottomPosition: function (combo, popup, extraHeight) {
var el = combo.element;
return {
top: el.offset().top + el.outerHeight() + (extraHeight || 0)
};
},
isLeftSpaceEnough: function (combo, popup, extraWidth) {
return $.getLeftPosition(combo, popup, extraWidth).left >= 0;
},
isRightSpaceEnough: function (combo, popup, extraWidth) {
var viewBounds = popup.element.bounds(), windowBounds = $("body").bounds();
return $.getRightPosition(combo, popup, extraWidth).left + viewBounds.width <= windowBounds.width;
},
isTopSpaceEnough: function (combo, popup, extraHeight) {
return $.getTopPosition(combo, popup, extraHeight).top >= 0;
},
isBottomSpaceEnough: function (combo, popup, extraHeight) {
var viewBounds = popup.element.bounds(), windowBounds = $("body").bounds();
return $.getBottomPosition(combo, popup, extraHeight).top + viewBounds.height <= windowBounds.height;
},
isRightSpaceLarger: function (combo) {
var windowBounds = $("body").bounds();
return windowBounds.width - combo.element.offset().left - combo.element.bounds().width >= combo.element.offset().left;
},
isBottomSpaceLarger: function (combo) {
var windowBounds = $("body").bounds();
return windowBounds.height - combo.element.offset().top - combo.element.bounds().height >= combo.element.offset().top;
},
getLeftAlignPosition: function (combo, popup, extraWidth) {
var viewBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var left = combo.element.offset().left + extraWidth;
if (left + viewBounds.width > windowBounds.width) {
left = windowBounds.width - viewBounds.width;
}
if (left < 0) {
left = 0;
}
return {
left: left
};
},
getLeftAdaptPosition: function (combo, popup, extraWidth) {
if ($.isLeftSpaceEnough(combo, popup, extraWidth)) {
return $.getLeftPosition(combo, popup, extraWidth);
}
return {
left: 0
};
},
getRightAlignPosition: function (combo, popup, extraWidth) {
var comboBounds = combo.element.bounds(), viewBounds = popup.element.bounds();
var left = combo.element.offset().left + comboBounds.width - viewBounds.width - extraWidth;
if (left < 0) {
left = 0;
}
return {
left: left
};
},
getRightAdaptPosition: function (combo, popup, extraWidth) {
if ($.isRightSpaceEnough(combo, popup, extraWidth)) {
return $.getRightPosition(combo, popup, extraWidth);
}
return {
left: $("body").bounds().width - popup.element.bounds().width
};
},
getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top, adaptHeight;
if ($.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + extraHeight;
} else if (needAdaptHeight) {
top = comboOffset.top + extraHeight;
adaptHeight = windowBounds.height - top;
} else {
top = windowBounds.height - popupBounds.height;
if (top < extraHeight) {
adaptHeight = windowBounds.height - extraHeight;
}
}
if (top < extraHeight) {
top = extraHeight;
}
return adaptHeight ? {
top: top,
adaptHeight: adaptHeight
} : {
top: top
};
},
getTopAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
if ($.isTopSpaceEnough(combo, popup, extraHeight)) {
return $.getTopPosition(combo, popup, extraHeight);
}
if (needAdaptHeight) {
return {
top: 0,
adaptHeight: combo.element.offset().top - extraHeight
};
}
if (popupBounds.height + extraHeight > windowBounds.height) {
return {
top: 0,
adaptHeight: windowBounds.height - extraHeight
};
}
return {
top: 0
};
},
getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top, adaptHeight;
if ($.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight;
} else if (needAdaptHeight) {
top = 0;
adaptHeight = comboOffset.top + comboBounds.height - extraHeight;
} else {
top = 0;
if (popupBounds.height + extraHeight > windowBounds.height) {
adaptHeight = windowBounds.height - extraHeight;
}
}
if (top < 0) {
top = 0;
}
return adaptHeight ? {
top: top,
adaptHeight: adaptHeight
} : {
top: top
};
},
getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
if ($.isBottomSpaceEnough(combo, popup, extraHeight)) {
return $.getBottomPosition(combo, popup, extraHeight);
}
if (needAdaptHeight) {
return {
top: comboOffset.top + comboBounds.height + extraHeight,
adaptHeight: windowBounds.height - comboOffset.top - comboBounds.height - extraHeight
};
}
if (popupBounds.height + extraHeight > windowBounds.height) {
return {
top: extraHeight,
adaptHeight: windowBounds.height - extraHeight
};
}
return {
top: windowBounds.height - popupBounds.height - extraHeight
};
},
getCenterAdaptPosition: function (combo, popup) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var left;
if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) {
left = windowBounds.width - popupBounds.width;
} else {
left = comboOffset.left + comboBounds.width / 2 - popupBounds.width / 2;
}
if (left < 0) {
left = 0;
}
return {
left: left
};
},
getMiddleAdaptPosition: function (combo, popup) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top;
if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) {
top = windowBounds.height - popupBounds.height;
} else {
top = comboOffset.top + comboBounds.height / 2 - popupBounds.height / 2;
}
if (top < 0) {
top = 0;
}
return {
top: top
};
},
getComboPositionByDirections: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions) {
extraWidth || (extraWidth = 0);
extraHeight || (extraHeight = 0);
var i, direct;
var leftRight = [], topBottom = [];
var isNeedAdaptHeight = false, tbFirst = false, lrFirst = false;
var left, top, pos;
for (i = 0; i < directions.length; i++) {
direct = directions[i];
switch (direct) {
case "left":
leftRight.push(direct);
break;
case "right":
leftRight.push(direct);
break;
case "top":
topBottom.push(direct);
break;
case "bottom":
topBottom.push(direct);
break;
}
}
for (i = 0; i < directions.length; i++) {
direct = directions[i];
switch (direct) {
case "left":
if (!isNeedAdaptHeight) {
var tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight;
if ($.isLeftSpaceEnough(combo, popup, tW)) {
left = $.getLeftPosition(combo, popup, tW).left;
if (topBottom[0] === "bottom") {
pos = $.getTopAlignPosition(combo, popup, tH, needAdaptHeight);
pos.dir = "left,bottom";
} else {
pos = $.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
pos.dir = "left,top";
}
if (tbFirst) {
pos.change = "left";
}
pos.left = left;
return pos;
}
}
lrFirst = true;
break;
case "right":
if (!isNeedAdaptHeight) {
var tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? extraWidth : extraHeight;
if ($.isRightSpaceEnough(combo, popup, tW)) {
left = $.getRightPosition(combo, popup, tW).left;
if (topBottom[0] === "bottom") {
pos = $.getTopAlignPosition(combo, popup, tH, needAdaptHeight);
pos.dir = "right,bottom";
} else {
pos = $.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
pos.dir = "right,top";
}
if (tbFirst) {
pos.change = "right";
}
pos.left = left;
return pos;
}
}
lrFirst = true;
break;
case "top":
var tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if ($.isTopSpaceEnough(combo, popup, tH)) {
top = $.getTopPosition(combo, popup, tH).top;
if (leftRight[0] === "right") {
pos = $.getLeftAlignPosition(combo, popup, tW, needAdaptHeight);
pos.dir = "top,right";
} else {
pos = $.getRightAlignPosition(combo, popup, tW);
pos.dir = "top,left";
}
if (lrFirst) {
pos.change = "top";
}
pos.top = top;
return pos;
}
if (needAdaptHeight) {
isNeedAdaptHeight = true;
}
tbFirst = true;
break;
case "bottom":
var tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if ($.isBottomSpaceEnough(combo, popup, tH)) {
top = $.getBottomPosition(combo, popup, tH).top;
if (leftRight[0] === "right") {
pos = $.getLeftAlignPosition(combo, popup, tW, needAdaptHeight);
pos.dir = "bottom,right";
} else {
pos = $.getRightAlignPosition(combo, popup, tW);
pos.dir = "bottom,left";
}
if (lrFirst) {
pos.change = "bottom";
}
pos.top = top;
return pos;
}
if (needAdaptHeight) {
isNeedAdaptHeight = true;
}
tbFirst = true;
break;
}
}
switch (directions[0]) {
case "left":
case "right":
if ($.isRightSpaceLarger(combo)) {
left = $.getRightAdaptPosition(combo, popup, extraWidth).left;
} else {
left = $.getLeftAdaptPosition(combo, popup, extraWidth).left;
}
if (topBottom[0] === "bottom") {
pos = $.getTopAlignPosition(combo, popup, extraHeight, needAdaptHeight);
pos.left = left;
pos.dir = directions[0] + ",bottom";
return pos;
}
pos = $.getBottomAlignPosition(combo, popup, extraHeight, needAdaptHeight);
pos.left = left;
pos.dir = directions[0] + ",top";
return pos;
default :
if ($.isBottomSpaceLarger(combo)) {
pos = $.getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight);
} else {
pos = $.getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight);
}
if (leftRight[0] === "right") {
left = $.getLeftAlignPosition(combo, popup, extraWidth, needAdaptHeight).left;
pos.left = left;
pos.dir = directions[0] + ",right";
return pos;
}
left = $.getRightAlignPosition(combo, popup, extraWidth).left;
pos.left = left;
pos.dir = directions[0] + ",left";
return pos;
}
},
getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle) {
extraWidth || (extraWidth = 0);
extraHeight || (extraHeight = 0);
var bodyHeight = $("body").bounds().height - extraHeight;
var maxHeight = Math.min(popup.attr("maxHeight") || bodyHeight, bodyHeight);
popup.resetHeight && popup.resetHeight(maxHeight);
var position = $.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"]);
switch (offsetStyle) {
case "center":
if (position.change) {
var p = $.getMiddleAdaptPosition(combo, popup);
position.top = p.top;
} else {
var p = $.getCenterAdaptPosition(combo, popup);
position.left = p.left;
}
break;
case "middle":
if (position.change) {
var p = $.getCenterAdaptPosition(combo, popup);
position.left = p.left;
} else {
var p = $.getMiddleAdaptPosition(combo, popup);
position.top = p.top;
}
break;
}
if (needAdaptHeight === true) {
popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight));
}
return position;
}
});

255
src/core/func/function.js

@ -75,258 +75,3 @@ BI.extend(BI.Func, {
};
}
});
/**
* 对DOM操作的通用函数
* @type {{}}
*/
BI.DOM = {};
BI.extend(BI.DOM, {
/**
* 把dom数组或元素悬挂起来,使其不对html产生影响
* @param dom
*/
hang: function (doms) {
if (BI.isEmpty(doms)) {
return;
}
var frag = document.createDocumentFragment();
BI.each(doms, function (i, dom) {
dom instanceof BI.Widget && (dom = dom.element);
dom instanceof $ && dom[0] && frag.appendChild(dom[0]);
});
return frag;
},
isExist: function (obj) {
return BI.Widget._renderEngine.createElement("body").find(obj.element).length > 0;
},
// 预加载图片
preloadImages: function (srcArray, onload) {
var count = 0, images = [];
function complete () {
count++;
if (count >= srcArray.length) {
onload();
}
}
BI.each(srcArray, function (i, src) {
images[i] = new Image();
images[i].src = src;
images[i].onload = function () {
complete();
};
images[i].onerror = function () {
complete();
};
});
},
isColor: function (color) {
return color && (this.isRGBColor(color) || this.isHexColor(color));
},
isRGBColor: function (color) {
if (!color) {
return false;
}
return color.substr(0, 3) === "rgb";
},
isHexColor: function (color) {
if (!color) {
return false;
}
return color[0] === "#" && color.length === 7;
},
isDarkColor: function (hex) {
if (!hex || !this.isHexColor(hex)) {
return false;
}
var rgb = this.rgb2json(this.hex2rgb(hex));
var grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114);
if (grayLevel < 192/** 网上给的是140**/) {
return true;
}
return false;
},
// 获取对比颜色
getContrastColor: function (color) {
if (!color || !this.isColor(color)) {
return "";
}
if (this.isDarkColor(color)) {
return "#ffffff";
}
return "#1a1a1a";
},
rgb2hex: function (rgbColour) {
if (!rgbColour || rgbColour.substr(0, 3) != "rgb") {
return "";
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
var red = BI.parseInt(rgbValues[0]);
var green = BI.parseInt(rgbValues[1]);
var blue = BI.parseInt(rgbValues[2]);
var hexColour = "#" + this.int2hex(red) + this.int2hex(green) + this.int2hex(blue);
return hexColour;
},
rgb2json: function (rgbColour) {
if (!rgbColour) {
return {};
}
if (!this.isRGBColor(rgbColour)) {
return {};
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return {
r: BI.parseInt(rgbValues[0]),
g: BI.parseInt(rgbValues[1]),
b: BI.parseInt(rgbValues[2])
};
},
rgba2json: function (rgbColour) {
if (!rgbColour) {
return {};
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return {
r: BI.parseInt(rgbValues[0]),
g: BI.parseInt(rgbValues[1]),
b: BI.parseInt(rgbValues[2]),
a: BI.parseFloat(rgbValues[3])
};
},
json2rgb: function (rgb) {
if (!BI.isKey(rgb.r) || !BI.isKey(rgb.g) || !BI.isKey(rgb.b)) {
return "";
}
return "rgb(" + rgb.r + "," + rgb.g + "," + rgb.b + ")";
},
json2rgba: function (rgba) {
if (!BI.isKey(rgba.r) || !BI.isKey(rgba.g) || !BI.isKey(rgba.b)) {
return "";
}
return "rgba(" + rgba.r + "," + rgba.g + "," + rgba.b + "," + rgba.a + ")";
},
int2hex: function (strNum) {
var hexdig = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
return hexdig[strNum >>> 4] + "" + hexdig[strNum & 15];
},
hex2rgb: function (color) {
if (!color) {
return "";
}
if (!this.isHexColor(color)) {
return color;
}
var tempValue = "rgb(", colorArray;
if (color.length === 7) {
colorArray = [BI.parseInt("0x" + color.substring(1, 3)),
BI.parseInt("0x" + color.substring(3, 5)),
BI.parseInt("0x" + color.substring(5, 7))];
} else if (color.length === 4) {
colorArray = [BI.parseInt("0x" + color.substring(1, 2)),
BI.parseInt("0x" + color.substring(2, 3)),
BI.parseInt("0x" + color.substring(3, 4))];
}
tempValue += colorArray[0] + ",";
tempValue += colorArray[1] + ",";
tempValue += colorArray[2] + ")";
return tempValue;
},
rgba2rgb: function (rgbColour, BGcolor) {
if (BI.isNull(BGcolor)) {
BGcolor = 1;
}
if (rgbColour.substr(0, 4) != "rgba") {
return "";
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
if (rgbValues.length < 4) {
return "";
}
var R = BI.parseFloat(rgbValues[0]);
var G = BI.parseFloat(rgbValues[1]);
var B = BI.parseFloat(rgbValues[2]);
var A = BI.parseFloat(rgbValues[3]);
return "rgb(" + Math.floor(255 * (BGcolor * (1 - A )) + R * A) + "," +
Math.floor(255 * (BGcolor * (1 - A )) + G * A) + "," +
Math.floor(255 * (BGcolor * (1 - A )) + B * A) + ")";
},
getTextSizeWidth: function (text, fontSize) {
var span = BI.Widget._renderEngine.createElement("<span></span>").addClass("text-width-span").appendTo($("body"));
if (fontSize == null) {
fontSize = 12;
}
fontSize = fontSize + "px";
span.css("font-size", fontSize).text(text);
var width = span.width();
span.remove();
return width;
},
// 获取滚动条的宽度
getScrollWidth: function () {
if (this._scrollWidth == null) {
var ul = BI.Widget._renderEngine.createElement("<div>").width(50).height(50).css({
position: "absolute",
top: "-9999px",
overflow: "scroll"
}).appendTo("body");
this._scrollWidth = ul[0].offsetWidth - ul[0].clientWidth;
ul.destroy();
}
return this._scrollWidth;
},
getImage: function (param, fillStyle, backgroundColor) {
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 14) + 6;
canvas.width = w * ratio;
canvas.height = 24 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3D4D66";
ctx.textBaseline = "middle";
ctx.fillText(param, 6 * ratio, 12 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "#EAF2FD";
// IE可以放大缩小所以要固定最大最小宽高
return {
width: w,
height: 24,
src: canvas.toDataURL("image/png"),
style: "background-color: " + backColor + ";vertical-align: middle; margin: 0 3px; width:" + w + "px;height: 24px; max-width:" + w + "px;max-height: 24px; min-width:" + w + "px;min-height: 24px",
param: param
};
}
});

22
src/core/platform/dom/ajax.js

@ -0,0 +1,22 @@
// BI请求
_.extend(BI, {
ajax: function (option) {
option || (option = {});
var async = option.async;
option.data = BI.cjkEncodeDO(option.data || {});
$.ajax({
url: option.url,
type: "POST",
data: option.data,
async: async,
error: option.error,
complete: function (res, status) {
if (BI.isFunction(option.complete)) {
option.complete(BI.jsonDecode(res.responseText), status);
}
}
});
}
});

20
src/core/config.js → src/core/platform/dom/config.js

@ -1,16 +1,21 @@
// 工程配置
BI.prepares.push(function () {
// 注册布局
var isSupportFlex = BI.isSupportCss3("flex");
var _isSupprtFlex;
var isSupportFlex = function () {
if(_isSupprtFlex == null) {
_isSupprtFlex = !!(BI.isSupportCss3 && BI.isSupportCss3("flex"));
}
return _isSupprtFlex;
};
BI.Plugin.registerWidget("bi.horizontal", function (ob) {
if (!BI.isIE() && isSupportFlex) {
if (!BI.isIE() && isSupportFlex()) {
return BI.extend(ob, {type: "bi.flex_horizontal"});
}
return ob;
});
BI.Plugin.registerWidget("bi.center_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex && ob.items && ob.items.length <= 1) {
if (!BI.isIE() && isSupportFlex() && ob.items && ob.items.length <= 1) {
// 有滚动条的情况下需要用到flex_wrapper_center布局
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
// 不是IE用flex_wrapper_center布局
@ -19,10 +24,9 @@ BI.prepares.push(function () {
return BI.extend(ob, {type: "bi.flex_center"});
}
return ob;
});
BI.Plugin.registerWidget("bi.vertical_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex) {
if (!BI.isIE() && isSupportFlex()) {
// 有滚动条的情况下需要用到flex_wrapper_center布局
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
// 不是IE用flex_wrapper_center布局
@ -31,10 +35,9 @@ BI.prepares.push(function () {
return BI.extend(ob, {type: "bi.flex_vertical_center"});
}
return ob;
});
BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex) {
if (!BI.isIE() && isSupportFlex()) {
// 有滚动条的情况下需要用到flex_wrapper_center布局
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
// 不是IE用flex_wrapper_center布局
@ -43,6 +46,5 @@ BI.prepares.push(function () {
return BI.extend(ob, {type: "bi.flex_center"});
}
return ob;
});
});

0
src/core/utils/detectElementResize.js → src/core/platform/dom/detectElementResize.js

254
src/core/platform/dom/dom.js

@ -0,0 +1,254 @@
/**
* 对DOM操作的通用函数
* @type {{}}
*/
BI.DOM = {};
BI.extend(BI.DOM, {
/**
* 把dom数组或元素悬挂起来,使其不对html产生影响
* @param dom
*/
hang: function (doms) {
if (BI.isEmpty(doms)) {
return;
}
var frag = document.createDocumentFragment();
BI.each(doms, function (i, dom) {
dom instanceof BI.Widget && (dom = dom.element);
dom instanceof $ && dom[0] && frag.appendChild(dom[0]);
});
return frag;
},
isExist: function (obj) {
return BI.Widget._renderEngine.createElement("body").find(obj.element).length > 0;
},
// 预加载图片
preloadImages: function (srcArray, onload) {
var count = 0, images = [];
function complete () {
count++;
if (count >= srcArray.length) {
onload();
}
}
BI.each(srcArray, function (i, src) {
images[i] = new Image();
images[i].src = src;
images[i].onload = function () {
complete();
};
images[i].onerror = function () {
complete();
};
});
},
isColor: function (color) {
return color && (this.isRGBColor(color) || this.isHexColor(color));
},
isRGBColor: function (color) {
if (!color) {
return false;
}
return color.substr(0, 3) === "rgb";
},
isHexColor: function (color) {
if (!color) {
return false;
}
return color[0] === "#" && color.length === 7;
},
isDarkColor: function (hex) {
if (!hex || !this.isHexColor(hex)) {
return false;
}
var rgb = this.rgb2json(this.hex2rgb(hex));
var grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114);
if (grayLevel < 192/** 网上给的是140**/) {
return true;
}
return false;
},
// 获取对比颜色
getContrastColor: function (color) {
if (!color || !this.isColor(color)) {
return "";
}
if (this.isDarkColor(color)) {
return "#ffffff";
}
return "#1a1a1a";
},
rgb2hex: function (rgbColour) {
if (!rgbColour || rgbColour.substr(0, 3) != "rgb") {
return "";
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
var red = BI.parseInt(rgbValues[0]);
var green = BI.parseInt(rgbValues[1]);
var blue = BI.parseInt(rgbValues[2]);
var hexColour = "#" + this.int2hex(red) + this.int2hex(green) + this.int2hex(blue);
return hexColour;
},
rgb2json: function (rgbColour) {
if (!rgbColour) {
return {};
}
if (!this.isRGBColor(rgbColour)) {
return {};
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return {
r: BI.parseInt(rgbValues[0]),
g: BI.parseInt(rgbValues[1]),
b: BI.parseInt(rgbValues[2])
};
},
rgba2json: function (rgbColour) {
if (!rgbColour) {
return {};
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return {
r: BI.parseInt(rgbValues[0]),
g: BI.parseInt(rgbValues[1]),
b: BI.parseInt(rgbValues[2]),
a: BI.parseFloat(rgbValues[3])
};
},
json2rgb: function (rgb) {
if (!BI.isKey(rgb.r) || !BI.isKey(rgb.g) || !BI.isKey(rgb.b)) {
return "";
}
return "rgb(" + rgb.r + "," + rgb.g + "," + rgb.b + ")";
},
json2rgba: function (rgba) {
if (!BI.isKey(rgba.r) || !BI.isKey(rgba.g) || !BI.isKey(rgba.b)) {
return "";
}
return "rgba(" + rgba.r + "," + rgba.g + "," + rgba.b + "," + rgba.a + ")";
},
int2hex: function (strNum) {
var hexdig = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
return hexdig[strNum >>> 4] + "" + hexdig[strNum & 15];
},
hex2rgb: function (color) {
if (!color) {
return "";
}
if (!this.isHexColor(color)) {
return color;
}
var tempValue = "rgb(", colorArray;
if (color.length === 7) {
colorArray = [BI.parseInt("0x" + color.substring(1, 3)),
BI.parseInt("0x" + color.substring(3, 5)),
BI.parseInt("0x" + color.substring(5, 7))];
} else if (color.length === 4) {
colorArray = [BI.parseInt("0x" + color.substring(1, 2)),
BI.parseInt("0x" + color.substring(2, 3)),
BI.parseInt("0x" + color.substring(3, 4))];
}
tempValue += colorArray[0] + ",";
tempValue += colorArray[1] + ",";
tempValue += colorArray[2] + ")";
return tempValue;
},
rgba2rgb: function (rgbColour, BGcolor) {
if (BI.isNull(BGcolor)) {
BGcolor = 1;
}
if (rgbColour.substr(0, 4) != "rgba") {
return "";
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
if (rgbValues.length < 4) {
return "";
}
var R = BI.parseFloat(rgbValues[0]);
var G = BI.parseFloat(rgbValues[1]);
var B = BI.parseFloat(rgbValues[2]);
var A = BI.parseFloat(rgbValues[3]);
return "rgb(" + Math.floor(255 * (BGcolor * (1 - A )) + R * A) + "," +
Math.floor(255 * (BGcolor * (1 - A )) + G * A) + "," +
Math.floor(255 * (BGcolor * (1 - A )) + B * A) + ")";
},
getTextSizeWidth: function (text, fontSize) {
var span = BI.Widget._renderEngine.createElement("<span></span>").addClass("text-width-span").appendTo("body");
if (fontSize == null) {
fontSize = 12;
}
fontSize = fontSize + "px";
span.css("font-size", fontSize).text(text);
var width = span.width();
span.remove();
return width;
},
// 获取滚动条的宽度
getScrollWidth: function () {
if (this._scrollWidth == null) {
var ul = BI.Widget._renderEngine.createElement("<div>").width(50).height(50).css({
position: "absolute",
top: "-9999px",
overflow: "scroll"
}).appendTo("body");
this._scrollWidth = ul[0].offsetWidth - ul[0].clientWidth;
ul.destroy();
}
return this._scrollWidth;
},
getImage: function (param, fillStyle, backgroundColor) {
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 14) + 6;
canvas.width = w * ratio;
canvas.height = 24 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3D4D66";
ctx.textBaseline = "middle";
ctx.fillText(param, 6 * ratio, 12 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "#EAF2FD";
// IE可以放大缩小所以要固定最大最小宽高
return {
width: w,
height: 24,
src: canvas.toDataURL("image/png"),
style: "background-color: " + backColor + ";vertical-align: middle; margin: 0 3px; width:" + w + "px;height: 24px; max-width:" + w + "px;max-height: 24px; min-width:" + w + "px;min-height: 24px",
param: param
};
}
});

0
src/core/utils/events/eventlistener.js → src/core/platform/dom/eventlistener.js

125
src/core/platform/dom/function.js

@ -0,0 +1,125 @@
// 浏览器相关方法
_.extend(BI, {
isIE: function () {
if(!_global.navigator) {
return false;
}
if (this.__isIE == null) {
this.__isIE = /(msie|trident)/i.test(navigator.userAgent.toLowerCase());
}
return this.__isIE;
},
getIEVersion: function () {
if(!_global.navigator) {
return 0;
}
if (this.__IEVersion != null) {
return this.__IEVersion;
}
var version = 0;
var agent = navigator.userAgent.toLowerCase();
var v1 = agent.match(/(?:msie\s([\w.]+))/);
var v2 = agent.match(/(?:trident.*rv:([\w.]+))/);
if (v1 && v2 && v1[1] && v2[1]) {
version = Math.max(v1[1] * 1, v2[1] * 1);
} else if (v1 && v1[1]) {
version = v1[1] * 1;
} else if (v2 && v2[1]) {
version = v2[1] * 1;
} else {
version = 0;
}
return this.__IEVersion = version;
},
isIE9Below: function () {
if (!BI.isIE()) {
return false;
}
return this.getIEVersion() < 9;
},
isEdge: function () {
if(!_global.navigator) {
return false;
}
return /edge/i.test(navigator.userAgent.toLowerCase());
},
isChrome: function () {
if(!_global.navigator) {
return false;
}
return /chrome/i.test(navigator.userAgent.toLowerCase());
},
isFireFox: function () {
if(!_global.navigator) {
return false;
}
return /firefox/i.test(navigator.userAgent.toLowerCase());
},
isOpera: function () {
if(!_global.navigator) {
return false;
}
return /opera/i.test(navigator.userAgent.toLowerCase());
},
isSafari: function () {
if(!_global.navigator) {
return false;
}
return /safari/i.test(navigator.userAgent.toLowerCase());
},
isKhtml: function () {
if(!_global.navigator) {
return false;
}
return /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
},
isMac: function () {
if(!_global.navigator) {
return false;
}
return /macintosh|mac os x/i.test(navigator.userAgent);
},
isWindows: function () {
if(!_global.navigator) {
return false;
}
return /windows|win32/i.test(navigator.userAgent);
},
isSupportCss3: function (style) {
if(!_global.document) {
return false;
}
var prefix = ["webkit", "Moz", "ms", "o"],
i, len,
humpString = [],
htmlStyle = document.documentElement.style,
_toHumb = function (string) {
return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase();
});
};
for (i in prefix) {
humpString.push(_toHumb(prefix[i] + "-" + style));
}
humpString.push(_toHumb(style));
for (i = 0, len = humpString.length; i < len; i++) {
if (humpString[i] in htmlStyle) {
return true;
}
}
return false;
}
});

0
src/core/jquery.js → src/core/platform/dom/jquery/_jquery.js vendored

0
src/core/proto/event.js → src/core/platform/dom/jquery/event.js vendored

424
src/core/platform/dom/jquery/extend.js vendored

@ -0,0 +1,424 @@
if(jQuery) {
BI.extend(jQuery, {
getLeftPosition: function (combo, popup, extraWidth) {
return {
left: combo.element.offset().left - popup.element.outerWidth() - (extraWidth || 0)
};
},
getRightPosition: function (combo, popup, extraWidth) {
var el = combo.element;
return {
left: el.offset().left + el.outerWidth() + (extraWidth || 0)
};
},
getTopPosition: function (combo, popup, extraHeight) {
return {
top: combo.element.offset().top - popup.element.outerHeight() - (extraHeight || 0)
};
},
getBottomPosition: function (combo, popup, extraHeight) {
var el = combo.element;
return {
top: el.offset().top + el.outerHeight() + (extraHeight || 0)
};
},
isLeftSpaceEnough: function (combo, popup, extraWidth) {
return $.getLeftPosition(combo, popup, extraWidth).left >= 0;
},
isRightSpaceEnough: function (combo, popup, extraWidth) {
var viewBounds = popup.element.bounds(), windowBounds = $("body").bounds();
return $.getRightPosition(combo, popup, extraWidth).left + viewBounds.width <= windowBounds.width;
},
isTopSpaceEnough: function (combo, popup, extraHeight) {
return $.getTopPosition(combo, popup, extraHeight).top >= 0;
},
isBottomSpaceEnough: function (combo, popup, extraHeight) {
var viewBounds = popup.element.bounds(), windowBounds = $("body").bounds();
return $.getBottomPosition(combo, popup, extraHeight).top + viewBounds.height <= windowBounds.height;
},
isRightSpaceLarger: function (combo) {
var windowBounds = $("body").bounds();
return windowBounds.width - combo.element.offset().left - combo.element.bounds().width >= combo.element.offset().left;
},
isBottomSpaceLarger: function (combo) {
var windowBounds = $("body").bounds();
return windowBounds.height - combo.element.offset().top - combo.element.bounds().height >= combo.element.offset().top;
},
getLeftAlignPosition: function (combo, popup, extraWidth) {
var viewBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var left = combo.element.offset().left + extraWidth;
if (left + viewBounds.width > windowBounds.width) {
left = windowBounds.width - viewBounds.width;
}
if (left < 0) {
left = 0;
}
return {
left: left
};
},
getLeftAdaptPosition: function (combo, popup, extraWidth) {
if ($.isLeftSpaceEnough(combo, popup, extraWidth)) {
return $.getLeftPosition(combo, popup, extraWidth);
}
return {
left: 0
};
},
getRightAlignPosition: function (combo, popup, extraWidth) {
var comboBounds = combo.element.bounds(), viewBounds = popup.element.bounds();
var left = combo.element.offset().left + comboBounds.width - viewBounds.width - extraWidth;
if (left < 0) {
left = 0;
}
return {
left: left
};
},
getRightAdaptPosition: function (combo, popup, extraWidth) {
if ($.isRightSpaceEnough(combo, popup, extraWidth)) {
return $.getRightPosition(combo, popup, extraWidth);
}
return {
left: $("body").bounds().width - popup.element.bounds().width
};
},
getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top, adaptHeight;
if ($.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + extraHeight;
} else if (needAdaptHeight) {
top = comboOffset.top + extraHeight;
adaptHeight = windowBounds.height - top;
} else {
top = windowBounds.height - popupBounds.height;
if (top < extraHeight) {
adaptHeight = windowBounds.height - extraHeight;
}
}
if (top < extraHeight) {
top = extraHeight;
}
return adaptHeight ? {
top: top,
adaptHeight: adaptHeight
} : {
top: top
};
},
getTopAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
if ($.isTopSpaceEnough(combo, popup, extraHeight)) {
return $.getTopPosition(combo, popup, extraHeight);
}
if (needAdaptHeight) {
return {
top: 0,
adaptHeight: combo.element.offset().top - extraHeight
};
}
if (popupBounds.height + extraHeight > windowBounds.height) {
return {
top: 0,
adaptHeight: windowBounds.height - extraHeight
};
}
return {
top: 0
};
},
getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top, adaptHeight;
if ($.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight;
} else if (needAdaptHeight) {
top = 0;
adaptHeight = comboOffset.top + comboBounds.height - extraHeight;
} else {
top = 0;
if (popupBounds.height + extraHeight > windowBounds.height) {
adaptHeight = windowBounds.height - extraHeight;
}
}
if (top < 0) {
top = 0;
}
return adaptHeight ? {
top: top,
adaptHeight: adaptHeight
} : {
top: top
};
},
getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
if ($.isBottomSpaceEnough(combo, popup, extraHeight)) {
return $.getBottomPosition(combo, popup, extraHeight);
}
if (needAdaptHeight) {
return {
top: comboOffset.top + comboBounds.height + extraHeight,
adaptHeight: windowBounds.height - comboOffset.top - comboBounds.height - extraHeight
};
}
if (popupBounds.height + extraHeight > windowBounds.height) {
return {
top: extraHeight,
adaptHeight: windowBounds.height - extraHeight
};
}
return {
top: windowBounds.height - popupBounds.height - extraHeight
};
},
getCenterAdaptPosition: function (combo, popup) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var left;
if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) {
left = windowBounds.width - popupBounds.width;
} else {
left = comboOffset.left + comboBounds.width / 2 - popupBounds.width / 2;
}
if (left < 0) {
left = 0;
}
return {
left: left
};
},
getMiddleAdaptPosition: function (combo, popup) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top;
if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) {
top = windowBounds.height - popupBounds.height;
} else {
top = comboOffset.top + comboBounds.height / 2 - popupBounds.height / 2;
}
if (top < 0) {
top = 0;
}
return {
top: top
};
},
getComboPositionByDirections: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions) {
extraWidth || (extraWidth = 0);
extraHeight || (extraHeight = 0);
var i, direct;
var leftRight = [], topBottom = [];
var isNeedAdaptHeight = false, tbFirst = false, lrFirst = false;
var left, top, pos;
for (i = 0; i < directions.length; i++) {
direct = directions[i];
switch (direct) {
case "left":
leftRight.push(direct);
break;
case "right":
leftRight.push(direct);
break;
case "top":
topBottom.push(direct);
break;
case "bottom":
topBottom.push(direct);
break;
}
}
for (i = 0; i < directions.length; i++) {
direct = directions[i];
switch (direct) {
case "left":
if (!isNeedAdaptHeight) {
var tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight;
if ($.isLeftSpaceEnough(combo, popup, tW)) {
left = $.getLeftPosition(combo, popup, tW).left;
if (topBottom[0] === "bottom") {
pos = $.getTopAlignPosition(combo, popup, tH, needAdaptHeight);
pos.dir = "left,bottom";
} else {
pos = $.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
pos.dir = "left,top";
}
if (tbFirst) {
pos.change = "left";
}
pos.left = left;
return pos;
}
}
lrFirst = true;
break;
case "right":
if (!isNeedAdaptHeight) {
var tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? extraWidth : extraHeight;
if ($.isRightSpaceEnough(combo, popup, tW)) {
left = $.getRightPosition(combo, popup, tW).left;
if (topBottom[0] === "bottom") {
pos = $.getTopAlignPosition(combo, popup, tH, needAdaptHeight);
pos.dir = "right,bottom";
} else {
pos = $.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
pos.dir = "right,top";
}
if (tbFirst) {
pos.change = "right";
}
pos.left = left;
return pos;
}
}
lrFirst = true;
break;
case "top":
var tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if ($.isTopSpaceEnough(combo, popup, tH)) {
top = $.getTopPosition(combo, popup, tH).top;
if (leftRight[0] === "right") {
pos = $.getLeftAlignPosition(combo, popup, tW, needAdaptHeight);
pos.dir = "top,right";
} else {
pos = $.getRightAlignPosition(combo, popup, tW);
pos.dir = "top,left";
}
if (lrFirst) {
pos.change = "top";
}
pos.top = top;
return pos;
}
if (needAdaptHeight) {
isNeedAdaptHeight = true;
}
tbFirst = true;
break;
case "bottom":
var tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if ($.isBottomSpaceEnough(combo, popup, tH)) {
top = $.getBottomPosition(combo, popup, tH).top;
if (leftRight[0] === "right") {
pos = $.getLeftAlignPosition(combo, popup, tW, needAdaptHeight);
pos.dir = "bottom,right";
} else {
pos = $.getRightAlignPosition(combo, popup, tW);
pos.dir = "bottom,left";
}
if (lrFirst) {
pos.change = "bottom";
}
pos.top = top;
return pos;
}
if (needAdaptHeight) {
isNeedAdaptHeight = true;
}
tbFirst = true;
break;
}
}
switch (directions[0]) {
case "left":
case "right":
if ($.isRightSpaceLarger(combo)) {
left = $.getRightAdaptPosition(combo, popup, extraWidth).left;
} else {
left = $.getLeftAdaptPosition(combo, popup, extraWidth).left;
}
if (topBottom[0] === "bottom") {
pos = $.getTopAlignPosition(combo, popup, extraHeight, needAdaptHeight);
pos.left = left;
pos.dir = directions[0] + ",bottom";
return pos;
}
pos = $.getBottomAlignPosition(combo, popup, extraHeight, needAdaptHeight);
pos.left = left;
pos.dir = directions[0] + ",top";
return pos;
default :
if ($.isBottomSpaceLarger(combo)) {
pos = $.getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight);
} else {
pos = $.getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight);
}
if (leftRight[0] === "right") {
left = $.getLeftAlignPosition(combo, popup, extraWidth, needAdaptHeight).left;
pos.left = left;
pos.dir = directions[0] + ",right";
return pos;
}
left = $.getRightAlignPosition(combo, popup, extraWidth).left;
pos.left = left;
pos.dir = directions[0] + ",left";
return pos;
}
},
getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle) {
extraWidth || (extraWidth = 0);
extraHeight || (extraHeight = 0);
var bodyHeight = $("body").bounds().height - extraHeight;
var maxHeight = Math.min(popup.attr("maxHeight") || bodyHeight, bodyHeight);
popup.resetHeight && popup.resetHeight(maxHeight);
var position = $.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"]);
switch (offsetStyle) {
case "center":
if (position.change) {
var p = $.getMiddleAdaptPosition(combo, popup);
position.top = p.top;
} else {
var p = $.getCenterAdaptPosition(combo, popup);
position.left = p.left;
}
break;
case "middle":
if (position.change) {
var p = $.getCenterAdaptPosition(combo, popup);
position.left = p.left;
} else {
var p = $.getMiddleAdaptPosition(combo, popup);
position.top = p.top;
}
break;
}
if (needAdaptHeight === true) {
popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight));
}
return position;
}
});
}

224
src/core/platform/dom/jquery/fn.js vendored

@ -0,0 +1,224 @@
if (jQuery) {
(function ($) {
// richer:容器在其各个边缘留出的空间
if (!$.fn.insets) {
$.fn.insets = function () {
var p = this.padding(),
b = this.border();
return {
top: p.top,
bottom: p.bottom + b.bottom + b.top,
left: p.left,
right: p.right + b.right + b.left
};
};
}
// richer:获取 && 设置jQuery元素的边界
if (!$.fn.bounds) {
$.fn.bounds = function (value) {
var tmp = {hasIgnoredBounds: true};
if (value) {
if (!isNaN(value.x)) {
tmp.left = value.x;
}
if (!isNaN(value.y)) {
tmp.top = value.y;
}
if (value.width != null) {
tmp.width = (value.width - (this.outerWidth(true) - this.width()));
tmp.width = (tmp.width >= 0) ? tmp.width : value.width;
// fix chrome
// tmp.width = (tmp.width >= 0) ? tmp.width : 0;
}
if (value.height != null) {
tmp.height = value.height - (this.outerHeight(true) - this.height());
tmp.height = (tmp.height >= 0) ? tmp.height : value.height;
// fix chrome
// tmp.height = (tmp.height >= 0) ? tmp.height : value.0;
}
this.css(tmp);
return this;
}
// richer:注意此方法只对可见元素有效
tmp = this.position();
return {
x: tmp.left,
y: tmp.top,
// richer:这里计算外部宽度和高度的时候,都不包括边框
width: this.outerWidth(),
height: this.outerHeight()
};
};
}
})(jQuery);
BI.extend(jQuery.fn, {
destroy: function () {
this.remove();
if (BI.isIE() === true) {
this[0].outerHTML = "";
}
},
/**
* 高亮显示
* @param text 必需
* @param keyword
* @param py 必需
* @returns {*}
* @private
*/
__textKeywordMarked__: function (text, keyword, py) {
if (!BI.isKey(keyword) || (text + "").length > 100) {
return this.html(BI.htmlEncode(text));
}
keyword = keyword + "";
keyword = BI.toUpperCase(keyword);
var textLeft = (text || "") + "";
py = (py || BI.makeFirstPY(text)) + "";
if (py != null) {
py = BI.toUpperCase(py);
}
this.empty();
while (true) {
var tidx = BI.toUpperCase(textLeft).indexOf(keyword);
var pidx = null;
if (py != null) {
pidx = py.indexOf(keyword);
if (pidx >= 0) {
pidx = pidx % text.length;
}
}
if (tidx >= 0) {
this.append(textLeft.substr(0, tidx));
this.append($("<span>").addClass("bi-keyword-red-mark")
.html(BI.htmlEncode(textLeft.substr(tidx, keyword.length))));
textLeft = textLeft.substr(tidx + keyword.length);
if (py != null) {
py = py.substr(tidx + keyword.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($("<span>").addClass("bi-keyword-red-mark")
.html(BI.htmlEncode(textLeft.substr(pidx, keyword.length))));
if (py != null) {
py = py.substr(pidx + keyword.length);
}
textLeft = textLeft.substr(pidx + keyword.length);
} else {
this.append(textLeft);
break;
}
}
return this;
},
getDomHeight: function (parent) {
var clone = $(this).clone();
clone.appendTo($(parent || "body"));
var height = clone.height();
clone.remove();
return height;
},
// 是否有竖直滚动条
hasVerticalScroll: function () {
return this.height() > 0 && this[0].clientWidth < this[0].offsetWidth;
},
// 是否有水平滚动条
hasHorizonScroll: function () {
return this.width() > 0 && this[0].clientHeight < this[0].offsetHeight;
},
// 获取计算后的样式
getStyle: function (name) {
var node = this[0];
var computedStyle = void 0;
// W3C Standard
if (_global.getComputedStyle) {
// In certain cases such as within an iframe in FF3, this returns null.
computedStyle = _global.getComputedStyle(node, null);
if (computedStyle) {
return computedStyle.getPropertyValue(BI.hyphenate(name));
}
}
// Safari
if (document.defaultView && document.defaultView.getComputedStyle) {
computedStyle = document.defaultView.getComputedStyle(node, null);
// A Safari bug causes this to return null for `display: none` elements.
if (computedStyle) {
return computedStyle.getPropertyValue(BI.hyphenate(name));
}
if (name === "display") {
return "none";
}
}
// Internet Explorer
if (node.currentStyle) {
if (name === "float") {
return node.currentStyle.cssFloat || node.currentStyle.styleFloat;
}
return node.currentStyle[BI.camelize(name)];
}
return node.style && node.style[BI.camelize(name)];
},
__isMouseInBounds__: function (e) {
var offset2Body = this.get(0).getBoundingClientRect ? this.get(0).getBoundingClientRect() : this.offset();
var width = offset2Body.width || this.outerWidth();
var height = offset2Body.height || this.outerHeight();
return !(e.pageX < offset2Body.left || e.pageX > offset2Body.left + width
|| e.pageY < offset2Body.top || e.pageY > offset2Body.top + height);
},
__hasZIndexMask__: function (zindex) {
return zindex && this.zIndexMask[zindex] != null;
},
__buildZIndexMask__: function (zindex, domArray) {
this.zIndexMask = this.zIndexMask || {};// 存储z-index的mask
this.indexMask = this.indexMask || [];// 存储mask
var mask = BI.createWidget({
type: "bi.center_adapt",
cls: "bi-z-index-mask",
items: domArray
});
mask.element.css({"z-index": zindex});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: mask,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.indexMask.push(mask);
zindex && (this.zIndexMask[zindex] = mask);
return mask.element;
},
__releaseZIndexMask__: function (zindex) {
if (zindex && this.zIndexMask[zindex]) {
this.indexMask.remove(this.zIndexMask[zindex]);
this.zIndexMask[zindex].destroy();
return;
}
this.indexMask = this.indexMask || [];
var indexMask = this.indexMask.pop();
indexMask && indexMask.destroy();
}
});
}

0
src/core/utils/load.js → src/core/platform/dom/load.js

58
src/core/proto/jquery.js vendored

@ -1,58 +0,0 @@
if (jQuery) {
(function ($) {
// richer:容器在其各个边缘留出的空间
if (!$.fn.insets) {
$.fn.insets = function () {
var p = this.padding(),
b = this.border();
return {
top: p.top,
bottom: p.bottom + b.bottom + b.top,
left: p.left,
right: p.right + b.right + b.left
};
};
}
// richer:获取 && 设置jQuery元素的边界
if (!$.fn.bounds) {
$.fn.bounds = function (value) {
var tmp = {hasIgnoredBounds: true};
if (value) {
if (!isNaN(value.x)) {
tmp.left = value.x;
}
if (!isNaN(value.y)) {
tmp.top = value.y;
}
if (value.width != null) {
tmp.width = (value.width - (this.outerWidth(true) - this.width()));
tmp.width = (tmp.width >= 0) ? tmp.width : value.width;
// fix chrome
// tmp.width = (tmp.width >= 0) ? tmp.width : 0;
}
if (value.height != null) {
tmp.height = value.height - (this.outerHeight(true) - this.height());
tmp.height = (tmp.height >= 0) ? tmp.height : value.height;
// fix chrome
// tmp.height = (tmp.height >= 0) ? tmp.height : value.0;
}
this.css(tmp);
return this;
}
// richer:注意此方法只对可见元素有效
tmp = this.position();
return {
x: tmp.left,
y: tmp.top,
// richer:这里计算外部宽度和高度的时候,都不包括边框
width: this.outerWidth(),
height: this.outerHeight()
};
};
}
})(jQuery);
}

14
src/css/widget/singleslider/slider/widget.css

@ -1,6 +1,7 @@
.bi-single-slider-button .slider-button {
cursor: ew-resize;
border: 2px solid #3685f2;
border-width: 2px;
border-style: solid;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
@ -32,3 +33,14 @@
top: 6px;
left: -8px;
}
.bi-theme-dark .bi-single-slider-button .slider-button {
background-color: #242640;
}
.bi-theme-dark .bi-single-slider-button .slider-button:hover,
.bi-theme-dark .bi-single-slider-button .slider-button.hover {
background-color: #191B2B;
}
.bi-theme-dark .bi-single-slider-button .slider-button.disabled:hover,
.bi-theme-dark .bi-single-slider-button .slider-button.disabled.hover {
background-color: #191B2B;
}

19
src/less/widget/singleslider/slider/widget.slider.less

@ -3,7 +3,8 @@
.bi-single-slider-button {
& .slider-button {
cursor: ew-resize;
border: 2px solid @color-bi-border-highlight;
border-width: 2px;
border-style: solid;
.border-radius(8px);
background-color: @color-bi-background-default;
height: 16px;
@ -29,4 +30,20 @@
}
}
}
}
.bi-theme-dark {
.bi-single-slider-button {
& .slider-button {
background-color: @color-bi-background-default-theme-dark;
&:hover, &.hover {
background-color: @color-bi-background-normal-theme-dark;
}
&.disabled {
&:hover, &.hover {
background-color: @color-bi-background-normal-theme-dark;
}
}
}
}
}

2
src/widget/singleslider/button/iconbutton.slider.js

@ -25,7 +25,7 @@ BI.SliderIconButton = BI.inherit(BI.Widget, {
el: {
type: "bi.text_button",
forceNotSelected: true,
cls: "slider-button bi-list-item-select3",
cls: "slider-button bi-list-item-select3 bi-high-light-border",
ref: function () {
self.slider = this;
}

Loading…
Cancel
Save