How to use the util.each function in util

To help you get started, we’ve selected a few util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kissyteam / kissy / src / combobox / multi-word / src / multi-word / cursor.js View on Github external
function getFakeDiv(elem) {
    var fake = FAKE_DIV;
    if (!fake) {
        fake = $(FAKE_DIV_HTML);
    }
    if (String(elem[0].type.toLowerCase()) === 'textarea') {
        fake.css('width', elem.css('width'));
    } else {
        // input does not wrap at all
        fake.css('width', 9999);
    }
    util.each(STYLES, function (s) {
        fake.css(s, elem.css(s));
    });
    if (!FAKE_DIV) {
        fake.insertBefore(elem[0].ownerDocument.body.firstChild);
    }
    FAKE_DIV = fake;
    return fake;
}
github kissyteam / kissy / src / event / sub-modules / gesture / util / src / util / add-event.js View on Github external
module.exports = function (events, config) {
    if (typeof events === 'string') {
        events = [events];
    }
    util.each(events, function (event) {
        var specialEvent = {};
        specialEvent.setup = config.setup ? setupExtra : setup;
        specialEvent.tearDown = config.tearDown ? tearDownExtra : tearDown;
        specialEvent.add = config.add;
        specialEvent.remove = config.remove;
        config.order = config.order || 100;
        // specialEvent.preFire = config.preFire;
        eventHandleMap[event] = config;
        Special[event] = specialEvent;
    });
};
github kissyteam / kissy / build / tabs-debug.js View on Github external
initializer: function () {
                var self = this, items = self.get('items');    // items sugar
                // items sugar
                if (items) {
                    var children = self.get('children'), barOrientation = self.get('barOrientation'), selected, prefixCls = self.get('prefixCls'), tabItem, panelItem, bar = {
                            prefixCls: prefixCls,
                            xclass: 'tabs-bar',
                            changeType: self.get('changeType'),
                            children: []
                        }, body = {
                            prefixCls: prefixCls,
                            xclass: 'tabs-body',
                            lazyRender: self.get('lazyRender'),
                            children: []
                        }, barChildren = bar.children, panels = body.children;
                    util.each(items, function (item) {
                        selected = selected || item.selected;
                        barChildren.push(tabItem = fromTabItemConfigToTabConfig(item));
                        panels.push(panelItem = {
                            content: item.content,
                            selected: item.selected
                        });
                    });
                    if (!selected && barChildren.length) {
                        barChildren[0].selected = true;
                        panels[0].selected = true;
                    }
                    setBar(children, barOrientation, bar);
                    setBody(children, barOrientation, body);
                }
            },
            beforeCreateDom: function (renderData) {
github kissyteam / kissy / src / dd / - / src / dd / ddm.js View on Github external
function _activeDrops(self) {
    var drops = self.get('drops');
    self.setInternal('validDrops', []);
    if (drops.length) {
        util.each(drops, function (d) {
            d._active();
        });
    }
}
github kissyteam / kissy / build / scroll-view / plugin / pull-to-refresh-debug.js View on Github external
pluginRenderUI: function (scrollView) {
            var self = this;
            self.scrollView = scrollView;
            var direction = [];
            if (self.get('pullUpLoadFn')) {
                direction.push('up');
            }
            if (self.get('pullDownLoadFn')) {
                direction.push('down');
            }
            var prefixCls = scrollView.get('prefixCls');
            util.each(direction, function (d) {
                var $el = $(substitute('<div class="{prefixCls}scroll-view-pull-{d}-to-refresh">' + '<div class="{prefixCls}scroll-view-pull-{d}-to-refresh-content">' + '<span class="{prefixCls}scroll-view-pull-{d}-icon"></span>' + '<span class="{prefixCls}scroll-view-pull-{d}-label"></span>' + '</div>' + '</div>', {
                        prefixCls: prefixCls,
                        d: d
                    }));
                self['$' + d + 'LabelEl'] = $el.one('.' + prefixCls + 'scroll-view-pull-' + d + '-label');
                scrollView.get('el').prepend($el);
                self['$' + d + 'El'] = $el;
                self['pull' + d + 'ElHeight'] = $el.height();
            });
        },
        pluginBindUI: function (scrollView) {
github kissyteam / kissy / build / tabs-debug.js View on Github external
syncUI: function () {
                var self = this, children = self.get('children');
                util.each(children, function (c) {
                    if (c.get('selected')) {
                        self.setInternal('selectedTab', c);
                        return false;
                    }
                    return undefined;
                });
            },
            handleKeyDownInternal: function (e) {
github kissyteam / kissy / src / node / coverage / src / node / attach.js View on Github external
};
});
  _$jscoverage['/node/attach.js'].lineData[146]++;
  util.each(DOM_INCLUDES_NORM_NODE_LIST, function(k) {
  _$jscoverage['/node/attach.js'].functionData[6]++;
  _$jscoverage['/node/attach.js'].lineData[147]++;
  NLP[k] = function() {
  _$jscoverage['/node/attach.js'].functionData[7]++;
  _$jscoverage['/node/attach.js'].lineData[148]++;
  var args = makeArray(arguments);
  _$jscoverage['/node/attach.js'].lineData[149]++;
  return accessNormList(k, this, args);
};
});
  _$jscoverage['/node/attach.js'].lineData[153]++;
  util.each(DOM_INCLUDES_NORM_IF, function(index, k) {
  _$jscoverage['/node/attach.js'].functionData[8]++;
  _$jscoverage['/node/attach.js'].lineData[154]++;
  NLP[k] = function() {
  _$jscoverage['/node/attach.js'].functionData[9]++;
  _$jscoverage['/node/attach.js'].lineData[155]++;
  var args = makeArray(arguments);
  _$jscoverage['/node/attach.js'].lineData[156]++;
  return accessNormIf(k, this, index, args);
};
});
  _$jscoverage['/node/attach.js'].lineData[160]++;
  util.each(EVENT_INCLUDES_SELF, function(k) {
  _$jscoverage['/node/attach.js'].functionData[10]++;
  _$jscoverage['/node/attach.js'].lineData[161]++;
  NLP[k] = function() {
  _$jscoverage['/node/attach.js'].functionData[11]++;
github kissyteam / kissy / src / html-parser / coverage / src / html-parser / parser.js View on Github external
_$jscoverage['/html-parser/parser.js'].lineData[90]++;
    if (visit244_90_1(body)) {
      _$jscoverage['/html-parser/parser.js'].lineData[100]++;
      var parent = body.parentNode, sibling = parent.childNodes, bodyIndex = util.indexOf(body, sibling);
      _$jscoverage['/html-parser/parser.js'].lineData[103]++;
      if (visit245_103_1(bodyIndex !== sibling.length - 1)) {
        _$jscoverage['/html-parser/parser.js'].lineData[104]++;
        var fixes = sibling.slice(bodyIndex + 1, sibling.length);
        _$jscoverage['/html-parser/parser.js'].lineData[105]++;
        for (var i = 0; visit246_105_1(i &lt; fixes.length); i++) {
          _$jscoverage['/html-parser/parser.js'].lineData[106]++;
          parent.removeChild(fixes[i]);
          _$jscoverage['/html-parser/parser.js'].lineData[107]++;
          if (visit247_107_1(fixes[i].tagName === 'body')) {
            _$jscoverage['/html-parser/parser.js'].lineData[109]++;
            util.each(fixes[i].childNodes, function(c) {
  _$jscoverage['/html-parser/parser.js'].functionData[6]++;
  _$jscoverage['/html-parser/parser.js'].lineData[110]++;
  body.appendChild(c);
});
          } else {
            _$jscoverage['/html-parser/parser.js'].lineData[113]++;
            body.appendChild(fixes[i]);
          }
        }
      }
    }
    _$jscoverage['/html-parser/parser.js'].lineData[118]++;
    return body;
  }
  _$jscoverage['/html-parser/parser.js'].lineData[121]++;