Example #1
0
 doStart: function () {
     var self = this, node = self.node, elStyle = node.style, _propsData = self._propsData, original = elStyle[TRANSITION], totalDuration = 0, propsCss = {};
     util.each(_propsData, function (propData, prop) {
         var v = propData.value;    // hack, for to reflow?
         // hack, for to reflow?
         Dom.css(node, prop, Dom.css(node, prop));
         propsCss[prop] = v;
         totalDuration = Math.max(propData.duration + propData.delay, totalDuration);
     });    // chrome none
            // firefox none 0s ease 0s
     // chrome none
     // firefox none 0s ease 0s
     if (original.indexOf('none') !== -1) {
         original = '';
     } else if (original) {
         original += ',';
     }
     elStyle[TRANSITION] = original + genTransition(_propsData);    // bug when set left on relative element
     // bug when set left on relative element
     setTimeout(function () {
         Dom.css(node, propsCss);
     }, 0);    // timer is more reliable and can deal with short hand css properties
     // timer is more reliable and can deal with short hand css properties
     self._transitionEndTimer = setTimeout(function () {
         self.stop(true);
     }, totalDuration * 1000);
 },
Example #2
0
 wrap: function (wrappedNodes, wrapperNode) {
     wrappedNodes = Dom.query(wrappedNodes);
     wrapperNode = Dom.get(wrapperNode);
     util.each(wrappedNodes, function (w) {
         Dom.wrapAll(w, wrapperNode);
     });
 },
Example #3
0
 unwrap: function (wrappedNodes) {
     wrappedNodes = Dom.query(wrappedNodes);
     util.each(wrappedNodes, function (w) {
         var p = w.parentNode;
         Dom.replaceWith(p, p.childNodes);
     });
 },
Example #4
0
    doStop: function (finish) {
        var self = this,
            node = self.node,
            elStyle = node.style,
            _propsData = self._propsData,
            propList = [],
            clear,
            propsCss = {};

        if (self._transitionEndTimer) {
            clearTimeout(self._transitionEndTimer);
            self._transitionEndTimer = null;
        }

        util.each(_propsData, function (propData, prop) {
            if (!finish) {
                propsCss[prop] = Dom.css(node, prop);
            }
            propList.push(prop);
        });

        // firefox need set transition and need set none
        clear = util.trim(elStyle[TRANSITION]
            .replace(new RegExp('(^|,)' + '\\s*(?:' + propList.join('|') + ')\\s+[^,]+', 'gi'),
            '$1'))
            .replace(/^,|,,|,$/g, '') || 'none';

        elStyle[TRANSITION] = clear;
        Dom.css(node, propsCss);
    }
