Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initCascaderDatas() {
let datas = [];
if (utils.isArray(this.param.datas)) {
datas = this.param.datas;
} else if (utils.isFunction(this.param.datas)) {
datas = this.param.datas.apply(this.param);
}
if (utils.isFunction(this.param.getTotalDatas) || utils.isFunction(this.param.getDatas)) {
datas = [];
this.globalloading = true;
let loadData = this.param.getTotalDatas || this.param.getDatas;
let param = [
result => {
this.cascaderDatas = this.initDatas(utils.copy(result));
this.parse();
this.globalloading = false;
this.$emit('loadDataSuccess');
},
() => {
this.globalloading = false;
}
];
if (this.param.getDatas) {
param.unshift(null);
initCategoryDatas() {
let datas = [];
if (utils.isArray(this.param.datas)) {
datas = this.param.datas;
} else if (utils.isFunction(this.param.datas)) {
datas = this.param.datas.apply(this.param);
}
if (utils.isFunction(this.param.getTotalDatas) || utils.isFunction(this.param.getDatas)) {
datas = [];
this.globalloading = true;
let loadData = this.param.getTotalDatas || this.param.getDatas;
let param = [
result => {
this.initDatas(utils.copy(result));
this.globalloading = false;
this.$emit('loadDataSuccess');
},
() => {
this.globalloading = false;
}
];
if (this.param.getDatas) {
param.unshift(null);
}
initTreeDatas() {
let datas = [];
if (utils.isArray(this.param.datas)) {
datas = this.param.datas;
} else if (utils.isFunction(this.param.datas)) {
datas = this.param.datas.apply(this.param);
}
if (utils.isFunction(this.param.getTotalDatas) || utils.isFunction(this.param.getDatas)) {
datas = [];
this.globalloading = true;
let loadData = this.param.getTotalDatas || this.param.getDatas;
let param = [
result => {
this.treeDatas = this.initDatas(utils.copy(result));
this.parse();
this.globalloading = false;
this.$emit('loadDataSuccess');
},
() => {
this.globalloading = false;
}
];
if (this.param.getDatas) {
param.unshift(null);
trigger(event, ...data) {
let param = this.param;
if (param.events && utils.isFunction(param.events[event])) {
param.events[event].call(null, this, ...data);
}
}
create(reference, template, content) {
const popGenerator = window.document.createElement('div');
popGenerator.innerHTML = template;
const popNode = popGenerator.childNodes[0];
const allowHtml = this.options.html;
popNode.id = `pop_${Math.random().toString(36).substr(2, 10)}`;
const contentNode = popGenerator.querySelector(this.innerSelector);
if (content.nodeType === 1) {
if (allowHtml) contentNode.appendChild(content);
content.style.display = 'block';
} else if (utils.isFunction(content)) {
const contentText = content.call(reference);
if (allowHtml) {
contentNode.innerHTML = contentText;
} else {
contentNode.innerText = contentText;
}
} else if (allowHtml) {
contentNode.innerHTML = content;
} else {
contentNode.innerText = content;
}
return popNode;
}
this.hideTimeout = setTimeout(() => {
utils.removeClass(this.reference, 'h-pop-trigger');
if (this.options.events && utils.isFunction(this.options.events.hide)) {
this.options.events.hide.call(null);
}
if (this.popNode) {
this.popNode.setAttribute('aria-hidden', 'true');
}
this.isOpen = false;
this.hideTimeout2 = setTimeout(() => {
if (this.popNode) {
this.popNode.style.display = 'none';
if (this.popperInstance) {
this.popperInstance.disableEventListeners();
}
}
}, 300);
}, this.options.delay);
return this;
initDatas(datas) {
let list = utils.copy(datas);
if (this.param.dataMode == 'list' && datas.length > 0) {
list = utils.generateTree(list, this.param);
}
let isWait = utils.isFunction(this.param.getDatas);
this.categoryDatas = this.initTreeModeData(list, null, isWait, 0);
this.list = this.categoryDatas;
this.parse();
},
initTreeModeData(list, parentKey, isWait, level) {
date: manba(nowDate.time())
.hours(i)
.minutes(0),
type: manba.HOUR,
show: utils.padLeft(i, 2) + ':00',
vm: this,
isNowDays: true
})
);
}
return dates;
} else if (this.view == 'minute') {
let dates = [];
let hour = nowDate.hours();
let list = [];
if (utils.isFunction(this.options.minutes)) {
list = this.options.minutes.call(null, hour);
} else {
list = utils.numList(0, 60, this.options.minuteStep);
}
for (let i of list) {
dates.push(
genData({
date: manba(nowDate.time()).minutes(i),
type: manba.MINUTE,
show: utils.padLeft(hour, 2) + ':' + utils.padLeft(i, 2),
vm: this,
isNowDays: true
})
);
}
return dates;
initDatas(datas) {
let list = (datas = utils.copy(datas));
if (this.param.dataMode == 'list' && datas.length > 0) {
list = utils.generateTree(datas, this.param);
}
let isWait = utils.isFunction(this.param.getDatas);
return this.initTreeModeData(list, isWait);
},
initTreeModeData(list, isWait, parentKey) {
show(event) {
if (this.hideTimeout) clearTimeout(this.hideTimeout);
if (this.hideTimeout2) clearTimeout(this.hideTimeout2);
if (this.options.events && utils.isFunction(this.options.events.show)) {
this.options.events.show(event);
}
if (this.isOpen || this.options.disabled) {
return this;
}
this.isOpen = true;
if (!this.popNode) {
this.initPopNode();
}
if (!this.popperInstance) {
this.initPopper();
}
this.popperInstance.enableEventListeners();
if (!this.popNode) {
return;
}