本文整理汇总了TypeScript中jb-core.jb类的典型用法代码示例。如果您正苦于以下问题:TypeScript jb类的具体用法?TypeScript jb怎么用?TypeScript jb使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了jb类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: addProperty
addProperty(path) {
var parent = profileFromPath(parentPath(path));
if (this.paramType(path) == 'data')
return jb.writeValue(profileRefFromPath(path),'');
var param = this.paramDef(path);
jb.writeValue(profileRefFromPath(path),param.defaultValue || {$: ''});
}
示例2: restoreWindowEvent
export function restoreWindowEvent(events) {
events = jb.toarray(events);
for (var i = 0; i < events.length; i++) {
window['on' + events[i]] = jb.path(jbart, ['windowOrigEvents', events[i]]);
jb.path(jbart, ['windowOrigEvents', events[i]], null);
}
}
示例3: wrap
wrap(path,args) {
var comp = getComp(args.compName);
var firstParam = jb_compParams(comp).filter(p=>p.composite)[0];
if (firstParam) {
var result = jb.extend({ $: args.compName }, jb.obj(firstParam.id, [profileFromPath(path)]));
jb.writeValue(profileRefFromPath(path),result);
}
}
示例4: isCompNameOfType
isCompNameOfType(name,type) {
var _jbart = jbart_base().comps[name] ? jbart_base() : jbart;
if (name && _jbart.comps[name]) {
while (!_jbart.comps[name].type && jb.compName(jbart.comps[name].impl))
name = jb.compName(_jbart.comps[name].impl);
return (_jbart.comps[name].type || '').indexOf(type) == 0;
}
}
示例5: getStyleComp
getStyleComp(path) {
var style = this.val(path);
var compName = jb.compName(style);
if (compName == 'customStyle')
return { type: 'inner', path: path, style : style }
var comp = compName && getComp(compName);
if (jb.compName(comp.impl) == 'customStyle')
return { type: 'global', path: compName, style: comp.impl, innerPath: path }
}
示例6: closest
impl: (ctx,pathRef) => {
var path = jb.val(pathRef);
var closest_path = closest(path);
if (path && path != closest_path) {
jb.writeValue(pathRef,closest_path);
// jb_ui.apply(ctx);
}
}
示例7: addArrayItem
addArrayItem(path,args) {
var val = profileFromPath(path);
var toAdd = args.toAdd || {$:''};
if (Array.isArray(val)) {
val.push(toAdd);
return { newPath: path + '~' + (val.length-1) }
}
else if (!val) {
jb.writeValue(profileRefFromPath(path),toAdd);
} else {
jb.writeValue(profileRefFromPath(path),[val].concat(toAdd));
return { newPath: path + '~1' }
}
}
示例8: Probe
impl: (ctx,control,staticPath,expectedDynamicCounter,probeCheck)=> {
// var probProf = findProbeProfile(control.profile);
// if (!probProf)
// return failure('no prob prof');
// ********** dynamic counter
var testId = ctx.vars.testID;
var full_path = testId + '~' + staticPath;
var probeRes = new Probe(jb.ctx(ctx,{ profile: control.profile, comp: testId, path: '' } ),true)
.runCircuit(full_path);
return probeRes.then(res=>{
try {
var match = Array.from(res.element.querySelectorAll('[jb-ctx]'))
.filter(e=> {
var ctx2 = jbart.ctxDictionary[e.getAttribute('jb-ctx')];
return ctx2.path == full_path || (ctx2.componentContext && ctx2.componentContext.callerPath == full_path)
})
if (match.length != expectedDynamicCounter)
return failure('dynamic counter', 'jb-path error: ' + staticPath + ' found ' + (match || []).length +' times. expecting ' + expectedDynamicCounter + ' occurrences');
if (!res.finalResult[0] || !probeCheck(res.finalResult[0].in) )
return failure('probe');
} catch(e) {
return failure('exception');
}
return success();
})
function failure(part,reason) { return { id: testId, title: testId + '- ' + part, success:false, reason: reason } };
function success() { return { id: testId, title: testId, success: true } };
}
示例9: wrapWithArray
wrapWithArray(path) {
var val = profileFromPath(path);
if (val && !Array.isArray(val)) {
jb.writeValue(profileRefFromPath(path),[val]);
return { newPath: path + '~0' }
}
}
示例10: makeLocal
makeLocal(path) {
var compName = this.compName(path);
var comp = compName && getComp(compName);
if (!compName || !comp || typeof comp.impl != 'object') return;
var res = JSON.stringify(comp.impl, (key, val) => typeof val === 'function' ? ''+val : val , 4);
var profile = profileFromPath(path);
// inject conditional param values
jb_compParams(comp).forEach(p=>{
var pUsage = '%$'+p.id+'%';
var pVal = '' + (profile[p.id] || p.defaultValue || '');
res = res.replace(new RegExp('{\\?(.*?)\\?}','g'),(match,condition_exp)=>{ // conditional exp
if (condition_exp.indexOf(pUsage) != -1)
return pVal ? condition_exp : '';
return match;
});
});
// inject param values
jb_compParams(comp).forEach(p=>{
var pVal = '' + (profile[p.id] || p.defaultValue || ''); // only primitives
res = res.replace(new RegExp(`%\\$${p.id}%`,'g') , pVal);
});
jb.writeValue(profileRefFromPath(path),evalProfile(res));
}