Browse Source

KERNEL-14316 chore: 删除 BI.jquery

es6
Treecat 2 years ago
parent
commit
1acb29dbb5
  1. 9
      src/case/ztree/asynctree.js
  2. 4
      src/case/ztree/jquery.ztree.core-3.5.js
  3. 4
      src/case/ztree/jquery.ztree.excheck-3.5.js
  4. 3
      src/case/ztree/list/listasynctree.js
  5. 3
      src/case/ztree/list/listparttree.js
  6. 3
      src/case/ztree/list/listtreeview.js
  7. 3
      src/case/ztree/parttree.js
  8. 3
      src/case/ztree/tree.display.js
  9. 3
      src/case/ztree/tree.list.display.js
  10. 9
      src/case/ztree/treeview.js
  11. 9
      src/core/4.widget.js
  12. 13
      src/core/conflict.js
  13. 12
      src/core/constant/var.js
  14. 3
      src/core/controller/controller.resizer.js
  15. 3
      src/core/platform/web/detectElementResize.js
  16. 10
      src/core/platform/web/jquery/_jquery.js
  17. 4
      src/core/platform/web/jquery/event.js
  18. 11
      src/core/platform/web/jquery/fn.js
  19. 3
      src/core/platform/web/jquery/jquery.mousewheel.js
  20. 14
      src/core/platform/web/load.js
  21. 7
      src/core/utils/dom.js

9
src/case/ztree/asynctree.js

