zoukankan      html  css  js  c++  java
  • JS_eventBind

    /*
    * Function.prototype.bind 外置函数;
    * 当连续bind事件的时候无法保证顺序;
    */
    if
    (!Function.prototype.bind){ Function.prototype.bind = function(){ var args = Array.prototype.slice.call(arguments); var _obj = args.shift(); var _fun = this; return function(){ return _fun.apply(_obj,args.concat(Array.prototype.slice.call(arguments))); }; }; } var eventHandler = { add:function(node,en,fu){ node.addEventListener ? node.addEventListener(en,fu,false) : node.attachEvent("on" + en, fu); }, remove:function(node,en,fu){ node.removeEventListener ? node.removeEventListener(en,fu,false) : node.detachEvent("on" + en, fu); }, guid:0, bind:function(node,en,fu){ var _this = this; fu = fu.bind(node); _this.guid++; if(!node.evenfun) node.evenfun = {}; if(!node.evenfun[en])node.evenfun[en] = {}; node.evenfun[en][_this.guid] = fu; _this.add(node,en,node.evenfun[en][_this.guid]); }, unbind:function(node,en){ var _this = this; if(!node.evenfun || !node.evenfun.hasOwnProperty(en)) return; for(var i in node.evenfun[en]){ _this.remove(node,en,node.evenfun[en][i]); } delete node.evenfun[en]; }, bindBn:function(node,en,fu){ var funame = fu.toString(),_this = this; fu = fu.bind(node); if(!node.evenfun) node.evenfun = {}; if(!node.evenfun[en])node.evenfun[en] = {}; node.evenfun[en][funame] = fu; _this.add(node,en,node.evenfun[en][funame]); }, unbindBn:function(node,en,name){ var _this = this; name = name.toString(); if(!node.evenfun || !node.evenfun[en].hasOwnProperty(name)) return; _this.remove(node,en,node.evenfun[en][name]); delete node.evenfun[en][name]; } }
  • 相关阅读:
    c++标准库容器【转】
    C++命名空间的解释 【转】
    [转载]定义、公理、定理、推论、命题和引理的区别
    待读论文
    矩阵分解 Matrix Factorization (RegularSVD) 实验总结
    Predicting the Next Location: A Recurrent Model with Spatial and Temporal Contexts AAAI2016
    Discovering Urban Functional Zones Using Latent Activity Trajectories TKDE 2015
    numpy
    python 编程 规范
    深度学习
  • 原文地址:https://www.cnblogs.com/somesayss/p/2787918.html
Copyright © 2011-2022 走看看