Browse Source

Pull request #3353: Es6

Merge in VISUAL/fineui from ~DAILER/fineui:es6 to es6

* commit 'c5eaf22cdcaf33acc93f91e480a662b1204cbfca':
  Update demo/app.js
  auto upgrade version to 2.0.20230109200447
  无jira refact:删除没有用的 less
  KERNEL-14041 feat: core/platform文件夹
  KERNEL-14041 feat: core/platform文件夹
  auto upgrade version to 2.0.20230109102030
  REPORT-85056 🦄 refactor: 升级jquery
es6
Dailer-刘荣歆 2 years ago
parent
commit
7b742dde5a
  1. 3
      demo/app.js
  2. 4
      package.json
  3. 2
      src/case/calendar/calendar.js
  4. 3
      src/core/index.js
  5. 147
      src/core/platform/web/config.js
  6. 590
      src/core/platform/web/detectElementResize.js
  7. 592
      src/core/platform/web/dom.js
  8. 129
      src/core/platform/web/function.js
  9. 7
      src/core/platform/web/index.js
  10. 11051
      src/core/platform/web/jquery/_jquery.js
  11. 4
      src/core/platform/web/jquery/event.js
  12. 161
      src/core/platform/web/jquery/fn.js
  13. 4
      src/core/platform/web/jquery/index.js
  14. 39
      src/core/platform/web/load.js
  15. 5
      src/less/case/calendar/calendar.less

3
demo/app.js

