Subclassing events : Layer Events « Ajax Layer « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Dojo toolkit
7. Event
8. Event onMethod
9. Ext JS
10. Form Control
11. GUI Components
12. HTML
13. Javascript Collections
14. Javascript Objects
15. Javascript Properties
16. jQuery
17. Language Basics
18. Mochkit
19. Mootools
20. Node Operation
21. Object Oriented
22. Page Components
23. Rico
24. Scriptaculous
25. Security
26. SmartClient
27. Style Layout
28. Table
29. Utilities
30. Window Browser
31. YUI Library
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.