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


TypeScript class.class_create函数代码示例

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


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

示例1: class_create

(function(){
	// TODO: refactor methods, use MaskNode Serialization instead Model Serialization
	custom_Tags['var'] = class_create(customTag_Base, {
		renderStart: function(model, ctx){
			set(this, this.attr, true, model, ctx);
		},
		onRenderStartClient: function(){
			set(this, this.model, false)
		}
	});

	function set(self, source, doEval, model?, ctx?) {
		// set data also to model, so that it will be serialized in NodeJS
		self.model = {};

		var parent = self.parent;
		var scope  = parent.scope;
		if (scope == null) {
			scope = parent.scope = {};
		}
		for(var key in source){
			self.model[key] = scope[key] = doEval === false
				? source[key]
				: expression_eval(source[key], model, ctx, parent);
		}
	}
}());
开发者ID:atmajs,项目名称:MaskJS,代码行数:27,代码来源:var.ts

示例2: m_registerModuleType

export function m_registerModuleType(baseModuleType, newType, mix) {
    _typeMappings[newType] = baseModuleType;
    m_Types[newType] = class_create(
        m_Types[baseModuleType],
        mix
    );
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:7,代码来源:utils.ts

示例3: function

(function () {
    manager_get = function (ctx, el) {
        if (ctx == null || is_DOM) {
            return manager || (manager = new Manager(document.body));
        }
        var KEY = '__contentManager';
        return ctx[KEY] || (ctx[KEY] = new Manager(el));
    };
    var manager;
    var Manager = class_create({
        constructor: function (el) {
            this.container = el.ownerDocument.body;
            this.ids = {};
        },
        append: function (tagName, node) {
            var id = node.id;
            var el = this.ids[id];
            if (el !== void 0) {
                return el;
            }
            el = render(tagName
                , node.attr
                , node.body
                , node.id
                , this.container
            );
            this.ids[id] = el;
        }
    });
}());
开发者ID:atmajs,项目名称:MaskJS,代码行数:30,代码来源:content.ts

示例4: _createHandlerForNodes

function _createHandlerForNodes(nodes, module) {
    return class_create({
        scope: module.scope,
        location: module.location,
        nodes: nodes,
        getHandler: _module_getHandlerDelegate(module)
    });
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:8,代码来源:ModuleMask.ts

示例5: _createExports

function _createExports(nodes, model, module) {
    var exports = module.exports,
        items = module.importItems,
        getHandler = _module_getHandlerDelegate(module);

    var i = -1,
        imax = items.length;
    while (++i < imax) {
        var x = items[i];
        if (x.registerScope) {
            x.registerScope(module);
        }
    }

    var i = -1,
        imax = nodes.length;
    while (++i < imax) {
        var node = nodes[i];
        var name = node.tagName;
        if (name === 'define' || name === 'let') {
            var Base = {
                getHandler: _fn_wrap(customTag_Compo_getHandler, getHandler),
                getModule: _module_getModuleDelegate(module),
                location: module.location
            };
            var Ctor = Define.create(node, model, module, Base);
            var Proto = Ctor.prototype;
            if (Proto.scope != null || module.scope != null) {
                Proto.scope = obj_extend(Proto.scope, module.scope);
            }

            var compoName = node.name;
            if (name === 'define') {
                exports[compoName] = Ctor;
                customTag_register(compoName, Ctor);
            }
            if (name === 'let') {
                customTag_registerResolver(compoName);
            }
            exports.__handlers__[compoName] = Ctor;
        }
    }
    exports['*'] = class_create(customTag_Base, {
        getHandler: getHandler,
        location: module.location,
        nodes: exports.__nodes__,
        scope: module.scope
    });

    return exports;
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:51,代码来源:ModuleMask.ts

示例6: class_create

	(function(){
		SyncMapper = class_create({
			map: function(node, fn) {
				var mapper = getMapper(node);
				return mapper(node, fn);
			}
		});
		function getMapper (node) {
			/* not strict */
			if (node.compoName) {
				return mapCompo;
			}
			return mapNode;
		}
		function mapNode(node, fn, parent?, index?) {
			if (node == null)
				return null;

			var nextNode = isFragment(node) 
				? new Dom.Fragment 
				: fn(node);
			if (nextNode == null) {
				return null;
			}
			var nodes = safe_getNodes(node);
			if (nodes == null) {
				return nextNode;
			}
			nextNode.nodes = coll_map(nodes, function (x) { 
				return mapNode(x, fn, node) 
			});
			return nextNode;
		}
		function mapCompo(compo, fn, parent?) {
			if (compo == null)
				return null;

			var next = fn(compo);
			if (next == null || compo.components == null) {
				return next;
			}
			next.components = coll_map(compo.components, function (x) { 
				return mapCompo(x, fn, compo)
			});
			return next;
		}
	}());
开发者ID:atmajs,项目名称:MaskJS,代码行数:47,代码来源:TreeWalker.ts

示例7: parse

(function () {
    function parse (def) {
        var rgx    = /^\s*([\w]+)[:\$]+([\w]+)\s*$/,
            parts  = rgx.exec(def),
            name   = parts && parts[1],
            signal = parts && parts[2];
        if (parts == null || name == null || signal == null) {
            log_error('PipeCompo. Invalid name.', def, 'Expect', rgx.toString());
            return null;
        }
        return [name, signal];
    }
    function attach(node, ctr) {
        var pipes = ctr.pipes;
        if (pipes == null) {
            pipes = ctr.pipes = {};
        }
        var signal = parse(node.name);
        if (signal == null) {
            return;
        }
        var name = signal[0],
            type = signal[1],
            pipe = ctr.pipes[name];
        if (pipe == null) {
            pipe = pipes[name] = {};
        }
        pipe[type] = node.fn;
    }
    custom_Tags['pipe'] = class_create(Method, {
        renderEnd: function(){
            attach(this, this.parent);
        }
    });
    custom_Tags.pipe.attach = attach;
}());
开发者ID:atmajs,项目名称:MaskJS,代码行数:36,代码来源:handlers.ts

示例8: class_create

import { class_create } from '@utils/class'
import { _appendChild } from './utils';
import { dom_TEXTNODE } from './NodeType';

/**
 * @name TextNode
 * @type {class}
 * @property {type} [type=2]
 * @property {(string|function)} content
 * @property {IMaskNode} parent
 * @memberOf mask.Dom
 */
export const TextNode = class_create({
	constructor: function(text, parent) {
		this.content = text;
		this.parent = parent;
	},
	type: dom_TEXTNODE,
	content: null,
	parent: null,
	sourceIndex: -1
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:22,代码来源:TextNode.ts

示例9: class_create

import { class_create } from '@utils/class';
import { obj_extend } from '@utils/obj';
import { class_Dfr } from '@utils/class/Dfr';


	export const builder_Ctx = class_create(class_Dfr as any, {
		constructor: function(data){
			obj_extend(this, data);
		},
		// Is true, if some of the components in a ctx is async
		async: false,
		// List of busy components
		defers: null /*Array*/,

		// NodeJS
		// Track components ID
		_id: null,
		// ModelsBuilder for HTML serialization
		_models: null,

		// ModulesBuilder fot HTML serialization
		_modules: null,

		_redirect: null,
		_rewrite: null
	});

	(builder_Ctx as any).clone = function(ctx){
		var data = {};
		for(var key in ctx) {
			if (builder_Ctx.prototype[key] === void 0) {
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:ctx.ts

示例10: class_create

import { class_create } from '@utils/class';
import { log_error } from '@core/util/reporters';
import { IBinder } from './IBinder';
import { expression_evalStatements } from '@project/expression/src/exports';

/*
 *	"expression, ...args"
 *	expression: to get the IEventEmitter
 */
export const EventEmitterBinder = class_create(IBinder, {
		on: function(exp, model, ctx, ctr, cb){
			call('on', exp, model, ctr, cb);
		},
		off: function(exp, model, ctr, cb){
			call('off', exp, model, ctr, cb);
		},
	});

	function call (method, expr, model, ctr, cb) {
		var arr = expression_evalStatements(expr, model, null, ctr);
		var observable = arr.shift();
		if (observable == null || observable[method] == null) {
			log_error('Method is undefined on observable: ' + method);
			return;
		}
		arr.push(cb);
		observable[method].apply(observable, arr);
	}
开发者ID:atmajs,项目名称:MaskJS,代码行数:28,代码来源:EventEmitterBinder.ts


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