var Glodon = window.Glodon || {};
window.Glodon = Glodon;
var BimfaceNS = Glodon.Bimface = Glodon.Bimface || {};
var ModuleNS = BimfaceNS.Module = BimfaceNS.Module || {};
!function(l){var a,c,h,t,p,i,d='',v=(v=document.getElementsByTagName("script"))[v.length-1].getAttribute("data-injectcss");if(v&&!l.__iconfont__svg__cssinject__){l.__iconfont__svg__cssinject__=!0;try{document.write("");}catch(l){console&&console.log(l);}}function f(){p||(p=!0,h());}a=function(){var l,a,c;(c=document.createElement("div")).innerHTML=d,d=null,(a=c.getElementsByTagName("svg")[0])&&(a.setAttribute("aria-hidden","true"),a.style.position="absolute",a.style.width=0,a.style.height=0,a.style.overflow="hidden",l=a,(c=document.body).firstChild?(a=c.firstChild).parentNode.insertBefore(l,a):c.appendChild(l));},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(a,0):(c=function(){document.removeEventListener("DOMContentLoaded",c,!1),a();},document.addEventListener("DOMContentLoaded",c,!1)):document.attachEvent&&(h=a,t=l.document,p=!1,(i=function(){try{t.documentElement.doScroll("left");}catch(l){return void setTimeout(i,50)}f();})(),t.onreadystatechange=function(){"complete"==t.readyState&&(t.onreadystatechange=null,f());});}(window);
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
/** @deprecated */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
// 事件处理基类
var EventManager = /** @class */ (function () {
function EventManager() {
this._eventContainer = {};
}
// 添加监听事件
EventManager.prototype.addEvent = function (type, fn) {
this._eventContainer[type] = this._eventContainer[type] || [];
this._eventContainer[type].push(fn);
return this;
};
// 删除监听事件
EventManager.prototype.removeEvent = function (type, fn) {
if (this._eventContainer[type]) {
var index = this._eventContainer[type].indexOf(fn);
index >= 0 && this._eventContainer[type].splice(index, 1);
}
return this;
};
// 触发监听事件
EventManager.prototype.fireEvent = function (type) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (type && this._eventContainer[type]) {
__spreadArrays(this._eventContainer[type]).forEach(function (fn) {
fn.apply(null, args);
});
}
return this;
};
// reset
EventManager.prototype.reset = function () {
this._eventContainer = {};
};
return EventManager;
}());
// 事件处理类
var EventEmmiter = /** @class */ (function (_super) {
__extends(EventEmmiter, _super);
function EventEmmiter() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._onceEvents = {};
_this._pausedEvents = {};
return _this;
}
// 增加监听事件
EventEmmiter.prototype.on = function (type, fn) {
return this.addEvent(type, fn);
};
// 删除监听事件
EventEmmiter.prototype.off = function (type, fn) {
var index;
if (this._onceEvents[type]) { // once列表中查找并删除此事件
(index = this._onceEvents[type].indexOf(fn)) >= 0 && this._onceEvents[type].splice(index, 1);
this._onceEvents[type].length === 0 && delete this._onceEvents[type];
}
if (this._pausedEvents[type]) { // pause列表中查找并删除此事件
(index = this._pausedEvents[type].indexOf(fn)) >= 0 && this._pausedEvents[type].splice(index, 1);
this._pausedEvents[type].length === 0 && delete this._pausedEvents[type];
}
return this.removeEvent(type, fn);
};
// 触发一类监听事件
EventEmmiter.prototype.trigger = function (type) {
var _this = this;
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (!this._eventContainer[type])
return this;
var originEvents = __spreadArrays(this._eventContainer[type]);
if (this._pausedEvents[type]) { // 此类监听事件中存在pause项时,另外记录完整的事件数组,并在现有的数组中删除pause项
this._pausedEvents[type].forEach(function (fn) {
_this.removeEvent(type, fn);
});
}
this.fireEvent.apply(this, __spreadArrays([type], args));
this._eventContainer[type] = originEvents; // 恢复完整的事件数组
if (this._onceEvents[type]) { // 单次执行的事件,执行后从数组中删除
this._onceEvents[type].forEach(function (fn) {
(!_this._pausedEvents[type] || _this._pausedEvents[type].indexOf(fn) < 0) && _this.off(type, fn); // 排除once事件pause状态
});
}
return this;
};
// 增加单次执行的事件
EventEmmiter.prototype.once = function (type, fn) {
this.on(type, fn);
this._onceEvents[type] = this._onceEvents[type] || [];
this._onceEvents[type].indexOf(fn) < 0 && this._onceEvents[type].push(fn);
return this;
};
// 暂停事件
EventEmmiter.prototype.pause = function (type, fn) {
this._pausedEvents[type] = this._pausedEvents[type] || [];
this._pausedEvents[type].indexOf(fn) < 0 && this._pausedEvents[type].push(fn);
return this;
};
// 恢复事件
EventEmmiter.prototype.resume = function (type, fn) {
if (!this._pausedEvents[type])
return this;
var index = this._pausedEvents[type].indexOf(fn);
index >= 0 && this._pausedEvents[type].splice(index, 1);
this._pausedEvents[type].length === 0 && delete this._pausedEvents[type];
return this;
};
EventEmmiter.prototype.reset = function () {
this._onceEvents = {};
this._pausedEvents = {};
_super.prototype.reset.call(this);
};
return EventEmmiter;
}(EventManager));
// 此对象用于简化处理各类数据,包括判断数据类型、判断属性、及数据的各类其他操作等,待丰富
var DataUtil = {
// 用于判断数据类型
assertType: function (param, typeName) {
var assert = function (fullTypeName) { return Object.prototype.toString.call(param) === "[object " + fullTypeName + "]"; };
switch (typeName) {
case 'obj':
case 'Obj':
case 'object':
case 'Object':
return assert('Object');
case 'arr':
case 'Arr':
case 'array':
case 'Array':
return assert('Array');
case 'num':
case 'Num':
case 'number':
case 'Number':
return assert('Number');
case 'func':
case 'Func':
case 'function':
case 'Function':
return assert('Function');
case 'str':
case 'Str':
case 'string':
case 'String':
return assert('String');
default:
return assert(typeName);
}
},
// 判断多个参数是否都是某个数据类型(参数平铺传入,最后一个参数是类型名)
assertParamsType: function () {
var _this = this;
var params = [];
for (var _i = 0; _i < arguments.length; _i++) {
params[_i] = arguments[_i];
}
if (params.length > 1) {
var typeName_1 = params.splice(params.length - 1, 1)[0];
var result_1 = true;
params.every(function (param) {
result_1 = _this.assertType(param, typeName_1);
return result_1;
});
return result_1;
}
},
// 判断对象是否包含某属性
hasProperty: function (param, propertyName) {
if (this.assertType(param, 'obj')) {
return param[propertyName] !== undefined;
}
},
// 颜色转换 hex to rgb
hexToRgb: function (hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
red: parseInt(result[1], 16),
green: parseInt(result[2], 16),
blue: parseInt(result[3], 16)
} : null;
},
componentToHex: function (c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
},
// 颜色转换 rgb to hex
rgbToHex: function (r, g, b) {
return "#" + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b);
}
};
// DomElement操作工具类
var Dom = /** @class */ (function () {
function Dom(element) {
this.eventMap = {};
this.element = element;
}
// 创建DomElement对象(使用空的Dom对象初始化时调用)
Dom.prototype.createElement = function (param) {
var element = document.createElement(param.elementType);
var className = param.className;
if (className) {
DataUtil.assertType(className, 'arr') && (className = className.join(' '));
element.className = className;
}
param.id && (element.id = param.id);
var domObject = new Dom(element);
if (param.parent) {
var parent_1 = param.parent instanceof Dom ? param.parent : new Dom(param.parent);
parent_1.append(domObject);
}
domObject.visible = true;
return domObject; // 返回一个新的以DomElement为参数创建的Dom对象以进行后续的链式操作
};
// 获取HTTPElement对象
Dom.prototype.getElement = function () {
return this.element;
};
// 获取父元素HTTPElement对象
Dom.prototype.getParent = function () {
return this.element.parentElement;
};
// 末尾附加一个子元素
Dom.prototype.append = function (childElement) {
this.element.appendChild(childElement.element);
return this;
};
// 附加一个子元素到指定位置
Dom.prototype.insert = function (childElement, index) {
if (index !== undefined && this.element.childNodes.length > index) {
this.element.insertBefore(childElement.element, this.element.childNodes[index]);
}
else {
this.append(childElement);
}
return this;
};
// 删除一个子元素
Dom.prototype.remove = function (childElement) {
this.element.removeChild(childElement.element);
return this;
};
// 删除所有子元素
Dom.prototype.clear = function () {
while (this.element.childNodes.length > 0) {
this.element.removeChild(this.element.childNodes[0]);
}
return this;
};
// 替换元素
Dom.prototype.replace = function (newElement, oldElement) {
this.element.replaceChild(newElement.getElement(), oldElement.getElement());
return this;
};
// 显示对象
Dom.prototype.show = function () {
if (this.visible)
return this;
this.element.style.display = this.displayType;
this.visible = true;
return this;
};
// 隐藏对象
Dom.prototype.hide = function () {
if (!this.visible)
return this;
if (this.element) {
this.displayType = this.element.style.display;
this.displayType === 'none' && (this.displayType = undefined);
this.element.style.display = 'none';
this.visible = false;
}
return this;
};
// 获取可见性
Dom.prototype.isVisible = function () {
return this.visible;
};
// 添加dom事件监听
Dom.prototype.on = function (eventType, fn, option) {
if (option === void 0) { option = null; }
this.element.addEventListener(eventType, fn, option);
this.eventMap[eventType] = this.eventMap[eventType] || [];
this.eventMap[eventType].push(fn);
return this;
};
// 删除dom事件监听
Dom.prototype.off = function (eventType, fn) {
this.element.removeEventListener(eventType, fn);
if (this.eventMap[eventType]) {
var index = this.eventMap[eventType].indexOf(fn);
index >= 0 && this.eventMap[eventType].splice(index, 1);
}
return this;
};
// 销毁对象
Dom.prototype.destroy = function () {
var _this = this;
var _loop_1 = function (eventType) {
this_1.eventMap[eventType].forEach(function (fn) {
_this.off(eventType, fn);
});
};
var this_1 = this;
for (var eventType in this.eventMap) {
_loop_1(eventType);
}
this.element.parentElement && this.element.parentElement.removeChild(this.element);
this.eventMap = undefined;
this.displayType = undefined;
this.themeType = undefined;
this.element = undefined;
};
Dom.prototype.getClass = function () {
return this.getElement().getAttribute('class');
};
Dom.prototype.hasClass = function (className) {
var currentClassName = this.getClass();
if (!currentClassName)
return false;
var arr = currentClassName && currentClassName.split(' ');
if (arr.indexOf(className) > -1) {
return true;
}
else {
return false;
}
};
// 添加一个或多个css class
Dom.prototype.addClass = function () {
var _a;
var classes = [];
for (var _i = 0; _i < arguments.length; _i++) {
classes[_i] = arguments[_i];
}
(_a = this.element.classList).add.apply(_a, classes);
return this;
};
// 删除一个或多个css class
Dom.prototype.removeClass = function () {
var _a;
var classes = [];
for (var _i = 0; _i < arguments.length; _i++) {
classes[_i] = arguments[_i];
}
(_a = this.element.classList).remove.apply(_a, classes);
return this;
};
Dom.prototype.toggleClass = function (className, enable) {
this.getClass(); var hasClassName = this.hasClass(className);
if (enable != undefined) {
if (enable && !hasClassName) {
this.addClass(className);
}
if (!enable) {
this.removeClass(className);
}
}
else {
if (hasClassName) {
this.removeClass(className);
}
else {
this.addClass(className);
}
}
return !hasClassName;
};
// toggle一个css class
Dom.prototype.toggle = function (classname) {
this.element.classList.toggle(classname);
return this;
};
// 获取元素当前在页面中的位置
Dom.prototype.getPosition = function () {
var _a = this.element.getBoundingClientRect(), top = _a.top, left = _a.left, right = _a.right, bottom = _a.bottom;
return { top: top, left: left, right: right, bottom: bottom };
};
// 获取元素的尺寸信息
Dom.prototype.getDimensions = function () {
var _a = this.element.getBoundingClientRect(), width = _a.width, height = _a.height;
return { width: width, height: height };
};
// 获取元素宽度
Dom.prototype.getWidth = function () {
var width = this.element.getBoundingClientRect().width;
return width;
};
// 获取元素高度
Dom.prototype.getHeight = function () {
var height = this.element.getBoundingClientRect().height;
return height;
};
// 获取或设置元素的内容
Dom.prototype.html = function (htmlContent) {
if (htmlContent != undefined) {
this.element.innerHTML = htmlContent;
return this;
}
else {
return this.element.innerHTML;
}
};
// 获取单个css属性或设置单个/多个css属性
Dom.prototype.css = function (key, value) {
if (DataUtil.assertType(key, 'str')) {
if (value) {
this.element.style[key] = value;
return this;
}
else {
return this.element.style[key];
}
}
else if (DataUtil.assertType(key, 'obj')) {
var cssOptions = key;
for (var cssKey in cssOptions) {
this.element.style[cssKey] = cssOptions[cssKey];
}
return this;
}
};
// 获取单个attribute属性或设置单个/多个attribute属性
Dom.prototype.attribute = function (key, value) {
if (DataUtil.assertType(key, 'str')) {
if (value != undefined) {
this.element[key] = value;
return this;
}
else {
return this.element[key];
}
}
else if (DataUtil.assertType(key, 'obj')) {
var attrOptions = key;
for (var attrKey in attrOptions) {
this.element[attrKey] = attrOptions[attrKey];
}
return this;
}
};
// 获取或设置元素的主题
Dom.prototype.theme = function (themeType) {
if (themeType) {
this.themeType && this.removeClass(this.themeType);
this.themeType = themeType;
this.addClass(themeType);
return this;
}
else {
return this.themeType;
}
};
// 点击组件
Dom.prototype.click = function () {
this.element.click();
return this;
};
return Dom;
}());
var BaseModule = /** @class */ (function () {
function BaseModule(config) {
this.data = {};
this._config = config;
this.domElement = new Dom().createElement({ elementType: 'div', className: 'bfui-app' });
if (config.webApplication3D) {
this.domElement.hide();
var appDom = config.webApplication3D.getViewer()._opt.domElement;
var parentDom = appDom.parentElement;
this._originAppInfo = {
replaced: false,
parentDom: parentDom,
app: config.webApplication3D,
};
config.domElement = config.domElement || parentDom;
}
config.domElement.appendChild(this.domElement.getElement());
this._eventEmmiter = new EventEmmiter();
this._moduleData = BaseModule.getCurrentModuleData();
}
BaseModule.prototype.getDomElement = function () {
return this.domElement;
};
BaseModule.prototype.getConfig = function () {
return this._config;
};
BaseModule.prototype.getModuleData = function () {
return this._moduleData;
};
BaseModule.prototype.getApp3D = function () {
return this._app3d;
};
BaseModule.prototype.getViewer3D = function () {
return this._viewer3d;
};
BaseModule.prototype.getModelType = function () {
return this._modelType;
};
BaseModule.prototype._initApp = function (options) {
var _this = this;
return new Promise(function (resolve, reject) {
var app = _this.getConfig().webApplication3D;
var successCb = function (viewMetaData) {
viewMetaData.viewType = viewMetaData.viewType || (viewMetaData.renderType == "bimView" ? "3DView" : viewMetaData.renderType);
var replaceAppDom = function () {
if (!_this._originAppInfo)
return;
_this.domElement.show();
_this._originAppInfo.replaced = true;
var currentApp = _this._originAppInfo.app;
currentApp.setDomElement(options.domElement);
};
if (viewMetaData.viewType === "drawingView") {
if (!app || app.getViewer().getViewerType() !== 'ViewerDrawing') {
var WebAppConfig = new Glodon.Bimface.Application.WebApplicationDrawingConfig();
WebAppConfig.domElement = options.domElement;
app = new Glodon.Bimface.Application.WebApplicationDrawing(WebAppConfig);
}
else {
replaceAppDom();
}
app.getViewer().loadDrawing({ viewMetaData: viewMetaData });
app.addEventListener(Glodon.Bimface.Application.WebApplicationDrawingEvent.ViewAdded, function () {
_this._eventEmmiter.trigger('ModuleInitialized');
resolve(app); // 返回具体的app对象,可在各个具体的子类中管理app
});
}
else if (viewMetaData.viewType === "3DView") {
if (!app || app.getViewer().getViewerType() !== 'Viewer3D') {
var WebAppConfig = new Glodon.Bimface.Application.WebApplication3DConfig();
WebAppConfig.domElement = options.domElement;
options.modelButtons && (WebAppConfig.Buttons = options.modelButtons);
app = new Glodon.Bimface.Application.WebApplication3D(WebAppConfig);
}
else {
replaceAppDom();
}
_this._app3d = app;
_this._viewer3d = app.getViewer();
_this._modelId = viewMetaData.modelId;
_this._modelType = viewMetaData.modelType;
var setConfigs_1 = function () {
// 配置信息,初始化保存在app下,便于后续统一维护
app.linkConfig = {
name: _this._viewer3d.getModels()[0]._data.name,
displayType: "Parallel",
showDrawingMaintoolbar: true,
showDrawingList: true,
showDrawingSearchTool: true,
showModelMaintoolbar: true,
showModelTreeToolbar: true,
showModelViewHouse: true,
};
// 链接的图纸信息
app.linkList = [];
};
// 预览时没有加载的模型,先加载模型
if (_this._viewer3d.getModels().length == 0) {
_this._viewer3d.loadModel({ viewMetaData: viewMetaData });
app.addEventListener("ModelAdded", function () {
setConfigs_1();
});
}
else {
setConfigs_1();
}
if (app.getViewer().getModels().filter(function (model) { return model.modelId == viewMetaData.modelId; }).length === 0) {
app.getViewer().loadModel({ viewMetaData: viewMetaData });
app.addEventListener(Glodon.Bimface.Application.WebApplication3DEvent.ModelAdded, function (modelId) {
if (viewMetaData.modelId == modelId) {
_this._eventEmmiter.trigger('ModuleInitialized');
_this._getFloors(modelId);
resolve(app);
}
});
}
else {
_this._getFloors(viewMetaData.modelId);
requestAnimationFrame(function () { return _this._eventEmmiter.trigger('ModuleInitialized'); });
resolve(app);
}
}
};
var errorCb = function (e) {
console.log(e);
reject();
};
if (options.viewMetaData) {
var metaData = __assign(__assign({}, options.viewMetaData), { viewToken: BaseModule._currentModuleData.viewToken });
successCb(metaData);
}
else if (app) {
successCb({
viewType: "3DView",
modelId: app.getViewer().getModel()._data.modelId,
modelType: app.getViewer().getModel()._data.modelType,
});
}
else {
var loaderConfig = new window.BimfaceSDKLoaderConfig();
loaderConfig = __assign(__assign({}, loaderConfig), _this.getConfig());
loaderConfig.viewToken = loaderConfig.viewToken || options.viewToken;
window.BimfaceSDKLoader.load(loaderConfig).then(successCb).catch(errorCb);
}
});
};
BaseModule.prototype._getFloors = function (modelId) {
var _this = this;
this.getViewer3D().getModel(modelId).getFloors(function (data) {
if (data) {
_this.floors = data;
}
});
};
BaseModule.prototype.getFloors = function () {
return this.floors;
};
BaseModule.prototype.addEventListener = function (type, fn) {
this._eventEmmiter.on(type, fn);
};
BaseModule.prototype.removeEventListener = function (type, fn) {
this._eventEmmiter.off(type, fn);
};
BaseModule.prototype.destroy = function () {
if (this._destroyed)
return;
this._config = null;
if (this._originAppInfo) {
if (this._originAppInfo.replaced) {
var _a = this._originAppInfo, parentDom = _a.parentDom, app = _a.app;
app.setDomElement(parentDom);
}
}
this.domElement.destroy();
this._eventEmmiter.trigger('ModuleDestroyed');
this._destroyed = true;
};
return BaseModule;
}());
BaseModule.setCurrentModuleData = function (moduleData) {
BaseModule._currentModuleData = moduleData;
};
BaseModule.getCurrentModuleData = function () { return BaseModule._currentModuleData; };
var ajax = function (options) {
return new Promise(function (resolve, reject) {
var defaults = {
type: 'get',
data: null,
};
var _opt = __assign(__assign({}, defaults), options);
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
var status = xmlhttp.status;
if (status >= 200 && status < 300 || status == 304 || (status === 0 && window.location.protocol === 'file:')) {
var json = void 0;
try {
json = JSON.parse(xmlhttp.responseText);
}
catch (error) {
throw error;
}
resolve({
json: json,
responseText: xmlhttp.responseText,
responseXML: xmlhttp.responseXML,
});
}
else {
reject(status);
}
}
};
xmlhttp.open(_opt.type, _opt.url, _opt.async);
xmlhttp.send(_opt.data);
});
};
var ClashDetectiveModule = /** @class */ (function (_super) {
__extends(ClashDetectiveModule, _super);
function ClashDetectiveModule(config) {
return _super.call(this, config) || this;
}
ClashDetectiveModule.prototype._initApp = function (options) {
var _this = this;
var _a, _b, _c;
this._clashDetectiveId = options.clashDetectiveId;
var viewMetaData = options.viewMetaData;
this._modelId = viewMetaData.modelId;
this._modelType = viewMetaData.modelType;
this._clashDetectiveViewToken = viewMetaData.viewToken;
var selectionInfo = (_c = (_b = (_a = BaseModule._currentModuleData) === null || _a === void 0 ? void 0 : _a.multiModelClashDetectiveList) === null || _b === void 0 ? void 0 : _b.items[0]) === null || _c === void 0 ? void 0 : _c.selectionA[0];
var fileType = selectionInfo.fileType, fileName = selectionInfo.fileName;
return new Promise(function (resolve, reject) {
var successCb = function (viewMetaData) {
var WebAppConfig = new Glodon.Bimface.Application.WebApplication3DConfig();
WebAppConfig.domElement = options.domElement;
var app = new Glodon.Bimface.Application.WebApplication3D(WebAppConfig);
_this._app3d = app;
_this._viewer3d = app.getViewer();
var setConfigs = function () {
var unitType = _this._viewer3d.getUnit();
var modelUnit = unitType;
var models = _this._viewer3d.getModels();
if (models === null || models === void 0 ? void 0 : models.length) {
modelUnit = models[0]._manifest.Metadata.Unit === 'm' ? 'Meter' : 'Millimeter';
}
app.clashDetectiveConfig = {
unitType: unitType,
modelUnit: modelUnit,
makeOthersTranslucent: window.Glodon.Bimface.Viewer.IsolateOption.MakeOthersTranslucent
};
var getFilesInfo = function (viewer) {
var modelType = viewMetaData.modelType;
var filesInfo = new Map();
if (modelType === 'INTEGRATE') {
viewer.getModel().getFiles(function (f) {
f.map(function (data) { return filesInfo.set(String(data.fileId), { fileName: data.fileName, fileType: data.fileType }); });
app.clashDetectiveConfig.filesInfo = filesInfo;
_this._eventEmmiter.trigger(Glodon.Bimface.Module.ClashDetective.WebApplicationEvent.FilesInfoAdded);
});
}
else {
filesInfo.set(String(viewMetaData.modelId), { fileName: fileName, fileType: fileType });
app.clashDetectiveConfig.filesInfo = filesInfo;
_this._eventEmmiter.trigger(Glodon.Bimface.Module.ClashDetective.WebApplicationEvent.FilesInfoAdded);
}
};
getFilesInfo(_this._viewer3d);
};
// 预览时没有加载的模型,先加载模型
if (_this._viewer3d.getModels().length == 0) {
_this._viewer3d.loadModel({ viewMetaData: viewMetaData });
app.addEventListener(Glodon.Bimface.Application.WebApplication3DEvent.ModelAdded, function () {
setConfigs();
_this._eventEmmiter.trigger(Glodon.Bimface.Module.ClashDetective.WebApplicationEvent.ModelAdded);
resolve(app);
});
}
else {
setConfigs();
requestAnimationFrame(function () { return _this._eventEmmiter.trigger(Glodon.Bimface.Module.ClashDetective.WebApplicationEvent.ModelAdded); });
resolve(app);
}
};
var errorCb = function (e) {
console.log(e);
reject();
};
if (viewMetaData) {
successCb(viewMetaData);
}
else {
var loaderConfig = new window.BimfaceSDKLoaderConfig();
loaderConfig = __assign(__assign({}, loaderConfig), _this.getConfig());
window.BimfaceSDKLoader.load(loaderConfig).then(successCb).catch(errorCb);
}
});
};
ClashDetectiveModule.prototype._getClashResults = function () {
var _this = this;
return new Promise(function (resolve, reject) {
_this.fetchClashResults(_this._clashDetectiveId, _this._clashDetectiveViewToken).then(function (res) {
var _a;
_this._clashResults = (_a = res === null || res === void 0 ? void 0 : res.json) === null || _a === void 0 ? void 0 : _a.results;
resolve(res === null || res === void 0 ? void 0 : res.json);
}).catch(function (e) {
reject(e);
});
});
};
ClashDetectiveModule.prototype._getClashGroups = function () {
var _this = this;
return new Promise(function (resolve, reject) {
_this.fetchClashGroups(_this._clashDetectiveId, _this._clashDetectiveViewToken).then(function (res) {
_this._clashGroups = res === null || res === void 0 ? void 0 : res.groups;
resolve(res === null || res === void 0 ? void 0 : res.groups);
}).catch(function (e) {
reject(e);
});
});
};
ClashDetectiveModule.prototype.fetchClashResults = function (clashDetectiveId, viewToken) {
return new Promise(function (resolve, reject) {
ajax({
type: 'get',
url: window.hostConfig.APIHost + "/data/v2/clash-detective/" + clashDetectiveId + "/result?view_token=" + viewToken,
}).then(function (res) {
if (res.json.code === 'bimfaceservice-0000' || res.json.code === 'success') {
var data = res.json.data;
ajax({
type: 'get',
dataType: 'json',
url: data
}).then(function (res1) {
resolve(res1);
});
}
else {
reject(res.json);
}
});
});
};
ClashDetectiveModule.prototype.fetchClashGroups = function (clashDetectiveId, viewToken) {
return new Promise(function (resolve, reject) {
ajax({
type: 'get',
url: window.hostConfig.APIHost + "/data/v2/clash-detective/" + clashDetectiveId + "/result-groups?view_token=" + viewToken,
}).then(function (res) {
if (res.json.code === 'bimfaceservice-0000' || res.json.code === 'success') {
resolve(res.json.data);
}
else {
reject(res.json);
}
});
});
};
return ClashDetectiveModule;
}(BaseModule));
var UIEvents;
(function (UIEvents) {
UIEvents["ValueChanged"] = "ValueChanged";
UIEvents["Clicked"] = "Clicked";
UIEvents["RightClicked"] = "RightClicked";
UIEvents["MouseOver"] = "MouseOver";
UIEvents["MouseOut"] = "MouseOut";
UIEvents["CheckedChanged"] = "CheckedChanged";
UIEvents["SelectionChanged"] = "SelectionChanged";
UIEvents["ExpendChanged"] = "ExpendChanged";
UIEvents["IsolateChanged"] = "IsolateChanged"; // 是否隔离
})(UIEvents || (UIEvents = {}));
var UIEvents$1 = UIEvents;
/**
* @namespace Glodon.Bimface.Tiles.UI.ControlAnchor
* @classdesc 常量:UI锚点(用以进行控件定位)
* @description Glodon.Bimface.Tiles.UI.ControlAnchor
* @property {String} TopLeft 视图左上角
* @property {String} TopCenter 视图中上侧
* @property {String} TopRight 视图右上角
* @property {String} MiddleLeft 视图左中侧
* @property {String} MiddleRight 视图右中侧
* @property {String} BottomLeft 视图左下角
* @property {String} BottomCenter 视图中下侧
* @property {String} BottomRight 视图右下角
* @property {String} MiddleCenter 视图中心
*/
var ControlAnchor;
(function (ControlAnchor) {
ControlAnchor["TopLeft"] = "TopLeft";
ControlAnchor["TopCenter"] = "TopCenter";
ControlAnchor["TopRight"] = "TopRight";
ControlAnchor["MiddleLeft"] = "MiddleLeft";
ControlAnchor["MiddleRight"] = "MiddleRight";
ControlAnchor["BottomLeft"] = "BottomLeft";
ControlAnchor["BottomCenter"] = "BottomCenter";
ControlAnchor["BottomRight"] = "BottomRight";
ControlAnchor["MiddleCenter"] = "MiddleCenter";
})(ControlAnchor || (ControlAnchor = {}));
var ControlAnchor$1 = ControlAnchor;
// UI组件基类
var Control = /** @class */ (function (_super) {
__extends(Control, _super);
function Control(param) {
var _this = _super.call(this) || this;
if (param.className) {
param.elementParam.className = (param.elementParam.className || '') + ' ' + param.className;
}
_this._domElement = param.element || new Dom().createElement(param.elementParam);
if (param.parent) {
var parentElement = param.parent instanceof Control ? param.parent._domElement
: param.parent instanceof Dom ? param.parent : new Dom(param.parent);
parentElement.append(_this._domElement);
param.parent instanceof Control && (_this._parent = param.parent);
}
_this.id = param.id || param.ref; // || uuid
_this.type = param.type;
_this.position = { anchor: 'TopLeft', offset: { x: 0, y: 0 } };
return _this;
}
//
Control.prototype.getParent = function () {
return this._parent;
};
// 设置本对象的父级Control对象
Control.prototype.setParent = function (control) {
this._parent = control;
};
// 获取DomElement对象
Control.prototype.getDomElement = function () {
return this._domElement;
};
// 设置点击事件
Control.prototype.onClick = function (fn) {
var _this = this;
this._domElement.on('click', function (eventData) {
fn(eventData);
_this.trigger(UIEvents$1.Clicked, _this);
});
return this;
};
// 设置鼠标移入事件
Control.prototype.onMouseOver = function (fn) {
var _this = this;
this._domElement.on('mouseover', function (eventData) {
fn(eventData);
_this.trigger(UIEvents$1.MouseOver, _this);
});
return this;
};
// 设置鼠标移出事件
Control.prototype.onMouseOut = function (fn) {
var _this = this;
this._domElement.on('mouseout', function (eventData) {
fn(eventData);
_this.trigger(UIEvents$1.MouseOut, _this);
});
return this;
};
/**
* 显示
* @function Glodon.Bimface.Tiles.UI.Control.prototype.show
*/
Control.prototype.show = function () {
this._domElement.show();
return this;
};
/**
* 隐藏
* @function Glodon.Bimface.Tiles.UI.Control.prototype.hide
*/
Control.prototype.hide = function () {
this._domElement.hide();
return this;
};
/**
* 获取可见性状态
* @function Glodon.Bimface.Tiles.UI.Control.prototype.isVisible
* @returns {Boolean} 可见性状态
*/
Control.prototype.isVisible = function () {
return this._domElement.isVisible();
};
// 销毁
Control.prototype.destroy = function () {
this._domElement.destroy();
};
/**
* 对组件增加CSS样式
* @function Glodon.Bimface.Tiles.UI.Control.prototype.addClass
* @param {String} class CSS类名
*/
Control.prototype.addClass = function () {
var _a;
var classes = [];
for (var _i = 0; _i < arguments.length; _i++) {
classes[_i] = arguments[_i];
}
(_a = this._domElement).addClass.apply(_a, classes);
return this;
};
/**
* 对组件移除CSS样式
* @function Glodon.Bimface.Tiles.UI.Control.prototype.removeClass
* @param {String} class CSS类名
*/
Control.prototype.removeClass = function () {
var _a;
var classes = [];
for (var _i = 0; _i < arguments.length; _i++) {
classes[_i] = arguments[_i];
}
(_a = this._domElement).removeClass.apply(_a, classes);
return this;
};
// 删除一个或多个css class
Control.prototype.toggleClass = function (className) {
this._domElement.toggleClass(className);
return this;
};
/**
* 设置组件的位置信息
* @function Glodon.Bimface.Tiles.UI.Control.prototype.setPosition
* @param {Object} position 组件的位置信息
* @param {Glodon.Bimface.Tiles.UI.ControlAnchor} position.anchor 定位组件位置的锚点
* @param {Object} position.offset 基于锚点的偏移值
* @param {Number} position.offset.x X方向偏移值,单位为px
* @param {Number} position.offset.y Y方向偏移值,单位为px
*/
Control.prototype.setPosition = function (position) {
if (position.anchor && ControlAnchor$1.hasOwnProperty(position.anchor)) {
for (var key in ControlAnchor$1) {
this.removeClass("bfui-anchor-" + key.toLowerCase());
}
var anchor = position.anchor.toLowerCase();
this.addClass("bfui-anchor-" + anchor);
this.position.anchor = position.anchor;
}
this.setOffset(position.offset);
return this;
};
Control.prototype.setOffset = function (offset) {
if (offset) {
var offsetX = offset.x || 0;
var offsetY = offset.y || 0;
var anchor = this.position.anchor.toLowerCase();
this.setStyle(anchor.indexOf('right') >= 0 ? { marginRight: -offsetX + "px" } : { marginLeft: offsetX + "px" })
.setStyle(anchor.indexOf('bottom') >= 0 ? { marginBottom: -offsetY + "px" } : { marginTop: offsetY + "px" });
this.position.offset.x = offsetX;
this.position.offset.y = offsetY;
}
return this;
};
Control.prototype.getPositionParam = function () {
return this.position;
};
/**
* 获取ID
* @function Glodon.Bimface.Tiles.UI.Control.prototype.getId
* @returns {String} ID
*/
Control.prototype.getId = function () {
return this.id;
};
// 获取Control类型
Control.prototype.getType = function () {
return this.type;
};
/**
* 获取组件的位置信息
* @function Glodon.Bimface.Tiles.UI.Control.prototype.getPosition
* @returns {Object} 组件的位置信息
*/
Control.prototype.getPosition = function () {
return this._domElement.getPosition();
};
/**
* 获取组件的尺寸信息
* @function Glodon.Bimface.Tiles.UI.Control.prototype.getDimensions
* @returns {Object} 组件的尺寸信息
*/
Control.prototype.getDimensions = function () {
return this._domElement.getDimensions();
};
// 获取元素宽度
Control.prototype.getWidth = function () {
return this._domElement.getWidth();
};
// 获取元素高度
Control.prototype.getHeight = function () {
return this._domElement.getHeight();
};
// 设置css style(传入多个键值对组成的对象参数)
Control.prototype.setStyle = function (style) {
this._domElement.css(style);
return this;
};
Control.prototype.getTooltip = function () {
return this.tooltip;
};
Control.prototype.setTooltip = function (tooltip) {
this.tooltip = tooltip;
this.getDomElement().attribute('title', tooltip);
return this;
};
/**
* 通过HTML字符串初始化Control内容,支持在字符串中插入Control对象标记,配合controlMap实现html与Control混合结构的整体初始化
* @param {string} html Control的内容html字符串。如需插入Control对象,则在插入的位置写入作为标记,id与controlMap中的key对应
* @param {IControlMap} controlMap 通过key、value方式提供需插入html中的各个Control对象,key与html字符串中标记处的id对应
*/
Control.prototype.setHTML = function (html, controlMap) {
var controlReg = /<[C,c]ontrol id="(.*?)".*?>.*?<\/[C,c]ontrol>/g;
var computedHtml = html.replace(controlReg, function (value) {
var execResult = controlReg.exec(value);
controlReg.lastIndex = 0;
var id = execResult[1];
var replaceHtml = "
";
return replaceHtml;
});
var dom = this.getDomElement();
dom.html(computedHtml);
for (var id in controlMap) {
var elements = dom.getElement().getElementsByClassName("BFUI_Control_" + id);
if (elements.length === 1) {
var element = elements[0];
var parent_1 = new Dom(element.parentElement);
parent_1.replace(controlMap[id].getDomElement && controlMap[id].getDomElement() || controlMap[id], new Dom(element));
}
}
return this;
};
/**
* 点击组件
*/
Control.prototype.click = function () {
this.getDomElement().click();
return this;
};
return Control;
}(EventEmmiter));
/**
* 基于tsx的响应式动态渲染模式
* 此文件是运行时部分,配合tsx编译结果,实现界面元素的递归渲染,以及响应式参数的触发和监听等
*/
var entityMap = {
"&": "amp",
"<": "lt",
">": "gt",
'"': "quot",
"'": "#39",
"/": "#x2F",
};
// 特殊字符转义
var escapeHtml = function (str) {
return String(str).replace(/[&<>"'\/\\]/g, function (s) { return "&" + entityMap[s] + ";"; });
};
// 设置element属性
var setElementAttrs = function (elm, name, val) {
if (name === "bf-show") {
elm.style.display = val ? "block" : "none";
return;
}
if (name === "style") {
if (typeof val === "string") {
val = val.split(";").reduce(function (prev, item) {
var _a = item.split(":"), key = _a[0], value = _a[1];
if (!key)
return prev;
prev[key.trim()] = value.trim();
return prev;
}, {});
}
Object.assign(elm.style, val);
}
else if (val === true) {
elm.setAttribute(name, name);
}
else if (val !== false && val != null) {
elm.setAttribute(name, escapeHtml(val));
}
else if (val === false) {
elm.removeAttribute(name);
}
};
// 单个节点的渲染函数
function __bf_h(tag, attrs) {
var children = [];
for (var _i = 2; _i < arguments.length; _i++) {
children[_i - 2] = arguments[_i];
}
attrs = attrs || {};
var stack = __spreadArrays(children); // 收集本节点的下一级子节点
var createdHandler = null; // 本节点的onCreated事件监听函数
// 如果handler不是function type,且包含__bf_render方法,就执行__bf_render方法得到真实的handler
var getRealHandler = function (handler) {
if (!handler)
return null;
if (typeof handler !== "function" && handler.__bf_render) {
handler = handler.__bf_render();
}
return handler;
};
var beforeDestroyHandlers = []; // 用于存储本节点以及所有子节点上需要监听onBeforeDestroy事件的handler,当本节点渲染为空时,触发这些handler
var destroyedHandlers = []; // 用于存储本节点以及所有子节点上需要监听onDestroy事件的handler,当本节点渲染为空时,触发这些handler
var beforeDestroyHandler = getRealHandler(attrs["on-before-destroy"] || attrs["onBeforeDestroy"]);
beforeDestroyHandler && beforeDestroyHandlers.push(beforeDestroyHandler);
var destroyedHandler = getRealHandler(attrs["on-destroyed"] || attrs["onDestroyed"]);
destroyedHandler && destroyedHandlers.push(destroyedHandler);
// tag为函数类型,表示是BFUI的Control构造函数,或者是自定义组件的渲染函数
if (typeof tag === "function") {
var resultAttrs_1 = {};
Object.entries(attrs).forEach(function (_a) {
var key = _a[0], val = _a[1];
resultAttrs_1[key] = (val && val.__bf_render) ? val.__bf_render() : val;
});
// 判断是否是BFUI的Control组件
var isControl = false, currentProto = tag.__proto__;
while (currentProto && !isControl) {
if (currentProto === Control) {
isControl = true;
}
else {
currentProto = currentProto.__proto__;
}
}
// tag是BFUI的Control构造函数,生成对应的Control组件并返回
if (isControl) {
var control = new tag(resultAttrs_1);
// 属性中有ref,则将此control对象赋值给传入的refItem
if (attrs.ref && attrs.ref._isBfRef) {
attrs.ref.value = control;
}
// 属性中有onCreated,判断是方法则在创建对象后触发onCreated监听事件
if (attrs.onCreated) {
var handler = attrs.onCreated;
if (typeof handler !== "function" && attrs.onCreated.__bf_render) {
handler = attrs.onCreated.__bf_render();
}
if (typeof handler === "function") {
handler(control);
}
}
return {
control: control,
};
}
else { // 自定义组件的渲染函数,返回该函数的执行结果
return tag(attrs);
}
}
// tag为string类型,表示是常规的dom节点,生成对应的Dom对象
var domElement = new Dom().createElement({ elementType: tag, className: attrs.class });
var elm = domElement.getElement();
var _loop_1 = function (name_1, val) {
name_1 = escapeHtml(name_1);
// on开头的属性名,认为是事件,绑定对应的事件
if (name_1.startsWith("on")) {
var handler = getRealHandler(val);
if (typeof handler === "function") {
var listenerName = name_1.toLowerCase().replace('-', '').substring(2);
if (listenerName === "created") {
// 属性名为onCreated || on-created,在创建对象后触发onCreated监听事件
createdHandler = handler;
}
else if ("on" + listenerName in window) {
// 其他事件认为是标准dom监听事件(click,mouseup等),绑定对应的监听事件
elm.addEventListener(listenerName, handler);
}
}
}
else if (name_1 === "ref") {
// 属性名为ref,将当前domElement对象赋值给传入的refItem
if (val && val._isBfRef) {
val.value = domElement;
}
}
else {
// 其他属性按照不同属性类型,调用setElementAttrs()进行设置
if (val.hasOwnProperty('__bf_refItems')) {
// val为 {__bf_render: () => xxx, ___bf_refItems: [x, y]},认为是包含需要动态响应的属性,在相关的refItem上添加监听事件,refItem更新时重新设置该属性
val.__bf_refItems.forEach(function (item) {
item && item._isBfRef && item._onChangeHandlers.push(function () { return setElementAttrs(elm, name_1, val.__bf_render()); });
});
setElementAttrs(elm, name_1, val.__bf_render());
}
else {
setElementAttrs(elm, name_1, val);
}
}
};
// 设置节点上的各个属性
for (var _a = 0, _b = Object.entries(attrs); _a < _b.length; _a++) {
var _c = _b[_a], name_1 = _c[0], val = _c[1];
_loop_1(name_1, val);
}
// 递归处理子节点的方法
var append = function (childItem) {
// 普通字符节点,不含响应式元素,直接渲染TextNode并返回
if (['[object String]', '[object Number]'].indexOf(Object.prototype.toString.call(childItem)) >= 0) {
domElement.element.appendChild(document.createTextNode(childItem.toString()));
return;
}
// 获取子节点的渲染结果,即实际需要渲染的指定类型的HTMLElement元素;isUpdate为true时,表示是更新操作,false表示是首次渲染操作
var getChildElement = function (data, isUpdate) {
// 判断是已经渲染过的节点,直接返回(data为Array时会进入此种情况)
if (!data.hasOwnProperty('__bf_refItems') || !data.hasOwnProperty('__bf_render')) {
return data.control ? data.control.getDomElement().getElement() : data.domElement.getElement();
}
// 使用__bf_render方法获取子节点的渲染结果,有可能是最终要渲染的HTMElement元素,也可能是一个或多个需要动态渲染的子节点,需遍历处理
var result = data.__bf_render();
var childElement;
if (['[object String]', '[object Number]'].includes(Object.prototype.toString.call(result))) { // string格式,认为是节点内容,创建一个TextNode
childElement = document.createTextNode(result);
}
else if (result === false || result === null || result === undefined) { // false/null/undefined,认为是条件语句未满足条件的情况,创建一个comment用于占位
childElement = document.createComment('');
}
else if (Object.prototype.toString.call(result) === '[object Object]') { // 对象形式,认为是需要渲染的HTMLElement元素
if (result._isBfRef) {
childElement = getChildElement(result.value); // 递归处理需要动态渲染的子节点
}
else {
childElement = result.control ? result.control.getDomElement().getElement() : result.domElement.getElement();
if (!isUpdate) { // 首次渲染时,收集子节点的onBeforeDestroy和onDestroyed事件监听函数
result.destroyedHandlers && (destroyedHandlers.push.apply(destroyedHandlers, result.destroyedHandlers));
result.beforeDestroyHandlers && (beforeDestroyHandlers.push.apply(beforeDestroyHandlers, result.beforeDestroyHandlers));
}
}
}
else if (Object.prototype.toString.call(result) === '[object Array]') { // 数组形式,认为是需要动态渲染的多个同级子节点,来源于jsx中array.map的循环渲染语句
if (result.length === 0) {
childElement = document.createComment(''); // 数组长度为0,创建一个comment用于占位
}
else {
childElement = result.map(function (item) {
return getChildElement(item);
});
}
}
return childElement;
};
var element = getChildElement(childItem);
var getIsEmptyElement = function (elm) { return elm instanceof Comment; }; // 判断是否为空元素(空元素实际也会渲染一个占位的Comment元素)
if (element) {
// 首次渲染时,将子节点的渲染结果挂载到父节点上
if (!childItem._element) {
Object.prototype.toString.call(element) === '[object Array]' ? element.forEach(function (item) { return domElement.getElement().appendChild(item); }) : domElement.getElement().appendChild(element);
childItem._element = element;
}
// 首次渲染时,判断是否有需要监听的响应式参数,如果有则添加监听事件,参数发生变化时更新子节点的渲染结果
if (!childItem._handler && childItem.__bf_refItems && childItem.__bf_refItems.length > 0) {
childItem._handler = function () {
var newElement = getChildElement(childItem, true); // 获取子节点更新的渲染结果
var isEmptyElement = getIsEmptyElement(newElement); // 判断本次渲染结果是否为空,为空则触发destroy相关监听
isEmptyElement && beforeDestroyHandlers.forEach(function (handler) { return handler && handler(); });
var referenceNode; // 原有节点元素的后一个HTML元素,用于插入新元素时作为标记,仍然插入在此元素之前
// 删除原有节点渲染结果
if (Object.prototype.toString.call(childItem._element) === '[object Array]') { // 原有节点渲染结果为数组形式,删除数组中的所有HTMLElement元素
var lastIndex = __spreadArrays(domElement.getElement().childNodes).indexOf(childItem._element[childItem._element.length - 1]);
domElement.getElement().childNodes.length > (lastIndex + 1) && (referenceNode = domElement.getElement().childNodes[lastIndex + 1]);
childItem._element.forEach(function (item) {
domElement.getElement().removeChild(item);
});
}
else { // 原有节点渲染结果为单个HTMLElement元素,删除该元素
var lastIndex = __spreadArrays(domElement.getElement().childNodes).indexOf(childItem._element);
domElement.getElement().childNodes.length > (lastIndex + 1) && (referenceNode = domElement.getElement().childNodes[lastIndex + 1]);
domElement.getElement().removeChild(childItem._element);
}
// 插入更新的节点渲染结果
if (Object.prototype.toString.call(newElement) === '[object Array]') {
newElement.forEach(function (item) {
domElement.getElement().insertBefore(item, referenceNode);
});
}
else {
domElement.getElement().insertBefore(newElement, referenceNode);
}
childItem._element = newElement;
isEmptyElement && destroyedHandlers.forEach(function (handler) { return handler && handler(); });
};
// 在需要监听的各个响应参数上添加监听事件,参数发生变化时更新子节点的渲染结果
childItem.__bf_refItems.forEach(function (item) {
item && item._isBfRef && item.onChange(childItem._handler);
});
}
}
};
// 遍历处理节点下一级的子节点
while (stack.length) {
var child = stack.shift();
if (!Array.isArray(child)) {
append(child);
}
else {
child.forEach(function (item) {
append(item);
});
}
}
// 触发此节点的created事件监听函数
createdHandler && createdHandler(domElement);
return {
domElement: domElement,
beforeDestroyHandlers: beforeDestroyHandlers,
destroyedHandlers: destroyedHandlers,
};
}
// 如果是refItem,则返回其value值,否则返回本身
var __bf_getRefValue = function (refItem) {
if (refItem && refItem._isBfRef) {
return refItem.value;
}
return refItem;
};
// ref函数,返回一个ref实例
var _refIndex = 0;
var _refMap = new Map();
var ref = function (value) {
var data = {
value: value,
_refIndex: _refIndex++,
_isBfRef: true,
_onChangeHandlers: [],
onChange: function (handler) { return data._onChangeHandlers.push(handler); },
offChange: function (handler) {
var index = data._onChangeHandlers.indexOf(handler);
if (index > -1) {
data._onChangeHandlers.splice(index, 1);
}
},
};
var proxy = new Proxy(data, {
set: function (obj, prop, value) {
if (prop === 'value') {
var formerValue_1 = obj[prop];
obj[prop] = value;
// refItem.value发生变化时,触发所有监听此refItem的事件
proxy._onChangeHandlers && proxy._onChangeHandlers.forEach(function (handler) {
typeof handler === 'function' && handler(value, formerValue_1);
});
}
return true;
}
});
_refMap.set(proxy._refIndex, proxy);
return proxy;
};
Glodon.__bf_getRefValue = __bf_getRefValue;
// 将渲染结果挂载到指定的HTMLElement容器上
var render = function (renderFunc, container) {
var domElement = renderFunc instanceof Function ? renderFunc().domElement : renderFunc.domElement;
domElement && container.append(domElement);
};
Glodon.__bf_h = __bf_h;
var app = ref(null);
var viewer = ref(null);
var modelId = ref(null);
var modelType = ref(null);
ref(null);
var clashData = ref(null);
var clashResults = ref([]);
var clashGroups = ref([]);
var selectedGroupIndex = ref(null);
var currentClashGroup = ref([]);
var showGroupItemPanel = ref(false);
var showFilterModal = ref(false);
function getTreeInfo(source, keys, parent) {
var _a, _b;
var parentId = parent.parentId, filterName = parent.filterName;
var pointerObj = {};
var tree = [];
var platTreeMap = {};
for (var i = 0; i < source.length; i++) {
var arr = tree;
var cur = pointerObj; // arr和cur都是指针的作用
var pId = parentId || 'all';
var pFilters = parentId && parentId !== 'all' ? (_a = {}, _a[filterName] = parentId, _a) : {};
for (var j = 0; j < keys.length; j++) {
var key = keys[j];
var originName = source[i][key];
if (!cur[originName]) {
var pusher = {
originName: originName,
name: originName === '' ? '未命名' : originName,
id: null,
};
var tmp = [];
if (j !== (keys.length - 1)) {
tmp = [];
pusher.children = tmp;
}
var index = arr.push(pusher) - 1;
pusher.pId = pId;
pusher.id = pId !== 'all' ? pId + "-" + index : "" + index;
var filters = {};
if (!pId) {
filters[key] = originName;
}
else {
filters = __assign(__assign({}, pFilters), (_b = {}, _b[key] = originName, _b));
}
cur[originName] = { position: index, id: pusher.id, filters: filters };
platTreeMap[pusher.id] = { filters: filters, pId: pId };
cur = cur[originName]; // cur指向到cur[field]对应的子节点
arr = tmp; // arr指向pusher.children这个节点
}
else {
cur = cur[originName];
arr = arr[cur.position].children;
}
pId = cur.id;
pFilters = cur.filters;
}
}
return { platTreeMap: platTreeMap, tree: tree };
}
var fileToKeys = {
rvt: ['specialty', 'levelName', 'categoryName', 'family', 'familyType'],
ifc: ['IfcProject', 'IfcSite', 'IfcBuilding', 'IfcBuildingStorey', 'IfcEntity'],
};
var EFileType;
(function (EFileType) {
EFileType["rvt"] = "rvt";
EFileType["ifc"] = "ifc";
})(EFileType || (EFileType = {}));
function handleTreeKeys(source, fileType) {
var keys = fileToKeys[fileType];
var keysRes = [];
var keysLength = keys.length;
var _loop_1 = function (i) {
var key = keys[i];
var isKeyWidthVal = source.find(function (s) { return s[key] && s[key] !== ''; });
isKeyWidthVal && keysRes.push(key);
};
for (var i = 0; i < keysLength; i++) {
_loop_1(i);
}
return keysRes;
}
var EFilterType;
(function (EFilterType) {
EFilterType["A"] = "A";
EFilterType["B"] = "B";
})(EFilterType || (EFilterType = {}));
var transMultiplyingMap = {
'Millimeter-Millimeter': 1,
'Millimeter-Centimeter': 0.1,
'Millimeter-Meter': 0.001,
'Millimeter-Kilometer': 0.0000001,
'Meter-Millimeter': 1000,
'Meter-Centimeter': 100,
'Meter-Meter': 1,
'Meter-Kilometer': 0.001,
};
var bBoxBorderMap = {
Millimeter: 1000 * 2,
Centimeter: 100 * 2,
Meter: 1 * 2,
Kilometer: 0.001 * 2,
};
var detailDisplayKeys = {
rvt: ['family'],
ifc: ['Name'],
};
var overrideAllColor = function () {
viewer.value.getModel(modelId.value).overrideAllComponentsColor(new window.Glodon.Web.Graphics.Color(200, 200, 200, 0.5));
viewer.value.getModel(modelId.value).overrideComponentsFrameColor({ all: true }, new window.Glodon.Web.Graphics.Color(150, 150, 150, 1));
};
var overrideColor = function (results) {
viewer.value.getModel(modelId.value).clearIsolation();
var objectIdACollector = new Map();
var objectIdsA = results.reduce(function (prev, cur) {
if (!objectIdACollector.get(cur.objectIdA)) {
objectIdACollector.set(cur.objectIdA, true);
prev.push(cur.objectIdA);
}
return prev;
}, []);
var objectIdBCollector = new Map();
var objectIdsB = results.reduce(function (prev, cur) {
if (!objectIdBCollector.get(cur.objectIdB)) {
objectIdBCollector.set(cur.objectIdB, true);
prev.push(cur.objectIdB);
}
return prev;
}, []);
// 构件A的集合和B的集合分别设置颜色
viewer.value.getModel(modelId.value).overrideComponentsColorById(objectIdsA, new window.Glodon.Web.Graphics.Color(255, 96, 88, 0.5));
viewer.value.getModel(modelId.value).overrideComponentsFrameColor({ ids: objectIdsA }, new window.Glodon.Web.Graphics.Color(255, 96, 88, 1));
viewer.value.getModel(modelId.value).overrideComponentsColorById(objectIdsB, new window.Glodon.Web.Graphics.Color(75, 217, 82, 0.5));
viewer.value.getModel(modelId.value).overrideComponentsFrameColor({ ids: objectIdsB }, new window.Glodon.Web.Graphics.Color(75, 217, 82, 1));
};
var clashEffectOnModel = function (results) {
if (results === void 0) { results = []; }
overrideAllColor();
overrideColor(results);
};
var handleClashName = function (clash, type) {
var _a, _b;
var filesInfo = app.value.clashDetectiveConfig.filesInfo;
var objectData = "objectData" + type;
var id = "fileId" + type;
var fileId = modelType.value === 'INTEGRATE' ? (_a = clash[objectData]) === null || _a === void 0 ? void 0 : _a.fileId : clash[id]; // 非集成模型 fileId不会在objectData中解析
var fileType = (_b = filesInfo.get(String(fileId))) === null || _b === void 0 ? void 0 : _b.fileType;
var objectId = "objectId" + type;
var showKeys = detailDisplayKeys[fileType];
var displayName;
if (showKeys) {
displayName = showKeys.map(function (k) { return clash[objectData][k]; }).join('');
if (fileType === 'rvt') {
displayName = displayName + "[" + clash[objectId] + "]";
}
}
else {
displayName = clash[objectId];
}
return displayName;
};
var getGroupClashResults = function (group) {
var filterA = group.filterA, filterB = group.filterB;
var results = clashResults.value;
// 展示的名称需要根据文件类型处理
results.forEach(function (r) {
r.nameA = handleClashName(r, EFilterType.A);
r.nameB = handleClashName(r, EFilterType.B);
});
if (filterA && filterB) {
var resA = [];
var _loop_1 = function (i) {
var filter = filterA[i];
if ((filter === null || filter === void 0 ? void 0 : filter.id) === 'all') {
resA = results;
return "break";
}
else {
var filteredRes = results.filter(function (cur) { return Object.keys(filter).every(function (k) { return (cur === null || cur === void 0 ? void 0 : cur.objectDataA[k]) === filter[k]; }); });
resA.push.apply(resA, filteredRes);
}
};
for (var i = 0; i < filterA.length; i++) {
var state_1 = _loop_1(i);
if (state_1 === "break")
break;
}
var resB = [];
var _loop_2 = function (j) {
var filter = filterB[j];
if ((filter === null || filter === void 0 ? void 0 : filter.id) === 'all') {
resB = resA;
return "break";
}
else {
var filteredRes = resA.filter(function (cur) { return Object.keys(filter).every(function (k) { return (cur === null || cur === void 0 ? void 0 : cur.objectDataB[k]) === filter[k]; }); });
resB.push.apply(resB, filteredRes);
}
};
for (var j = 0; j < filterB.length; j++) {
var state_2 = _loop_2(j);
if (state_2 === "break")
break;
}
return resB;
}
return [];
};
/** 处理点击碰撞检测结果后触发的模型交互 */
var clearIsolation = function () {
// eslint-disable-next-line no-underscore-dangle
var model = viewer.value.getModels().find(function (m) { return String(m._data.modelId) === String(modelId.value); });
if (model) {
model.clearOverrideColorComponents();
model.restoreComponentsFrameColor({ all: true });
model.clearIsolation();
}
viewer.value.render();
};
var isolateComponentsById = function (currentItem) {
var _a, _b;
clearIsolation();
// eslint-disable-next-line no-underscore-dangle
var model = viewer.value.getModel(modelId.value);
if (model) {
model.isolateComponentsById([currentItem === null || currentItem === void 0 ? void 0 : currentItem.objectIdA, currentItem === null || currentItem === void 0 ? void 0 : currentItem.objectIdB], (_b = (_a = app.value) === null || _a === void 0 ? void 0 : _a.clashDetectiveConfig) === null || _b === void 0 ? void 0 : _b.makeOthersTranslucent);
model.overrideComponentsColorById([currentItem === null || currentItem === void 0 ? void 0 : currentItem.objectIdA], new window.Glodon.Web.Graphics.Color(229, 120, 115, 1));
model.overrideComponentsFrameColor({
ids: [[
currentItem === null || currentItem === void 0 ? void 0 : currentItem.objectIdA
]],
}, new window.Glodon.Web.Graphics.Color(255, 96, 88, 1));
model.overrideComponentsColorById([currentItem === null || currentItem === void 0 ? void 0 : currentItem.objectIdB], new window.Glodon.Web.Graphics.Color(105, 205, 112, 1));
model.overrideComponentsFrameColor({
ids: [[
currentItem === null || currentItem === void 0 ? void 0 : currentItem.objectIdB
]],
}, new window.Glodon.Web.Graphics.Color(75, 217, 82, 1));
}
viewer.value.render();
};
var transformToBoundingBox = function (position, unitTypeParam, modelUnitParam) {
var transMultiplying = viewer.value.getGlobalUnit() ? 1 : transMultiplyingMap[modelUnitParam + "-" + unitTypeParam];
var bBoxBorder = bBoxBorderMap[unitTypeParam];
return {
max: {
x: position.x * transMultiplying + bBoxBorder,
y: position.y * transMultiplying + bBoxBorder,
z: position.z * transMultiplying + bBoxBorder,
},
min: {
x: position.x * transMultiplying - bBoxBorder,
y: position.y * transMultiplying - bBoxBorder,
z: position.z * transMultiplying - bBoxBorder,
},
};
};
var zoomToBoundingBox = function (position) {
var _a;
var _b = (_a = app.value) === null || _a === void 0 ? void 0 : _a.clashDetectiveConfig, unitType = _b.unitType, modelUnit = _b.modelUnit;
var boundingbox = transformToBoundingBox(position, unitType, modelUnit);
viewer.value.zoomToBoundingBox(boundingbox);
};
var resetHomeView = function () {
viewer.value.setView(window.Glodon.Bimface.Viewer.ViewOption.Home);
};
var handleObjectData = function (results, type) {
var objectIdsMap = new Map();
var objectId = "objectId" + type;
var objectData = "objectData" + type;
var res = [];
for (var i = 0, l = results.length; i < l; i++) {
var cur = results[i];
var objectIdValue = cur[objectId];
if (!objectIdsMap.get(objectIdValue)) {
objectIdsMap.set(cur[objectId], true);
res.push(cur[objectData]);
}
}
return res;
};
var isResultsWithProperty = function (results, property) { return results.findIndex(function (r) { return r[property] && r[property] !== ''; }) !== -1; };
var getObjectTree = function (type) {
var isIntegrateModel = modelType.value === 'INTEGRATE';
var objectData = handleObjectData(clashResults.value, type);
var filterMap = { all: { filters: { id: 'all' }, pId: null } };
var rootTreeItem = {
id: 'all',
name: '全部构件',
children: [],
pId: null,
};
var filesInfo = app.value.clashDetectiveConfig.filesInfo;
var fileIds = Array.from(filesInfo.keys());
// 集成模型 如果数据上有specialty 则去除文件 否则仍保留文件
if (isIntegrateModel) {
var hasSpecialty = isResultsWithProperty(objectData, 'specialty');
if (hasSpecialty) {
var _a = getTreeInfo(objectData, fileToKeys.rvt, { parentId: 'all', filterName: '' }), tree_1 = _a.tree, platTreeMap = _a.platTreeMap;
return {
filterMap: __assign(__assign({}, filterMap), platTreeMap),
tree: [__assign(__assign({}, rootTreeItem), { children: tree_1 })],
};
}
var trees = fileIds.reduce(function (prev, cur) {
var _a, _b;
var _c = filesInfo.get(cur), fileName = _c.fileName, fileType = _c.fileType;
var fileTreeItem;
if (!['ifc', 'rvt'].includes(fileType)) {
fileTreeItem = {
id: cur, name: fileName, children: [], pId: 'all',
};
filterMap = __assign(__assign({}, filterMap), (_a = {}, _a[cur] = { filters: { fileId: cur }, pId: 'all' }, _a));
}
else {
var keys_1 = handleTreeKeys(objectData, fileType);
var _d = getTreeInfo(objectData, keys_1, { parentId: cur, filterName: 'fileId' }), tree_2 = _d.tree, idFilterMap = _d.platTreeMap;
fileTreeItem = {
id: cur, name: fileName, children: tree_2, pId: 'all',
};
filterMap = __assign(__assign(__assign({}, filterMap), idFilterMap), (_b = {}, _b[cur] = { filters: { fileId: cur }, pId: 'all' }, _b));
}
prev.push(fileTreeItem);
return prev;
}, []);
return {
filterMap: filterMap,
tree: [__assign(__assign({}, rootTreeItem), { children: trees })],
};
}
var fileType = filesInfo.get(fileIds[0]).fileType;
if (!['ifc', 'rvt'].includes(fileType)) {
return {
filterMap: filterMap,
tree: [rootTreeItem],
};
}
var keys = handleTreeKeys(objectData, fileType);
var _b = getTreeInfo(objectData, keys, { parentId: 'all', filterName: '' }), tree = _b.tree, filterMap1 = _b.platTreeMap;
return {
filterMap: __assign(__assign({}, filterMap), filterMap1),
tree: [__assign(__assign({}, rootTreeItem), { children: tree })],
};
};
var isObjectEqual = function (obj1, obj2) {
var obj1Keys = Object.keys(obj1);
var obj2Keys = Object.keys(obj2);
if (obj1Keys.length !== obj2Keys.length) {
return false;
}
// eslint-disable-next-line no-restricted-syntax
for (var _i = 0, obj1Keys_1 = obj1Keys; _i < obj1Keys_1.length; _i++) {
var key = obj1Keys_1[_i];
if (obj1[key] !== obj2[key]) {
return false;
}
}
return true;
};
var getCheckedKeys = function (filterType, hashTreeMap, filters) {
var keys = filters.reduce(function (acc, cur) {
var someId = Object.keys(hashTreeMap).find(function (k) { return isObjectEqual(hashTreeMap[k].filters, cur); });
if (someId) {
acc.push(someId);
}
return acc;
}, []);
return keys;
};
// 异步处理 根据分组信息得到碰撞列表和目录树信息
var hanldeClashResults = function () {
return new Promise(function (resolve, reject) {
var groups = clashGroups.value;
if (Array.isArray(groups) && groups.length) {
groups.forEach(function (group) {
group.clashList = getGroupClashResults(group);
var treeSourceA = getObjectTree(EFilterType.A);
group.treeA = treeSourceA.tree;
group.platTreeMapA = treeSourceA.filterMap;
group.checkedTreeIdsA = getCheckedKeys(EFilterType.A, treeSourceA.filterMap, group["filter" + EFilterType.A]);
var treeSourceB = getObjectTree(EFilterType.B);
group.treeB = treeSourceB.tree;
group.platTreeMapB = treeSourceB.filterMap;
group.checkedTreeIdsB = getCheckedKeys(EFilterType.B, treeSourceB.filterMap, group["filter" + EFilterType.B]);
});
resolve();
}
else {
reject();
}
});
};
var handleClickGroup = function (index) {
var _a;
selectedGroupIndex.value = index;
currentClashGroup.value = clashGroups.value[index];
resetHomeView();
clashEffectOnModel((_a = currentClashGroup.value) === null || _a === void 0 ? void 0 : _a.clashList);
showGroupItemPanel.value = true;
};
var ClashGroup = (function () {
return window.Glodon.__bf_h("div", {
class: "bf-clashdetective-group"
}, window.Glodon.__bf_h("div", {
class: "bf-clashdetective-title"
}, window.Glodon.__bf_h("span", null, "\u78B0\u649E\u5206\u7EC4")), window.Glodon.__bf_h("div", {
class: "bf-clashdetective-group-list"
}, window.Glodon.__bf_h("div", {
class: "bf-clashdetective-group-header bf-clashdetective-title"
}, window.Glodon.__bf_h("div", {
class: "bf-clashdetective-group-column-1-name"
}, "\u5206\u7EC4\u540D\u79F0"), window.Glodon.__bf_h("div", {
class: "bf-clashdetective-group-column-2-name"
}, "\u78B0\u649E\u70B9")), window.Glodon.__bf_h("ul", {
class: "bf-clashdetective-group-main"
}, {
__bf_render: () => clashGroups.value.map(function (group, index) {
return window.Glodon.__bf_h("li", {
class: "bf-clashdetective-row bf-clashdetective-group-row",
onClick: function () {
return handleClickGroup(index);
}
}, window.Glodon.__bf_h("span", {
class: {
__bf_render: () => index === selectedGroupIndex.value ? 'bf-clashdetective-group-column-1 bf-clashdetective-group-column-selected' : 'bf-clashdetective-group-column-1',
__bf_refItems: [(() => {
try {
return selectedGroupIndex;
} catch {}
})()]
}
}, group.name), window.Glodon.__bf_h("span", {
class: "bf-clashdetective-group-column-2"
}, group.count || 0));
}),
__bf_refItems: [(() => {
try {
return clashGroups;
} catch {}
})()]
})));
});
var Modal = (function (_a) {
var slot = _a.slot,
title = _a.title,
closeHandler = _a.closeHandler;
var modalContainer = ref(null);
var showModal = ref(false);
var open = function () {
showModal.value = true;
};
var close = function (handler) {
handler && handler();
showModal.value = false;
};
return window.Glodon.__bf_h("div", {
ref: modalContainer,
onCreated: open,
class: {
__bf_render: () => showModal.value ? 'bf-clashdetective-modal bf-clashdetective-modal-show' : 'bf-clashdetective-modal',
__bf_refItems: [(() => {
try {
return showModal;
} catch {}
})()]
}
}, window.Glodon.__bf_h("div", {
class: "modal-main"
}, window.Glodon.__bf_h("div", {
class: "modal-header"
}, window.Glodon.__bf_h("span", {
class: "modal-title"
}, title), window.Glodon.__bf_h("i", {
class: "bficon bf-gld-del-sm modal-close",
onClick: function () {
return close(closeHandler);
}
})), window.Glodon.__bf_h("div", {
class: "modal-content"
}, slot && slot())));
});
var SyleUtil = /** @class */ (function () {
function SyleUtil() {
}
SyleUtil.formatElementParam = function (defaultParam, customParam) {
if (typeof customParam == 'undefined')
return defaultParam;
var className = defaultParam.className, customClassName = customParam.className;
// style = customParam.style;
// 默认类名 自定义类名
if (customClassName) {
className = className + " " + customClassName;
}
// // 类型类名
// if(style) {
// className = `${className} is-${customClassName}`;
// }
var elementParam = window.Object.assign(defaultParam, customParam);
elementParam.className = className;
return elementParam;
};
return SyleUtil;
}());
var _a, _b, _c, _d;
var SDM = (_d = (_c = (_b = (_a = window.Glodon) === null || _a === void 0 ? void 0 : _a.Bimface) === null || _b === void 0 ? void 0 : _b.Data) === null || _c === void 0 ? void 0 : _c.StatisticsDataManager) === null || _d === void 0 ? void 0 : _d.getInstance();
var UINamespace = 'Gldon.Bimface.Tiles.UI';
var getUINamespace = function (className) {
if (DataUtil.assertType(className, 'str') && className.length > 0) {
className[0] !== '.' && (className = "." + className);
return "" + UINamespace + className;
}
else {
return UINamespace;
}
};
var SNS$9 = getUINamespace('Button');
/**
* @classdesc 类:Button组件类
* @class Glodon.Bimface.Tiles.UI.Button
* @constructs Glodon.Bimface.Tiles.UI.Button
* @description 构造按钮组件对象
* @extends Glodon.Bimface.Tiles.UI.Control
* @param {Object} option 构造按钮对象的配置项
* @param {String} option.id 按钮对象ID
* @param {Boolean} option.selectable 按钮是否有选中状态
* @param {String} option.iconClass 按钮图标样式
* @param {String} option.text 按钮对象的文本内容
*/
/** @class */ ((function (_super) {
__extends(Button, _super);
function Button(param) {
var _this = this;
SDM && (!param || !param.isInside) && SDM.send(SNS$9, "bf_c_UIButton_new");
param = param || {};
var elementParam = SyleUtil.formatElementParam({
elementType: 'div',
className: 'bfui-button'
}, param.elementParam);
var controlParam = {
elementParam: elementParam,
type: 'Button',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
param.text && _this.setText(param.text);
_this.selectable = param.selectable === true;
_this.selectable && (_this.select = false);
param.iconClass && _this.setIcon(param.iconClass);
param.tooltip && _this.setTooltip(param.tooltip);
param.clickCallback instanceof Function && _this.onClick(param.clickCallback);
return _this;
}
/**
* 获取按钮文字内容
* @function Glodon.Bimface.Tiles.UI.Button.prototype.getText
* @returns {String} 按钮文字内容
*/
Button.prototype.getText = function () {
return this._domElement.html();
};
/**
* 设置按钮文字内容
* @function Glodon.Bimface.Tiles.UI.Button.prototype.setText
* @param {String} test 按钮文字内容
*/
Button.prototype.setText = function (text) {
this._domElement.html(text);
return this;
};
/*
* 设置按钮的图标
* @function Glodon.Bimface.Tiles.UI.Button.prototype.setIcon
* @param {String} class 按钮图标样式类名
*/
Button.prototype.setIcon = function (iconClass) {
if (!iconClass)
return this;
if (!this.icon) {
this.icon = new Dom().createElement({ elementType: 'div', className: 'bfui-button-icon' });
this._domElement.append(this.icon);
}
else {
this.icon.removeClass(this.iconClass);
}
this.iconClass = iconClass;
this.icon.addClass(iconClass);
return this;
};
/**
* 获取按钮是否允许选中
* @function Glodon.Bimface.Tiles.UI.Button.prototype.isSelectable
* @returns {Boolean} 按钮是否允许选中
*/
Button.prototype.isSelectable = function () {
return this.selectable;
};
/**
* 获取按钮当前的选中状态
* @function Glodon.Bimface.Tiles.UI.Button.prototype.isSelected
* @returns {Boolean} 按钮当前的选中状态
*/
Button.prototype.isSelected = function () {
return this.select;
};
/**
* 设置按钮当前的选中状态
* @function Glodon.Bimface.Tiles.UI.Button.prototype.setSelected
* @param {Boolean} select 按钮当前的选中状态
*/
Button.prototype.setSelected = function (select) {
if (!this.selectable)
return this;
select = select === true;
if (select) {
this._domElement.addClass('bfui-button-select');
}
else {
this._domElement.removeClass('bfui-button-select');
}
this.select = select;
return this;
};
return Button;
})(Control));
var SNS$8 = getUINamespace('Label');
/**
* @classdesc 类:Label组件类
* @class Glodon.Bimface.Tiles.UI.Label
* @constructs Glodon.Bimface.Tiles.UI.Label
* @description 构造标签组件
* @extends Glodon.Bimface.Tiles.UI.Control
* @param {Object} option 构造标签的配置项
* @param {String} option.id 标签组件ID
* @param {String} option.text 标签的文字内容
*/
/** @class */ ((function (_super) {
__extends(Label, _super);
function Label(param) {
var _this = this;
SDM && (!param || !param.isInside) && SDM.send(SNS$8, "bf_c_UILabel_new");
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-label'
};
var controlParam = {
elementParam: elementParam,
type: 'Label',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
param.text && _this.setText(param.text);
param.onClick && _this.onClick(param.onClick);
param.className && _this.addClass(param.className);
return _this;
}
/**
* 获取文字内容
* @function Glodon.Bimface.Tiles.UI.Label.prototype.getText
* @returns {String} 文字内容
*/
Label.prototype.getText = function () {
return this._domElement.html();
};
/**
* 设置文字内容
* @function Glodon.Bimface.Tiles.UI.Label.prototype.setText
* @param {String} text 文字内容
*/
Label.prototype.setText = function (text) {
this._domElement.html(text);
return this;
};
return Label;
})(Control));
getUINamespace('Link');
//Link组件类
/** @class */ ((function (_super) {
__extends(Link, _super);
function Link(param) {
// SDM && SDM.send(SNS, "bf_c_UILink_new");
var _this = this;
param = param || {};
var elementParam = {
elementType: 'a',
className: 'bfui-link'
};
var controlParam = {
elementParam: elementParam,
type: 'Link',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
param.text && _this.setText(param.text);
_this.setHref(param.href);
param.onClick && _this.onClick(param.onClick);
return _this;
}
// 获取文本
Link.prototype.getText = function () {
return this._domElement.html();
};
// 设置文本
Link.prototype.setText = function (text) {
this._domElement.html(text);
return this;
};
Link.prototype.getHref = function () {
return this.href;
};
Link.prototype.setHref = function (href) {
this.href = href || 'javascript:void(0)';
this._domElement.attribute('href', this.href);
return this;
};
return Link;
})(Control));
/**
* @classdesc 类:Tooltip组件类
* @class Glodon.Bimface.Tiles.UI.Tooltip
* @constructs Glodon.Bimface.Tiles.UI.Tooltip
* @description 构造提示框组件
* @extends Glodon.Bimface.Tiles.UI.Control
* @param {Object} option 构造提示框的配置项
* @param {String} option.id 提示框组件ID
* @param {String} option.content 提示框的文字内容
*/
var Tooltip = /** @class */ (function (_super) {
__extends(Tooltip, _super);
function Tooltip(param) {
var _this = this;
var elementParam = {
elementType: 'div',
className: 'bfui-tooltip'
};
var controlParam = {
elementParam: elementParam,
type: 'Tooltip',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
_this.hostDom = param.hostDom;
_this.placement = param.placement || 'right';
_this.isFixed = param.isFixed || false;
_this.addClass("bfui-tooltip-" + _this.placement).setHTML(param.content).hide();
if (param.theme === 'dark') {
_this.addClass('bfui-tooltip-dark');
}
param.className && _this.addClass(param.className);
param.width && _this.getDomElement().css({ width: param.width + "px" });
var onHover = false;
var duration = 500;
var hideTimeout = null;
var hideWhenLeave = function () {
// dom元素被删除后取消监听
if (_this._domElement.displayType == undefined) {
param.hostDom.off('mouseleave', hideWhenLeave);
return;
}
onHover = false;
if (_this.enableAlwaysShow)
return;
if (hideTimeout) {
clearTimeout(hideTimeout);
hideTimeout = null;
}
hideTimeout = setTimeout(function () {
onHover || _this.hide();
}, duration);
};
var mouseEnterFn = function () {
// dom元素被删除后取消监听
if (_this._domElement.displayType == undefined) {
param.hostDom.off('mouseenter', mouseEnterFn);
return;
}
onHover = true;
_this.show();
requestAnimationFrame(function () {
!_this.isFixed && _this.updatePosition();
});
};
param.hostDom.on('mouseenter', mouseEnterFn).on('mouseleave', hideWhenLeave);
_this.getDomElement().on('mouseenter', function () {
onHover = true;
}).on('mouseleave', hideWhenLeave);
document.body.appendChild(_this.getDomElement().getElement());
return _this;
}
Tooltip.prototype.setEnableAlwaysShow = function (enable) {
this.enableAlwaysShow = enable;
if (enable) {
this.show();
}
else {
this.hide();
}
this.updatePosition();
};
Tooltip.prototype.setToolTipPosition = function (position) {
this.newLeft = position.left;
this.newTop = position.top;
this.getDomElement().css({ left: this.hostDom.getPosition().left + this.newLeft + "px",
top: this.hostDom.getPosition().top + position.top + "px" });
};
Tooltip.prototype.updatePosition = function () {
var _this = this;
var _a = this.hostDom.getPosition(), top = _a.top, right = _a.right; _a.bottom; var left = _a.left;
var _b = this.hostDom.getDimensions(), parentHeight = _b.height, parentWidth = _b.width;
var _c = this.getDimensions(), width = _c.width, height = _c.height;
switch (this.placement) {
case 'right':
(function () {
var computedTop = top + parentHeight / 2 - height / 2;
var computedLeft = right + 10;
_this.getDomElement().css({ left: computedLeft + "px", top: computedTop + "px" });
})();
break;
case 'top':
(function () {
var computedTop = top - height - 10;
var computedLeft = left + parentWidth / 2 - width / 2;
_this.getDomElement().css({ left: computedLeft + "px", top: computedTop + "px" });
})();
break;
case 'bottom':
(function () {
var computedTop = top + (typeof _this.newTop !== 'undefined' ? _this.newTop : 30);
var computedLeft = left - (typeof _this.newTop !== 'undefined' ? _this.newLeft : parentWidth - 10);
_this.getDomElement().css({ left: computedLeft + "px", top: computedTop + "px" });
})();
}
};
return Tooltip;
}(Control));
var SNS$7 = getUINamespace('Input');
/**
* @classdesc 类:Input组件类
* @class Glodon.Bimface.Tiles.UI.Input
* @constructs Glodon.Bimface.Tiles.UI.Input
* @description 构造输入框组件
* @extends Glodon.Bimface.Tiles.UI.Control
* @param {Object} option 构造输入框的配置项
* @param {String} option.id 输入框ID
*/
var Input = /** @class */ (function (_super) {
__extends(Input, _super);
function Input(param) {
var _this = this;
SDM && (!param || !param.isInside) && SDM.send(SNS$7, "bf_c_UIInput_new");
param = param || {};
var elementParam = {
elementType: 'input',
className: 'bfui-input'
};
var controlParam = __assign(__assign({}, param), { elementParam: elementParam, type: 'Input', id: param.id, parent: param.parent });
_this = _super.call(this, controlParam) || this;
_this._domElement.attribute('type', 'text');
param.value != undefined && _this.setValue(param.value);
param.onChange && _this.onChange(param.onChange);
param.onClick && _this.onClick(param.onClick);
param.onBlur && _this.onBlur(param.onBlur);
return _this;
}
/**
* 获取输入框的值
* @function Glodon.Bimface.Tiles.UI.Input.prototype.getValue
* @returns {String} 输入框的值
*/
Input.prototype.getValue = function () {
return this._domElement.attribute('value');
};
/**
* 设置输入框的值
* @function Glodon.Bimface.Tiles.UI.Input.prototype.setValue
* @param {String} value 输入框的值
*/
Input.prototype.setValue = function (value) {
return this._domElement.attribute('value', value);
};
/**
* 输入框的值发生变化的事件
* @function Glodon.Bimface.Tiles.UI.Input.prototype.onChange
* @param {Function} event 输入框值发生变化时执行的函数
*/
Input.prototype.onChange = function (fn) {
var _this = this;
this.onChangeFn && this._domElement.off('change', this.onChangeFn);
this._domElement.on('change', function (evt) {
_this.onChangeFn(evt.target.value);
});
this.onChangeFn = fn;
return this;
};
Input.prototype.onBlur = function (fn) {
this.onBlurFn && this._domElement.off('blur', this.onBlurFn);
this._domElement.on('blur', fn);
this.onBlurFn = fn;
return this;
};
Input.prototype.onFocus = function (fn) {
this._domElement.on('focus', fn);
return this;
};
Input.prototype.onInput = function (fn) {
this._domElement.on('input', fn);
return this;
};
Input.prototype.enabled = function (isEnabled) {
this._domElement.attribute('disabled', isEnabled ? '' : true);
return this;
};
Input.prototype.setPlaceholder = function (placeholder) {
this._domElement.attribute('placeholder', placeholder);
};
// 开启状态组件
Input.prototype.enableStatus = function (isEnable) {
if (isEnable === void 0) { isEnable = true; }
if (isEnable) {
this._domElement.addClass('bfui-input-status');
}
else {
this._domElement.removeClass('bfui-input-status');
}
};
// 组件出错状态
Input.prototype.enableErrorStatus = function (isEnable, errorMessage, width, left, top) {
if (isEnable === void 0) { isEnable = true; }
if (width === void 0) { width = 220; }
if (left === void 0) { left = 0; }
if (top === void 0) { top = 40; }
if (isEnable) {
this._domElement.addClass('bfui-input-error');
if (!this._toolTip && errorMessage) {
this._toolTip = new Tooltip({
hostDom: this._domElement,
placement: 'bottom',
width: width,
content: errorMessage,
isFixed: false,
});
this._toolTip.setToolTipPosition({ left: left, top: top });
this._toolTip.show();
}
}
else {
this._domElement.removeClass('bfui-input-error');
if (this._toolTip) {
this._toolTip.destroy();
this._toolTip = null;
}
}
};
return Input;
}(Control));
// 组件Group
var ControlGroup = /** @class */ (function (_super) {
__extends(ControlGroup, _super);
function ControlGroup(param) {
var _this = _super.call(this, param) || this;
_this._children = [];
return _this;
}
/**
* 添加组件
* @function Glodon.Bimface.Tiles.UI.ControlGroup.prototype.addControl
* @param {Object} control UI控件,对应Glodon.Bimface.Tiles.UI下的组件相关类
* @param {Object} option 添加组件的选项
* @param {Object} option.position 组件添加的位置
* @param {Glodon.Bimface.Tiles.UI.ControlAnchor} option.position.anchor 组件添加的锚点位置
* @param {Object} option.position.offset 基于锚点的偏移值
* @param {Number} option.position.offset.x X方向偏移值,单位为px
* @param {Number} option.position.offset.y Y方向偏移值,单位为px
*/
ControlGroup.prototype.addControl = function (control, option) {
if (!option || isNaN(option.index) || option.index === -1) {
this._children.push(control);
control.setParent(this);
this._domElement.append(control.getDomElement());
}
else {
var index = option.index;
if (index < -1) {
index = this.getControlCount() + index + 1;
}
this.insertControl(control, index);
}
return this;
};
// 插入子组件到指定index
ControlGroup.prototype.insertControl = function (control, index) {
if (!isNaN(index) && index < this._children.length) {
this._children.splice(index, 0, control);
control.setParent(this);
this._domElement.insert(control.getDomElement(), index);
}
else {
this.addControl(control);
}
return this;
};
/**
* 移除指定组件
* @function Glodon.Bimface.Tiles.UI.ControlGroup.prototype.removeControl
* @param {Object} control UI控件,对应Glodon.Bimface.Tiles.UI下的组件相关类
*/
ControlGroup.prototype.removeControl = function (control) {
var index = this.indexOf(control);
if (index >= 0) {
this._children.splice(index, 1);
control.setParent(undefined);
this._domElement.remove(control.getDomElement());
}
return this;
};
ControlGroup.prototype.clearControls = function (destroy) {
if (destroy === void 0) { destroy = false; }
while (this.getControlCount() > 0) {
var control = this.getControl({ index: 0 });
this.removeControl(control);
destroy && control.destroy();
}
return this;
};
/**
* 根据筛选条件获取组件对象
* @function Glodon.Bimface.Tiles.UI.ControlGroup.prototype.getControl
* @param {Object} condition 筛选条件
* @param {String} condition.id 组件ID
* @returns {Object} UI控件,对应Glodon.Bimface.Tiles.UI下的组件相关类
*/
ControlGroup.prototype.getControl = function (condition) {
var resultControl;
if (!condition)
return;
if (condition.id) {
this.getAllControls().some(function (control) {
if (control.getId() === condition.id) {
resultControl = control;
return true;
}
});
}
else if (!isNaN(condition.index) && condition.index < this.getControlCount()) {
resultControl = this._children[condition.index];
}
return resultControl;
};
/**
* 获取所有组件
* @function Glodon.Bimface.Tiles.UI.ControlGroup.prototype.getAllControls
* @returns {Array} 组件对象列表
*/
ControlGroup.prototype.getAllControls = function () {
return this._children;
};
// 根据子组件获取index
ControlGroup.prototype.indexOf = function (control) {
return this._children.indexOf(control);
};
// 获取当前已有子组件数量
ControlGroup.prototype.getControlCount = function () {
return this._children.length;
};
return ControlGroup;
}(Control));
var SNS$6 = getUINamespace('Panel');
/**
* @classdesc 类:Panel组件类
* @class Glodon.Bimface.Tiles.UI.Panel
* @constructs Glodon.Bimface.Tiles.UI.Panel
* @description 构造面板组件
* @extends Glodon.Bimface.Tiles.UI.Control
* @param {Object} option 构造标签的配置项
* @param {String} option.id 标签组件ID
* @param {String} option.title 标签标题的文字内容
* @param {Boolean} option.sizeFixed 面板大小是否固定,默认为false
* @param {Number} option.width 面板宽度,单位为px,默认为300
* @param {Number} option.height 面板宽度,单位为px,默认为200
* @param {Boolean} option.draggable 面板是否可拖动,默认为true
* @param {Object} option.position 面板位置
* @param {Glodon.Bimface.Tiles.UI.ControlAnchor} option.position.anchor 描述面板位置的锚点
* @param {Object} option.position.offset 面板基于锚点的偏移量,单位为px,默认值为{x: 0, y: 0}
*/
//Panel组件类
/** @class */ ((function (_super) {
__extends(Panel, _super);
function Panel(param) {
var _this = this;
SDM && (!param || !param.isInside) && SDM.send(SNS$6, "bf_c_UIPanel_new");
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-panel'
};
var controlParam = {
elementParam: elementParam,
type: 'Panel',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
param.onClick && _this.onClick(param.onClick);
var header = _this.header = new Dom().createElement({ elementType: 'div', className: 'bfui-panel-header' });
var contentElementParam = {
elementType: 'div',
className: 'bfui-panel-content'
};
var contentControlParam = {
elementParam: contentElementParam,
type: 'ControlGroup',
};
var content = _this.content = new ControlGroup(contentControlParam);
_this._domElement.append(header).append(content.getDomElement());
var title = _this.title = new Dom().createElement({ elementType: 'div', className: 'bfui-panel-title' });
var headerCloseButton = _this.headerCloseButton = new Dom().createElement({ elementType: 'div', className: 'bfui-button bfui-panel-headerclosebutton gld-bf-close-sm' });
header.append(title).append(headerCloseButton);
_this.onCloseFn = function () { _this.hide(); };
headerCloseButton.on('click', _this.onCloseFn);
param.title && _this.setTitle(param.title);
_this.sizeFixed = param.sizeFixed === true;
_this.draggable = param.draggable !== false;
_this.footerDisabled = param.footerDisabled === true;
param.position && _this.setPosition(param.position);
if (!isNaN(param.width)) {
_this.width = param.width;
if (!isNaN(param.minWidth) && param.minWidth > _this.width) {
param.minWidth = _this.width;
}
}
else {
_this.width = 300;
}
param.minWidth = param.minWidth || 100;
_this.getDomElement().css({ 'width': _this.width + "px" });
if (!isNaN(param.height)) {
_this.height = param.height;
if (!isNaN(param.minHeight) && param.minHeight > _this.height) {
param.minHeight = _this.height;
}
_this.getDomElement().css('height', _this.height + "px");
}
else { // 根据产品定义,用户未定义高度时,默认最小高度200px,最大高度420px,中间根据内容浮动
_this.height = 200;
_this.getDomElement().css({ 'minHeight': "200px", 'maxHeight': "420px" });
}
param.minHeight = param.minHeight || 80;
// 鼠标按下时此panel移到最上层
_this.getDomElement().on('mousedown', function () {
_this.topShow();
});
// 设置拖动位置事件
if (_this.draggable) {
var dragging_1 = false, startX_1, startY_1, startOffsetX_1, startOffsetY_1, parentDom_1, parentDimensions_1, selfDimensions_1, selfAnchor_1;
var mousemove_1 = function (event) {
if (!dragging_1)
return;
var x = event.clientX - startX_1 + startOffsetX_1;
var y = event.clientY - startY_1 + startOffsetY_1;
// 控制panel不超出父级div范围
var parentWidth = parentDimensions_1.width, parentHeight = parentDimensions_1.height;
var selfWidth = selfDimensions_1.width, selfHeight = selfDimensions_1.height;
var minX, minY, maxX, maxY;
if (selfAnchor_1.indexOf('left') >= 0) {
minX = 0;
maxX = parentWidth - selfWidth;
}
else if (selfAnchor_1.indexOf('right') >= 0) {
minX = -parentWidth + selfWidth;
maxX = 0;
}
else if (selfAnchor_1.indexOf('center') >= 0) {
minX = -(parentWidth - selfWidth) / 2;
maxX = (parentWidth - selfWidth) / 2;
}
if (selfAnchor_1.indexOf('top') >= 0) {
minY = 0;
maxY = parentHeight - selfHeight;
}
else if (selfAnchor_1.indexOf('bottom') >= 0) {
minY = -parentHeight + selfHeight;
maxY = 0;
}
else if (selfAnchor_1.indexOf('middle') >= 0) {
minY = -(parentHeight - selfHeight) / 2;
maxY = (parentHeight - selfHeight) / 2;
}
x = Math.max(x, minX);
x = Math.min(x, maxX);
y = Math.max(y, minY);
y = Math.min(y, maxY);
_this.setOffset({ x: x, y: y });
};
var mouseup_1 = function (event) {
dragging_1 = false;
parentDom_1.off('mousemove', mousemove_1).off('mouseup', mouseup_1);
};
header.on('mousedown', function (event) {
dragging_1 = true;
startX_1 = event.clientX;
startY_1 = event.clientY;
var _a = _this.getPositionParam(), anchor = _a.anchor, _b = _a.offset, x = _b.x, y = _b.y;
selfAnchor_1 = anchor.toLowerCase();
startOffsetX_1 = x;
startOffsetY_1 = y;
parentDom_1 = parentDom_1 || new Dom(_this.getDomElement().getElement().parentElement);
parentDom_1.on('mousemove', mousemove_1).on('mouseup', mouseup_1);
parentDimensions_1 = parentDom_1.getDimensions();
selfDimensions_1 = _this.getDimensions();
}).on('mousemove', mousemove_1).on('mouseup', mouseup_1).addClass('bfui-panel-header-dragable');
}
// 设置拖动大小事件
if (!_this.sizeFixed) {
var minWidth_1 = param.minWidth, minHeight_1 = param.minHeight;
_this.sizeFixedDom = new Dom().createElement({ elementType: 'div', className: 'bfui-panel-sizefixed' });
_this.getDomElement().append(_this.sizeFixedDom);
var dragging_2 = false, startX_2, startY_2, startWidth_1, startHeight_1, parentDom_2;
var mousemove_2 = function (event) {
if (!dragging_2)
return;
var formerWidth = _this.width, formerHeight = _this.height;
_this.width = event.clientX - startX_2 + startWidth_1;
_this.height = event.clientY - startY_2 + startHeight_1;
_this.width < minWidth_1 && (_this.width = minWidth_1);
_this.height < minHeight_1 && (_this.height = minHeight_1);
_this.getDomElement().css({ width: _this.width + "px", height: _this.height + "px" });
var _a = _this.getPositionParam(), _b = _a.offset, x = _b.x, y = _b.y, anchor = _a.anchor;
var deltaX = _this.width - formerWidth, deltaY = _this.height - formerHeight;
if (anchor.indexOf('Center') >= 0) {
x += deltaX / 2;
}
if (anchor.indexOf('Middle') >= 0) {
y += deltaY / 2;
}
if (anchor.indexOf('Right') >= 0) {
x += deltaX;
}
if (anchor.indexOf('Bottom') >= 0) {
y += deltaY;
}
_this.setOffset({ x: x, y: y });
};
var mouseup_2 = function (event) {
dragging_2 = false;
parentDom_2.off('mousemove', mousemove_2).off('mouseup', mouseup_2);
};
_this.sizeFixedDom.on('mousedown', function (event) {
_this.getDomElement().css({ height: _this.getHeight() + "px" }).css({ minWidth: minWidth_1 + "px", minHeight: minHeight_1 + "px", maxHeight: '' });
dragging_2 = true;
startX_2 = event.clientX;
startY_2 = event.clientY;
startWidth_1 = _this.getWidth();
startHeight_1 = _this.getHeight();
parentDom_2 = parentDom_2 || new Dom(_this.getDomElement().getElement().parentElement);
parentDom_2.on('mousemove', mousemove_2).on('mouseup', mouseup_2);
}).on('mousemove', mousemove_2).on('mouseup', mouseup_2);
}
// 设置footer
if (_this.footerDisabled) {
var footerElementParam = {
elementType: 'div',
className: 'bfui-panel-footer'
};
var footerControlParam = {
elementParam: footerElementParam,
type: 'ControlGroup',
};
_this.footer = new ControlGroup(footerControlParam);
_this._domElement.append(_this.footer.getDomElement());
}
return _this;
}
Panel.prototype.setTips = function (tips, type) {
if (this.tipsElement) {
this.tipsElement.destroy();
}
var classMap = {
default: "bfui-panel-tips",
loading: "bfui-panel-loading"
};
var className = classMap[type] || classMap.default;
var tipsElement = new Dom().createElement({ elementType: 'div', className: className });
tipsElement.html(tips);
this.tipsElement = tipsElement;
this.showTips();
};
Panel.prototype.showTips = function () {
if (this.tipsElement) {
this.content.getDomElement().html('');
this.content.getDomElement().append(this.tipsElement);
return this;
}
};
Panel.prototype.getContent = function () {
return this.content;
};
Panel.prototype.clearContent = function () {
this.content.getDomElement().html('');
return this;
};
Panel.prototype.getFooter = function () {
return this.footer;
};
Panel.prototype.clearFooter = function () {
this.footerDisabled && this.footer.getDomElement().html('');
return this;
};
/**
* 设置面板标题文字内容
* @function Glodon.Bimface.Tiles.UI.Panel.prototype.setTitle
* @param {String} text 面板标题文字内容
*/
Panel.prototype.setTitle = function (text) {
this.title.html(text);
return this;
};
/**
* 获取面板标题文字内容
* @function Glodon.Bimface.Tiles.UI.Panel.prototype.getTitle
* @returns {String} 面板标题文字内容
*/
Panel.prototype.getTitle = function () {
return this.title.html();
};
/**
* 添加控件
* @function Glodon.Bimface.Tiles.UI.Panel.prototype.addControl
* @param {Object} control UI控件,对应Glodon.Bimface.Tiles.UI下的组件相关类
* @param {Object} option 添加控件的选项(选填)
* @param {Number} index 控件插入位置,index为0时控件插入至面板第一个位置,1为第二个位置,以此类推,为-1时则将该控件放至面板最后
*/
Panel.prototype.addControl = function (control, option) {
this.content.addControl(control, option);
return this;
};
/**
* 移除控件
* @function Glodon.Bimface.Tiles.UI.Panel.prototype.removeControl
* @param {Object} control UI控件,对应Glodon.Bimface.Tiles.UI下的组件相关类
*/
Panel.prototype.removeControl = function (control) {
this.content.removeControl(control);
return this;
};
/**
* 获取指定控件的序号
* @function Glodon.Bimface.Tiles.UI.Panel.prototype.indexOf
* @param {Object} control UI控件,对应Glodon.Bimface.Tiles.UI下的组件相关类
* @returns {Number} 控件在面板中的序号
*/
Panel.prototype.indexOf = function (control) {
return this.content.indexOf(control);
};
/**
* 根据筛选条件获取控件对象
* @function Glodon.Bimface.Tiles.UI.Panel.prototype.getControl
* @param {Object} condition 筛选条件
* @param {String} condition.id 控件ID
* @param {Number} condition.index 控件在面板中的序号
* @returns {Object} UI控件,对应Glodon.Bimface.Tiles.UI下的组件相关类
*/
Panel.prototype.getControl = function (condition) {
return this.content.getControl(condition);
};
/**
* 根据筛选条件获取控件对象
* @function Glodon.Bimface.Tiles.UI.Panel.prototype.getAllControls
* @returns {Array} 由控件对象组成的列表
*/
Panel.prototype.getAllControls = function () {
return this.content.getAllControls();
};
/**
* 面板关闭的事件
* @function Glodon.Bimface.Tiles.UI.Panel.prototype.onClose
* @param {Function} event 面板关闭时执行的函数
*/
Panel.prototype.onClose = function (fn, hide) {
var _this = this;
if (hide === void 0) { hide = true; }
this.headerCloseButton.off('click', this.onCloseFn);
this.onCloseFn = function (data) {
fn(data);
hide && _this.hide();
};
this.headerCloseButton.on('click', this.onCloseFn);
return this;
};
Panel.prototype.topShow = function () {
var list = document.querySelectorAll('.bfui-panel');
list.forEach(function (element) {
var dom = new Dom(element);
dom.removeClass('bfui-panel-topshow');
});
this.getDomElement().addClass('bfui-panel-topshow');
};
return Panel;
})(Control));
/**
* SelectOption组件类,作为Select组件的单条option
*/
var SelectOption = /** @class */ (function (_super) {
__extends(SelectOption, _super);
function SelectOption(param) {
var _this = this;
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-select-option'
};
var controlParam = {
elementParam: elementParam,
type: 'SelectOption',
};
_this = _super.call(this, controlParam) || this;
_this.setTooltip(param.text).getDomElement().html(param.text);
_this.disabled = param.disabled === true;
_this.selected = param.selected === true;
_this.value = param.value;
_this.setDisabled(_this.disabled).setSelected(_this.selected);
param.visible === false && _this.hide();
// 点击本条option时,调用SelectOptionGroup的setSelected事件,将本条option设置为选中,其他option取消选中
_this.onClick(function () {
if (!_this.selected && !_this.disabled) {
_this._parent.setSelected(_this);
}
_this.trigger(UIEvents$1.Clicked);
});
return _this;
}
/**
* 设置选中状态
* @param {Boolean} selected 选中状态
*/
SelectOption.prototype.setSelected = function (selected) {
if (!this.disabled && this.selected !== selected) {
this.selected = selected;
selected ? this.addClass('bfui-select-option-selected') : this.removeClass('bfui-select-option-selected');
}
return this;
};
/**
* 设置不可用状态
* @param {Boolean} disabled 不可用状态
*/
SelectOption.prototype.setDisabled = function (disabled) {
if (this.disabled !== disabled) {
this.setSelected(false);
this.disabled = disabled;
disabled ? this.addClass('bfui-select-option-disabled') : this.removeClass('bfui-select-option-disabled');
}
return this;
};
/**
* 获取option的文本内容
*/
SelectOption.prototype.getText = function () {
return this.getDomElement().html();
};
/**
* 获取option的实际value,如未设置value则返回option的text文本内容
*/
SelectOption.prototype.getValue = function () {
return this.value === undefined ? this.getText() : this.value;
};
return SelectOption;
}(Control));
/**
* SelectOptionGroup组件类,管理多条SelectOption
*/
var SelectOptionGroup = /** @class */ (function (_super) {
__extends(SelectOptionGroup, _super);
function SelectOptionGroup(config) {
var _this = this;
var contentElementParam = {
elementType: 'div',
className: 'bfui-select-content'
};
var contentControlParam = {
// parent: document.getElementsByTagName('body')[0],
elementParam: contentElementParam,
type: 'ControlGroup',
};
_this = _super.call(this, contentControlParam) || this;
_this.enableAnimation = config.enableAnimation !== false;
_this.enableAnimation && _this.addClass('bfui-select-animation');
_this._maxHeight = config.maxHeight || 125;
_this._showTop = false;
_this.getDomElement().css('maxHeight', _this._maxHeight + "px");
config.values && _this.setValues(config.values);
_this.hide();
return _this;
}
/**
* 设置option内容
* @param {Array} values option内容
*/
SelectOptionGroup.prototype.setValues = function (values) {
var _this = this;
this.clearControls();
this.values = [];
values.forEach(function (value) {
var param;
if (!DataUtil.assertType(value, 'obj')) {
param = { text: value.toString() };
}
else {
param = value;
}
_this.values.push(param);
var option = new SelectOption(param);
_this.addControl(option);
option.on(UIEvents$1.Clicked, function () {
_this.trigger(UIEvents$1.Clicked, option);
});
});
this._height = 0;
return this;
};
/**
* 获取当前显示/隐藏状态
*/
SelectOptionGroup.prototype.isVisible = function () {
return this.enableAnimation ? this._visible : _super.prototype.isVisible.call(this);
};
SelectOptionGroup.prototype.getOptionsHeight = function () {
if (!this._height) {
var height_1 = 2;
this._children && this._children.forEach(function (child) {
if (child.isVisible()) {
height_1 += child.getHeight();
}
});
this._height = height_1;
}
return this._height;
};
SelectOptionGroup.prototype.setFixedPosition = function (position) {
var pageHeight = window.innerHeight, maxHeight = this._maxHeight, dom = this.getDomElement().getElement(), minHeight = Math.min(maxHeight, this.getOptionsHeight());
if (position.bottom + minHeight > pageHeight) {
dom.style.top = '';
dom.style.bottom = pageHeight - position.top + 'px';
}
else {
dom.style.top = position.bottom + 'px';
dom.style.bottom = '';
}
dom.style.left = position.left + 'px';
dom.style.width = position.right - position.left + 'px';
};
SelectOptionGroup.prototype.setTop = function (value) {
this._showTop = value;
if (value) {
this.removeClass('bfui-select-animation');
}
else {
this.addClass('bfui-select-animation');
}
};
/**
* 显示组件
*/
SelectOptionGroup.prototype.show = function () {
var _this = this;
if (this.enableAnimation) { // 支持动画状态时,通过height变化显示组件
this._visible = true;
var transitionEndFn_1 = function () {
if (_this._inTransition) {
_this.getDomElement().removeClass('bfui-select-overflow-hidden').off('transitionend', transitionEndFn_1);
_this._inTransition = false;
}
};
this._inTransition = true;
this.getDomElement().addClass('bfui-select-overflow-hidden').css({ 'border-width': '1px', 'height': this.getOptionsHeight() + 'px' }).on('transitionend', transitionEndFn_1);
if (this._showTop) {
var topMargin = 27 + this.getOptionsHeight();
this.getDomElement().css({ 'margin-top': '-' + topMargin + 'px' });
}
}
else {
_super.prototype.show.call(this);
}
return this;
};
/**
* 隐藏组件
*/
SelectOptionGroup.prototype.hide = function () {
if (this.enableAnimation) { // 支持动画状态时,通过height变化隐藏组件
this._visible = false;
this.getDomElement().addClass('bfui-select-overflow-hidden').css({ 'border-width': '0px', 'height': '0px' });
}
else {
_super.prototype.hide.call(this);
}
return this;
};
/**
* 设置某条option为选中状态,其他option取消选中
* @param {SelectOption | string} option 选中的内容
*/
SelectOptionGroup.prototype.setSelected = function (option) {
if (option === undefined)
return;
var isValidOption = false;
if (!(option instanceof SelectOption)) {
this.getAllControls().some(function (cControl) {
if (cControl.getText() === option.toString()) {
option = cControl;
isValidOption = true;
return true;
}
});
}
else if (this.indexOf(option) >= 0) {
isValidOption = true;
}
if (isValidOption && this.selected !== option) {
this.getAllControls().forEach(function (cControl) {
cControl.setSelected(cControl === option ? true : false);
});
this.selected = option;
var text = this.selected.getText();
var index = this.indexOf(this.selected);
var value = this.selected.getValue();
this.trigger(UIEvents$1.ValueChanged, { text: text, value: value, index: index });
}
return this;
};
/**
* 根据序号设置Option选中状态
* @param {Number} index Option
*/
SelectOptionGroup.prototype.setSelectedByIndex = function (index) {
var option = this.getControl({ index: index });
if (option) {
this.setSelected(option);
}
return this;
};
/**
* 根据Value设置Option选中状态
* @param {String | Number} value Option的Value值
*/
SelectOptionGroup.prototype.setSelectedByValue = function (value) {
var result;
this.getAllControls().some(function (option) {
option = option;
if (option.getValue() === value) {
result = option;
return true;
}
});
return this.setSelected(result);
};
/**
* 获取当前选中的Option
*/
SelectOptionGroup.prototype.getSelected = function () {
return this.selected;
};
/**
* 获取所有Option的信息数组
*/
SelectOptionGroup.prototype.getValues = function () {
return this.values;
};
SelectOptionGroup.prototype.clearSelection = function () {
this.selected = null;
this.trigger(UIEvents$1.ValueChanged);
};
SelectOptionGroup.prototype.setMaxHeight = function (maxHeight) {
this._maxHeight = maxHeight;
this.getDomElement().css('maxHeight', this._maxHeight + "px");
};
return SelectOptionGroup;
}(ControlGroup));
getUINamespace('Select');
/**
* Select组件类
*/
/** @class */ ((function (_super) {
__extends(Select, _super);
function Select(param) {
var _this = this;
// SDM && SDM.send(SNS, "bf_c_UISelect_new");
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-select'
};
var controlParam = __assign(__assign({}, param), { elementParam: elementParam, type: 'Select', id: param.id, parent: param.parent });
_this = _super.call(this, controlParam) || this;
_this.enableAnimation = param.enableAnimation !== false;
// Select的header部分,由显示的选中Text及下拉button组成
var header = _this.header = new Dom().createElement({ elementType: 'div', className: 'bfui-select-header' });
var title = _this.title = new Dom().createElement({ elementType: 'div', className: 'bfui-select-title' });
title.html('请选择');
var toggleButton = _this.toggleButton = new Dom().createElement({ elementType: 'div', className: 'bfui-button bfui-select-togglebutton gld-bf-arrow-down-sm' });
_this.enableAnimation && toggleButton.addClass('bfui-select-animation');
header.append(title).append(toggleButton).on('click', function (evt) {
if (_this.disabled)
return;
_this.content.isVisible() ? _this.hideContent() : _this.showContent();
});
// Select的content部分,基于ControlGroup建立了SelectOptionGroup子类,用于管理多个SelectOption
var content = _this.content = new SelectOptionGroup({ enableAnimation: _this.enableAnimation, values: param.values, maxHeight: param.maxHeight });
_this.getDomElement().append(header);
new Dom(document.body).append(content.getDomElement());
_this.onChange(param.onChange);
// 选中项发生变化时,更新header文字,隐藏content,并触发onChange事件
content.on(UIEvents$1.ValueChanged, function (data) {
data && _this.title.html(data.text);
_this.onChangeCallback instanceof Function && _this.onChangeCallback(data);
});
content.on(UIEvents$1.Clicked, function (clickedOption) {
_this.hideContent();
});
// this.getDomElement().on('mouseleave', ()=> this.hideContent()); // 鼠标离开Select组件时隐藏content
param.defaultIndex !== undefined && _this.setSelected(param.defaultIndex); // 根据配置设置初始选中序号
param.width && (_this.getDomElement().css('width', param.width + "px")); // 根据配置设置Select组件的宽度
document.addEventListener('mousedown', function (evt) {
var headerDom = header.getElement(), targetParent = evt.target.parentElement;
if (evt.target == headerDom || targetParent == headerDom || targetParent == content.getDomElement().getElement() || evt.target == content.getDomElement().getElement()) {
return;
}
_this.hideContent();
}, false);
window.addEventListener('resize', function () {
_this._resize();
});
_this.scrollFunc = _this._scrollFunc.bind(_this);
return _this;
}
Select.prototype._resize = function () {
var domRect = this.header.getPosition();
this.content.setFixedPosition(domRect);
};
/**
* 设置option内容
* @param {Array} values 由string或IOptionParam组成的数组
*/
Select.prototype.setValues = function (values) {
this.content.setValues(values);
return this;
};
/**
* 设置选中项
* @param {Number} index 选中序号
*/
Select.prototype.setSelected = function (index) {
this.content.setSelectedByIndex(index);
this.title.html(this.content.getSelected().getText());
this.hideContent();
return this;
};
/**
* 根据Value设置Option选中状态
* @param {String | Number} value Option的Value值
*/
Select.prototype.setSelectedByValue = function (value) {
this.content.setSelectedByValue(value);
return this;
};
/**
* 设置Select组件不可用状态
* @param {Boolean} disabled 组件不可用状态,默认为true
*/
Select.prototype.setDisabled = function (disabled) {
if (disabled === void 0) { disabled = true; }
this.disabled = disabled;
disabled ? this.addClass('bfui-select-disabled') : this.removeClass('bfui-select-disabled');
return this;
};
/**
* 设置onChange回调函数
* @param {Function} fn onChange回调函数
*/
Select.prototype.onChange = function (fn) {
fn instanceof Function && (this.onChangeCallback = fn);
return this;
};
Select.prototype._scrollFunc = function () {
this.hideContent();
//移除监听容器的滚动事件
this.getDomElement().getParent().removeEventListener('scroll', this.scrollFunc, false);
};
/**
* 显示options
*/
Select.prototype.showContent = function () {
this.toggleButton.addClass('bfui-select-togglebutton-opened');
this._resize();
this.content.show();
//监听容器的滚动事件
this.getDomElement().getParent().addEventListener('scroll', this.scrollFunc, false);
return this;
};
/**
* 隐藏options
*/
Select.prototype.hideContent = function () {
this.toggleButton.removeClass('bfui-select-togglebutton-opened');
this.content.hide();
return this;
};
Select.prototype.clearSelection = function (defaultText) {
this.content.clearSelection();
this.setText(defaultText);
return this;
};
Select.prototype.setText = function (text) {
this.title.html(text);
return this;
};
Select.prototype.setMaxHeight = function (maxHeight) {
this.content.setMaxHeight(maxHeight);
};
Select.prototype.setId = function (id) {
this.id = id;
};
Select.prototype.getId = function () {
return this.id;
};
return Select;
})(Control));
getUINamespace('Switch');
//Switch组件类
/** @class */ ((function (_super) {
__extends(Switch, _super);
function Switch(param) {
// SDM && SDM.send(SNS, "bf_c_UISwitch_new");
var _this = this;
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-switch'
};
var controlParam = {
elementParam: elementParam,
type: 'Switch',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
param.onClick && _this.onClick(param.onClick);
param.onChange && _this.onChange(param.onChange);
var switchPart = _this.switchPart = new Dom().createElement({ elementType: 'input', className: 'bfui-switch-switch' });
switchPart.attribute('type', 'checkbox');
switchPart.on('click', function () {
_this.value = switchPart.attribute('checked');
_this.onChangeFn && _this.onChangeFn(_this.value);
});
var textPart = _this.textPart = new Dom().createElement({ elementType: 'div', className: 'bfui-switch-text' });
_this._domElement.append(switchPart).append(textPart);
param.text && _this.setText(param.text);
param.value && _this.setValue(param.value);
return _this;
}
// 获取文本
Switch.prototype.getText = function () {
return this.textPart.html();
};
// 设置文本
Switch.prototype.setText = function (text) {
this.textPart.html(text);
return this;
};
// 获取当前switch状态
Switch.prototype.getValue = function () {
return this.value;
};
// 设置switch状态
Switch.prototype.setValue = function (value) {
this.value = value;
this.switchPart.attribute('checked', value);
this.trigger(UIEvents$1.ValueChanged, this, value);
return this;
};
Switch.prototype.onChange = function (fn) {
fn instanceof Function && (this.onChangeFn = fn);
return this;
};
return Switch;
})(Control));
var CheckState = /** @class */ (function (_super) {
__extends(CheckState, _super);
function CheckState(param) {
var _this = _super.call(this, param) || this;
var inputPart = _this.inputPart = new Dom().createElement({ elementType: 'input', className: param.className });
inputPart.attribute('type', param.name);
_this._domElement.on('click', function (evt) {
if (!evt.target.hasClass(param.className)) {
_this.inputPart.getElement().click();
}
});
inputPart.on('change', function () {
_this.trigger(UIEvents$1.ValueChanged, _this, _this.getValue(), _this.isChecked());
});
var textPart = _this.textPart = new Dom().createElement({ elementType: 'label', className: "bfui-checkState-text" });
_this._domElement.append(inputPart).append(textPart);
_this.setValue(param.value === undefined ? true : param.value);
param.label && _this.setLabel(param.label);
param.enabled === false && _this.setEnabled(param.enabled);
param.checked === true && _this.setChecked(param.checked);
return _this;
}
/**
* 多选框选中状态发生变化的事件
* @function Glodon.Bimface.Tiles.UI.CheckState.prototype.onChange
* @param {Function} event 多选框选中状态发生变化时执行的函数
*/
CheckState.prototype.onChange = function (fn) {
this.on(UIEvents$1.ValueChanged, fn);
return this;
};
/**
* 获取多选框文字内容
* @function Glodon.Bimface.Tiles.UI.CheckState.prototype.getLabel
* @returns {String} 多选框文字内容
*/
CheckState.prototype.getLabel = function () {
return this.textPart.html();
};
/**
* 设置多选框文字内容
* @function Glodon.Bimface.Tiles.UI.CheckState.prototype.setLabel
* @param {String} text 多选框文字内容
*/
CheckState.prototype.setLabel = function (text) {
this.textPart.html(text);
return this;
};
/**
* 获取多选框的启用状态
* @function Glodon.Bimface.Tiles.UI.CheckState.prototype.isEnabled
* @returns {Boolean} 多选框的启用状态
*/
CheckState.prototype.isEnabled = function () {
return !this.inputPart.attribute('disabled');
};
/**
* 设置多选框的启用状态
* @function Glodon.Bimface.Tiles.UI.CheckState.prototype.setEnabled
* @param {Boolean} isEnabled 多选框的启用状态
*/
CheckState.prototype.setEnabled = function (isEnabled) {
if (isEnabled != this.isEnabled()) {
this.textPart.toggle('bfui-checkState-text-disabled');
this.inputPart.attribute('disabled', !isEnabled);
}
return this;
};
/**
* 获取多选框的选中状态
* @function Glodon.Bimface.Tiles.UI.CheckState.prototype.isChecked
* @returns {Boolean} 多选框的选中状态
*/
CheckState.prototype.isChecked = function () {
return this.inputPart.attribute('checked');
};
/**
* 设置多选框的选中状态
* @function Glodon.Bimface.Tiles.UI.CheckState.prototype.setChecked
* @param {Boolean} checked 多选框的选中状态
*/
CheckState.prototype.setChecked = function (checked) {
if (checked != this.isChecked()) {
this.inputPart.attribute('checked', checked);
this.trigger(UIEvents$1.ValueChanged, this, this.getValue(), checked);
}
return this;
};
/**
* 获取多选框的返回值
* @function Glodon.Bimface.Tiles.UI.CheckState.prototype.getValue
* @returns {String} 多选框的返回值
*/
CheckState.prototype.getValue = function () {
return this.value;
};
/**
* 设置多选框的返回值
* @function Glodon.Bimface.Tiles.UI.CheckState.prototype.setValue
* @param {String} value 多选框的返回值
*/
CheckState.prototype.setValue = function (value) {
this.value = value;
return this;
};
return CheckState;
}(Control));
var SNS$5 = getUINamespace('Checkbox');
/**
* @classdesc 类:Checkbox组件类
* @class Glodon.Bimface.Tiles.UI.Checkbox
* @constructs Glodon.Bimface.Tiles.UI.Checkbox
* @extends Glodon.Bimface.Tiles.UI.CheckState
* @extends Glodon.Bimface.Tiles.UI.Control
* @description 构造Checkbox组件对象
* @param {Object} option 构造多选框的配置项
* @param {String} option.id 多选框ID
* @param {String} option.label 多选框文字内容
* @param {String} option.value 多选框状态变化时的返回值
* @param {Boolean} option.checked 多选框的选中状态,缺省值为false
* @param {Boolean} option.enabled 多选框是否可用,缺省值为true
*/
var Checkbox = /** @class */ (function (_super) {
__extends(Checkbox, _super);
function Checkbox(param) {
var _this = this;
SDM && (!param || !param.isInside) && SDM.send(SNS$5, "bf_c_UICheckBox_new");
var elementParam = {
elementType: 'div',
className: 'bfui-checkbox'
};
var controlParam = {
elementParam: elementParam,
type: 'Checkbox',
name: 'checkbox',
id: param.id,
className: 'bfui-checkbox-checkbox',
parent: param.parent
};
param = Object.assign({}, controlParam, param);
_this = _super.call(this, param) || this;
return _this;
}
return Checkbox;
}(CheckState));
getUINamespace('Collapse');
//Collapse组件类
var Collapse = /** @class */ (function (_super) {
__extends(Collapse, _super);
function Collapse(param) {
// SDM && SDM.send(SNS, "bf_c_UICollapse_new");
var _this = this;
var elementParam = {
elementType: 'tbody',
className: 'bfui-collapse-tbody'
};
var controlParam = {
elementParam: elementParam,
type: 'Collapse',
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
// let tbodyPart = this.tbodyPart = new Dom().createElement({ elementType: 'tbody', className :param.isCollapse?'bf-collapse':'' });
var tbodyPart = _this._domElement;
var titlePart = new Dom().createElement({ elementType: 'tr', className: 'bfui-collapse-title bfui-transition' });
if (param.group === '基本属性') {
param.group = window.BimfaceLanguage.bf_panel_basic_attribute;
}
titlePart.html("" + param.group + " | ");
tbodyPart.append(titlePart);
if (param.items && param.items.length > 0) {
param.items.forEach(function (item) {
var tr = new Dom().createElement({ elementType: 'tr', className: 'bfui-collapse-content' });
tr.html("" + item.key + " | " + item.value + " | ");
tbodyPart.append(tr);
});
}
titlePart.on('click', function () {
tbodyPart.toggleClass('bfui-collapse-collapse');
});
return _this;
}
return Collapse;
}(Control));
getUINamespace('Radio');
//Radio组件类
var Radio = /** @class */ (function (_super) {
__extends(Radio, _super);
function Radio(param) {
// SDM && SDM.send(SNS, "bf_c_UIRadio_new");
var _this = this;
var elementParam = {
elementType: 'div',
className: 'bfui-radio'
};
var controlParam = {
elementParam: elementParam,
type: 'Radio',
name: 'radio',
id: param.id,
className: 'bfui-radio-radio',
parent: param.parent
};
param = Object.assign({}, controlParam, param);
_this = _super.call(this, param) || this;
return _this;
}
return Radio;
}(CheckState));
getUINamespace('Slider');
//Slider组件类
/** @class */ ((function (_super) {
__extends(Slider, _super);
function Slider(param) {
// SDM && SDM.send(SNS, "bf_c_UISlider_new");
var _this = this;
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-slider'
};
var controlParam = {
elementParam: elementParam,
type: 'Slider',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
_this.minValue = param.minValue || 0;
_this.maxValue = param.maxValue || 100;
param.onClick && _this.onClick(param.onClick);
_this.onChangeCallback = param.onChangeCallback || param.onChange;
var sliderLinePart = _this.sliderLinePart = new Dom().createElement({ elementType: 'div', className: 'bfui-slider-line' });
var sliderLeftPart = _this.sliderLeftPart = new Dom().createElement({ elementType: 'div', className: 'bfui-slider-left' });
var sliderValuePart = _this.sliderValuePart = new Dom().createElement({ elementType: 'div', className: 'bfui-slider-value' });
_this._domElement.append(sliderLinePart).append(sliderLeftPart).append(sliderValuePart);
_this.setValue(param.value || 0);
_this.setEnableTooltip(param.enableTooltip);
_this.on(UIEvents$1.ValueChanged, function (data) {
_this.onChangeCallback instanceof Function && _this.onChangeCallback(Math.round(data));
});
var dragging = false;
var startX, startValue;
sliderValuePart.on('mousedown', function (data) {
dragging = true;
startX = data.clientX;
startValue = _this.getValue();
if (_this.enableTooltip && _this.tooltipControl) {
_this.tooltipControl.setEnableAlwaysShow(true);
}
});
var setValue = function (data) {
if (!dragging)
return;
var cX = data.clientX;
var cValue = startValue + ((cX - startX) * (_this.maxValue - _this.minValue) / (_this.sliderLinePart.getWidth() - 10));
cValue > _this.maxValue && (cValue = _this.maxValue);
cValue < _this.minValue && (cValue = _this.minValue);
_this.setValue(cValue);
startX = cX;
startValue = cValue;
if (_this.enableTooltip && _this.tooltipControl) {
_this.tooltipControl.updatePosition();
}
data.preventDefault && data.preventDefault();
};
var body = new Dom(document.body);
body.on('mousemove', setValue);
body.on('mouseup', function (data) {
setValue(data);
if (_this.enableTooltip && _this.tooltipControl) {
_this.tooltipControl.setEnableAlwaysShow(false);
}
dragging = false;
});
return _this;
// this._domElement.on('mouseout', (data: any)=> {setValue(data); dragging = false});
}
Slider.prototype.setValueRange = function (minValue, maxValue) {
this.minValue = minValue;
this.maxValue = maxValue;
};
// 获取当前slider的值
Slider.prototype.getValue = function () {
return this.value;
};
// 设置slider的值
Slider.prototype.setValue = function (value) {
this.value = Math.round(value);
var cssValue = (this.sliderLinePart.getWidth() - 10) * this.value / (this.maxValue - this.minValue);
this.sliderValuePart.css('left', cssValue + "px");
this.sliderLeftPart.css('width', cssValue + 3 + "px");
this.trigger(UIEvents$1.ValueChanged, this.value);
if (this.enableTooltip) {
this.setTooltipValue();
}
return this;
};
/**
* 设置onChange回调函数
* @param {Function} fn onChange回调函数
*/
Slider.prototype.onChange = function (fn) {
fn instanceof Function && (this.onChangeCallback = fn);
return this;
};
Slider.prototype.setEnableTooltip = function (enable) {
this.enableTooltip = enable;
if (enable && !this.tooltipControl) {
this.tooltipControl = new Tooltip({
hostDom: this.sliderValuePart,
content: '',
placement: 'top',
theme: 'dark',
className: 'bfui-slider-tooltip'
});
this.setTooltipValue();
}
};
Slider.prototype.setTooltipFormater = function (fn) {
this.tooltipFormater = fn;
this.setTooltipValue();
};
Slider.prototype.setTooltipValue = function () {
if (!this.enableTooltip || !this.tooltipControl)
return;
this.tooltipControl.setHTML(this.tooltipFormater ? this.tooltipFormater(this.getValue()) : this.getValue().toString());
};
Slider.prototype.getTooltipControl = function () {
return this.tooltipControl;
};
return Slider;
})(Control));
var SNS$4 = getUINamespace('Tree');
//Tree组件类
var Tree = /** @class */ (function (_super) {
__extends(Tree, _super);
function Tree(param) {
var _this = this;
SDM && (!param || !param.isInside) && SDM.send(SNS$4, "bf_c_UITree_new");
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-tree'
};
var controlParam = {
elementParam: elementParam,
type: 'Tree',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
var contentElementParam = {
elementType: 'div',
className: 'bfui-tree-content'
};
var contentControlParam = {
elementParam: contentElementParam,
type: 'ControlGroup',
};
var content = _this.content = new ControlGroup(contentControlParam);
_this.header = new Dom().createElement({ elementType: 'div', className: 'bfui-tree-header' });
_this.footer = new Dom().createElement({ elementType: 'div', className: 'bfui-tree-footer' });
_this.title = new Dom().createElement({ elementType: 'div', className: 'bfui-tree-title' });
_this._domElement.append(content.getDomElement());
// this._domElement.append(header).append(content.getDomElement()).append(footer);
// header.append(title);
param.title && _this.setTitle(param.title);
_this.sizeFixed = param.sizeFixed;
return _this;
}
Tree.prototype.addTreeNode = function (control, option) {
var _this = this;
this.content.addControl(control, option);
control.on(UIEvents$1.RightClicked, function (params) {
_this.trigger(UIEvents$1.RightClicked, params);
});
};
Tree.prototype.getControl = function (condition) {
return this.content.getControl(condition);
};
Tree.prototype.getAllControls = function () {
return this.content.getAllControls();
};
/******* public for client *********/
// 设置Header文字
Tree.prototype.setTitle = function (text) {
this.title.html(text);
return this;
};
Tree.prototype.getTitle = function () {
return this.title.html();
};
// 获取当前选择项
Tree.prototype.getSelection = function () {
// 交互细节待补充
};
// 清空当前选择
Tree.prototype.clearSelection = function () {
var selection = function (control) {
if (control.length > 0) {
control.find(function (subChild) {
if (subChild.getSelectState()) {
subChild.setSelectState(false);
}
else {
selection(subChild.getAllControls());
}
});
}
};
selection(this.getAllControls());
};
return Tree;
}(Control));
/**
* @namespace Glodon.Bimface.Tiles.UI.ControlAlignOption
* @classdesc 常量:UI对齐样式(控件对齐样式的选项)
* @description Glodon.Bimface.Tiles.UI.ControlAlignOption
* @property {String} Left 左侧对齐
* @property {String} Center 居中对齐
* @property {String} Right 右侧对齐
* @property {String} Top 顶部对齐
* @property {String} Middle 中部对齐
* @property {String} Bottom 底部对齐
*/
var ControlAlignOption;
(function (ControlAlignOption) {
ControlAlignOption["Left"] = "Left";
ControlAlignOption["Center"] = "Center";
ControlAlignOption["Right"] = "Right";
ControlAlignOption["Top"] = "Top";
ControlAlignOption["Middle"] = "Middle";
ControlAlignOption["Bottom"] = "Bottom";
})(ControlAlignOption || (ControlAlignOption = {}));
var ControlAlignOption$1 = ControlAlignOption;
var SNS$3 = getUINamespace('Toolbar');
/**
* @classdesc 类:工具条组件类
* @class Glodon.Bimface.Tiles.UI.Toolbar
* @constructs Glodon.Bimface.Tiles.UI.Toolbar
* @extends Glodon.Bimface.Tiles.UI.Control
* @extends Glodon.Bimface.Tiles.UI.ControlGroup
* @description 构造工具条组件对象
* @param {Object} option 构造工具条对象的配置项
* @param {String} option.id 工具条对象ID
* @param {Boolean} option.isHorizontal 工具条是否为水平放置,默认为true
* @param {Boolean} option.isFullLength 工具条长度是否与视图DOM容器保持一致,默认为false
* @param {Glodon.Bimface.Tiles.UI.ControlAlignOption} option.controlAlign 组件的对齐方式,当水平放置时默认为Left,垂直放置时默认为Top
*/
/** @class */ ((function (_super) {
__extends(Toolbar, _super);
function Toolbar(param) {
var _this = this;
(!param || !param.isInside) && SDM.send(SNS$3, "bf_c_UIToolbar_new");
param = param || {};
var elementParam = SyleUtil.formatElementParam({
elementType: 'div',
className: 'bfui-toolbar'
}, param.elementParam);
var controlParam = {
elementParam: elementParam,
type: 'Toolbar',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
_this.isHorizontal = param.isHorizontal !== false;
_this.isFullLength = param.isFullLength === true;
_this.controlAlign = param.controlAlign || (_this.isHorizontal ? ControlAlignOption$1.Left : ControlAlignOption$1.Top);
var fullClass = _this.isFullLength ? '-full' : '';
_this.isHorizontal ? _this.addClass("bfui-toolbar-horizontal" + fullClass) : _this.addClass("bfui-toolbar-vertical" + fullClass);
_this.addClass("bfui-align-" + _this.controlAlign.toLowerCase());
return _this;
}
return Toolbar;
})(ControlGroup));
var SNS$2 = getUINamespace('Row');
var JustifyContent;
(function (JustifyContent) {
JustifyContent["Start"] = "flex-start";
JustifyContent["End"] = "flex-end";
JustifyContent["Center"] = "center";
JustifyContent["Between"] = "space-between";
JustifyContent["Around"] = "space-around";
})(JustifyContent || (JustifyContent = {}));
/**
* @classdesc 类:行元素组件类
* @class Glodon.Bimface.Tiles.UI.Row
* @constructs Glodon.Bimface.Tiles.UI.Row
* @extends Glodon.Bimface.Tiles.UI.Control
* @extends Glodon.Bimface.Tiles.UI.ControlGroup
* @description 构造行元素组件对象
* @param {Object} option 构造行元素对象的配置项
* @param {String} option.id 行元素对象ID
*/
var Row = /** @class */ (function (_super) {
__extends(Row, _super);
function Row(param) {
var _this = this;
(!param || !param.isInside) && SDM.send(SNS$2, "bf_c_UIRow_new");
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-row'
};
var controlParam = {
elementParam: elementParam,
type: 'Row',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
_this.setJustifyContent(param.justifyContent);
param.contents && param.contents.forEach(function (control) {
_this.addControl(control);
});
return _this;
}
Row.prototype.setJustifyContent = function (justifyContentKeyParam) {
var justifyContentKey = Object.keys(JustifyContent).indexOf(justifyContentKeyParam) >= 0 ? justifyContentKeyParam : 'Between';
var justifyContent = JustifyContent[justifyContentKey];
this.getDomElement().css('justifyContent', justifyContent);
};
return Row;
}(ControlGroup));
var SNS$1 = getUINamespace('RadioGroup');
/**
* @classdesc 类:RadioGroup组件类
* @class Glodon.Bimface.Tiles.UI.RadioGroup
* @constructs Glodon.Bimface.Tiles.UI.RadioGroup
* @description 构造单选组件对象
* @extends Glodon.Bimface.Tiles.UI.Control
* @param {Object} opt 构造单选组件的配置项
* @param {String} opt.id 单选对象ID
* @param {Array} opt.options 单选框数组
* @param {String} opt.options.value 单选框的返回值
* @param {String} opt.options.label 单选框显示的文本信息
* @param {Boolean} opt.options.checked 单选框的选中状态
* @param {Boolean} opt.options.enabled 单选框的可用状态,缺省值为true
*/
/** @class */ ((function (_super) {
__extends(RadioGroup, _super);
function RadioGroup(param) {
var _this = this;
(!param || !param.isInside) && SDM.send(SNS$1, "bf_c_UIRadioGroup_new");
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-radioGroup'
};
var controlParam = {
elementParam: elementParam,
type: 'RadioGroup',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
_this.radioArray = [];
param.options && _this.setOptions(param.options);
_this.on(UIEvents$1.ValueChanged, function (radio, value, checked) {
checked && _this.setCheckedByValue(value);
});
return _this;
}
// 创建单个radio
RadioGroup.prototype.addRadio = function (param) {
var _this = this;
param.parent = this.getDomElement();
var radio = new Radio(param);
radio.onChange(function (radio, value) {
radio.isChecked() && _this.trigger(UIEvents$1.ValueChanged, radio, value, radio.isChecked());
});
this.radioArray.push(radio);
return radio;
};
// 创建多个radio
RadioGroup.prototype.setOptions = function (options) {
var _this = this;
var checkedIndex;
this.clearOptions();
options.forEach(function (label, index) {
if (checkedIndex == undefined && label.checked) {
checkedIndex = index;
}
_this.addRadio(label);
});
this.setChecked(checkedIndex == undefined ? 0 : checkedIndex);
};
// 获取单选框数值内容列表
RadioGroup.prototype.getOptions = function () {
var options = [];
this.radioArray.forEach(function (radio) {
options.push({ value: radio.getValue(), enabled: radio.isEnabled(), checked: radio.isChecked(), label: radio.getLabel() });
});
return options;
};
/**
* 设置选中的单选框
* @function Glodon.Bimface.Tiles.UI.RadioGroup.prototype.setChecked
* @param {Number} index 选中选项的序号
*/
RadioGroup.prototype.setChecked = function (index) {
this.radioArray.forEach(function (radio, idx) {
radio.setChecked(idx === index);
});
};
//设置选中的单选框
RadioGroup.prototype.setCheckedByValue = function (value) {
this.radioArray.forEach(function (radio) {
radio.setChecked(radio.getValue() == value);
});
};
/**
* 获取当前选中选项的序号
* @function Glodon.Bimface.Tiles.UI.RadioGroup.prototype.getChecked
* @returns {Number} 选中选项的序号
*/
RadioGroup.prototype.getChecked = function () {
var index;
this.radioArray.forEach(function (radio, idx) {
radio.isChecked() && (index = idx);
});
return index;
};
// 清空radio
RadioGroup.prototype.clearOptions = function () {
this.radioArray = [];
this._domElement.html('');
};
/**
* 设置可用的单选框选项
* @function Glodon.Bimface.Tiles.UI.RadioGroup.prototype.setEnabled
* @param {Array} index 可用选项的序号列表
*/
RadioGroup.prototype.setEnabled = function (indexs) {
this.radioArray.forEach(function (radio, idx) {
radio.setEnabled(indexs.indexOf(idx) > -1);
});
};
/**
* 获取可用的单选框选项
* @function Glodon.Bimface.Tiles.UI.RadioGroup.prototype.getEnabled
* @returns {Array} 可用选项的序号列表
*/
RadioGroup.prototype.getEnabled = function () {
var indexs = [];
this.radioArray.forEach(function (radio, idx) {
radio.isEnabled() && indexs.push(idx);
});
return indexs;
};
/**
* 单选框值发生变化的事件
* @function Glodon.Bimface.Tiles.UI.RadioGroup.prototype.onChange
* @param {Function} event 单选框值发生变化时执行的函数
*/
RadioGroup.prototype.onChange = function (fn) {
this.on(UIEvents$1.ValueChanged, fn);
return this;
};
return RadioGroup;
})(Control));
//PropertyPanel组件类
/** @class */ ((function (_super) {
__extends(PropertyControl, _super);
function PropertyControl(param) {
var _this = this;
param = param || {};
var elementParam = {
elementType: 'table',
className: 'bfui-property-panel'
};
var controlParam = {
elementParam: elementParam,
type: 'PropertyPanel',
};
_this = _super.call(this, controlParam) || this;
_this.createCollapse(param.propertyData);
return _this;
}
// 清空radio
PropertyControl.prototype.clear = function () {
this._domElement.html('');
};
PropertyControl.prototype.createCollapse = function (properties) {
var _this = this;
this.clear();
if (properties) {
properties.forEach(function (item) {
item.parent = _this.getDomElement();
new Collapse(item);
});
}
};
return PropertyControl;
})(Control));
/**
* TabOption组件类,作为Tab组件的单条option
*/
var Tab = /** @class */ (function (_super) {
__extends(Tab, _super);
function Tab(param) {
var _this = this;
var elementParam = {
elementType: 'div',
className: 'bfui-tab'
};
var controlParam = {
elementParam: elementParam,
type: 'Tab',
name: 'tab',
className: 'bfui-tab-tab',
parent: param.parent
};
param = Object.assign({}, controlParam, param);
param.extraClass && (elementParam.className = elementParam.className + ' ' + param.extraClass);
_this = _super.call(this, param) || this;
_this.param = param;
_this._domElement.on('click', function (evt) {
if (!_this.isActived() && _this.isEnabled()) {
_this.trigger(UIEvents$1.SelectionChanged, _this);
}
});
param.label && _this.setLabel(param.label);
param.enabled === false && _this.setEnabled(param.enabled);
return _this;
}
Tab.prototype.isEnabled = function () {
return !this._domElement.hasClass('disabled');
};
Tab.prototype.setEnabled = function (isEnabled) {
if (isEnabled != this.isEnabled()) {
this._domElement.toggle('disabled');
}
return this;
};
Tab.prototype.setLabel = function (text) {
this.setHTML(text);
return this;
};
Tab.prototype.setActive = function () {
if (!this.isActived()) {
this._domElement.addClass('is-active');
}
return this;
};
Tab.prototype.isActived = function () {
return this._domElement.hasClass('is-active');
};
Tab.prototype.getValue = function () {
return this.param.value;
};
return Tab;
}(Control));
getUINamespace('Tabs');
/**
* Tabs组件类
*/
/** @class */ ((function (_super) {
__extends(Tabs, _super);
function Tabs(param) {
var _this = this;
// SDM && SDM.send(SNS, "bf_c_UITabs_new");
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-tabs'
};
var controlParam = {
elementParam: elementParam,
type: 'Tabs',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
var header = _this.header = new Dom().createElement({ elementType: 'div', className: 'bfui-tabs-header' });
var content = _this.content = new Dom().createElement({ elementType: 'div', className: 'bfui-tabs-content' });
_this.getDomElement().append(header).append(content);
_this.tabLeft = param.tabLeft != null ? param.tabLeft : null;
_this.tabsArray = [];
param.options && _this.setOptions(param.options);
return _this;
}
// 创建单个tab
Tabs.prototype.addTab = function (param) {
var _this = this;
param.parent = this.header;
var tab = new Tab(param);
var pane = new Dom().createElement({ elementType: 'div', className: 'bfui-tabs-pane', id: "pane-" + param.name });
this.content.append(pane);
if (typeof param.content === 'string') {
pane.html(param.content);
}
else {
pane.append(param.content);
}
tab.on(UIEvents$1.SelectionChanged, function (tab) {
var idx = _this.getIndex(tab);
_this.setActive(idx);
_this.trigger(UIEvents$1.SelectionChanged, tab.param);
});
this.tabsArray.push(tab);
return tab;
};
Tabs.prototype.getIndex = function (tab) {
for (var i = 0; i < this.tabsArray.length; i++) {
if (tab.param.name === this.tabsArray[i].param.name) {
return i;
}
}
};
// 创建多个tab
Tabs.prototype.setOptions = function (options) {
var _this = this;
var activedIndex;
this.clearOptions();
this.header.html("");
options.forEach(function (label, index) {
if (activedIndex == undefined && label.actived) {
activedIndex = index;
}
_this.addTab(label);
});
this.setActive(activedIndex == undefined ? 0 : activedIndex);
};
// 获取tab数值内容列表
Tabs.prototype.getOptions = function () {
var options = [];
this.tabsArray.forEach(function (tab) {
options.push(tab.param);
});
return options;
};
/**
* 设置选中的tab
* @function Glodon.Bimface.Tiles.UI.Tabs.prototype.setActive
* @param {Number} index 选中选项的序号
*/
Tabs.prototype.setActive = function (index) {
var _this = this;
var left = 0;
this.tabsArray.forEach(function (tab, idx) {
if (idx === index) {
_this.activeValue = tab.getValue();
var header_active = _this.header.getElement().querySelector('.is-active');
var content_active = _this.content.getElement().querySelector('.is-active');
header_active && header_active.removeClass('is-active');
content_active && content_active.removeClass('is-active');
tab.setActive();
var pane = _this.content.getElement().querySelector("#pane-" + tab.param.name);
pane.addClass('is-active');
var header_bar = _this.header.getElement().querySelector('.bfui-tabs-active-bar');
if (index == 1)
left = left - 5;
if (index == 2)
left = left - 10;
header_bar.style.transform = "translateX(" + left + "px)";
header_bar.style.width = tab.getDomElement().getWidth() + 'px';
}
else {
var marginLeft = _this.tabLeft ? _this.tabLeft : 20;
left = left + tab.getDomElement().getWidth() + marginLeft;
}
});
this.selectHandler && this.selectHandler(this.activeValue);
};
Tabs.prototype.getActiveValue = function () {
return this.activeValue;
};
// 清空
Tabs.prototype.clearOptions = function () {
this.tabsArray = [];
this.header.html('');
this.content.html('');
};
/**
* 设置可用的单选框选项
* @function Glodon.Bimface.Tiles.UI.Tabs.prototype.setEnabled
* @param {Array} index 可用选项的序号列表
*/
Tabs.prototype.setEnabled = function (indexs) {
this.tabsArray.forEach(function (tab, idx) {
tab.setEnabled(indexs.indexOf(idx) > -1);
});
};
Tabs.prototype.onSelect = function (fn) {
this.selectHandler = fn;
};
return Tabs;
})(Control));
getUINamespace('Input');
/**
* @classdesc 类:Crumb组件类
* @class Glodon.Bimface.Tiles.UI.Crumb
* @constructs Glodon.Bimface.Tiles.UI.Crumb
* @description 构造面包屑组件
* @extends Glodon.Bimface.Tiles.UI.Control
* @param {Object} option 构造面包屑的配置项
* @param {String} option.id 面包屑ID
*/
/** @class */ ((function (_super) {
__extends(Crumb, _super);
function Crumb(param) {
// SDM && SDM.send(SNS, "bf_c_UICrumb_new");
var _this = this;
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-crumb'
};
var controlParam = {
elementParam: elementParam,
type: 'Crumb',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
_this.value = [];
_this.getDomElement().on('click', function (event) {
var target = new Dom(event.target);
var selectedId = target.attribute('data-id');
if (selectedId) {
_this._selectHandler && _this._selectHandler(selectedId);
}
});
return _this;
}
/**
* 获取面包屑的信息数组
* @function Glodon.Bimface.Tiles.UI.Crumb.prototype.getValue
* @returns {Array} 面包屑的信息数组
*/
Crumb.prototype.getValue = function () {
return this.value;
};
/**
* 设置面包屑的信息数组
* @function Glodon.Bimface.Tiles.UI.Crumb.prototype.setValue
* @param {Array} value 面包屑的信息数组
*/
Crumb.prototype.setValue = function (value) {
var _this = this;
this.value = value;
this.getDomElement().clear();
value.forEach(function (data, index) {
var item = new Dom().createElement({ elementType: 'a', className: 'bfui-crumb-item' });
item.html(data.text);
item.attribute('title', data.text);
item.attribute('data-id', data.id);
_this.getDomElement().append(item);
if (index !== value.length - 1) {
var array = new Dom().createElement({ elementType: 'i', className: 'bfui-crumb-array gld-bf-arrow-up-sm' });
_this.getDomElement().append(array);
}
});
return this;
};
Crumb.prototype.onSelect = function (handler) {
this._selectHandler = handler;
return this;
};
return Crumb;
})(Control));
getUINamespace('Input');
/**
* @classdesc 类:List组件类
* @class Glodon.Bimface.Tiles.UI.List
* @constructs Glodon.Bimface.Tiles.UI.List
* @description 构造列表组件
* @extends Glodon.Bimface.Tiles.UI.Control
* @param {Object} option 构造列表的配置项
* @param {String} option.id 列表ID
*/
/** @class */ ((function (_super) {
__extends(List, _super);
function List(param) {
// SDM && SDM.send(SNS, "bf_c_UIList_new");
var _this = this;
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-list'
};
var controlParam = {
elementParam: elementParam,
type: 'List',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
_this.value = [];
_this._domElements = [];
_this._checkedList = [];
_this._singleCheckedMode = false;
_this._checkBoxMap = new Map();
return _this;
}
/**
* 获取列表的信息数组
* @function Glodon.Bimface.Tiles.UI.List.prototype.getValue
* @returns {Array} 列表的信息数组
*/
List.prototype.getValue = function () {
return this.value;
};
/**
* 设置列表的信息数组
* @function Glodon.Bimface.Tiles.UI.List.prototype.setValue
* @param {Array} value 列表的信息数组
*/
List.prototype.setValue = function (value) {
var _this = this;
this.value = value;
this._domElements.forEach(function (dom) {
dom.destroy();
});
this._domElements = [];
this._checkedList = [];
this._checkBoxMap.clear();
this.getDomElement().clear();
value.forEach(function (data) {
var row = new Row({ justifyContent: 'Start', isInside: true });
if (!!data.hasCheckBox) {
var checkBox_1 = new Checkbox({ value: data.id, isInside: true });
if (data.isCheckBoxDisabled) {
checkBox_1.setEnabled(false);
}
else {
checkBox_1.onChange(function () {
if (checkBox_1.isChecked()) {
if (_this._singleCheckedMode) {
_this._checkedList.forEach(function (value) {
_this._checkBoxMap.get(value.id).setChecked(false);
});
_this._checkedList = [];
}
_this._checkedList.push(data);
}
else {
var index = _this._checkedList.indexOf(data);
if (index >= 0) {
_this._checkedList.splice(index, 1);
}
}
_this._checkedHandler && _this._checkedHandler(__spreadArrays(_this._checkedList));
});
}
_this._domElements.push(checkBox_1.getDomElement());
_this._checkBoxMap.set(data.id, checkBox_1);
row.addControl(checkBox_1);
if (data.checked) {
checkBox_1.setChecked(true);
}
}
if (!!data.hasIcon) {
var icon = void 0;
if (data.iconType === 'svg') {
icon = new Dom().createElement({ elementType: 'div', className: "bfui-list-icon" });
icon.html("");
}
else {
icon = new Dom().createElement({ elementType: 'i', className: "bfui-list-icon " + (data.iconClass ? data.iconClass : '') });
}
row.getDomElement().append(icon);
}
var text = new Dom().createElement({ elementType: 'div', className: 'bfui-list-text' });
text.html(data.text);
text.on('click', function () {
_this._itemClickedHandler && _this._itemClickedHandler(data);
});
_this._domElements.push(text);
row.getDomElement().append(text);
_this.getDomElement().append(row.getDomElement());
});
return this;
};
List.prototype.onChecked = function (handler) {
this._checkedHandler = handler;
return this;
};
List.prototype.onItemClicked = function (handler) {
this._itemClickedHandler = handler;
return this;
};
List.prototype.getCheckedIds = function () {
return this._checkedList.map(function (item) { return item.id; });
};
List.prototype.getCheckedValue = function () {
return this._checkedList;
};
List.prototype.setSingleCheckedMode = function (singleCheckedMode) {
this._singleCheckedMode = singleCheckedMode;
};
return List;
})(Control));
/**
* SearchResultOption组件类,作为Search组件的单条option
*/
var SearchResultOption = /** @class */ (function (_super) {
__extends(SearchResultOption, _super);
function SearchResultOption(param) {
var _this = this;
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-search-option'
};
var controlParam = {
elementParam: elementParam,
type: 'SearchResultOption',
};
_this = _super.call(this, controlParam) || this;
_this.getDomElement().html(param.html || param.text || '');
_this.param = param;
_this.disabled = param.disabled === true;
_this.selected = param.selected === true;
_this.value = param.value;
_this.text = param.text;
_this.setTooltip(_this.text);
_this.setDisabled(_this.disabled).setSelected(_this.selected);
param.class && _this.addClass(param.class);
// 点击本条option时,调用SearchResultOptionGroup的setSelected事件,将本条option设置为选中,其他option取消选中
_this.onClick(function () {
if (!_this.selected && !_this.disabled) {
_this._parent.setSelected(_this);
}
_this.trigger(UIEvents$1.Clicked);
});
return _this;
}
/**
* 设置选中状态
* @param {Boolean} selected 选中状态
*/
SearchResultOption.prototype.setSelected = function (selected) {
if (!this.disabled && this.selected !== selected) {
this.selected = selected;
selected ? this.addClass('bfui-search-option-selected') : this.removeClass('bfui-search-option-selected');
}
return this;
};
/**
* 设置不可用状态
* @param {Boolean} disabled 不可用状态
*/
SearchResultOption.prototype.setDisabled = function (disabled) {
if (this.disabled !== disabled) {
this.setSelected(false);
this.disabled = disabled;
disabled ? this.addClass('bfui-search-option-disabled') : this.removeClass('bfui-search-option-disabled');
}
return this;
};
/**
* 获取option的文本内容
*/
SearchResultOption.prototype.getText = function () {
return this.text;
};
/**
* 获取option的实际value,如未设置value则返回option的text文本内容
*/
SearchResultOption.prototype.getValue = function () {
return this.value === undefined ? this.getText() : this.value;
};
SearchResultOption.prototype.getParam = function () {
return this.param;
};
return SearchResultOption;
}(Control));
/**
* SearchResultOptionGroup组件类,管理多条SearchResultOption
*/
var SearchResultOptionGroup = /** @class */ (function (_super) {
__extends(SearchResultOptionGroup, _super);
function SearchResultOptionGroup(config) {
var _this = this;
var contentElementParam = {
elementType: 'div',
className: 'bfui-search-content'
};
var contentControlParam = {
// parent: document.getElementsByTagName('body')[0],
elementParam: contentElementParam,
type: 'ControlGroup',
};
_this = _super.call(this, contentControlParam) || this;
_this.enableAnimation = config.enableAnimation !== false;
_this.enableAnimation && _this.addClass('bfui-search-animation');
config.values && _this.setValues(config.values);
_this.hide();
return _this;
}
/**
* 设置option内容
* @param {Array} values option内容
*/
SearchResultOptionGroup.prototype.setValues = function (values) {
var _this = this;
this.clearControls(true);
this.values = [];
values.forEach(function (value) {
var param;
if (!DataUtil.assertType(value, 'obj')) {
param = { html: value.toString() };
}
else {
param = value;
}
_this.values.push(param);
var option = new SearchResultOption(param);
_this.addControl(option);
option.on(UIEvents$1.Clicked, function () {
_this.trigger(UIEvents$1.Clicked, option);
});
});
return this;
};
/**
* 获取当前显示/隐藏状态
*/
SearchResultOptionGroup.prototype.isVisible = function () {
return this.enableAnimation ? this._visible : _super.prototype.isVisible.call(this);
};
SearchResultOptionGroup.prototype.setFixedPosition = function (position) {
var pageHeight = window.innerHeight, maxHeight = 125, dom = this.getDomElement().getElement(), minHeight = Math.min(maxHeight, this._height);
if (position.bottom + minHeight > pageHeight) {
dom.style.top = '';
dom.style.bottom = pageHeight - position.top + 'px';
}
else {
dom.style.top = position.bottom + 'px';
dom.style.bottom = '';
}
dom.style.left = position.left + 'px';
dom.style.width = position.right - position.left + 'px';
};
/**
* 显示组件
*/
SearchResultOptionGroup.prototype.show = function () {
var _this = this;
if (this.enableAnimation) { // 支持动画状态时,通过height变化显示组件
this._visible = true;
var transitionEndFn_1 = function () {
if (_this._inTransition) {
_this.getDomElement().removeClass('bfui-search-overflow-hidden').off('transitionend', transitionEndFn_1);
_this._inTransition = false;
}
};
this._inTransition = true;
if (this._children.length > 0) {
var itemHeight = this._children[0].getDimensions().height;
this._height = this._children.length * itemHeight + 2;
}
this.getDomElement().addClass('bfui-search-overflow-hidden').css({ 'border-width': '1px', 'height': this._height + 'px' }).on('transitionend', transitionEndFn_1);
}
else {
_super.prototype.show.call(this);
}
return this;
};
/**
* 隐藏组件
*/
SearchResultOptionGroup.prototype.hide = function () {
if (this.enableAnimation) { // 支持动画状态时,通过height变化隐藏组件
this._visible = false;
this.getDomElement().addClass('bfui-search-overflow-hidden').css({ 'border-width': '0px', 'height': '0px' });
}
else {
_super.prototype.hide.call(this);
}
return this;
};
/**
* 设置某条option为选中状态,其他option取消选中
* @param {SearchResultOption | string} option 选中的内容
*/
SearchResultOptionGroup.prototype.setSelected = function (option) {
if (option === undefined)
return;
var isValidOption = false;
if (!(option instanceof SearchResultOption)) {
this.getAllControls().some(function (cControl) {
if (cControl.getText() === option.toString()) {
option = cControl;
isValidOption = true;
return true;
}
});
}
else if (this.indexOf(option) >= 0) {
isValidOption = true;
}
if (isValidOption && this.selected !== option) {
this.getAllControls().forEach(function (cControl) {
cControl.setSelected(cControl === option ? true : false);
});
this.selected = option;
var index = this.indexOf(this.selected);
var value = this.selected.getValue();
var text = this.selected.getText();
var data = this.selected.getParam();
this.trigger(UIEvents$1.ValueChanged, { text: text, value: value, index: index, data: data });
}
return this;
};
/**
* 根据序号设置Option选中状态
* @param {Number} index Option
*/
SearchResultOptionGroup.prototype.setSelectedByIndex = function (index) {
var option = this.getControl({ index: index });
if (option) {
this.setSelected(option);
}
return this;
};
/**
* 根据Value设置Option选中状态
* @param {String | Number} value Option的Value值
*/
SearchResultOptionGroup.prototype.setSelectedByValue = function (value) {
var result;
this.getAllControls().some(function (option) {
option = option;
if (option.getValue() === value) {
result = option;
return true;
}
});
return this.setSelected(result);
};
/**
* 获取当前选中的Option
*/
SearchResultOptionGroup.prototype.getSelected = function () {
return this.selected;
};
/**
* 获取所有Option的信息数组
*/
SearchResultOptionGroup.prototype.getValues = function () {
return this.values;
};
SearchResultOptionGroup.prototype.clearSelection = function () {
this.selected = null;
this.trigger(UIEvents$1.ValueChanged);
};
return SearchResultOptionGroup;
}(ControlGroup));
getUINamespace('Search');
/**
* Search组件类
*/
/** @class */ ((function (_super) {
__extends(Search, _super);
function Search(param) {
var _this = this;
// SDM && SDM.send(SNS, "bf_c_UISearch_new");
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-search'
};
var controlParam = {
elementParam: elementParam,
type: 'Search',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
_this.enableAnimation = param.enableAnimation !== false;
new Dom().createElement({ elementType: 'i', className: 'bfui-search-icon gld-bf-search-md', parent: _this.getDomElement() });
_this.input = new Input({ parent: _this, isInside: true });
_this.input.addClass('bfui-search-input')
.onBlur(function () { return window.setTimeout(function () { return _this.searchResult.hide(); }, 100); })
.onFocus(function () {
if (_this.input.getValue()) {
_this.onSearch();
}
});
param.placeholder && _this.setPlaceholder(param.placeholder);
_this.noResultText = param.noResultText || '没有找到对应内容';
_this.setSearchHandler(param.searchHandler || (function () { return []; }));
_this.setSelectHandler(param.selectHandler || (function () { return null; }));
_this.searchResult = new SearchResultOptionGroup({ enableAnimation: _this.enableAnimation });
new Dom(document.body).append(_this.searchResult.getDomElement());
_this.searchResult.on(UIEvents$1.ValueChanged, function (data) {
data && _this.input.setValue(data.text);
_this.searchResult.hide();
_this.selectHandler instanceof Function && _this.selectHandler(data);
});
return _this;
}
// input变化时搜索符合条件的结果
Search.prototype.onSearch = function () {
var _this = this;
var value = this.input.getValue();
if (!value) {
this.searchResult.hide();
return;
}
var searchResultValue = this.searchResultValue = this.searchHandler(value);
if (searchResultValue && searchResultValue.length > 0) {
this.searchResult.setValues(searchResultValue);
}
else { // 未搜索到结果
this.searchResult.setValues([
{
html: this.noResultText,
class: 'bfui-search-noresult',
},
{
html: '',
class: 'bfui-search-noresult',
}
]);
}
var domRect = this.getPosition();
this.searchResult.setFixedPosition(domRect);
requestAnimationFrame(function () { return _this.searchResult.show(); });
};
// 设置搜索回调
Search.prototype.setSearchHandler = function (handler) {
var _this = this;
if (handler instanceof Function) {
this.searchHandler = handler;
this.input.onInput(function () {
_this.onSearch();
});
}
};
// 设置选中回调
Search.prototype.setSelectHandler = function (handler) {
if (handler instanceof Function) {
this.selectHandler = handler;
}
};
// 设置input中的placeholder
Search.prototype.setPlaceholder = function (value) {
this.input.getDomElement().attribute('placeholder', value);
};
// 设置未匹配到结果时的文本
Search.prototype.setNoResultText = function (value) {
this.noResultText = value;
};
Search.prototype.getSearchResultGroup = function () {
return this.searchResult;
};
return Search;
})(Control));
/**
* @classdesc 类:ColorPicker组件类
* @class Glodon.Bimface.Tiles.UI.ColorPicker
* @constructs Glodon.Bimface.Tiles.UI.ColorPicker
* @description 构造颜色选择器组件
* @extends Glodon.Bimface.Tiles.UI.Control
* @param {Object} option 构造输入框的配置项
* @param {String} option.id 输入框ID
*/
/** @class */ ((function (_super) {
__extends(ColorPicker, _super);
function ColorPicker(param) {
var _this = this;
param = param || {};
var elementParam = {
elementType: 'div',
className: 'bfui-colorpicker'
};
var controlParam = {
elementParam: elementParam,
type: 'ColorPicker',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
_this.inputColor = new Dom().createElement({ elementType: 'input', className: 'bfui-colorpicker-input' });
_this.inputColor.attribute('type', 'color');
_this._domElement.append(_this.inputColor);
_this.onClick(function () {
_this.inputColor.click();
});
_this.onInput(function () { });
_this.setValue('');
param.onChange && _this.onChange(param.onChange);
return _this;
}
/**
* 获取输入框的值
* @function Glodon.Bimface.Tiles.UI.Input.prototype.getValue
* @returns {String} 输入框的值
*/
ColorPicker.prototype.getValue = function () {
return this.value;
};
/**
* 设置输入框的值
* @function Glodon.Bimface.Tiles.UI.Input.prototype.setValue
* @param {String} value 输入框的值
*/
ColorPicker.prototype.setValue = function (value) {
this.value = value;
if (value) {
this.inputColor.attribute('value', value);
this.getDomElement().css('background', value);
this.getDomElement().removeClass('no-color');
}
else {
this.getDomElement().css('background', 'none');
this.getDomElement().addClass('no-color');
}
return this;
};
ColorPicker.prototype.onChange = function (fn) {
var _this = this;
this.onChangeFn && this._domElement.off('change', this.onChangeFn);
this.onChangeFn = function (evt) {
var value = evt.target.value;
_this.value = value;
_this.getDomElement().css('background', value);
_this.getDomElement().removeClass('no-color');
fn(value);
};
this._domElement.on('change', this.onChangeFn);
return this;
};
ColorPicker.prototype.onInput = function (fn) {
var _this = this;
this.onInputFn && this._domElement.off('input', this.onInputFn);
this.onInputFn = function (evt) {
var value = evt.target.value;
_this.value = value;
_this.getDomElement().css('background', value);
_this.getDomElement().removeClass('no-color');
fn(value);
};
this._domElement.on('input', this.onInputFn);
return this;
};
return ColorPicker;
})(Control));
//Tree组件类
var TreeNode = /** @class */ (function (_super) {
__extends(TreeNode, _super);
function TreeNode(param) {
var _this = this;
param = param || {};
typeof (param.isLoaded) === "undefined" && (param.isLoaded = true); //默认不许要判断模型是否加载
var elementParam = {
elementType: 'div',
className: param.isLoaded ? 'bfui-tree-node' : 'bfui-tree-node not-allowed'
};
var controlParam = {
elementParam: elementParam,
type: 'TreeNode',
id: param.id,
parent: param.parent
};
_this = _super.call(this, controlParam) || this;
_this.isLoaded = param.isLoaded;
_this.parent = param.parent;
var subElementParam = {
elementType: 'div',
className: 'bfui-subtree'
};
var subControlParam = {
elementParam: subElementParam,
type: 'ControlGroup',
};
_this.subNode = new ControlGroup(subControlParam);
_this.opt = param;
_this.opt.isChecked ? _this.checkedState = 'checked'
: _this.checkedState = 'unchecked';
return _this;
}
TreeNode.prototype.initTreeNode = function (name, icon) {
var _this = this;
var treeInfoDom = new Dom().createElement({ elementType: 'div', className: "bfui-tree-info" });
// 是否有展开收起
if (this.opt.hasCollapse) {
var className = this.opt.hasCollapse && this.opt.isExpand ? 'open' : '';
this.opt.isExpand ? this.subNode.show() : this.subNode.hide();
var collapseWrap = this.collapseWrap = new Dom().createElement({ elementType: 'span', className: "bfui-collapse " + className });
collapseWrap.html("");
collapseWrap.on('click', function () {
_this.toggleExpansion();
});
}
// 是否有checkbox
if (this.opt.hasCheckBox) {
// 在visible是布尔值的情况下,查找子数据是否有uncheck的情况,以此初始化半选状态"bfui-checkbox bfui-half"
var checkedClass = '';
if (this.opt.isChecked) {
if (this.isChildHasUncheckState(this.opt.content.children) && this.opt.parent.checkedState !== 'checked') {
checkedClass = "bfui-checkbox bfui-half";
this.checkedState = 'half';
}
else {
checkedClass = 'bfui-checked';
}
}
if (this.opt.canCheck === false) {
checkedClass = "bfui-checkbox-disabled " + checkedClass;
}
var checkbox = this.checkbox = new Dom().createElement({ elementType: 'span', className: "bfui-checkbox " + checkedClass });
checkbox.on('click', function () {
if (_this.opt.canCheck !== false) {
var enable = !_this.opt.isChecked;
_this.setCheckState(enable);
_this.trigger(UIEvents$1.CheckedChanged, _this, enable);
}
});
}
// 是否有隔离显示
if (this.opt.hasIsolate) {
var isolateClass = this.opt.isIsolate ? 'gld-bf-component-sm' : 'gld-bf-component-fill-sm';
var isolateBox = this.isolateBox = new Dom().createElement({ elementType: 'i', className: "bfui-isolate bimface-icon " + isolateClass });
isolateBox.on('click', function () {
_this.setIsolateState(!_this.opt.isIsolate);
_this.trigger(UIEvents$1.IsolateChanged, _this, !_this.opt.isIsolate);
});
}
// 节点名称
var treeName = this.treeName = new Dom().createElement({ elementType: 'span', className: "bfui-tree-name" });
var nodeIcon = '';
icon && (icon.type === 'svg' ? nodeIcon = ""
: nodeIcon = "");
treeName.html("" + nodeIcon + name);
treeName.attribute('title', "" + name);
treeName.on('click', function () {
if (!_this.opt.hasSelection && _this.opt.hasCollapse) { // 如果不能被选中择展开收起
_this.toggleExpansion();
}
else { // 节点能被select
if (!_this.isLoaded)
return;
var enable = !_this.selectionState;
_this.currentUnSelect(_this.opt.rootTree);
_this.setSelectState(enable);
_this.trigger(UIEvents$1.SelectionChanged, _this, enable);
}
});
treeName.on('contextmenu', function (event) {
event.preventDefault();
_this.trigger(UIEvents$1.RightClicked, { event: event, node: _this });
});
this._domElement.append(treeInfoDom);
this.checkbox && treeInfoDom.append(this.checkbox);
this.collapseWrap && treeInfoDom.append(this.collapseWrap);
this.isolateBox && treeInfoDom.append(this.isolateBox);
treeInfoDom.append(this.treeName);
this.getTreeInfoDom = function () { return treeInfoDom; };
this._domElement.append(this.subNode.getDomElement());
};
// 选择接口
TreeNode.prototype.getSelectState = function () {
return this.selectionState;
};
// 获取Checkbox状态
TreeNode.prototype.getIsChecked = function () {
return this.opt.isChecked;
};
TreeNode.prototype.setSelectState = function (enable) {
this.selectionState = enable;
this.selectionState ? this.opt.hasSelection && this.treeName.addClass('bfui-selected')
: this.treeName && this.treeName.removeClass('bfui-selected');
};
TreeNode.prototype.currentUnSelect = function (node) {
var childNodes = node.getAllControls();
for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) {
var child = childNodes_1[_i];
if (child.getSelectState()) {
child.setSelectState(false);
child.trigger(UIEvents$1.SelectionChanged, child, false);
break;
}
else {
this.currentUnSelect(child);
}
}
};
// 勾选接口
TreeNode.prototype.getCheckedState = function () {
return this.checkedState;
};
TreeNode.prototype.setCheckState = function (enable) {
this.checkedState = enable ? 'checked' : 'unchecked';
this.opt.isChecked = enable;
if (this.opt.hasCheckBox && this.checkbox) {
this.checkbox.toggleClass('bfui-checked', enable);
this.checkbox.removeClass('bfui-half');
}
this.setChildCheckState(enable);
};
TreeNode.prototype.setChildCheckState = function (enable) {
//更新子节点的checkstate
if (this.opt.hasCheckBox && this.checkbox) {
var subNodes = this.getAllControls();
this.getCheckedState() !== 'half' && subNodes.forEach(function (node) {
node.setCheckState(enable);
});
}
};
TreeNode.prototype.setParentCheckState = function (control) {
if (!this.checkbox)
return;
var children = this.getAllControls();
if (children && children.length > 0) {
var checkedState = void 0;
for (var i = 0, len = children.length; i < len; i++) {
var testState = children[i].getCheckedState();
if (checkedState === undefined) {
checkedState = testState;
}
else if (testState != checkedState) {
checkedState = 'half';
}
}
this.checkedState = checkedState;
}
switch (this.checkedState) {
case 'checked':
this.opt.isChecked = true;
this.checkbox.addClass('bfui-checked');
this.checkbox.removeClass('bfui-half');
break;
case 'unchecked':
this.opt.isChecked = false;
this.checkbox.removeClass('bfui-checked');
this.checkbox.removeClass('bfui-half');
break;
case 'half':
this.opt.isChecked = true;
this.checkbox.addClass('bfui-half');
this.checkbox.removeClass('bfui-checked');
break;
}
this.trigger(UIEvents$1.ValueChanged, 'check');
};
//在visible是布尔值的情况下,查找子数据是否有uncheck的情况,以此初始化半选状态"bfui-checkbox bfui-half
TreeNode.prototype.isChildHasUncheckState = function (datas) {
var state;
var results = [];
if (datas) { // BFS遍历获取所有子节isVisble点情况
var queue_1 = [];
queue_1.unshift(datas);
var _loop_1 = function () {
var item = void 0, children;
item = queue_1.shift();
item.map(function (node) {
results.push(node.isVisible);
children = node.children;
if (children && children.length > 0) {
for (var i = 0; i < children.length; i++)
queue_1.push([children[i]]);
}
});
};
while (queue_1.length > 0) {
_loop_1();
}
}
results.includes(false) ? state = true : state = false;
return state;
};
//隔离接口
TreeNode.prototype.getIsolateState = function () {
return this.opt.isIsolate;
};
TreeNode.prototype.setIsolateState = function (enable) {
this.opt.isIsolate = enable;
if (this.opt.hasIsolate) {
if (enable) {
this.isolateBox.removeClass('gld-bf-component-fill-sm');
this.isolateBox.addClass('gld-bf-component-sm');
}
else {
this.isolateBox.addClass('gld-bf-component-fill-sm');
this.isolateBox.removeClass('gld-bf-component-sm');
}
//更新子节点的checkstate
var subNodes = this.getAllControls();
subNodes.forEach(function (node) {
node.setIsolateState(enable);
});
}
};
TreeNode.prototype.setParentIsolateState = function (control) {
var children = this.getAllControls();
if (children && children.length > 0) {
var isolateCount = 0;
for (var i = 0; i < children.length; i++) {
children[i].getIsolateState() && (isolateCount++);
}
// 默认隔离的节点为0, 有隔离加1, 当被隔离的个数等于节点长度时,父节点为true。其余情况为false
isolateCount === children.length ? (this.opt.isIsolate = true) : (this.opt.isIsolate = false);
}
if (this.opt.isIsolate) {
this.isolateBox.removeClass('gld-bf-component-fill-sm');
this.isolateBox.addClass('gld-bf-component-sm');
}
else {
this.isolateBox.addClass('gld-bf-component-fill-sm');
this.isolateBox.removeClass('gld-bf-component-sm');
}
this.trigger(UIEvents$1.ValueChanged, 'isolate');
};
TreeNode.prototype.toggleExpansion = function () {
this.collapseWrap.toggleClass('open');
this.opt.isExpand = !this.opt.isExpand;
this.trigger(UIEvents$1.ExpendChanged, this, this.opt.isExpand);
this.opt.isExpand ? this.subNode.show() : this.subNode.hide();
};
TreeNode.prototype.setExpansion = function (isExpand) {
if (this.opt.hasCollapse && isExpand !== this.opt.isExpand) {
this.toggleExpansion();
}
};
// 子节点接口
TreeNode.prototype.addChildNode = function (control, option) {
var _this = this;
this.subNode.addControl(control, option);
control.on('ValueChanged', function (type) {
switch (type) {
case 'check':
_this.setParentCheckState(control);
break;
case 'isolate':
_this.setParentIsolateState(control);
break;
}
});
control.on('CheckedChanged', function () {
_this.setParentCheckState(control);
});
control.on('IsolateChanged', function () {
_this.setParentIsolateState(control);
});
control.on('SelectionChanged', function () {
});
control.on(UIEvents$1.RightClicked, function (params) {
_this.trigger(UIEvents$1.RightClicked, params);
});
};
TreeNode.prototype.removeChildNode = function () {
var subTrees = this.getAllControls();
for (var i = subTrees.length - 1; i >= 0; i--) {
this.subNode.removeControl(subTrees[i]);
}
};
TreeNode.prototype.getControl = function (condition, deep) {
if (deep === void 0) { deep = false; }
if (deep) {
if (this.subNode.getControl(condition)) {
return this.subNode.getControl(condition);
}
else {
var controls = this.getAllControls();
for (var _i = 0, controls_1 = controls; _i < controls_1.length; _i++) {
var control = controls_1[_i];
var result = control.getControl(condition, deep);
if (result)
return result;
}
}
}
else {
return this.subNode.getControl(condition);
}
};
TreeNode.prototype.getAllControls = function () {
return this.subNode.getAllControls();
};
TreeNode.prototype.updateUnloadControl = function (condition) {
if (this.getControl(condition)) {
var node = this.getControl(condition);
node.removeClass('not-allowed');
node.isLoaded = true;
}
else {
var controls = this.getAllControls();
controls.forEach(function (item) {
if (item.getControl(condition)) {
var node = item.getControl(condition);
node.removeClass('not-allowed');
node.isLoaded = true;
}
else {
item.updateUnloadControl(condition);
}
});
}
};
// 获取构件ID
TreeNode.prototype.getInstanceIds = function () {
return this.opt.instanceIds;
};
TreeNode.prototype.setInstanceIds = function (ids) {
this.opt.instanceIds = ids;
};
TreeNode.prototype.getParent = function () {
return this.parent;
};
// 获取option参数
TreeNode.prototype.getOptions = function () {
return this.opt;
};
TreeNode.prototype.getTreeName = function () {
return this.treeName;
};
TreeNode.prototype.getSubNode = function () {
return this.subNode;
};
return TreeNode;
}(Control));
var FilterTree = (function (_a) {
var filterType = _a.filterType;
var source = currentClashGroup.value;
var treeData = source["tree" + filterType];
var hashTreeMap = source["platTreeMap" + filterType];
var checkedIds = source["checkedTreeIds" + filterType];
var refTreeContainer = ref(null);
var onTreeCreated = function () {
createTreeNode(refTreeContainer.value, treeData[0]);
checkedIds.forEach(function (id) {
getNode(id).setCheckState(true);
updateCheckState(id);
});
};
var createTreeNode = function (parentNode, data) {
var nodeConfig = {
hasCollapse: Boolean(data.children),
hasCheckBox: true,
isExpand: data.id === 'all',
canCheck: false,
hasSelection: false,
rootTree: refTreeContainer.value,
content: data,
id: data.id
};
var node = new TreeNode(nodeConfig);
node.initTreeNode(data.name);
parentNode instanceof TreeNode ? parentNode.addChildNode(node) : parentNode.addTreeNode(node);
data.children && data.children.forEach(function (item) {
return createTreeNode(node, item);
});
};
var getRootNode = function () {
return refTreeContainer.value.getControl({
id: 'all'
});
};
var getNode = function (id) {
if (id === 'all') {
return getRootNode();
} else {
return getRootNode().getControl({
id: id
}, true);
}
};
var updateCheckState = function (id) {
var parentNode = getNode(hashTreeMap[id].pId);
if (parentNode) {
parentNode.setParentCheckState(parentNode);
}
};
return window.Glodon.__bf_h(Tree, {
ref: refTreeContainer,
onCreated: onTreeCreated
});
});
var slotElement = function () {
return window.Glodon.__bf_h("div", {
class: "bf-clashdetective-filter-detail"
}, window.Glodon.__bf_h("div", {
class: "filter-detail-section"
}, window.Glodon.__bf_h("div", {
class: "section-name"
}, "\u6784\u4EF6A"), window.Glodon.__bf_h("div", {
class: "section-tree"
}, window.Glodon.__bf_h(FilterTree, {
filterType: EFilterType.A
}))), window.Glodon.__bf_h("div", {
class: "filter-detail-section"
}, window.Glodon.__bf_h("div", {
class: "section-name"
}, "\u6784\u4EF6B"), window.Glodon.__bf_h("div", {
class: "section-tree"
}, window.Glodon.__bf_h(FilterTree, {
filterType: EFilterType.B
}))));
};
var closeHandler = function () {
return showFilterModal.value = false;
};
var FilterDetail = (function () {
return Modal({
slot: slotElement,
title: '筛选条件',
closeHandler: closeHandler
});
});
var ClashGroupItem = (function () {
var _a, _b, _c, _d, _e, _f;
var handleReback = function () {
selectedGroupIndex.value = null;
showGroupItemPanel.value = false;
clearIsolation();
resetHomeView();
};
var selectedId = ref(null);
var handleDetailClick = function (detail) {
var _a;
if (selectedId.value !== detail.clashId) {
selectedId.value = detail.clashId;
isolateComponentsById(detail);
zoomToBoundingBox(detail.position);
} else {
selectedId.value = null;
resetHomeView();
clashEffectOnModel((_a = currentClashGroup.value) === null || _a === void 0 ? void 0 : _a.clashList);
}
};
return window.Glodon.__bf_h("div", {
class: "bf-clashgroup-item"
}, window.Glodon.__bf_h("div", {
class: "header bf-clashdetective-title"
}, window.Glodon.__bf_h("i", {
class: "bficon bf-reback bf-arrow-left",
onClick: function () {
return handleReback();
}
}), window.Glodon.__bf_h("span", {
class: "header-name text-ellipsis"
}, {
__bf_render: () => (_a = currentClashGroup.value) === null || _a === void 0 ? void 0 : _a.name,
__bf_refItems: [(() => {
try {
return currentClashGroup;
} catch {}
})()]
})), window.Glodon.__bf_h("div", {
class: "bf-clashdetective-title item-header"
}, window.Glodon.__bf_h("span", {
class: "color-suffix"
}), window.Glodon.__bf_h("span", {
class: "header-name"
}, "\u57FA\u672C\u4FE1\u606F")), window.Glodon.__bf_h("div", {
class: "basic-info-list"
}, window.Glodon.__bf_h("div", {
class: "basic-info"
}, window.Glodon.__bf_h("span", {
class: "basic-info-name"
}, "\u78B0\u649E\u7C7B\u578B\uFF1A"), window.Glodon.__bf_h("span", {
class: "basic-info-value"
}, {
__bf_render: () => ((_b = clashData.value) === null || _b === void 0 ? void 0 : _b.clashType) === 'Hard' ? '硬碰撞' : '',
__bf_refItems: [(() => {
try {
return clashData;
} catch {}
})()]
})), window.Glodon.__bf_h("div", {
class: "basic-info"
}, window.Glodon.__bf_h("span", {
class: "basic-info-name"
}, "\u78B0\u649E\u70B9\uFF1A"), window.Glodon.__bf_h("span", {
class: "basic-info-value"
}, {
__bf_render: () => (_c = currentClashGroup.value) === null || _c === void 0 ? void 0 : _c.count,
__bf_refItems: [(() => {
try {
return currentClashGroup;
} catch {}
})()]
})), window.Glodon.__bf_h("div", {
class: "basic-info"
}, window.Glodon.__bf_h("span", {
class: "basic-info-name"
}, "\u7B5B\u9009\u6761\u4EF6\uFF1A"), {
__bf_render: () => window.Glodon.__bf_h("span", {
class: "basic-info-value basic-info-view-detail",
onClick: function () {
return showFilterModal.value = true;
}
}, "\u67E5\u770B\u8BE6\u60C5"),
__bf_refItems: [(() => {
try {
return showFilterModal;
} catch {}
})()]
})), window.Glodon.__bf_h("div", {
class: "bf-clashdetective-title item-header"
}, window.Glodon.__bf_h("span", {
class: "color-suffix"
}), window.Glodon.__bf_h("span", {
class: "header-name"
}, "\u78B0\u649E\u8BE6\u60C5")), window.Glodon.__bf_h("div", {
class: "group-detail"
}, window.Glodon.__bf_h("div", {
class: "group-detail-header bf-clashdetective-row"
}, window.Glodon.__bf_h("div", {
class: "column column-1"
}, "\u5E8F\u53F7"), window.Glodon.__bf_h("div", {
class: "column column-2"
}, "\u6784\u4EF6A"), window.Glodon.__bf_h("div", {
class: "column column-3"
}, "\u6784\u4EF6B")), {
__bf_render: () => ((_d = currentClashGroup.value) === null || _d === void 0 ? void 0 : _d.clashList.length) > 0 ? window.Glodon.__bf_h("ul", {
class: "group-detail-list"
}, {
__bf_render: () => (_f = (_e = currentClashGroup.value) === null || _e === void 0 ? void 0 : _e.clashList) === null || _f === void 0 ? void 0 : _f.map(function (detail, index) {
return window.Glodon.__bf_h("div", {
class: {
__bf_render: () => detail.clashId === selectedId.value ? "bf-clashdetective-row bf-clashdetective-row-selected" : "bf-clashdetective-row",
__bf_refItems: [(() => {
try {
return selectedId;
} catch {}
})()]
},
onClick: function () {
return handleDetailClick(detail);
}
}, window.Glodon.__bf_h("div", {
class: "column column-1"
}, index + 1), window.Glodon.__bf_h("div", {
class: "column column-2",
title: detail.nameA
}, detail.nameA), window.Glodon.__bf_h("div", {
class: "column column-3",
title: detail.nameB
}, detail.nameB));
}),
__bf_refItems: [(() => {
try {
return currentClashGroup;
} catch {}
})()]
}) : window.Glodon.__bf_h("div", {
class: "group-detail-list group-detail-list-empty"
}, "\u6682\u65E0\u6570\u636E"),
__bf_refItems: [(() => {
try {
return currentClashGroup;
} catch {}
})()]
}), {
__bf_render: () => showFilterModal.value === true && window.Glodon.__bf_h(FilterDetail, null),
__bf_refItems: [(() => {
try {
return showFilterModal;
} catch {}
})()]
});
});
var LeftPanel = (function () {
return window.Glodon.__bf_h("div", {
class: "bf-clashdetective-left-panel"
}, {
__bf_render: () => showGroupItemPanel.value === false ? window.Glodon.__bf_h(ClashGroup, null) : window.Glodon.__bf_h(ClashGroupItem, null),
__bf_refItems: [(() => {
try {
return showGroupItemPanel;
} catch {}
})()]
});
});
var SNS = 'Glodon.Bimface.Module.ClashDetective.WebApplication';
var SNSM = 'Glodon.Bimface.Module.ModuleManager';
/**
* @classdesc 类:碰撞检测应用
* @class Glodon.Bimface.Module.ClashDetective.WebApplication
* @description 构造碰撞检测应用
* @constructs Glodon.Bimface.Module.ClashDetective.WebApplication
* @param {Glodon.Bimface.Module.ClashDetective.WebApplicationConfig} webApplicationConfig 碰撞检测应用的配置项
*/
var WebApplication = function (_super) {
__extends(WebApplication, _super);
function WebApplication(config) {
var _this = this;
SDM.send(SNS, "bf_c_clashDetectiveWebApplication_new");
SDM.send(SNSM, "bf_c_loadModule_new");
_this = _super.call(this, config) || this;
_this.init();
return _this;
}
WebApplication.prototype.prepare = function (dom) {
var _a, _b, _c, _d, _e, _f;
return __awaiter(this, void 0, void 0, function () {
var response, selectionInfo, modelMetaData, clashDetectiveId, _g, groups;
return __generator(this, function (_h) {
switch (_h.label) {
case 0:
response = BaseModule._currentModuleData;
selectionInfo = (_b = (_a = response === null || response === void 0 ? void 0 : response.multiModelClashDetectiveList) === null || _a === void 0 ? void 0 : _a.items[0]) === null || _b === void 0 ? void 0 : _b.selectionA[0];
modelMetaData = {
databagId: selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.databagId,
isSupportComponentProperty: response === null || response === void 0 ? void 0 : response.isSupportComponentProperty,
isSupportDrawing: response === null || response === void 0 ? void 0 : response.isSupportDrawing,
isSupportFamilyTypeList: response === null || response === void 0 ? void 0 : response.isSupportFamilyTypeList,
isSupportMaterialProperty: response === null || response === void 0 ? void 0 : response.isSupportMaterialProperty,
isSupportMiniMap: response === null || response === void 0 ? void 0 : response.isSupportMiniMap,
isSupportModelTree: false,
isSupportRoomArea: true,
isSurpportWalk: false,
jsSDKVersion: response === null || response === void 0 ? void 0 : response.jsSDKVersion,
loadMode: response === null || response === void 0 ? void 0 : response.loadMode,
modelId: selectionInfo.modelType === 'INTEGRATE' ? selectionInfo.integrateId : selectionInfo.fileId,
modelType: selectionInfo.modelType,
renderType: response === null || response === void 0 ? void 0 : response.renderType,
renderVersion: response === null || response === void 0 ? void 0 : response.renderVersion,
sceneJsonInfo: response === null || response === void 0 ? void 0 : response.sceneJsonInfo,
shell: response === null || response === void 0 ? void 0 : response.shell,
split: response === null || response === void 0 ? void 0 : response.split,
subRenders: response === null || response === void 0 ? void 0 : response.subRenders,
type: response === null || response === void 0 ? void 0 : response.type,
viewType: '3DView',
workerType: response === null || response === void 0 ? void 0 : response.workerType,
viewToken: response === null || response === void 0 ? void 0 : response.viewToken
};
clashDetectiveId = (_d = (_c = response === null || response === void 0 ? void 0 : response.multiModelClashDetectiveList) === null || _c === void 0 ? void 0 : _c.items[0]) === null || _d === void 0 ? void 0 : _d.clashDetectiveId;
return [4
/*yield*/
, this._initApp({
domElement: dom,
viewMetaData: modelMetaData,
clashDetectiveId: clashDetectiveId
})];
case 1:
_h.sent();
app.value = this._app3d;
viewer.value = this._viewer3d;
modelId.value = this._modelId;
modelType.value = this._modelType;
_g = clashData;
return [4
/*yield*/
, this._getClashResults()];
case 2:
_g.value = _h.sent();
clashResults.value = ((_e = clashData.value) === null || _e === void 0 ? void 0 : _e.results) || [];
return [4
/*yield*/
, this._getClashGroups()];
case 3:
groups = _h.sent();
if (!groups) {
clashGroups.value = [{
name: '碰撞分组',
id: 0,
filterA: [{
id: 'all'
}],
filterB: [{
id: 'all'
}],
count: ((_f = clashResults.value) === null || _f === void 0 ? void 0 : _f.length) || 0
}];
} else {
clashGroups.value = groups;
}
this.handleClashData();
return [2
/*return*/
];
}
});
});
};
WebApplication.prototype.handleClashData = function () {
if (this._modelType !== 'INTEGRATE') {
hanldeClashResults();
} else {
this._eventEmmiter.on(Glodon.Bimface.Module.ClashDetective.WebApplicationEvent.FilesInfoAdded, hanldeClashResults);
}
};
WebApplication.prototype.resizeHandler = function () {
var _this = this;
window.addEventListener('resize', function () {
var clashDetectiveDom = document.getElementsByClassName('bf-clashdetective')[0];
var clientWidth = clashDetectiveDom.clientWidth,
clientHeight = clashDetectiveDom.clientHeight;
var leftPanelDom = document.getElementsByClassName('bf-clashdetective-left')[0];
var leftPanelWidth = leftPanelDom.getBoundingClientRect().width;
_this._viewer3d.resize(clientWidth - leftPanelWidth, clientHeight);
});
};
WebApplication.prototype.handleViewerChange = function () {
var _this = this;
this._eventEmmiter.on(Glodon.Bimface.Module.ClashDetective.WebApplicationEvent.ModelAdded, function () {
return _this.resizeHandler();
});
};
WebApplication.prototype.init = function () {
return __awaiter(this, void 0, void 0, function () {
var refViewerDom, initViewer, destroyApp, content;
var _this = this;
return __generator(this, function (_a) {
refViewerDom = ref(null);
this.handleViewerChange();
initViewer = function () {
// 延迟使得获取element的准确宽高
requestAnimationFrame(function () {
_this.prepare(refViewerDom.value.getElement());
});
};
destroyApp = function () {
_this.removeEventListener(Glodon.Bimface.Module.ClashDetective.WebApplicationEvent.FilesInfoAdded, hanldeClashResults);
_this.removeEventListener(Glodon.Bimface.Module.ClashDetective.WebApplicationEvent.ModelAdded, function () {
return _this.resizeHandler();
});
_this.destroy();
};
content = window.Glodon.__bf_h("div", {
class: "bf-clashdetective",
onDestroyed: destroyApp
}, window.Glodon.__bf_h("div", {
class: "bf-clashdetective-left"
}, window.Glodon.__bf_h(LeftPanel, null)), window.Glodon.__bf_h("div", {
ref: refViewerDom,
class: "bf-clashdetective-viewer",
onCreated: initViewer
}));
render(content, this.getDomElement());
return [2
/*return*/
];
});
});
};
return WebApplication;
}(ClashDetectiveModule);
/**
* @classdesc 类:碰撞检测应用的配置项
* @class Glodon.Bimface.Module.ClashDetective.WebApplicationConfig
* @constructs Glodon.Bimface.Module.ClashDetective.WebApplicationConfig
* @description 构造碰撞检测应用的配置项
*/
var WebApplicationConfig = /** @class */ (function () {
function WebApplicationConfig(options) {
var config;
if (options) {
options = {
/**
* 存放组件界面的DOM容器
* @var {DOMElement} Glodon.Bimface.Module.ClashDetective.WebApplicationConfig.prototype.domElement
*/
domElement: options.domElement
};
}
return config;
}
return WebApplicationConfig;
}());
/**
* @namespace Glodon.Bimface.Module.ClashDetective.WebApplicationEvent
* @classdesc 常量:WebApplication的事件
* @description Glodon.Bimface.Module.ClashDetective.WebApplicationEvent
* @property {String} ModuleDestroyed 组件销毁完成事件
*/
var WebApplicationEvent;
(function (WebApplicationEvent) {
WebApplicationEvent["ModuleInitialized"] = "ModuleInitialized";
WebApplicationEvent["ModuleDestroyed"] = "ModuleDestroyed";
WebApplicationEvent["FilesInfoAdded"] = "FilesInfoAdded";
WebApplicationEvent["ModelAdded"] = "ModelAdded";
})(WebApplicationEvent || (WebApplicationEvent = {}));
var WebApplicationEvent$1 = WebApplicationEvent;
var ClashDetective = ModuleNS.ClashDetective = ModuleNS.ClashDetective || {};
ClashDetective.WebApplication = WebApplication;
ClashDetective.WebApplicationConfig = WebApplicationConfig;
ClashDetective.WebApplicationEvent = WebApplicationEvent$1;
export { ClashDetective as default };