@ -1,6 +1,9 @@
Demo = {
version: 1.0
};
BI.EVENT_BLUR = false
BI.$(function () {
var ref;

4
package.json

@ -1,6 +1,6 @@
{
"name": "fineui",
"version": "2.0.20230107203454",
"version": "2.0.20230109200447",
"description": "fineui",
"main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts",
@ -12,6 +12,7 @@
"@babel/polyfill": "7.6.0",
"@fui/babel-preset-fineui": "^2.0.0",
"@fui/eslint-plugin": "^1.0.19",
"@juggle/resize-observer": "^3.4.0",
"@types/node": "15.6.1",
"@typescript-eslint/eslint-plugin": "2.33.0",
"@typescript-eslint/parser": "2.33.0",
@ -89,6 +90,7 @@
"license": "MIT",
"dependencies": {
"@types/yargs": "17.0.13",
"jquery": "3.6.3",
"yargs": "17.6.2"
}
}

2
src/case/calendar/calendar.js

@ -170,7 +170,7 @@ BI.Calendar = BI.inherit(BI.Widget, {
forceSelected: true,
value: year + "-" + month + "-" + td.text,
disabled: td.disabled,
cls: td.lastMonth || td.nextMonth ? "not-current-month-day" : "",
cls: td.lastMonth || td.nextMonth ? "bi-tips" : "",
lgap: 2,
rgap: 2,
tgap: 4,

3
src/core/index.js

@ -16,6 +16,7 @@ import * as constant from "./constant";
import * as logic from "./logic";
import { Element } from "./element";
import * as utils from "./utils";
import * as platform from "./platform/web";
export * from "./decorator";
export * from "./2.base";
@ -31,6 +32,7 @@ export * from "./h";
export * from "./constant";
export * from "./logic";
export * from "./utils";
export * from "./platform/web";
export {
StyleLoaderManager,
@ -60,4 +62,5 @@ Object.assign(BI, {
useInWorker,
...h,
...utils,
...platform,
});

147
src/core/platform/web/config.js

@ -1,38 +1,49 @@
import { Plugin } from "../../6.plugin";
// 工程配置
!(function () {
// 注册布局
// adapt类布局优先级规则
// 1、支持flex的浏览器下使用flex布局
// 2、不支持flex的浏览器下使用inline布局
// 3、当列宽既需要自动列宽又需要自适应列宽时,inline布局也处理不了了。当横向出滚动条时使用table布局,不出滚动条时使用float布局
var _isSupportFlex, _isSupportGrid;
var isSupportFlex = function () {
if (_isSupportFlex == null) {
let _isSupportFlex, _isSupportGrid;
function isSupportFlex() {
if (!_isSupportFlex) {
_isSupportFlex = !!(BI.isSupportCss3 && BI.isSupportCss3("flex"));
}
return _isSupportFlex;
};
var isSupportGrid = function () {
if (_isSupportGrid == null) {
}
function isSupportGrid() {
if (!_isSupportGrid) {
_isSupportGrid = !!(BI.isSupportCss3 && BI.isSupportCss3("grid"));
}
return _isSupportGrid;
};
}
// 判断浏览器是否支持sticky 属性
var isSupportSticky = (function () {
var vendorList = ["", "-webkit-", "-ms-", "-moz-", "-o-"],
const isSupportSticky = (function () {
const vendorList = ["", "-webkit-", "-ms-", "-moz-", "-o-"],
vendorListLength = vendorList.length,
stickyElement = document.createElement("div");
for (var i = 0; i < vendorListLength; i++) {
stickyElement.style.position = vendorList[i] + "sticky";
for (let i = 0; i < vendorListLength; i++) {
stickyElement.style.position = `${vendorList[i]}sticky`;
if (stickyElement.style.position !== "") {
return true;
}
}
return false;
})();
BI.Plugin.configWidget("bi.horizontal", function (ob) {
var supportFlex = isSupportFlex();
}());
const configWidget = Plugin.configWidget;
configWidget("bi.horizontal", ob => {
const supportFlex = isSupportFlex();
// // 在横向自适应场景下我们需要使用table的自适应撑出滚动条的特性(flex处理不了这种情况)
// // 主要出现在center_adapt或者horizontal_adapt的场景,或者主动设置horizontalAlign的场景
// if (ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch) {
@ -41,25 +52,27 @@
if (supportFlex) {
return BI.extend({}, ob, { type: "bi.flex_horizontal" });
}
return BI.extend({
scrollx: true
scrollx: true,
}, ob, { type: "bi.inline" });
});
BI.Plugin.configWidget("bi.vertical", function (ob) {
configWidget("bi.vertical", ob => {
if (ob.horizontalAlign === BI.HorizontalAlign.Left || ob.horizontalAlign === BI.HorizontalAlign.Right) {
if (isSupportFlex()) {
return BI.extend({}, ob, { type: "bi.flex_vertical" });
}
return BI.extend({}, ob, {
horizontalAlign: BI.HorizontalAlign.Stretch,
type: "bi.vertical",
items: BI.map(ob.items, function (i, item) {
items: BI.map(ob.items, (i, item) => {
return {
type: "bi.inline",
horizontalAlign: ob.horizontalAlign,
items: [item]
items: [item],
};
})
}),
});
}
if (ob.verticalAlign === BI.VerticalAlign.Stretch) {
@ -69,18 +82,19 @@
}, ob, { type: "bi.flex_vertical" });
}
}
return ob;
});
BI.Plugin.configWidget("bi.inline", function (ob) {
configWidget("bi.inline", ob => {
// 当列宽既需要自动列宽又需要自适应列宽时,inline布局也处理不了了,降级table处理吧
var hasAutoAndFillColumnSize = false;
let hasAutoAndFillColumnSize = false;
if (ob.columnSize && ob.columnSize.length > 0) {
if ((ob.columnSize.indexOf("") >= 0 || ob.columnSize.indexOf("auto") >= 0) && ob.columnSize.indexOf("fill") >= 0) {
hasAutoAndFillColumnSize = true;
}
} else {
var hasAuto = false, hasFill = false;
BI.each(ob.items, function (i, item) {
let hasAuto = false, hasFill = false;
BI.each(ob.items, (i, item) => {
if (item.width === "fill") {
hasFill = true;
} else if (BI.isNull(item.width) || item.width === "" || item.width === "auto") {
@ -94,116 +108,123 @@
// 宽度是不是受限
if ((ob.scrollable !== true && ob.scrollx !== true) || ob.horizontalAlign === BI.HorizontalAlign.Stretch) {
return BI.extend({
verticalAlign: BI.VerticalAlign.Top
verticalAlign: BI.VerticalAlign.Top,
}, ob, { type: "bi.horizontal_float_fill" });
}
return BI.extend({
horizontalAlign: BI.HorizontalAlign.Stretch
horizontalAlign: BI.HorizontalAlign.Stretch,
}, ob, { type: "bi.table_adapt" });
}
if (BI.Providers.getProvider("bi.provider.system").getResponsiveMode()) {
return BI.extend({}, ob, { type: "bi.responsive_inline" });
}
return ob;
});
BI.Plugin.configWidget("bi.center_adapt", function (ob) {
var supportFlex = isSupportFlex();
configWidget("bi.center_adapt", ob => {
const supportFlex = isSupportFlex();
// var isAdapt = !ob.horizontalAlign || ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch;
// if (!isAdapt || justOneItem) {
if (supportFlex) {
return BI.extend({}, ob, { type: "bi.flex_center_adapt" });
}
return BI.extend({}, ob, { type: "bi.inline_center_adapt" });
// }
// return ob;
});
BI.Plugin.configWidget("bi.vertical_adapt", function (ob) {
var supportFlex = isSupportFlex();
configWidget("bi.vertical_adapt", ob => {
const supportFlex = isSupportFlex();
// var isAdapt = ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch;
// if (!isAdapt || justOneItem) {
if (supportFlex) {
return BI.extend({}, ob, { type: "bi.flex_vertical_center_adapt" });
}
return BI.extend({}, ob, { type: "bi.inline_vertical_adapt" });
// }
// return ob;
});
BI.Plugin.configWidget("bi.horizontal_adapt", function (ob) {
var justOneItem = (ob.items && ob.items.length <= 1);
var isAdapt = !ob.horizontalAlign || ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch;
var verticalAlignTop = !ob.verticalAlign || ob.verticalAlign === BI.VerticalAlign.TOP;
configWidget("bi.horizontal_adapt", ob => {
const justOneItem = (ob.items && ob.items.length <= 1);
const isAdapt = !ob.horizontalAlign || ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch;
const verticalAlignTop = !ob.verticalAlign || ob.verticalAlign === BI.VerticalAlign.TOP;
if (verticalAlignTop && justOneItem) {
return BI.extend({}, ob, { type: "bi.horizontal_auto" });
}
var supportFlex = isSupportFlex();
const supportFlex = isSupportFlex();
// 在横向自适应场景下我们需要使用table的自适应撑出滚动条的特性(flex处理不了这种情况)
// 主要出现在center_adapt或者horizontal_adapt的场景,或者主动设置horizontalAlign的场景
if (isAdapt) {
return BI.extend({
horizontalAlign: BI.HorizontalAlign.Center
horizontalAlign: BI.HorizontalAlign.Center,
}, ob, { type: "bi.table_adapt" });
}
if (supportFlex) {
return BI.extend({
horizontalAlign: BI.HorizontalAlign.Center,
scrollx: false
scrollx: false,
}, ob, { type: "bi.flex_horizontal" });
}
return BI.extend({
horizontalAlign: BI.HorizontalAlign.Center
horizontalAlign: BI.HorizontalAlign.Center,
}, ob, { type: "bi.table_adapt" });
});
BI.Plugin.configWidget("bi.horizontal_float", function (ob) {
configWidget("bi.horizontal_float", ob => {
if (isSupportFlex()) {
return BI.extend({}, ob, { type: "bi.flex_horizontal_adapt" });
}
if (ob.items && ob.items.length <= 1) {
return BI.extend({}, ob, { type: "bi.inline_horizontal_adapt" });
}
return ob;
});
BI.Plugin.configWidget("bi.horizontal_fill", function (ob) {
configWidget("bi.horizontal_fill", ob => {
if (isSupportFlex()) {
return BI.extend({
horizontalAlign: BI.HorizontalAlign.Stretch,
verticalAlign: BI.VerticalAlign.Stretch,
scrollx: false
scrollx: false,
}, ob, { type: "bi.flex_horizontal" });
}
if ((ob.horizontalAlign && ob.horizontalAlign !== BI.HorizontalAlign.Stretch) || (ob.scrollable === true || ob.scrollx === true)) {
// 宽度不受限,要用table布局
return BI.extend({
horizontalAlign: BI.HorizontalAlign.Stretch,
verticalAlign: BI.VerticalAlign.Stretch
verticalAlign: BI.VerticalAlign.Stretch,
}, ob, { type: "bi.table_adapt" });
}
return BI.extend({}, ob, { type: "bi.horizontal_float_fill" });
});
BI.Plugin.configWidget("bi.vertical_fill", function (ob) {
configWidget("bi.vertical_fill", ob => {
if (isSupportFlex()) {
return BI.extend({
horizontalAlign: BI.HorizontalAlign.Stretch,
verticalAlign: BI.VerticalAlign.Stretch,
scrolly: false
scrolly: false,
}, ob, { type: "bi.flex_vertical" });
}
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
// 有滚动条,降级到table布局处理
return BI.extend({}, ob, {
type: "bi.td",
items: BI.map(ob.items, function (i, item) {
return [item];
})
items: BI.map(ob.items, (i, item) => [item]),
});
}
var hasAuto = false;
let hasAuto = false;
if (ob.rowSize && ob.rowSize.length > 0) {
if (ob.rowSize.indexOf("") >= 0 || ob.rowSize.indexOf("auto") >= 0) {
hasAuto = true;
}
} else {
BI.each(ob.items, function (i, item) {
BI.each(ob.items, (i, item) => {
if (BI.isNull(item.height) || item.height === "") {
hasAuto = true;
}
@ -213,34 +234,37 @@
// 有自动高的时候
return BI.extend({}, ob, { type: "bi.vtape_auto" });
}
return BI.extend({}, ob, { type: "bi.vtape" });
});
BI.Plugin.configWidget("bi.horizontal_sticky", function (ob) {
configWidget("bi.horizontal_sticky", ob => {
if (!isSupportSticky) {
return BI.extend({ scrollx: true }, ob, { type: "bi.horizontal_fill" });
}
});
BI.Plugin.configWidget("bi.vertical_sticky", function (ob) {
configWidget("bi.vertical_sticky", ob => {
if (!isSupportSticky) {
return BI.extend({ scrolly: true }, ob, { type: "bi.vertical_fill" });
}
});
BI.Plugin.configWidget("bi.left_right_vertical_adapt", function (ob) {
configWidget("bi.left_right_vertical_adapt", ob => {
if (isSupportFlex()) {
// IE下其实也是可以使用flex布局的,只要排除掉出现滚动条的情况
// if (!BI.isIE() || (ob.scrollable !== true && ob.scrolly !== true)) {
return BI.extend({}, ob, { type: "bi.flex_left_right_vertical_adapt" });
// }
}
return ob;
});
BI.Plugin.configWidget("bi.flex_horizontal", function (ob) {
configWidget("bi.flex_horizontal", ob => {
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
if (ob.hgap > 0 || ob.lgap > 0 || ob.rgap > 0) {
if (BI.Providers.getProvider("bi.provider.system").getResponsiveMode()) {
return BI.extend({}, ob, { type: "bi.responsive_flex_scrollable_horizontal" });
}
return BI.extend({}, ob, { type: "bi.flex_scrollable_horizontal" });
}
}
@ -248,7 +272,7 @@
return BI.extend({}, ob, { type: "bi.responsive_flex_horizontal" });
}
});
BI.Plugin.configWidget("bi.flex_vertical", function (ob) {
configWidget("bi.flex_vertical", ob => {
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
if (ob.hgap > 0 || ob.lgap > 0 || ob.rgap > 0) {
return BI.extend({}, ob, { type: "bi.flex_scrollable_vertical" });
@ -256,31 +280,36 @@
}
});
BI.Plugin.configWidget("bi.table", function (ob) {
configWidget("bi.table", ob => {
if (!isSupportGrid()) {
return BI.extend({}, ob, { type: "bi.td" });
}
return ob;
});
BI.Plugin.configWidget("bi.radio", function (ob) {
configWidget("bi.radio", ob => {
if (BI.isIE() && BI.getIEVersion() <= 9) {
return BI.extend({}, ob, { type: "bi.image_radio" });
}
return ob;
});
BI.Plugin.configWidget("bi.checkbox", function (ob) {
configWidget("bi.checkbox", ob => {
if (BI.isIE() && BI.getIEVersion() <= 9) {
return BI.extend({}, ob, { type: "bi.image_checkbox" });
}
return ob;
});
BI.Plugin.configWidget("bi.half_icon_button", function (ob) {
configWidget("bi.half_icon_button", ob => {
if (BI.isIE() && BI.getIEVersion() < 9) {
return ob;
}
return BI.extend({}, ob, { type: "bi.half_button" });
});
}());

590
src/core/platform/web/detectElementResize.js

@ -1,571 +1,15 @@
/**
* Detect Element Resize.
* A minimal library which polyfills the ResizeObserver API and is entirely based on the latest Draft Specification.
* https://github.com/juggle/resize-observer
* version: 3.4.0
**/
var ResizeObserverPolyfill = (function (exports) {
'use strict';
import { ResizeObserver as ResizeObserverPolyfill } from "@juggle/resize-observer";
var resizeObservers = [];
const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
var hasActiveObservations = function () {
return resizeObservers.some(function (ro) {
return ro.activeTargets.length > 0;
});
};
var hasSkippedObservations = function () {
return resizeObservers.some(function (ro) {
return ro.skippedTargets.length > 0;
});
};
var msg = 'ResizeObserver loop completed with undelivered notifications.';
var deliverResizeLoopError = function () {
var event;
if (typeof ErrorEvent === 'function') {
event = new ErrorEvent('error', {
message: msg
});
} else {
event = document.createEvent('Event');
event.initEvent('error', false, false);
event.message = msg;
}
window.dispatchEvent(event);
};
var ResizeObserverBoxOptions;
(function (ResizeObserverBoxOptions) {
ResizeObserverBoxOptions["BORDER_BOX"] = "border-box";
ResizeObserverBoxOptions["CONTENT_BOX"] = "content-box";
ResizeObserverBoxOptions["DEVICE_PIXEL_CONTENT_BOX"] = "device-pixel-content-box";
})(ResizeObserverBoxOptions || (ResizeObserverBoxOptions = {}));
var freeze = function (obj) {
return Object.freeze(obj);
};
var ResizeObserverSize = (function () {
function ResizeObserverSize(inlineSize, blockSize) {
this.inlineSize = inlineSize;
this.blockSize = blockSize;
freeze(this);
}
return ResizeObserverSize;
}());
var DOMRectReadOnly = (function () {
function DOMRectReadOnly(x, y, width, height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.top = this.y;
this.left = this.x;
this.bottom = this.top + this.height;
this.right = this.left + this.width;
return freeze(this);
}
DOMRectReadOnly.prototype.toJSON = function () {
var _a = this, x = _a.x, y = _a.y, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left,
width = _a.width, height = _a.height;
return { x: x, y: y, top: top, right: right, bottom: bottom, left: left, width: width, height: height };
};
DOMRectReadOnly.fromRect = function (rectangle) {
return new DOMRectReadOnly(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
};
return DOMRectReadOnly;
}());
var isSVG = function (target) {
return target instanceof SVGElement && 'getBBox' in target;
};
var isHidden = function (target) {
if (isSVG(target)) {
var _a = target.getBBox(), width = _a.width, height = _a.height;
return !width && !height;
}
var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
return !(offsetWidth || offsetHeight || target.getClientRects().length);
};
var isElement = function (obj) {
var _a;
if (obj instanceof Element) {
return true;
}
var scope = (_a = obj === null || obj === void 0 ? void 0 : obj.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
return !!(scope && obj instanceof scope.Element);
};
var isReplacedElement = function (target) {
switch (target.tagName) {
case 'INPUT':
if (target.type !== 'image') {
break;
}
case 'VIDEO':
case 'AUDIO':
case 'EMBED':
case 'OBJECT':
case 'CANVAS':
case 'IFRAME':
case 'IMG':
return true;
}
return false;
};
var global = typeof window !== 'undefined' ? window : {};
var cache = new WeakMap();
var scrollRegexp = /auto|scroll/;
var verticalRegexp = /^tb|vertical/;
var IE = (/msie|trident/i).test(global.navigator && global.navigator.userAgent);
var parseDimension = function (pixel) {
return parseFloat(pixel || '0');
};
var size = function (inlineSize, blockSize, switchSizes) {
if (inlineSize === void 0) {
inlineSize = 0;
}
if (blockSize === void 0) {
blockSize = 0;
}
if (switchSizes === void 0) {
switchSizes = false;
}
return new ResizeObserverSize((switchSizes ? blockSize : inlineSize) || 0, (switchSizes ? inlineSize : blockSize) || 0);
};
var zeroBoxes = freeze({
devicePixelContentBoxSize: size(),
borderBoxSize: size(),
contentBoxSize: size(),
contentRect: new DOMRectReadOnly(0, 0, 0, 0)
});
var calculateBoxSizes = function (target, forceRecalculation) {
if (forceRecalculation === void 0) {
forceRecalculation = false;
}
if (cache.has(target) && !forceRecalculation) {
return cache.get(target);
}
if (isHidden(target)) {
cache.set(target, zeroBoxes);
return zeroBoxes;
}
var cs = getComputedStyle(target);
var svg = isSVG(target) && target.ownerSVGElement && target.getBBox();
var removePadding = !IE && cs.boxSizing === 'border-box';
var switchSizes = verticalRegexp.test(cs.writingMode || '');
var canScrollVertically = !svg && scrollRegexp.test(cs.overflowY || '');
var canScrollHorizontally = !svg && scrollRegexp.test(cs.overflowX || '');
var paddingTop = svg ? 0 : parseDimension(cs.paddingTop);
var paddingRight = svg ? 0 : parseDimension(cs.paddingRight);
var paddingBottom = svg ? 0 : parseDimension(cs.paddingBottom);
var paddingLeft = svg ? 0 : parseDimension(cs.paddingLeft);
var borderTop = svg ? 0 : parseDimension(cs.borderTopWidth);
var borderRight = svg ? 0 : parseDimension(cs.borderRightWidth);
var borderBottom = svg ? 0 : parseDimension(cs.borderBottomWidth);
var borderLeft = svg ? 0 : parseDimension(cs.borderLeftWidth);
var horizontalPadding = paddingLeft + paddingRight;
var verticalPadding = paddingTop + paddingBottom;
var horizontalBorderArea = borderLeft + borderRight;
var verticalBorderArea = borderTop + borderBottom;
var horizontalScrollbarThickness = !canScrollHorizontally ? 0 : target.offsetHeight - verticalBorderArea - target.clientHeight;
var verticalScrollbarThickness = !canScrollVertically ? 0 : target.offsetWidth - horizontalBorderArea - target.clientWidth;
var widthReduction = removePadding ? horizontalPadding + horizontalBorderArea : 0;
var heightReduction = removePadding ? verticalPadding + verticalBorderArea : 0;
var contentWidth = svg ? svg.width : parseDimension(cs.width) - widthReduction - verticalScrollbarThickness;
var contentHeight = svg ? svg.height : parseDimension(cs.height) - heightReduction - horizontalScrollbarThickness;
var borderBoxWidth = contentWidth + horizontalPadding + verticalScrollbarThickness + horizontalBorderArea;
var borderBoxHeight = contentHeight + verticalPadding + horizontalScrollbarThickness + verticalBorderArea;
var boxes = freeze({
devicePixelContentBoxSize: size(Math.round(contentWidth * devicePixelRatio), Math.round(contentHeight * devicePixelRatio), switchSizes),
borderBoxSize: size(borderBoxWidth, borderBoxHeight, switchSizes),
contentBoxSize: size(contentWidth, contentHeight, switchSizes),
contentRect: new DOMRectReadOnly(paddingLeft, paddingTop, contentWidth, contentHeight)
});
cache.set(target, boxes);
return boxes;
};
var calculateBoxSize = function (target, observedBox, forceRecalculation) {
var _a = calculateBoxSizes(target, forceRecalculation), borderBoxSize = _a.borderBoxSize,
contentBoxSize = _a.contentBoxSize, devicePixelContentBoxSize = _a.devicePixelContentBoxSize;
switch (observedBox) {
case ResizeObserverBoxOptions.DEVICE_PIXEL_CONTENT_BOX:
return devicePixelContentBoxSize;
case ResizeObserverBoxOptions.BORDER_BOX:
return borderBoxSize;
default:
return contentBoxSize;
}
};
var ResizeObserverEntry = (function () {
function ResizeObserverEntry(target) {
var boxes = calculateBoxSizes(target);
this.target = target;
this.contentRect = boxes.contentRect;
this.borderBoxSize = freeze([boxes.borderBoxSize]);
this.contentBoxSize = freeze([boxes.contentBoxSize]);
this.devicePixelContentBoxSize = freeze([boxes.devicePixelContentBoxSize]);
}
return ResizeObserverEntry;
}());
var calculateDepthForNode = function (node) {
if (isHidden(node)) {
return Infinity;
}
var depth = 0;
var parent = node.parentNode;
while (parent) {
depth += 1;
parent = parent.parentNode;
}
return depth;
};
var broadcastActiveObservations = function () {
var shallowestDepth = Infinity;
var callbacks = [];
resizeObservers.forEach(function processObserver(ro) {
if (ro.activeTargets.length === 0) {
return;
}
var entries = [];
ro.activeTargets.forEach(function processTarget(ot) {
var entry = new ResizeObserverEntry(ot.target);
var targetDepth = calculateDepthForNode(ot.target);
entries.push(entry);
ot.lastReportedSize = calculateBoxSize(ot.target, ot.observedBox);
if (targetDepth < shallowestDepth) {
shallowestDepth = targetDepth;
}
});
callbacks.push(function resizeObserverCallback() {
ro.callback.call(ro.observer, entries, ro.observer);
});
ro.activeTargets.splice(0, ro.activeTargets.length);
});
for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
var callback = callbacks_1[_i];
callback();
}
return shallowestDepth;
};
var gatherActiveObservationsAtDepth = function (depth) {
resizeObservers.forEach(function processObserver(ro) {
ro.activeTargets.splice(0, ro.activeTargets.length);
ro.skippedTargets.splice(0, ro.skippedTargets.length);
ro.observationTargets.forEach(function processTarget(ot) {
if (ot.isActive()) {
if (calculateDepthForNode(ot.target) > depth) {
ro.activeTargets.push(ot);
} else {
ro.skippedTargets.push(ot);
}
}
});
});
};
var process = function () {
var depth = 0;
gatherActiveObservationsAtDepth(depth);
while (hasActiveObservations()) {
depth = broadcastActiveObservations();
gatherActiveObservationsAtDepth(depth);
}
if (hasSkippedObservations()) {
deliverResizeLoopError();
}
return depth > 0;
};
var trigger;
var callbacks = [];
var notify = function () {
return callbacks.splice(0).forEach(function (cb) {
return cb();
});
};
var queueMicroTask = function (callback) {
if (!trigger) {
var toggle_1 = 0;
var el_1 = document.createTextNode('');
var config = { characterData: true };
new MutationObserver(function () {
return notify();
}).observe(el_1, config);
trigger = function () {
el_1.textContent = "".concat(toggle_1 ? toggle_1-- : toggle_1++);
};
}
callbacks.push(callback);
trigger();
};
var queueResizeObserver = function (cb) {
queueMicroTask(function ResizeObserver() {
requestAnimationFrame(cb);
});
};
var watching = 0;
var isWatching = function () {
return !!watching;
};
var CATCH_PERIOD = 250;
var observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };
var events = [
'resize',
'load',
'transitionend',
'animationend',
'animationstart',
'animationiteration',
'keyup',
'keydown',
'mouseup',
'mousedown',
'mouseover',
'mouseout',
'blur',
'focus'
];
var time = function (timeout) {
if (timeout === void 0) {
timeout = 0;
}
return Date.now() + timeout;
};
var scheduled = false;
var Scheduler = (function () {
function Scheduler() {
var _this = this;
this.stopped = true;
this.listener = function () {
return _this.schedule();
};
}
Scheduler.prototype.run = function (timeout) {
var _this = this;
if (timeout === void 0) {
timeout = CATCH_PERIOD;
}
if (scheduled) {
return;
}
scheduled = true;
var until = time(timeout);
queueResizeObserver(function () {
var elementsHaveResized = false;
try {
elementsHaveResized = process();
} finally {
scheduled = false;
timeout = until - time();
if (!isWatching()) {
return;
}
if (elementsHaveResized) {
_this.run(1000);
} else if (timeout > 0) {
_this.run(timeout);
} else {
_this.start();
}
}
});
};
Scheduler.prototype.schedule = function () {
this.stop();
this.run();
};
Scheduler.prototype.observe = function () {
var _this = this;
var cb = function () {
return _this.observer && _this.observer.observe(document.body, observerConfig);
};
document.body ? cb() : global.addEventListener('DOMContentLoaded', cb);
};
Scheduler.prototype.start = function () {
var _this = this;
if (this.stopped) {
this.stopped = false;
this.observer = new MutationObserver(this.listener);
this.observe();
events.forEach(function (name) {
return global.addEventListener(name, _this.listener, true);
});
}
};
Scheduler.prototype.stop = function () {
var _this = this;
if (!this.stopped) {
this.observer && this.observer.disconnect();
events.forEach(function (name) {
return global.removeEventListener(name, _this.listener, true);
});
this.stopped = true;
}
};
return Scheduler;
}());
var scheduler = new Scheduler();
var updateCount = function (n) {
!watching && n > 0 && scheduler.start();
watching += n;
!watching && scheduler.stop();
};
var skipNotifyOnElement = function (target) {
return !isSVG(target)
&& !isReplacedElement(target)
&& getComputedStyle(target).display === 'inline';
};
var ResizeObservation = (function () {
function ResizeObservation(target, observedBox) {
this.target = target;
this.observedBox = observedBox || ResizeObserverBoxOptions.CONTENT_BOX;
this.lastReportedSize = {
inlineSize: -1,
blockSize: -1
};
}
ResizeObservation.prototype.isActive = function () {
var size = calculateBoxSize(this.target, this.observedBox, true);
if (skipNotifyOnElement(this.target)) {
this.lastReportedSize = size;
}
if (this.lastReportedSize.inlineSize !== size.inlineSize
|| this.lastReportedSize.blockSize !== size.blockSize) {
return true;
}
return false;
};
return ResizeObservation;
}());
var ResizeObserverDetail = (function () {
function ResizeObserverDetail(resizeObserver, callback) {
this.activeTargets = [];
this.skippedTargets = [];
this.observationTargets = [];
this.observer = resizeObserver;
this.callback = callback;
}
return ResizeObserverDetail;
}());
var observerMap = new WeakMap();
var getObservationIndex = function (observationTargets, target) {
for (var i = 0; i < observationTargets.length; i += 1) {
if (observationTargets[i].target === target) {
return i;
}
}
return -1;
};
var ResizeObserverController = (function () {
function ResizeObserverController() {
}
ResizeObserverController.connect = function (resizeObserver, callback) {
var detail = new ResizeObserverDetail(resizeObserver, callback);
observerMap.set(resizeObserver, detail);
};
ResizeObserverController.observe = function (resizeObserver, target, options) {
var detail = observerMap.get(resizeObserver);
var firstObservation = detail.observationTargets.length === 0;
if (getObservationIndex(detail.observationTargets, target) < 0) {
firstObservation && resizeObservers.push(detail);
detail.observationTargets.push(new ResizeObservation(target, options && options.box));
updateCount(1);
scheduler.schedule();
}
};
ResizeObserverController.unobserve = function (resizeObserver, target) {
var detail = observerMap.get(resizeObserver);
var index = getObservationIndex(detail.observationTargets, target);
var lastObservation = detail.observationTargets.length === 1;
if (index >= 0) {
lastObservation && resizeObservers.splice(resizeObservers.indexOf(detail), 1);
detail.observationTargets.splice(index, 1);
updateCount(-1);
}
};
ResizeObserverController.disconnect = function (resizeObserver) {
var _this = this;
var detail = observerMap.get(resizeObserver);
detail.observationTargets.slice().forEach(function (ot) {
return _this.unobserve(resizeObserver, ot.target);
});
detail.activeTargets.splice(0, detail.activeTargets.length);
};
return ResizeObserverController;
}());
var ResizeObserver = (function () {
function ResizeObserver(callback) {
if (arguments.length === 0) {
throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
}
if (typeof callback !== 'function') {
throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
}
ResizeObserverController.connect(this, callback);
}
ResizeObserver.prototype.observe = function (target, options) {
if (arguments.length === 0) {
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
}
if (!isElement(target)) {
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
}
ResizeObserverController.observe(this, target, options);
};
ResizeObserver.prototype.unobserve = function (target) {
if (arguments.length === 0) {
throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
}
if (!isElement(target)) {
throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
}
ResizeObserverController.unobserve(this, target);
};
ResizeObserver.prototype.disconnect = function () {
ResizeObserverController.disconnect(this);
};
ResizeObserver.toString = function () {
return 'function ResizeObserver () { [polyfill code] }';
};
return ResizeObserver;
}());
return ResizeObserver;
})();
var ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
var addResizeListener = function (element, fn) {
function addResizeListener(element, fn) {
if (ResizeObserver) {
if (!element.__resizeObserver__) {
var resizeObserver = new ResizeObserver(function () {
element.__resizeListeners__.forEach(function (listener) {
const resizeObserver = new ResizeObserver((() => {
element.__resizeListeners__.forEach(listener => {
BI.$(element).is(":visible") && listener();
});
});
}));
resizeObserver.observe(element);
element.__resizeObserver__ = resizeObserver;
}
@ -574,16 +18,18 @@ var addResizeListener = function (element, fn) {
}
element.__resizeListeners__.push(fn);
}
};
var removeResizeListener = function (element, fn) {
}
function removeResizeListener(element, fn) {
if (ResizeObserver) {
if (BI.isNull(fn)) {
element.__resizeListeners__ = [];
element.__resizeObserver__ && element.__resizeObserver__.unobserve(element);
element.__resizeObserver__ = null;
return;
}
var index = element.__resizeListeners__.indexOf(fn);
const index = element.__resizeListeners__.indexOf(fn);
if (index >= 0) {
element.__resizeListeners__.splice(index, 1);
if (!element.__resizeListeners__.length) {
@ -592,19 +38,17 @@ var removeResizeListener = function (element, fn) {
}
}
}
};
}
export const ResizeDetector = {
addResizeListener: function (widget, fn) {
addResizeListener(widget, fn) {
addResizeListener(widget.element[0], fn);
return function () {
removeResizeListener(widget.element[0], fn);
};
}, removeResizeListener: function (widget, fn) {
},
removeResizeListener(widget, fn) {
removeResizeListener(widget.element[0], fn);
}
},
};
Object.assign(BI, {
ResizeDetector
});

592
src/core/platform/web/dom.js

File diff suppressed because it is too large Load Diff

129
src/core/platform/web/function.js

@ -1,26 +1,32 @@
// 浏览器相关方法
BI._.extend(BI, {
isIE: function () {
import { isString } from "../../2.base";
let __isIE;
export function isIE() {
if (!_global.navigator) {
return false;
}
if (this.__isIE == null) {
this.__isIE = /(msie|trident)/i.test(navigator.userAgent.toLowerCase());
if (!__isIE) {
__isIE = /(msie|trident)/i.test(navigator.userAgent.toLowerCase());
}
return __isIE;
}
return this.__isIE;
},
getIEVersion: function () {
let __IEVersion;
export function getIEVersion() {
if (!_global.navigator) {
return 0;
}
if (this.__IEVersion != null) {
return this.__IEVersion;
if (__IEVersion) {
return __IEVersion;
}
var version = 0;
var agent = navigator.userAgent.toLowerCase();
var v1 = agent.match(/(?:msie\s([\w.]+))/);
var v2 = agent.match(/(?:trident.*rv:([\w.]+))/);
let version = 0;
const agent = navigator.userAgent.toLowerCase();
const v1 = agent.match(/(?:msie\s([\w.]+))/);
const 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]) {
@ -30,92 +36,103 @@ BI._.extend(BI, {
} else {
version = 0;
}
return this.__IEVersion = version;
},
__IEVersion = version;
return __IEVersion;
}
isIE9Below: function () {
if (!BI.isIE()) {
export function isIE9Below() {
if (!isIE()) {
return false;
}
return this.getIEVersion() < 9;
},
isEdge: function () {
return getIEVersion() < 9;
}
export function isEdge() {
if (!_global.navigator) {
return false;
}
return /edg/i.test(navigator.userAgent.toLowerCase());
},
}
isChrome: function () {
export function isChrome() {
if (!_global.navigator) {
return false;
}
return /chrome/i.test(navigator.userAgent.toLowerCase());
},
}
isFireFox: function () {
export function isFireFox() {
if (!_global.navigator) {
return false;
}
return /firefox/i.test(navigator.userAgent.toLowerCase());
},
}
isOpera: function () {
export function isOpera() {
if (!_global.navigator) {
return false;
}
return /opera/i.test(navigator.userAgent.toLowerCase());
},
}
isSafari: function () {
export function isSafari() {
if (!_global.navigator) {
return false;
}
return /safari/i.test(navigator.userAgent.toLowerCase()) && !/chrome/i.test(navigator.userAgent.toLowerCase());
},
}
isKhtml: function () {
export function isKhtml() {
if (!_global.navigator) {
return false;
}
return /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
},
}
isMac: function () {
export function isMac() {
if (!_global.navigator) {
return false;
}
return /macintosh|mac os x/i.test(navigator.userAgent);
},
}
isWindows: function () {
export function isWindows() {
if (!_global.navigator) {
return false;
}
return /windows|win32/i.test(navigator.userAgent);
},
}
isSupportCss3: function (style) {
export function isSupportCss3(style) {
if (!_global.document) {
return false;
}
var prefix = ["webkit", "Moz", "ms", "o"],
i, len,
humpString = [],
htmlStyle = document.documentElement.style,
_toHumb = function (string) {
if (!BI.isString(string)) {
const prefix = ["webkit", "Moz", "ms", "o"];
const humpString = [];
const htmlStyle = document.documentElement.style;
let i;
let len;
function _toHumb(string) {
if (!isString(string)) {
return "";
}
return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase();
});
return string.replace(/-(\w)/g, ($0, $1) => $1.toUpperCase());
};
for (i = 0; i < prefix.length; i++) {
humpString.push(_toHumb(prefix[i] + "-" + style));
humpString.push(_toHumb(`${prefix[i]}-${style}`));
}
humpString.push(_toHumb(style));
@ -124,28 +141,30 @@ BI._.extend(BI, {
return true;
}
}
return false;
},
}
getSafariVersion: function () {
export function getSafariVersion() {
if (!_global.navigator) {
return 0;
}
var agent = navigator.userAgent.toLowerCase();
var version = agent.match(/version\/([\d.]+)/);
const agent = navigator.userAgent.toLowerCase();
const version = agent.match(/version\/([\d.]+)/);
if (version && version[1]) {
return version[1] * 1;
}
return 0;
},
}
getMinimumFontSize: function () {
export function getMinimumFontSize() {
// not work for firefox
const el = document.createElement('div');
const el = document.createElement("div");
el.style.fontSize = "1px";
document.body.appendChild(el);
const size = getComputedStyle(el).fontSize;
el.remove();
return parseInt(size);
return parseInt(size, 10);
}
});

7
src/core/platform/web/index.js

@ -0,0 +1,7 @@
export * as DOM from "./dom";
export * from "./detectElementResize";
export * from "./function";
export * from "./load";
import "./jquery/index";
import "./config";

11051
src/core/platform/web/jquery/_jquery.js vendored

File diff suppressed because it is too large Load Diff

4
src/core/platform/web/jquery/event.js vendored

@ -3,8 +3,8 @@
*/
BI.$.extend(BI.$.Event.prototype, {
// event.stopEvent
stopEvent: function () {
stopEvent() {
this.stopPropagation();
this.preventDefault();
}
},
});

161
src/core/platform/web/jquery/fn.js vendored

@ -1,23 +1,25 @@
if (BI.jQuery) {
(function ($) {
// richer:容器在其各个边缘留出的空间
if (!$.fn.insets) {
$.fn.insets = function () {
var p = this.padding(),
import { isIE, isIE9Below } from "../function";
import { htmlEncode } from "../../../func";
import { toUpperCase, remove, camelize, isKey, isNull, isNotEmptyString, map, hyphenate } from "../../../2.base";
import { makeFirstPY } from "../../../utils";
import { createWidget } from "../../../5.inject";
BI.jQuery.fn.extend({
insets() {
const 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
};
right: p.right + b.right + b.left,
};
}
},
// richer:获取 && 设置jQuery元素的边界
if (!$.fn.bounds) {
$.fn.bounds = function (value) {
var tmp = {hasIgnoredBounds: true};
bounds(value) {
let tmp = { hasIgnoredBounds: true };
if (value) {
if (!isNaN(value.x)) {
@ -39,31 +41,29 @@ if (BI.jQuery) {
// 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()
};
height: this.outerHeight(),
};
}
})(BI.jQuery);
BI.extend(BI.jQuery.fn, {
},
destroy: function () {
destroy() {
this.remove();
if (BI.isIE() === true) {
if (isIE() === true) {
this[0].outerHTML = "";
}
},
/**
* 高亮显示
* @param text 必需
@ -76,31 +76,32 @@ if (BI.jQuery) {
* 2比较tidx和pidx, 取大于-1且较小的索引标红[索引索引 + keyword.length - 1]的文本
* 3text和py各自取tidx/pidx + keyword.length索引开始的子串作为新的text和py, 重复1, 直到text和py有一个为""
*/
__textKeywordMarked__: function (text, keyword, py) {
if (BI.isNull(text)) {
__textKeywordMarked__(text, keyword, py) {
if (isNull(text)) {
text = "";
}
if (!BI.isKey(keyword) || (text + "").length > 100) {
if (BI.isIE9Below()) {
return this.html(BI.htmlEncode(text));
if (!isKey(keyword) || (`${text}`).length > 100) {
if (isIE9Below()) {
return this.html(htmlEncode(text));
}
// textContent性能更好,并且原生防xss
this[0].textContent = text;
return this;
}
keyword = keyword + "";
keyword = BI.toUpperCase(keyword);
var textLeft = text + "";
py = (py || BI.makeFirstPY(text, {
splitChar: "\u200b"
})) + "";
py = BI.toUpperCase(py);
keyword = `${keyword}`;
keyword = toUpperCase(keyword);
let textLeft = `${text}`;
py = `${py || makeFirstPY(text, {
splitChar: "\u200b",
})}`;
py = toUpperCase(py);
this.empty();
// BI-48487 性能: makeFirstPY出来的py中包含多音字是必要的,但虽然此方法中做了限制。但是对于一个长度为60,包含14个多音字的字符串
// 获取的的py长度将达到1966080, 远超过text的长度,到后面都是在做"".substring的无用功,所以此循环应保证py和textLeft长度不为0
while (py.length > 0 && textLeft.length > 0) {
var tidx = BI.toUpperCase(textLeft).indexOf(keyword);
var pidx = py.indexOf(keyword);
const tidx = toUpperCase(textLeft).indexOf(keyword);
let pidx = py.indexOf(keyword);
if (pidx >= 0) {
pidx = (pidx - Math.floor(pidx / (textLeft.length + 1))) % textLeft.length;
}
@ -108,33 +109,29 @@ if (BI.jQuery) {
// BI-56945 场景: 对'啊a'标红, a为keyword, 此时tidx为1, pidx为0, 此时使用tidx显然'啊'就无法标红了
if (tidx >= 0 && (pidx > tidx || pidx === -1)) {
// 标红的text未encode
this.append(BI.htmlEncode(textLeft.substr(0, tidx)));
this.append(htmlEncode(textLeft.substr(0, tidx)));
this.append(BI.$("<span>").addClass("bi-keyword-red-mark")
.html(BI.htmlEncode(textLeft.substr(tidx, keyword.length))));
.html(htmlEncode(textLeft.substr(tidx, keyword.length))));
textLeft = textLeft.substr(tidx + keyword.length);
if (BI.isNotEmptyString(py)) {
if (isNotEmptyString(py)) {
// 每一组拼音都应该前进,而不是只是当前的
py = BI.map(py.split("\u200b"), function (idx, ps) {
return ps.slice(tidx + keyword.length);
}).join("\u200b");
py = map(py.split("\u200b"), (idx, ps) => ps.slice(tidx + keyword.length)).join("\u200b");
}
} else if (pidx >= 0) {
// BI-56386 这边两个pid / text.length是为了防止截取的首字符串不是完整的,但光这样做还不够,即时错位了,也不能说明就不符合条件
// 标红的text未encode
this.append(BI.htmlEncode(textLeft.substr(0, pidx)));
this.append(htmlEncode(textLeft.substr(0, pidx)));
this.append(BI.$("<span>").addClass("bi-keyword-red-mark")
.html(BI.htmlEncode(textLeft.substr(pidx, keyword.length))));
if (BI.isNotEmptyString(py)) {
.html(htmlEncode(textLeft.substr(pidx, keyword.length))));
if (isNotEmptyString(py)) {
// 每一组拼音都应该前进,而不是只是当前的
py = BI.map(py.split("\u200b"), function (idx, ps) {
return ps.slice(pidx + keyword.length);
}).join("\u200b");
py = map(py.split("\u200b"), (idx, ps) => ps.slice(pidx + keyword.length)).join("\u200b");
}
textLeft = textLeft.substr(pidx + keyword.length);
} else {
// 标红的text未encode
this.append(BI.htmlEncode(textLeft));
this.append(htmlEncode(textLeft));
break;
}
}
@ -142,35 +139,36 @@ if (BI.jQuery) {
return this;
},
getDomHeight: function (parent) {
var clone = BI.$(this).clone();
getDomHeight(parent) {
const clone = BI.$(this).clone();
clone.appendTo(BI.$(parent || "body"));
var height = clone.height();
const height = clone.height();
clone.remove();
return height;
},
// 是否有竖直滚动条
hasVerticalScroll: function () {
hasVerticalScroll() {
return this.height() > 0 && this[0].clientWidth < this[0].offsetWidth;
},
// 是否有水平滚动条
hasHorizonScroll: function () {
hasHorizonScroll() {
return this.width() > 0 && this[0].clientHeight < this[0].offsetHeight;
},
// 获取计算后的样式
getStyle: function (name) {
var node = this[0];
var computedStyle = void 0;
getStyle(name) {
const node = this[0];
let 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));
return computedStyle.getPropertyValue(hyphenate(name));
}
}
// Safari
@ -178,7 +176,7 @@ if (BI.jQuery) {
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));
return computedStyle.getPropertyValue(hyphenate(name));
}
if (name === "display") {
return "none";
@ -189,59 +187,66 @@ if (BI.jQuery) {
if (name === "float") {
return node.currentStyle.cssFloat || node.currentStyle.styleFloat;
}
return node.currentStyle[BI.camelize(name)];
return node.currentStyle[camelize(name)];
}
return node.style && node.style[BI.camelize(name)];
return node.style && node.style[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();
__isMouseInBounds__(e) {
const offset2Body = this.get(0).getBoundingClientRect ? this.get(0).getBoundingClientRect() : this.offset();
const width = offset2Body.width || this.outerWidth();
const height = offset2Body.height || this.outerHeight();
// offset2Body.left的值可能会有小数,导致某点出现false
return !(e.pageX < Math.floor(offset2Body.left) || e.pageX > offset2Body.left + width
|| e.pageY < Math.floor(offset2Body.top) || e.pageY > offset2Body.top + height);
},
__hasZIndexMask__: function (zindex) {
__hasZIndexMask__(zindex) {
return zindex && this.zIndexMask[zindex] != null;
},
__buildZIndexMask__: function (zindex, domArray) {
__buildZIndexMask__(zindex, domArray) {
this.zIndexMask = this.zIndexMask || {};// 存储z-index的mask
this.indexMask = this.indexMask || [];// 存储mask
var mask = BI.createWidget({
const mask = createWidget({
type: "bi.center_adapt",
cls: "bi-z-index-mask",
items: domArray
items: domArray,
});
mask.element.css({ "z-index": zindex });
BI.createWidget({
createWidget({
type: "bi.absolute",
element: this,
items: [{
items: [
{
el: mask,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
bottom: 0,
}
],
});
this.indexMask.push(mask);
zindex && (this.zIndexMask[zindex] = mask);
return mask.element;
},
__releaseZIndexMask__: function (zindex) {
__releaseZIndexMask__(zindex) {
if (zindex && this.zIndexMask[zindex]) {
BI.remove(this.indexMask, this.zIndexMask[zindex]);
remove(this.indexMask, this.zIndexMask[zindex]);
this.zIndexMask[zindex].destroy();
return;
}
this.indexMask = this.indexMask || [];
var indexMask = this.indexMask.pop();
const indexMask = this.indexMask.pop();
indexMask && indexMask.destroy();
}
},
});
}

4
src/core/platform/web/jquery/index.js vendored

@ -0,0 +1,4 @@
import "./_jquery";
import "./event";
import "./fn";
import "./jquery.mousewheel";

39
src/core/platform/web/load.js

@ -1,35 +1,38 @@
BI._.extend(BI, {
$import: function () {
var _LOADED = {}; // alex:保存加载过的
const _LOADED = {}; // alex:保存加载过的
function loadReady(src, must) {
var $scripts = BI.$("head script, body script");
BI.$.each($scripts, function (i, item) {
if (item.src.indexOf(src) != -1) {
const $scripts = BI.$("head script, body script");
BI.$.each($scripts, (i, item) => {
if (item.src.indexOf(src) !== -1) {
_LOADED[src] = true;
}
});
var $links = BI.$("head link");
BI.$.each($links, function (i, item) {
if (item.href.indexOf(src) != -1 && must) {
const $links = BI.$("head link");
BI.$.each($links, (i, item) => {
if (item.href.indexOf(src) !== -1 && must) {
_LOADED[src] = false;
BI.$(item).remove();
}
});
}
// must=true 强行加载
return function (src, ext, must) {
/**
*
* @param src
* @param ext
* @param must 强行加载
*/
export function $import(src, ext, must) {
loadReady(src, must);
// alex:如果已经加载过了的,直接return
if (_LOADED[src] === true) {
return;
}
if (ext === "css") {
var link = document.createElement("link");
const link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = src;
var head = document.getElementsByTagName("head")[0];
const head = document.getElementsByTagName("head")[0];
head.appendChild(link);
_LOADED[src] = true;
} else {
@ -39,17 +42,15 @@ BI._.extend(BI, {
dataType: "script", // alex:指定dataType为script,jquery会帮忙做globalEval的事情
async: false,
cache: true,
complete: function (res, status) {
complete(res, status) {
/*
* alex:发现jquery会很智能地判断一下返回的数据类型是不是script,然后做一个globalEval
* 所以当status为success时就不需要再把其中的内容加到script里面去了
*/
if (status == "success") {
if (status === "success") {
_LOADED[src] = true;
}
}
},
});
}
};
}()
});
}

5
src/less/case/calendar/calendar.less

@ -1,5 +0,0 @@
@import "../../index.less";
.bi-calendar-date-item.not-current-month-day {
color: @color-bi-text-disabled-button !important;
}
Loading…
Cancel
Save