本文整理汇总了TypeScript中@utils/arr.arr_each函数的典型用法代码示例。如果您正苦于以下问题:TypeScript arr_each函数的具体用法?TypeScript arr_each怎么用?TypeScript arr_each使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了arr_each函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
refresh: function(value, method, args, result){
var i = 0,
x, imax;
var node = this.node,
model = this.model,
ctx = this.ctx,
ctr = this.node
;
if (method == null) {
// this was new array/object setter and not an immutable function call
var compos = node.components;
if (compos != null) {
var imax = compos.length,
i = -1;
while ( ++i < imax ){
if (compo_dispose(compos[i], node)){
i--;
imax--;
}
}
compos.length = 0;
}
var frag = this._build(node, value, ctx, ctr);
dom_insertBefore(frag, this.placeholder);
arr_each(node.components, compo_inserted);
return;
}
var array = value;
arr_createRefs(value);
switch (method) {
case 'push':
list_update(this, null, null, array.length - 1, array.slice(array.length - 1));
break;
case 'pop':
list_update(this, array.length, 1);
break;
case 'unshift':
list_update(this, null, null, 0, array.slice(0, 1));
break;
case 'shift':
list_update(this, 0, 1);
break;
case 'splice':
var sliceStart = args[0],
sliceRemove = args.length === 1 ? this.components.length : args[1],
sliceAdded = args.length > 2 ? array.slice(args[0], args.length - 2 + args[0]) : null;
list_update(this, sliceStart, sliceRemove, sliceStart, sliceAdded);
break;
case 'sort':
case 'reverse':
list_sort(this, array);
break;
case 'remove':
if (result != null && result.length)
list_remove(this, result);
break;
}
},
开发者ID:atmajs,项目名称:MaskJS,代码行数:68,代码来源:proto.ts
示例2: jMask
return node
});
return jMask(result);
},
wrapAll: function(wrapper){
var $wrap = jMask(wrapper);
if ($wrap.length === 0){
log_error('Not valid wrapper', wrapper);
return this;
}
this.parent().mask($wrap);
jmask_deepest($wrap[0]).nodes = this.toArray();
return this.pushStack($wrap);
}
};
arr_each(['empty', 'remove'], function(method) {
ManipDom[method] = function(){
return coll_each(this, Methods_[method]);
};
var Methods_ = {
remove: function(node){
if (node.parent != null)
coll_remove(node.parent.nodes, node);
},
empty: function(node){
node.nodes = null;
}
};
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:30,代码来源:manip_dom.ts
示例3: arr_each
arr_each([
'filter',
'children',
'closest',
'parent',
'find',
'first',
'last'
], function(method) {
Traverse[method] = function(selector) {
var result = [],
matcher = selector == null
? null
: selector_parse(selector, this.type, method === 'closest' ? 'up' : 'down'),
i, x;
switch (method) {
case 'filter':
return jMask(jmask_filter(this, matcher));
case 'children':
var nextKey = selector_getNextKey(this);
for (i = 0; i < this.length; i++) {
x = this[i];
var arr = x[nextKey];
if (arr == null) {
continue;
}
result = result.concat(matcher == null ? arr : jmask_filter(arr, matcher));
}
break;
case 'parent':
for (i = 0; i < this.length; i++) {
x = this[i].parent;
if (!x || x.type === Dom.FRAGMENT || (matcher && selector_match(x, matcher))) {
continue;
}
result.push(x);
}
arr_unique(result);
break;
case 'closest':
case 'find':
if (matcher == null) {
break;
}
for (i = 0; i < this.length; i++) {
jmask_find(this[i][matcher.nextKey], matcher, result);
}
break;
case 'first':
case 'last':
var index;
for (i = 0; i < this.length; i++) {
index = method === 'first' ? i : this.length - i - 1;
x = this[index];
if (matcher == null || selector_match(x, matcher)) {
result[0] = x;
break;
}
}
break;
}
return this.pushStack(result);
};
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:69,代码来源:traverse.ts
示例4: dom_removeAll
export function dom_removeAll (arr) {
arr_each(arr, dom_removeElement);
};
开发者ID:atmajs,项目名称:MaskJS,代码行数:3,代码来源:dom.ts
示例5: dom_showAll
export function dom_showAll (arr) {
arr_each(arr, dom_showEl);
};
开发者ID:atmajs,项目名称:MaskJS,代码行数:3,代码来源:dom.ts
示例6: dom_hideAll
export function dom_hideAll (arr) {
arr_each(arr, dom_hideEl);
};
开发者ID:atmajs,项目名称:MaskJS,代码行数:3,代码来源:dom.ts
示例7: arr_each
arr_each(['append', 'prepend'], function(method) {
Proto[method] = function(mix) {
var $mix = jMask(mix),
i = 0,
length = this.length,
arr, node;
for (; i < length; i++) {
node = this[i];
// we create each iteration a new array to prevent collisions in future manipulations
arr = $mix.toArray();
for (var j = 0, jmax = arr.length; j < jmax; j++) {
arr[j].parent = node;
}
if (node.nodes == null) {
node.nodes = arr;
continue;
}
node.nodes = method === 'append' ? node.nodes.concat(arr) : arr.concat(node.nodes);
}
return this;
};
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:29,代码来源:proto.ts
示例8: add
if (has(node, klass) === false)
add(node, klass);
},
remove: function(node, klass){
if (has(node, klass) === true)
remove(node, klass);
},
toggle: function(node, klass){
var fn = has(node, klass) === true ? remove : add;
fn(node, klass);
}
};
arr_each(['add', 'remove', 'toggle'], function(method) {
var fn = Mutator_[method];
ManipClass[method + 'Class'] = function(klass) {
return coll_each(this, function(node){
fn(node, klass);
});
};
});
function current(node){
var className = node.attr['class'];
return typeof className === 'string' ? className : '';
}
function has(node, klass){
return -1 !== (' ' + current(node) + ' ').indexOf(' ' + klass + ' ');
}
function add(node, klass){
node.attr['class'] = (current(node) + ' ' + klass).trim();
}
function remove(node, klass) {
node.attr['class'] = (' ' + current(node) + ' ').replace(' ' + klass + ' ', '').trim();
开发者ID:atmajs,项目名称:MaskJS,代码行数:32,代码来源:manip_class.ts
注:本文中的@utils/arr.arr_each函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论