@ -1,6 +1,7 @@
import { cjkEncodeDO, deepClone, each, extend, isEmpty, isNotNull, isNull, shortcut } from "@/core"; import { cjkEncodeDO, deepClone, each, extend, isEmpty, isNotNull, isNull, shortcut } from "@/core";
import { TreeView } from "./treeview"; import { TreeView } from "./treeview";
import { TreeRenderPageService } from "./treerender.page.service"; import { TreeRenderPageService } from "./treerender.page.service";
import $ from "jquery";
@shortcut() @shortcut()
export class Asynctree extends TreeView { export class Asynctree extends TreeView {
@ -18,8 +19,8 @@ export class Asynctree extends TreeView {
const self = this; const self = this;
this.service = new TreeRenderPageService({ this.service = new TreeRenderPageService({
subNodeListGetter(tId) { subNodeListGetter(tId) {
// 获取待检测的子节点列表, ztree并没有获取节点列表dom的API, 此处使用BI.$获取 // 获取待检测的子节点列表, ztree并没有获取节点列表dom的API, 此处使用$获取
return BI.$(`#${self.id} #${tId}_ul`); return $(`#${self.id} #${tId}_ul`);
}, },
}); });
} }
@ -34,7 +35,7 @@ export class Asynctree extends TreeView {
if (treeNode.disabled) { if (treeNode.disabled) {
return false; return false;
} }
const zTree = BI.$.fn.zTree.getZTreeObj(treeId); const zTree = $.fn.zTree.getZTreeObj(treeId);
// 当前点击节点的状态是半选,且为true_part, 则将其改为false_part,使得点击半选后切换到的是全选 // 当前点击节点的状态是半选,且为true_part, 则将其改为false_part,使得点击半选后切换到的是全选
let checked = treeNode.checked; let checked = treeNode.checked;
const status = treeNode.getCheckStatus(); const status = treeNode.getCheckStatus();
@ -63,7 +64,7 @@ export class Asynctree extends TreeView {
track(treeNode.children); track(treeNode.children);
const treeObj = BI.$.fn.zTree.getZTreeObj(treeId); const treeObj = $.fn.zTree.getZTreeObj(treeId);
const nodes = treeObj.getSelectedNodes(); const nodes = treeObj.getSelectedNodes();
each(nodes, (index, node) => { each(nodes, (index, node) => {
node.halfCheck = false; node.halfCheck = false;

4
src/case/ztree/jquery.ztree.core-3.5.js

@ -1,3 +1,5 @@
import $ from "jquery";
/* eslint-disable */ /* eslint-disable */
/* /*
* JQuery zTree core * JQuery zTree core
@ -2205,4 +2207,4 @@
var zt = $.fn.zTree, var zt = $.fn.zTree,
$$ = tools.$, $$ = tools.$,
consts = zt.consts; consts = zt.consts;
})(BI.jQuery); })($);

4
src/case/ztree/jquery.ztree.excheck-3.5.js

@ -1,3 +1,5 @@
import $ from "jquery";
/* eslint-disable */ /* eslint-disable */
/* /*
* JQuery zTree excheck v3.5.18 * JQuery zTree excheck v3.5.18
@ -718,4 +720,4 @@
} }
return html; return html;
}; };
})(BI.jQuery); })($);

3
src/case/ztree/list/listasynctree.js

@ -1,5 +1,6 @@
import { Listtreeview } from "./listtreeview"; import { Listtreeview } from "./listtreeview";
import { cjkEncodeDO, delay, isEmpty, shortcut, extend } from "@/core"; import { cjkEncodeDO, delay, isEmpty, shortcut, extend } from "@/core";
import $ from "jquery";
/** /**
* author: windy * author: windy
@ -23,7 +24,7 @@ export class Listasynctree extends Listtreeview {
} }
function onClick(event, treeId, treeNode) { function onClick(event, treeId, treeNode) {
const zTree = BI.$.fn.zTree.getZTreeObj(treeId); const zTree = $.fn.zTree.getZTreeObj(treeId);
const checked = treeNode.checked; const checked = treeNode.checked;
self._checkValue(treeNode, !checked); self._checkValue(treeNode, !checked);
zTree.checkNode(treeNode, !checked, true, true); zTree.checkNode(treeNode, !checked, true, true);

3
src/case/ztree/list/listparttree.js

@ -1,6 +1,7 @@
import { Listasynctree } from "./listasynctree"; import { Listasynctree } from "./listasynctree";
import { shortcut, extend, Events, delay } from "@/core"; import { shortcut, extend, Events, delay } from "@/core";
import { TreeView } from "../treeview"; import { TreeView } from "../treeview";
import $ from "jquery";
/** /**
* guy * guy
@ -75,7 +76,7 @@ export class ListPartTree extends Listasynctree {
if (self._stop === true) { if (self._stop === true) {
return; return;
} }
self.nodes = BI.$.fn.zTree.init(tree.element, setting, nodes); self.nodes = $.fn.zTree.init(tree.element, setting, nodes);
} }
delay(() => { delay(() => {

3
src/case/ztree/list/listtreeview.js

@ -1,5 +1,6 @@
import { TreeView } from "../treeview"; import { TreeView } from "../treeview";
import { extend, isNotNull, concat, each, shortcut } from "@/core"; import { extend, isNotNull, concat, each, shortcut } from "@/core";
import $ from "jquery";
/** /**
* author: windy * author: windy
@ -36,7 +37,7 @@ export class Listtreeview extends TreeView {
const self = this; const self = this;
function onClick(event, treeId, treeNode) { function onClick(event, treeId, treeNode) {
const zTree = BI.$.fn.zTree.getZTreeObj(treeId); const zTree = $.fn.zTree.getZTreeObj(treeId);
const checked = treeNode.checked; const checked = treeNode.checked;
self._checkValue(treeNode, !checked); self._checkValue(treeNode, !checked);
zTree.checkNode(treeNode, !checked, true, true); zTree.checkNode(treeNode, !checked, true, true);

3
src/case/ztree/parttree.js

@ -1,6 +1,7 @@
import { isEmpty, shortcut, extend, deepClone, each, isNotEmptyArray, Events, delay, isNull } from "@/core"; import { isEmpty, shortcut, extend, deepClone, each, isNotEmptyArray, Events, delay, isNull } from "@/core";
import { Asynctree } from "./asynctree"; import { Asynctree } from "./asynctree";
import { TreeView } from "./treeview"; import { TreeView } from "./treeview";
import $ from "jquery";
/** /**
* guy * guy
@ -165,7 +166,7 @@ export class PartTree extends Asynctree {
if (self._stop === true) { if (self._stop === true) {
return; return;
} }
self.nodes = BI.$.fn.zTree.init(tree.element, setting, nodes); self.nodes = $.fn.zTree.init(tree.element, setting, nodes);
} }
delay(() => { delay(() => {

3
src/case/ztree/tree.display.js

@ -1,5 +1,6 @@
import { extend, shortcut, each, i18nText } from "@/core"; import { extend, shortcut, each, i18nText } from "@/core";
import { TreeView } from "./treeview"; import { TreeView } from "./treeview";
import $ from "jquery";
/** /**
* guy * guy
@ -65,6 +66,6 @@ export class DisplayTree extends TreeView {
} }
initTree(nodes, setting) { initTree(nodes, setting) {
this.nodes = BI.$.fn.zTree.init(this.tree.element, setting || this._configSetting(), nodes); this.nodes = $.fn.zTree.init(this.tree.element, setting || this._configSetting(), nodes);
} }
} }

3
src/case/ztree/tree.list.display.js

@ -1,5 +1,6 @@
import { Listtreeview } from "./list/listtreeview"; import { Listtreeview } from "./list/listtreeview";
import { each, shortcut, i18nText } from "@/core"; import { each, shortcut, i18nText } from "@/core";
import $ from "jquery";
/** /**
* guy * guy
@ -70,6 +71,6 @@ export class ListDisplayTree extends Listtreeview {
} }
initTree(nodes, setting) { initTree(nodes, setting) {
this.nodes = BI.$.fn.zTree.init(this.tree.element, setting || this._configSetting(), nodes); this.nodes = $.fn.zTree.init(this.tree.element, setting || this._configSetting(), nodes);
} }
} }

9
src/case/ztree/treeview.js

@ -26,6 +26,7 @@ import {
STYLE_CONSTANTS STYLE_CONSTANTS
} from "@/core"; } from "@/core";
import { Msg, Pane, LoadingBar, Text } from "@/base"; import { Msg, Pane, LoadingBar, Text } from "@/base";
import $ from "jquery";
@shortcut() @shortcut()
export class TreeView extends Pane { export class TreeView extends Pane {
@ -241,7 +242,7 @@ export class TreeView extends Pane {
track(treeNode.children); track(treeNode.children);
const treeObj = self.nodes; const treeObj = self.nodes;
const nodes = treeObj.getSelectedNodes(); const nodes = treeObj.getSelectedNodes();
BI.$.each(nodes, (index, node) => { $.each(nodes, (index, node) => {
node.halfCheck = false; node.halfCheck = false;
}); });
} }
@ -416,7 +417,7 @@ export class TreeView extends Pane {
// // 处理标红 // // 处理标红
// if (BI.isNotNull(n.text)) { // if (BI.isNotNull(n.text)) {
// if (BI.isKey(o.paras.keyword)) { // if (BI.isKey(o.paras.keyword)) {
// n.text = BI.$("<div>").__textKeywordMarked__(BI.Text.formatText(n.text + ""), o.paras.keyword, n.py).html(); // n.text = $("<div>").__textKeywordMarked__(BI.Text.formatText(n.text + ""), o.paras.keyword, n.py).html();
// } else { // } else {
// n.text = BI.htmlEncode(BI.Text.formatText(n.text + "")); // n.text = BI.htmlEncode(BI.Text.formatText(n.text + ""));
// } // }
@ -466,7 +467,7 @@ export class TreeView extends Pane {
if (self._stop === true) { if (self._stop === true) {
return; return;
} }
self.nodes = BI.$.fn.zTree.init(tree.element, setting, nodes); self.nodes = $.fn.zTree.init(tree.element, setting, nodes);
} }
const op = extend({}, o.paras, { const op = extend({}, o.paras, {
@ -518,7 +519,7 @@ export class TreeView extends Pane {
}, },
callback: {}, callback: {},
}; };
this.nodes = BI.$.fn.zTree.init(this.tree.element, setting || defaultSetting, nodes); this.nodes = $.fn.zTree.init(this.tree.element, setting || defaultSetting, nodes);
} }
start() { start() {

9
src/core/4.widget.js

@ -6,6 +6,7 @@
* @cfg {JSON} options 配置属性 * @cfg {JSON} options 配置属性
*/ */
import $ from "jquery";
import { import {
isFunction, isFunction,
isArray, isArray,
@ -1135,16 +1136,16 @@ Widget.registerRenderEngine({
if (isWidget(widget)) { if (isWidget(widget)) {
const o = widget.options; const o = widget.options;
if (o.element) { if (o.element) {
return BI.$(o.element); return $(o.element);
} }
if (o.tagName) { if (o.tagName) {
return BI.$(document.createElement(o.tagName)); return $(document.createElement(o.tagName));
} }
return BI.$(document.createDocumentFragment()); return $(document.createDocumentFragment());
} }
return BI.$(widget); return $(widget);
}, },
createFragment() { createFragment() {
return document.createDocumentFragment(); return document.createDocumentFragment();

13
src/core/conflict.js

@ -1,7 +1,6 @@
// if (!_global.$ && !_global.jQuery) {
if (!_global.$ && !_global.jQuery) { // _global.jQuery = _global.$ = BI.jQuery;
_global.jQuery = _global.$ = BI.jQuery; // }
} // if (!_global._) {
if (!_global._) { // _global._ = BI._;
_global._ = BI._; // }
}

12
src/core/constant/var.js

@ -142,10 +142,10 @@ export function pixFormat(pix, border) {
if (!isNumber(pix)) { if (!isNumber(pix)) {
return pix; return pix;
} }
if (BI.pixUnit === "px") { if (pixUnit === "px") {
return (pix / BI.pixRatio - (border || 0)) + BI.pixUnit; return (pix / pixRatio - (border || 0)) + pixUnit;
} }
const length = pix / BI.pixRatio + BI.pixUnit; const length = pix / pixRatio + pixUnit;
if (border > 0) { if (border > 0) {
return `calc(${length} - ${`${border}px`})`; return `calc(${length} - ${`${border}px`})`;
} }
@ -157,11 +157,11 @@ export function toPix(pix, border) {
if (!isNumber(pix)) { if (!isNumber(pix)) {
return pix; return pix;
} }
if (BI.pixUnit === "px") { if (pixUnit === "px") {
return pix - (border || 0) * BI.pixRatio; return pix - (border || 0) * pixRatio;
} }
if (border > 0) { if (border > 0) {
return `calc(${pix / BI.pixRatio + BI.pixUnit} - ${`${border}px`})`; return `calc(${pix / pixRatio + pixUnit} - ${`${border}px`})`;
} }
return pix; return pix;

3
src/core/controller/controller.resizer.js

@ -7,6 +7,7 @@ import { Controller } from "./0.controller";
import { isNull, each, debounce, isNotNull, isFunction } from "../2.base"; import { isNull, each, debounce, isNotNull, isFunction } from "../2.base";
import { Widget } from "../4.widget"; import { Widget } from "../4.widget";
import { _global } from "../0.foundation"; import { _global } from "../0.foundation";
import $ from "jquery";
export class ResizeController extends Controller { export class ResizeController extends Controller {
init() { init() {
@ -24,7 +25,7 @@ export class ResizeController extends Controller {
_resize(ev) { _resize(ev) {
each(this.resizerManger, (key, resizer) => { each(this.resizerManger, (key, resizer) => {
if (resizer instanceof BI.$) { if (resizer instanceof $) {
if (resizer.is(":visible")) { if (resizer.is(":visible")) {
resizer.trigger("__resize__"); resizer.trigger("__resize__");
} }

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

@ -1,4 +1,5 @@
import { ResizeObserver as ResizeObserverPolyfill } from "@juggle/resize-observer"; import { ResizeObserver as ResizeObserverPolyfill } from "@juggle/resize-observer";
import $ from "jquery";
const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill; const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
@ -7,7 +8,7 @@ function addResizeListener(element, fn) {
if (!element.__resizeObserver__) { if (!element.__resizeObserver__) {
const resizeObserver = new ResizeObserver((() => { const resizeObserver = new ResizeObserver((() => {
element.__resizeListeners__.forEach(listener => { element.__resizeListeners__.forEach(listener => {
BI.$(element).is(":visible") && listener(); $(element).is(":visible") && listener();
}); });
})); }));
resizeObserver.observe(element); resizeObserver.observe(element);

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

@ -1,7 +1,7 @@
import jQuery from "jquery"; // import jQuery from "jquery";
import { _global } from "@/core/0.foundation"; // import { _global } from "@/core/0.foundation";
// todo:先垫着,不然开发会崩 // // todo:先垫着,不然开发会崩
_global.BI = _global.BI || {}; // _global.BI = _global.BI || {};
_global.BI.jQuery = _global.BI.$ = jQuery; // _global.BI.jQuery = _global.BI.$ = jQuery;

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

@ -1,7 +1,9 @@
import $ from "jquery";
/* /*
* 给jQuery.Event对象添加的工具方法 * 给jQuery.Event对象添加的工具方法
*/ */
BI.$.extend(BI.$.Event.prototype, { $.extend($.Event.prototype, {
// event.stopEvent // event.stopEvent
stopEvent() { stopEvent() {
this.stopPropagation(); this.stopPropagation();

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

@ -4,8 +4,9 @@ import { toUpperCase, remove, camelize, isKey, isNull, isNotEmptyString, map, hy
import { makeFirstPY } from "../../../utils"; import { makeFirstPY } from "../../../utils";
import { createWidget } from "../../../5.inject"; import { createWidget } from "../../../5.inject";
import { _global } from "../../../0.foundation"; import { _global } from "../../../0.foundation";
import $ from "jquery";
BI.jQuery.fn.extend({ $.fn.extend({
insets() { insets() {
const p = this.padding(), const p = this.padding(),
@ -111,7 +112,7 @@ BI.jQuery.fn.extend({
if (tidx >= 0 && (pidx > tidx || pidx === -1)) { if (tidx >= 0 && (pidx > tidx || pidx === -1)) {
// 标红的text未encode // 标红的text未encode
this.append(htmlEncode(textLeft.substr(0, tidx))); this.append(htmlEncode(textLeft.substr(0, tidx)));
this.append(BI.$("<span>").addClass("bi-keyword-red-mark") this.append($("<span>").addClass("bi-keyword-red-mark")
.html(htmlEncode(textLeft.substr(tidx, keyword.length)))); .html(htmlEncode(textLeft.substr(tidx, keyword.length))));
textLeft = textLeft.substr(tidx + keyword.length); textLeft = textLeft.substr(tidx + keyword.length);
@ -123,7 +124,7 @@ BI.jQuery.fn.extend({
// BI-56386 这边两个pid / text.length是为了防止截取的首字符串不是完整的,但光这样做还不够,即时错位了,也不能说明就不符合条件 // BI-56386 这边两个pid / text.length是为了防止截取的首字符串不是完整的,但光这样做还不够,即时错位了,也不能说明就不符合条件
// 标红的text未encode // 标红的text未encode
this.append(htmlEncode(textLeft.substr(0, pidx))); this.append(htmlEncode(textLeft.substr(0, pidx)));
this.append(BI.$("<span>").addClass("bi-keyword-red-mark") this.append($("<span>").addClass("bi-keyword-red-mark")
.html(htmlEncode(textLeft.substr(pidx, keyword.length)))); .html(htmlEncode(textLeft.substr(pidx, keyword.length))));
if (isNotEmptyString(py)) { if (isNotEmptyString(py)) {
// 每一组拼音都应该前进,而不是只是当前的 // 每一组拼音都应该前进,而不是只是当前的
@ -141,8 +142,8 @@ BI.jQuery.fn.extend({
}, },
getDomHeight(parent) { getDomHeight(parent) {
const clone = BI.$(this).clone(); const clone = $(this).clone();
clone.appendTo(BI.$(parent || "body")); clone.appendTo($(parent || "body"));
const height = clone.height(); const height = clone.height();
clone.remove(); clone.remove();

3
src/core/platform/web/jquery/jquery.mousewheel.js

@ -1,4 +1,5 @@
import { _global } from "../../../0.foundation"; import { _global } from "../../../0.foundation";
import $ from "jquery";
/* eslint-disable */ /* eslint-disable */
/* ! /* !
@ -11,7 +12,7 @@ import { _global } from "../../../0.foundation";
(function (factory) { (function (factory) {
// Browser globals // Browser globals
factory(BI.jQuery); factory($);
// if ( typeof define === "function" && define.amd ) { // if ( typeof define === "function" && define.amd ) {
// // AMD. Register as an anonymous module. // // AMD. Register as an anonymous module.
// define(["../core/jquery"], factory); // define(["../core/jquery"], factory);

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

@ -1,16 +1,18 @@
import $ from "jquery";
const _LOADED = {}; // alex:保存加载过的 const _LOADED = {}; // alex:保存加载过的
function loadReady(src, must) { function loadReady(src, must) {
const $scripts = BI.$("head script, body script"); const $scripts = $("head script, body script");
BI.$.each($scripts, (i, item) => { $.each($scripts, (i, item) => {
if (item.src.indexOf(src) !== -1) { if (item.src.indexOf(src) !== -1) {
_LOADED[src] = true; _LOADED[src] = true;
} }
}); });
const $links = BI.$("head link"); const $links = $("head link");
BI.$.each($links, (i, item) => { $.each($links, (i, item) => {
if (item.href.indexOf(src) !== -1 && must) { if (item.href.indexOf(src) !== -1 && must) {
_LOADED[src] = false; _LOADED[src] = false;
BI.$(item).remove(); $(item).remove();
} }
}); });
} }
@ -37,7 +39,7 @@ export function $import(src, ext, must) {
_LOADED[src] = true; _LOADED[src] = true;
} else { } else {
// alex:这里用同步调用的方式,必须等待ajax完成 // alex:这里用同步调用的方式,必须等待ajax完成
BI.$.ajax({ $.ajax({
url: src, url: src,
dataType: "script", // alex:指定dataType为script,jquery会帮忙做globalEval的事情 dataType: "script", // alex:指定dataType为script,jquery会帮忙做globalEval的事情
async: false, async: false,

7
src/core/utils/dom.js

@ -2,13 +2,14 @@
* 对DOM操作的通用函数 * 对DOM操作的通用函数
*/ */
import { each, isEmpty, isNull } from "../2.base"; import { each, isEmpty, isNull } from "../2.base";
import $ from "jquery";
export function ready(fn) { export function ready(fn) {
BI.Widget._renderEngine.createElement(document).ready(fn); BI.Widget._renderEngine.createElement(document).ready(fn);
} }
export function patchProps(fromElement, toElement) { export function patchProps(fromElement, toElement) {
const elemData = BI.jQuery._data(fromElement[0]); const elemData = $._data(fromElement[0]);
const events = elemData.events; const events = elemData.events;
each(events, (eventKey, event) => { each(events, (eventKey, event) => {
each(event, (i, handler) => { each(event, (i, handler) => {
@ -20,7 +21,7 @@ export function patchProps(fromElement, toElement) {
throw new Error("不匹配"); throw new Error("不匹配");
} }
each(fromChildren, (i, child) => { each(fromChildren, (i, child) => {
patchProps(BI.jQuery(child), BI.jQuery(toChildren[i])); patchProps($(child), $(toChildren[i]));
}); });
each(fromElement.data("__widgets"), (i, widget) => { each(fromElement.data("__widgets"), (i, widget) => {
widget.element = toElement; widget.element = toElement;
@ -38,7 +39,7 @@ export function hang(doms) {
const frag = BI.Widget._renderEngine.createFragment(); const frag = BI.Widget._renderEngine.createFragment();
each(doms, (i, dom) => { each(doms, (i, dom) => {
dom instanceof BI.Widget && (dom = dom.element); dom instanceof BI.Widget && (dom = dom.element);
dom instanceof BI.$ && dom[0] && frag.appendChild(dom[0]); dom instanceof $ && dom[0] && frag.appendChild(dom[0]);
}); });
return frag; return frag;

Loading…
Cancel
Save