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

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

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

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

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

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

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

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

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

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

@ -1,5 +1,6 @@
import { TreeView } from "../treeview";
import { extend, isNotNull, concat, each, shortcut } from "@/core";
import $ from "jquery";
/**
* author: windy
@ -36,7 +37,7 @@ export class Listtreeview extends TreeView {
const self = this;
function onClick(event, treeId, treeNode) {
const zTree = BI.$.fn.zTree.getZTreeObj(treeId);
const zTree = $.fn.zTree.getZTreeObj(treeId);
const checked = treeNode.checked;
self._checkValue(treeNode, !checked);
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 { Asynctree } from "./asynctree";
import { TreeView } from "./treeview";
import $ from "jquery";
/**
* guy
@ -165,7 +166,7 @@ export class PartTree extends Asynctree {
if (self._stop === true) {
return;
}
self.nodes = BI.$.fn.zTree.init(tree.element, setting, nodes);
self.nodes = $.fn.zTree.init(tree.element, setting, nodes);
}
delay(() => {

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

@ -1,5 +1,6 @@
import { extend, shortcut, each, i18nText } from "@/core";
import { TreeView } from "./treeview";
import $ from "jquery";
/**
* guy
@ -65,6 +66,6 @@ export class DisplayTree extends TreeView {
}
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 { each, shortcut, i18nText } from "@/core";
import $ from "jquery";
/**
* guy
@ -70,6 +71,6 @@ export class ListDisplayTree extends Listtreeview {
}
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
} from "@/core";
import { Msg, Pane, LoadingBar, Text } from "@/base";
import $ from "jquery";
@shortcut()
export class TreeView extends Pane {
@ -241,7 +242,7 @@ export class TreeView extends Pane {
track(treeNode.children);
const treeObj = self.nodes;
const nodes = treeObj.getSelectedNodes();
BI.$.each(nodes, (index, node) => {
$.each(nodes, (index, node) => {
node.halfCheck = false;
});
}
@ -416,7 +417,7 @@ export class TreeView extends Pane {
// // 处理标红
// if (BI.isNotNull(n.text)) {
// 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 {
// n.text = BI.htmlEncode(BI.Text.formatText(n.text + ""));
// }
@ -466,7 +467,7 @@ export class TreeView extends Pane {
if (self._stop === true) {
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, {
@ -518,7 +519,7 @@ export class TreeView extends Pane {
},
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() {

9
src/core/4.widget.js

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

13
src/core/conflict.js

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

12
src/core/constant/var.js

@ -142,10 +142,10 @@ export function pixFormat(pix, border) {
if (!isNumber(pix)) {
return pix;
}
if (BI.pixUnit === "px") {
return (pix / BI.pixRatio - (border || 0)) + BI.pixUnit;
if (pixUnit === "px") {
return (pix / pixRatio - (border || 0)) + pixUnit;
}
const length = pix / BI.pixRatio + BI.pixUnit;
const length = pix / pixRatio + pixUnit;
if (border > 0) {
return `calc(${length} - ${`${border}px`})`;
}
@ -157,11 +157,11 @@ export function toPix(pix, border) {
if (!isNumber(pix)) {
return pix;
}
if (BI.pixUnit === "px") {
return pix - (border || 0) * BI.pixRatio;
if (pixUnit === "px") {
return pix - (border || 0) * pixRatio;
}
if (border > 0) {
return `calc(${pix / BI.pixRatio + BI.pixUnit} - ${`${border}px`})`;
return `calc(${pix / pixRatio + pixUnit} - ${`${border}px`})`;
}
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 { Widget } from "../4.widget";
import { _global } from "../0.foundation";
import $ from "jquery";
export class ResizeController extends Controller {
init() {
@ -24,7 +25,7 @@ export class ResizeController extends Controller {
_resize(ev) {
each(this.resizerManger, (key, resizer) => {
if (resizer instanceof BI.$) {
if (resizer instanceof $) {
if (resizer.is(":visible")) {
resizer.trigger("__resize__");
}

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

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

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

@ -1,7 +1,7 @@
import jQuery from "jquery";
import { _global } from "@/core/0.foundation";
// import jQuery from "jquery";
// import { _global } from "@/core/0.foundation";
// todo:先垫着,不然开发会崩
_global.BI = _global.BI || {};
// // todo:先垫着,不然开发会崩
// _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对象添加的工具方法
*/
BI.$.extend(BI.$.Event.prototype, {
$.extend($.Event.prototype, {
// event.stopEvent
stopEvent() {
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 { createWidget } from "../../../5.inject";
import { _global } from "../../../0.foundation";
import $ from "jquery";
BI.jQuery.fn.extend({
$.fn.extend({
insets() {
const p = this.padding(),
@ -111,7 +112,7 @@ BI.jQuery.fn.extend({
if (tidx >= 0 && (pidx > tidx || pidx === -1)) {
// 标红的text未encode
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))));
textLeft = textLeft.substr(tidx + keyword.length);
@ -123,7 +124,7 @@ BI.jQuery.fn.extend({
// BI-56386 这边两个pid / text.length是为了防止截取的首字符串不是完整的,但光这样做还不够,即时错位了,也不能说明就不符合条件
// 标红的text未encode
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))));
if (isNotEmptyString(py)) {
// 每一组拼音都应该前进,而不是只是当前的
@ -141,8 +142,8 @@ BI.jQuery.fn.extend({
},
getDomHeight(parent) {
const clone = BI.$(this).clone();
clone.appendTo(BI.$(parent || "body"));
const clone = $(this).clone();
clone.appendTo($(parent || "body"));
const height = clone.height();
clone.remove();

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

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

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

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

7
src/core/utils/dom.js

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

Loading…
Cancel
Save