Sha256: 81b9f1f28b5ac06b4223feab8b5406ba410b1bbccfae01b0a78021d6e763fcec

Contents?: true

Size: 1.68 KB

Versions: 8

Compression:

Stored size: 1.68 KB

Contents

<html>
<!--
Copyright 2010 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
  <title>Event Test</title>
  <script type="text/javascript" src="../base.js"></script>
  <script type="text/javascript">
    goog.require('goog.events.EventTarget');
    goog.require('goog.events.Event');
  </script>
</head>
<body>

  <script type="text/javascript">

  var preventDefault = false;
  var stopPropagation = false;

  function func1(e) {
    alert('func1');
    if (preventDefault) e.preventDefault();
    if (stopPropagation) e.stopPropagation();
  }

  function func2(e) {
    alert('func2');
  }


  function Something() { }
  goog.inherits(Something, goog.events.EventTarget);

  Something.prototype.DoSomething = function() {
    alert('Doing something');
    return this.dispatchEvent(new DemoEventObject('Wooo'));
  }

  function DemoEventObject(arg) {
    this.type = 'synth';
    this.arg = arg;
  }
  goog.inherits(DemoEventObject, goog.events.Event);

  var st = new Something();

  goog.events.listen(st, 'synth', func1, true);
  goog.events.listen(st, 'synth', func2, false);


  alert('Response = ' + st.DoSomething() + '\nShould be true');

  preventDefault = true;
  stopPropagation = false;
  alert('Response = ' + st.DoSomething() + '\nShould be false');

  preventDefault = false;
  stopPropagation = true;
  alert('Response = ' + st.DoSomething() + '\nShould be true and only func1 should have been called');

  preventDefault = true;
  stopPropagation = true;
  alert('Response = ' + st.DoSomething() + '\nShould be false and only func1 should have been called');

  </script>
</body>
</html>

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
k4compiler-0.0.1 third_party/closure-library/closure/goog/demos/eventtarget.html
middleman-wizard-template-1.0.4 lib/middleman-wizard-template/template/closure/library/closure/goog/demos/eventtarget.html
middleman-wizard-template-1.0.3 lib/middleman-wizard-template/template/closure/library/closure/goog/demos/eventtarget.html
middleman-wizard-template-1.0.2 lib/middleman-wizard-template/template/closure/library/closure/goog/demos/eventtarget.html
middleman-wizard-template-1.0.1 lib/middleman-wizard-template/template/closure/library/closure/goog/demos/eventtarget.html
middleman-wizard-template-1.0.0.pre.1 lib/middleman-wizard-template/template/closure/library/closure/goog/demos/eventtarget.html
closure-1.2.701 closure-library/closure/goog/demos/eventtarget.html
closure-1.1.692 closure-library/closure/goog/demos/eventtarget.html