Subclassing events : Layer Events « Ajax Layer « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Event
7. Event onMethod
8. Form Control
9. GUI Components
10. HTML
11. Javascript Collections
12. Javascript Objects
13. Language Basics
14. Node Operation
15. Object Oriented
16. Page Components
17. Security
18. Style Layout
19. Table
20. Utilities
21. Window Browser
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
JavaScript DHTML » Ajax Layer » Layer Events 
Subclassing events


http://dynapi.sourceforge.net/
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999       
<html>
<head>
<title>DynAPI Examples - Subclassing Events</title>
<script language="JavaScript" src="./dynapisrc/dynapi.js"></script>
<script language="Javascript">
  dynapi.library.setPath('./dynapisrc/');
  dynapi.library.include('dynapi.api');

  // note: this library is NOT necessary for subclassing
  dynapi.library.include('dynapi.functions');

</script>
<script language="Javascript">
  var l1,l2;

  l1=new DynLayer('<p align="center"><br>L1</p>',50,50,100,100,'yellow');
  l2=new DynLayer(null,250,50,100,100,'green');
  l3=new DynLayer(null,250,200,100,100,'blue');

  // note: click event added to l1
  l1.addEventListener({
    onclick:function(e){
      var o=e.getSource();
      o.setBgColor(dynapi.functions.getRandomColor());
    }
  });

  // note: click event added to l2
  l2.addEventListener({
    onclick:function(e){
      var o=e.getSource();
      o.setHTML('You can\'t read this message');
    }
  });

  dynapi.functions.subClassEvent('click',l1,sbl1);
  dynapi.functions.subClassEvent('click',l2,sbl2);

  // callback functions
  function sbl1(e,args){
    l2.setHTML('<p align="center"><font size="2" face="arial"><br>I am L2 and I\'m in control of L1</font></p>');
    e.src=l2; // the click event on l1 is now controlled by l2
  };
  function sbl2(e,args){
    var t='<p align="center"><font size="2" face="arial" color="white"><br>I am L3 and I\'m in control of L2<br>'
    +'X:'+e.x+' Y:'+e.y+'</font></p>'
    l3.setHTML(t);
    // stop the event from been passed to l2
    return false;
  }

  dynapi.document.addChild(l1)
  dynapi.document.addChild(l2)
  dynapi.document.addChild(l3)

</script>
</head>
<body>
Click on the Yellow Layer labeled L1 then click layer labeled L2
</body>
</html>


           
       
dynapi.zip( 791 k)
Related examples in the same category
1. Layer: On Content Change Event
2. Layer: On Location Change Event
3. Relative Layers : Events example
w__ww_.j_a___v___a__2s._com___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.