Example #5
0
File: json.js Project: Gumpg/kissy
KISSY.add('json/quote', ['util'], function (S, require) {
    var util = require('util');
    var CONTROL_MAP = {
            '\b': '\\b',
            '\f': '\\f',
            '\n': '\\n',
            '\r': '\\r',
            '\t': '\\t',
            '"': '\\"'
        }, REVERSE_CONTROL_MAP = {}, QUOTE_REG = /["\b\f\n\r\t\x00-\x1f]/g, UN_QUOTE_REG = /\\b|\\f|\\n|\\r|\\t|\\"|\\u[0-9a-zA-Z]{4}/g;
    util.each(CONTROL_MAP, function (original, encoded) {
        REVERSE_CONTROL_MAP[original] = encoded;
    });
    REVERSE_CONTROL_MAP['\\/'] = '/';
    return {
        quote: function (value) {
            return '"' + value.replace(QUOTE_REG, function (m) {
                var v;
                if (!(v = CONTROL_MAP[m])) {
                    v = '\\u' + ('0000' + m.charCodeAt(0).toString(16)).slice(0 - 4);
                }
                return v;
            }) + '"';
        },
        unQuote: function (value) {
            return value.slice(1, value.length - 1).replace(UN_QUOTE_REG, function (m) {
                var v;
                if (!(v = REVERSE_CONTROL_MAP[m])) {
                    v = String.fromCharCode(parseInt(m.slice(2), 16));
                }
                return v;
            });
        }
    };
});
Example #6
0
 toJSON: function () {
     var ret = this.getAttrVals();
     util.each(blacklist, function (b) {
         delete ret[b];
     });
     return ret;
 }
Example #7
0
KISSY.add(function(S, require) {
  _$jscoverage['/focusin.js'].functionData[0]++;
  _$jscoverage['/focusin.js'].lineData[7]++;
  var DomEvent = require('event/dom/base');
  _$jscoverage['/focusin.js'].lineData[8]++;
  var Special = DomEvent.Special;
  _$jscoverage['/focusin.js'].lineData[9]++;
  var util = require('util');
  _$jscoverage['/focusin.js'].lineData[11]++;
  util.each([{
  name: 'focusin', 
  fix: 'focus'}, {
  name: 'focusout', 
  fix: 'blur'}], function(o) {
  _$jscoverage['/focusin.js'].functionData[1]++;
  _$jscoverage['/focusin.js'].lineData[15]++;
  var key = util.guid('attaches_' + util.now() + '_');
  _$jscoverage['/focusin.js'].lineData[16]++;
  Special[o.name] = {
  setup: function() {
  _$jscoverage['/focusin.js'].functionData[2]++;
  _$jscoverage['/focusin.js'].lineData[22]++;
  var doc = visit1_22_1(this.ownerDocument || this);
  _$jscoverage['/focusin.js'].lineData[23]++;
  if (visit2_23_1(!(key in doc))) {
    _$jscoverage['/focusin.js'].lineData[24]++;
    doc[key] = 0;
  }
  _$jscoverage['/focusin.js'].lineData[26]++;
  doc[key] += 1;
  _$jscoverage['/focusin.js'].lineData[27]++;
  if (visit3_27_1(doc[key] === 1)) {
    _$jscoverage['/focusin.js'].lineData[28]++;
    doc.addEventListener(o.fix, handler, true);
  }
}, 
  tearDown: function() {
  _$jscoverage['/focusin.js'].functionData[3]++;
  _$jscoverage['/focusin.js'].lineData[33]++;
  var doc = visit4_33_1(this.ownerDocument || this);
  _$jscoverage['/focusin.js'].lineData[34]++;
  doc[key] -= 1;
  _$jscoverage['/focusin.js'].lineData[35]++;
  if (visit5_35_1(doc[key] === 0)) {
    _$jscoverage['/focusin.js'].lineData[36]++;
    doc.removeEventListener(o.fix, handler, true);
  }
}};
  _$jscoverage['/focusin.js'].lineData[41]++;
  function handler(event) {
    _$jscoverage['/focusin.js'].functionData[4]++;
    _$jscoverage['/focusin.js'].lineData[42]++;
    var target = event.target;
    _$jscoverage['/focusin.js'].lineData[43]++;
    return DomEvent.fire(target, o.name);
  }
});
  _$jscoverage['/focusin.js'].lineData[48]++;
  return DomEvent;
});
Example #8
0
File: index.js Project: Gumpg/kissy
            it('solve JsEnumBug', function () {
                function x() {
                    return 1;
                }

                var v = {
                    toString: x,
                    isPrototypeOf: x,
                    propertyIsEnumerable: x,
                    toLocaleString: x,
                    valueOf: x,
                    constructor: x
                };
                var t = 'hasOwnProperty';
                v[t] = x;
                var z = {};
                util.mix(z, v);
                expect(z.toString).toBe(x);
                var fs = [], vs = [];
                util.each(v, function (v, k) {
                    fs.push(k);
                    if (typeof v === 'function') {
                        v = v();
                    }
                    vs.push(v);
                });
                fs.sort();
                expect(fs).toEqual(['toString',
                    'hasOwnProperty', 'isPrototypeOf',
                    'propertyIsEnumerable',
                    'toLocaleString',
                    'valueOf',
                    'constructor'].sort());
                expect(vs).toEqual([1, 1, 1, 1, 1, 1, 1]);
            });
    init: function (opts) {
        TMXTiledMap.superclass.init.call(this, opts);

        this.set('anchorPoint', ccp(0, 0));

        var mapInfo = TMXMapInfo.create(opts.file);

        this.mapSize        = mapInfo.get('mapSize');
        this.tileSize       = mapInfo.get('tileSize');
        this.mapOrientation = mapInfo.get('orientation');
        this.objectGroups   = mapInfo.get('objectGroups');
        this.properties     = mapInfo.get('properties');
        this.tileProperties = mapInfo.get('tileProperties');

        // Add layers to map
        var idx = 0;
        util.each(mapInfo.layers, util.callback(this, function (layerInfo) {
            if (layerInfo.get('visible')) {
                var child = this.parseLayer({layerInfo: layerInfo, mapInfo: mapInfo});
                this.addChild({child: child, z: idx, tag: idx});

                var childSize   = child.get('contentSize');
                var currentSize = this.get('contentSize');
                currentSize.width  = Math.max(currentSize.width,  childSize.width);
                currentSize.height = Math.max(currentSize.height, childSize.height);
                this.set('contentSize', currentSize);

                idx++;
            }
        }));
    },
Example #10
0
File: base.js Project: Snger/kissy
 util.each(extensions.concat(SubClass), function (ext) {
     if (ext) {
         // 合并 ATTRS 到主类
         // 不覆盖主类上的定义(主类位于 constructors 最后)
         // 因为继承层次上扩展类比主类层次高
         // 注意:最好 value 必须是简单对象,自定义 new 出来的对象就会有问题
         // (用 function return 出来)!
         // a {y:{value:2}} b {y:{value:3,getter:fn}}
         // b is a extension of a
         // =>
         // a {y:{value:2,getter:fn}}
         util.each(ext.ATTRS, function (v, name) {
             var av = attrs[name] = attrs[name] || {};
             util.mix(av, v);
         });    // 方法合并
         // 方法合并
         var exp = ext.prototype, p;
         for (p in exp) {
             // do not mess with parent class
             if (exp.hasOwnProperty(p)) {
                 prototype[p] = exp[p];
             }
         }
     }
 });
Example #11
0
        formatPath: function(paths) {
            var self = this,
                userConfig = self.userConfig,
                SPLIT = ',',
                pathList = {};

            Util.each(paths, function(ph, i) {
                var str = ph.path,
                    reg = /(\d)+\.?(\d)*(\s)*,(\s)*(\d)+\.?(\d)*/g,
                    ar = [];

                str = str.replace(/\s+/g, ' ');
                if (ar = str.match(reg)) {
                    str = str.replace(reg, 'X');
                    str = str.split('X');
                    Util.each(ar, function(item, index) {
                        ar[index] = self.formatNumber(item);
                    });
                }
                pathList[i] = {
                    path: ar,
                    other: str
                };
            });
            return pathList;
        },
Example #12
0
File: anim.js Project: Gumpg/kissy
 pause: function (end, queue) {
     var self = this;
     util.each(self, function (elem) {
         Anim.pause(elem, queue);
     });
     return self;
 },
Example #13
0
  function addDataToForm(query, form, serializeArray) {
    _$jscoverage['/io/iframe-transport.js'].functionData[5]++;
    _$jscoverage['/io/iframe-transport.js'].lineData[74]++;
    var ret = [], isArray, vs, i, e;
    _$jscoverage['/io/iframe-transport.js'].lineData[75]++;
    util.each(query, function(data, k) {
  _$jscoverage['/io/iframe-transport.js'].functionData[6]++;
  _$jscoverage['/io/iframe-transport.js'].lineData[76]++;
  isArray = util.isArray(data);
  _$jscoverage['/io/iframe-transport.js'].lineData[77]++;
  vs = util.makeArray(data);
  _$jscoverage['/io/iframe-transport.js'].lineData[79]++;
  for (i = 0; visit48_79_1(i < vs.length); i++) {
    _$jscoverage['/io/iframe-transport.js'].lineData[80]++;
    e = doc.createElement('input');
    _$jscoverage['/io/iframe-transport.js'].lineData[81]++;
    e.type = 'hidden';
    _$jscoverage['/io/iframe-transport.js'].lineData[82]++;
    e.name = k + (visit49_82_1(isArray && serializeArray) ? '[]' : '');
    _$jscoverage['/io/iframe-transport.js'].lineData[83]++;
    e.value = vs[i];
    _$jscoverage['/io/iframe-transport.js'].lineData[84]++;
    Dom.append(e, form);
    _$jscoverage['/io/iframe-transport.js'].lineData[85]++;
    ret.push(e);
  }
});
    _$jscoverage['/io/iframe-transport.js'].lineData[88]++;
    return ret;
  }
Example #14
0
 function fixBody(doc) {
     // 3 limit depth
     var body = findTagWithName(doc, 'body', 3);
     if (body) {
         /**
          * <body>
          <li>2</li>
          <span>1</span>
          <li>2</li>
          <span>3</span>
          <li>2</li>
          </body>
          */
         var parent = body.parentNode,
             sibling = parent.childNodes,
             bodyIndex = util.indexOf(body, sibling);
         if (bodyIndex !== sibling.length - 1) {
             var fixes = sibling.slice(bodyIndex + 1, sibling.length);
             for (var i = 0; i < fixes.length; i++) {
                 parent.removeChild(fixes[i]);
                 if (fixes[i].tagName === 'body') {
                     /*jshint loopfunc:true*/
                     util.each(fixes[i].childNodes, function (c) {
                         body.appendChild(c);
                     });
                 } else {
                     body.appendChild(fixes[i]);
                 }
             }
         }
     }
     return body;
 }
Example #15
0
 expandAll: function () {
     var self = this;
     self.set('expanded', true);
     util.each(self.get('children'), function (c) {
         c.expandAll();
     });
 },
Example #16
0
function definePredefinedProps(constructor, obj)
{
  var setter = function(propName, val){
    this['_' + propName] = val;
  };

  var getter = function(propName)
  {
    return this['_' + propName];
  }

  while (constructor)
  {
    if (constructor._predefinedProps)
      util.each(constructor._predefinedProps, function(val, key){
        Object.defineProperty(obj, key, 
                              {
                                configurable: true,
                                get:createFGet(key, getter), 
                                set:createFSet(key, setter)
                              });
        obj[key] = val;
      });
    
    constructor = constructor.__proto__;
  }
}
Example #17
0
File: swf.js Project: Gumpg/kissy
    function _stringSWF(src, attrs, params, ie) {
        var res,
            attr = EMPTY,
            par = EMPTY;

        // 普通属性
        util.each(attrs, function (v, k) {
            attr += stringAttr(k, v);
        });

        if (ie) {
            attr += stringAttr('classid', CID);
            par += stringParam('movie', src);
        } else {
            // 源
            attr += stringAttr('data', src);
            // 特殊属性
            attr += stringAttr('type', TYPE);
        }

        par += collectionParams(params);

        res = LT + OBJECT_TAG + attr + GT + par;

        return res;
    }
Example #18
0
File: anim.js Project: Gumpg/kissy
 stop: function (end, clearQueue, queue) {
     var self = this;
     util.each(self, function (elem) {
         Anim.stop(elem, end, clearQueue, queue);
     });
     return self;
 },
    init: function (opts) {
        Menu.superclass.init.call(this, opts);

        var items = opts.items;

        this.set('isMouseEnabled', true);
        
        var s = Director.get('sharedDirector').get('winSize');

        this.set('isRelativeAnchorPoint', false);
        this.anchorPoint = ccp(0.5, 0.5);
        this.set('contentSize', s);

        this.set('position', ccp(s.width / 2, s.height / 2));


        if (items) {
            var z = 0;
            util.each(items, util.callback(this, function (item) {
                this.addChild({child: item, z: z++});
            }));
        }

        
    },
Example #20
0
function wrapProtoForSuper(px, SubClass) {
    var hooks = SubClass.__hooks__;
    // in case px contains toString
    if (hooks) {
        for (var p in hooks) {
            if (p in px) {
                px[p] = hooks[p](px[p]);
            }
        }
    }
    util.each(px, function (v, p) {
        if (typeof v === 'function') {
            var wrapped = 0;
            if (v.__owner__) {
                var originalOwner = v.__owner__;
                delete v.__owner__;
                delete v.__name__;
                wrapped = v.__wrapped__ = 1;
                var newV = bind(v);
                newV.__owner__ = originalOwner;
                newV.__name__ = p;
                originalOwner.prototype[p] = newV;
            } else if (v.__wrapped__) {
                wrapped = 1;
            }
            if (wrapped) {
                px[p] = v = bind(v);
            }
            v.__owner__ = SubClass;
            v.__name__ = p;
        }
    });
}
Example #21
0
  function getTopPosition(self) {
    _$jscoverage['/bubble.js'].functionData[3]++;
    _$jscoverage['/bubble.js'].lineData[41]++;
    var archor = null, editor = self.get('editor'), myBubbles = editor.getControls();
    _$jscoverage['/bubble.js'].lineData[44]++;
    util.each(myBubbles, function(bubble) {
  _$jscoverage['/bubble.js'].functionData[4]++;
  _$jscoverage['/bubble.js'].lineData[45]++;
  if (visit5_45_1(bubble.isKeBubble && visit6_46_1(visit7_46_2(bubble !== self) && visit8_47_1(bubble.get('visible') && overlap(self, bubble))))) {
    _$jscoverage['/bubble.js'].lineData[49]++;
    if (visit9_49_1(!archor)) {
      _$jscoverage['/bubble.js'].lineData[50]++;
      archor = bubble;
    } else {
      _$jscoverage['/bubble.js'].lineData[51]++;
      if (visit10_51_1(archor.get('y') < bubble.get('y'))) {
        _$jscoverage['/bubble.js'].lineData[52]++;
        archor = bubble;
      }
    }
  }
});
    _$jscoverage['/bubble.js'].lineData[56]++;
    return archor;
  }
Example #22
0
File: base.js Project: Snger/kissy
 unplug: function (plugin) {
     var plugins = [], self = this, isString = typeof plugin === 'string';
     util.each(self.get('plugins'), function (p) {
         var keep = 0, pluginId;
         if (plugin) {
             if (isString) {
                 // user defined takes priority
                 pluginId = p.get && p.get('pluginId') || p.pluginId;
                 if (pluginId !== plugin) {
                     plugins.push(p);
                     keep = 1;
                 }
             } else {
                 if (p !== plugin) {
                     plugins.push(p);
                     keep = 1;
                 }
             }
         }
         if (!keep) {
             p.pluginDestructor(self);
         }
     });
     self.setInternal('plugins', plugins);
     return self;
 },
Example #23
0
IO.applyTo = function (_, cmd, args) {
    var cmds = cmd.split('.').slice(1),
        func = IO;
    util.each(cmds, function (c) {
        func = func[c];
    });
    func.apply(null, args);
};
Example #24
0
 each: function (fn, context) {
     var self = this;
     util.each(self, function (n, i) {
         n = new Node(n);
         return fn.call(context || n, n, i, self);
     });
     return self;
 },
Example #25
0
 setRenderer : function (rend) {
   util.each(emptyRenderer, function (val, key) {
     if (!(key in rend)) {
       rend[key] = val;
     }
   });
   renderer.set(rend);
 },
Example #26
0
 click: function (e) {
     var self = this, content = e.target.get('content');
     util.each(handlers, function (h) {
         if (h.content === content) {
             h.fn.call(self);
         }
     });
 }
Example #27
0
    onEnter: function () {
        util.each(this.children, function (child) {
            child.onEnter();
        });

        this.resumeSchedulerAndActions();
        this.set('isRunning', true);
    },
Example #28
0
 util.each(domEventObservables, function (customEvent, type) {
     util.each(customEvent.observers, function (observer) {
         // context undefined
         // 不能 this 写死在 handlers 中
         // 否则不能保证 clone 时的 this
         addInternal(dest, type, observer.config);
     });
 });
Example #29
0
    onExit: function () {
        this.pauseSchedulerAndActions();
        this.set('isRunning', false);

        util.each(this.children, function (child) {
            child.onExit();
        });
    },
Example #30
0
        proceedSeries: function() {
            var self = this,
                c2e = MapData.c2e,
                userConfig = self.userConfig;

            self.series = userConfig.series;
            var temp = {};
            Util.each(self.series, function(item, index) {
                index = c2e[index] || index;
                temp[index] = item;
            });
            self.series = temp;
            Util.each(self.series, function(item, index) {
                var pro = MapData.mapScale[index];
                item.areaName = pro.text = decodeURIComponent(pro.text);
            });
        },