当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript exports.customAttr_register函数代码示例

本文整理汇总了TypeScript中@core/custom/exports.customAttr_register函数的典型用法代码示例。如果您正苦于以下问题:TypeScript customAttr_register函数的具体用法?TypeScript customAttr_register怎么用?TypeScript customAttr_register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了customAttr_register函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: _create

function _create(name, asEvent?) {
    customAttr_register('x-' + name, 'client', function(node, attrValue, model, ctx, el, ctr) {
        var listenSlot = node === ctr;
        _attachListener(el, ctr, attrValue, asEvent, listenSlot);
    });
}	
开发者ID:atmajs,项目名称:MaskJS,代码行数:6,代码来源:attributes.ts

示例2: customAttr_register

import { customAttr_register } from '@core/custom/exports';
import { expression_eval_safe } from '../utils/expression';
import { obj_setProperty } from '@utils/obj';
import { expression_varRefs } from '@project/expression/src/exports';
import { Component } from '@compo/exports';

/**
 *	Toggle value with ternary operator on an event.
 *
 *	button x-toggle='click: foo === "bar" ? "zet" : "bar" > 'Toggle'
 */
customAttr_register('x-toggle', 'client', function(node, attrValue, model, ctx, el, ctr){
    var event = attrValue.substring(0, attrValue.indexOf(':')),
        expression = attrValue.substring(event.length + 1),
        ref = expression_varRefs(expression);
    
	if (typeof ref !== 'string') {
		// assume is an array
		ref = ref[0];
	}
	
    Component.Dom.addEventListener(el, event, function(){
        var val = expression_eval_safe(expression, model, ctx, ctr, node);
        obj_setProperty(model, ref, val);
    });
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:26,代码来源:xToggle.ts

示例3: customAttr_register

import { customAttr_register } from '@core/custom/exports';
import { domLib, Component } from '@compo/exports';

/**
 *	Toggle Class Name
 *
 *	button x-toggle='click: selected'
 */

customAttr_register('x-class-toggle', 'client', function(node, attrVal, model, ctx, element){
    
    var event = attrVal.substring(0, attrVal.indexOf(':')),
        klass = attrVal.substring(event.length + 1).trim();
    
	
    Component.Dom.addEventListener(element, event, function(){
        domLib(element).toggleClass(klass);
    });
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:19,代码来源:xClassToggle.ts

示例4: customAttr_register

customAttr_register('x-pipe-signal', 'client', function(node, attrValue, model, ctx, element, ctr) {

    var arr = attrValue.split(';'),
        imax = arr.length,
        i = -1,
        x;
    while ( ++i < imax ) {
        x = arr[i].trim();
        if (x === '') 
            continue;
        
        var i_colon = x.indexOf(':'),
            event = x.substring(0, i_colon),
            handler = x.substring(i_colon + 1).trim(),
            dot = handler.indexOf('.'),
            
            pipe, signal;

        if (dot === -1) {
            log_error('Pipe-slot is invalid: {0} Usage e.g. "click: pipeName.pipeSignal"', x);
            return;
        }

        pipe = handler.substring(0, dot);
        signal = handler.substring(++dot);

        // if DEBUG
        !event && log_error('Pipe-slot is invalid. Event type is not set', attrValue);
        // endif

        dom_addEventListener(
            element
            , event
            , _createListener(pipe, signal)
        );
    }
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:37,代码来源:pipes.ts

示例5: customAttr_register

import { customAttr_register } from '@core/custom/exports';
import { expression_eval } from '@project/expression/src/exports';
import { Component } from '@compo/exports';
import { expression_createBinder, expression_bind, expression_unbind } from '@project/observer/src/exports';

customAttr_register('xx-visible', function(node, attrValue, model, ctx, el, ctr) {

	var binder = expression_createBinder(attrValue, model, ctx, ctr, function(value){
		el.style.display = value ? '' : 'none';
	});

	expression_bind(attrValue, model, ctx, ctr, binder);

	Component.attach(ctr, 'dispose', function(){
		expression_unbind(attrValue, model, ctr, binder);
	});

	if (expression_eval(attrValue, model, ctx, ctr, node)) {
		el.style.display = 'none';
	}
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:21,代码来源:xxVisible.ts


注:本文中的@core/custom/exports.customAttr_register函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。