[Sie-announce] SIEコード [1452] イベントにクロージャを活用

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 12月 10日 (木) 22:17:29 JST


Revision: 1452
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1452
Author:   dhrname
Date:     2009-12-10 22:17:29 +0900 (Thu, 10 Dec 2009)

Log Message:
-----------
イベントにクロージャを活用

Modified Paths:
--------------
    branches/05x/055/sie.js

Modified: branches/05x/055/sie.js
===================================================================
--- branches/05x/055/sie.js	2009-12-08 13:36:22 UTC (rev 1451)
+++ branches/05x/055/sie.js	2009-12-10 13:17:29 UTC (rev 1452)
@@ -2272,7 +2272,7 @@
         tar = this.target.tar;
       }
       var tea = this.beginElementAt;
-      tar.attachEvent( "on" + this.begin.match(/(mouse|activ|clic)[a-z]+/),
+      tar.attachEvent( "on" + this.begin.match(/(mouse|activ|clic)[a-z]+/)[0],
           (function(){tea(offset)}) );
     } else {
       this.beginElementAt(offset);
@@ -2293,7 +2293,7 @@
           tar = this.target.tar;
         }
         var tea = this.endElementAt;
-        tar.attachEvent( "on" + this.end.match(/(mouse|activ|clic)[a-z]+/),
+        tar.attachEvent( "on" + this.end.match(/(mouse|activ|clic)[a-z]+/)[0],
             (function(){tea(offset)}) );
       } else {
         this.endElementAt(offset);
@@ -2418,9 +2418,11 @@
       } else {
         tar = this.target.tar;
       }
-      var tea = this.beginElementAt;
-      tar.addEventListener( this.begin.match(/(mouse|activ|clic)[a-z]+/),
-          (function(){tea(offset)}), false );
+      //クロージャを参照
+      (function(te, offse, ta, tb) {
+      ta.addEventListener( tb.match(/(mouse|activ|clic)[a-z]+/)[0],
+          function(){te(offse);}, false );
+      })(this.beginElementAt, offset, tar, this.begin);
     } else {
       this.beginElementAt(offset);
       beginOffset = offset;
@@ -2439,9 +2441,11 @@
         } else {
           tar = this.target.tar;
         }
-        var tea = this.endElementAt;
-        tar.addEventListener( this.end.match(/(mouse|activ|clic)[a-z]+/),
-            (function(){tea(offset)}), false );
+        //クロージャを参照
+        (function(te, offse, ta, tb) {
+        ta.addEventListener( tb.match(/(mouse|activ|clic)[a-z]+/)[0],
+            function(){te(offse);}, false );
+        })(this.endElementAt, offset, tar, this.end);
       } else {
         this.endElementAt(offset);
       }




Sie-announce メーリングリストの案内
Back to archive index