aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/demos/silverlightclipboardbutton.html
blob: ebe62800cbd964a75e737d0e6197c59809099e59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<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>goog.silverlight.ClipboardButton</title>
  <meta charset="utf-8">
  <script src="../base.js"></script>
<script src="../../../third_party/closure/goog/deps.js"></script>
  <script>
    goog.require('goog.dom');
    goog.require('goog.silverlight.CopyButton');
    goog.require('goog.silverlight.PasteButton');

  </script>
  <link rel="stylesheet" href="css/demo.css">
  <style>
  </style>
</head>
<body>
  <h1>goog.silverlight.ClipboardButton</h1>

  <div>Click 'Paste' to alert the contents on your clipboard:</div>
  <div id='pasteButton'></div>

  <p/>
  <div>Click 'Copy' to put the contents of
      this textarea on your clipboard:</div>
  <div id='copyButton'></div>
  <textarea id='textarea'>
  Content to copy
  </textarea>

  <script>

  var $ = goog.dom.$;
 var DIR = '../../../third_party/closure/goog/';

  var XAP = DIR + 'silverlight/' +
      'clipboardbuttonxap/Bin/Release/ClosureClipboardButton.xap';

  if (goog.silverlight.ClipboardButton.hasClipboardAccess()) {
    var pasteButton = new goog.silverlight.PasteButton(XAP);
    pasteButton.render($('pasteButton'));
    goog.events.listen(
        pasteButton,
        goog.silverlight.ClipboardEventType.PASTE,
        function(e) {
          alert(e.getData());
        });

    var copyButton = new goog.silverlight.CopyButton(XAP, 'Copy Textarea');
    copyButton.render($('copyButton'));
    goog.events.listen(
        copyButton,
        goog.silverlight.ClipboardEventType.COPY,
        function(e) {
          e.setData($('textarea').value);
        });
  } else {
    document.write(
        '<b>No native clipboard access--demo will not function</b>');
  }

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